mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 16:32:12 -05:00
Fix summary issues
* Add missing time conversion for month * #9606: FIx wrong usage of function when accessing data from summary file The result values are aggregated into the destination vector in RimSummaryCaseCollection::computeMinMax(), so make sure the vector is recreated per case. * #9602 : Make sure the plot is updated correctly for "Time since simulation start" * Move roundToNumSignificantDigits() to RiaNumericalTools * Make sure the time axis is consistent when individual time range differs
This commit is contained in:
1 parent
984557a46a
commit
09e05e9996
18 files changed
+293
-179
No files matched your search
@@ -984,11 +984,11 @@ void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& ad
|
||||
double minimumValue( std::numeric_limits<double>::infinity() );
|
||||
double maximumValue( -std::numeric_limits<double>::infinity() );
|
||||
|
||||
std::vector<double> values;
|
||||
for ( const auto& s : m_cases() )
|
||||
{
|
||||
if ( !s->summaryReader() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
s->summaryReader()->values( address, &values );
|
||||
if ( values.empty() ) continue;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaNumericalTools.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
#include "RiaSummaryAddressAnalyzer.h"
|
||||
#include "RiaSummaryStringTools.h"
|
||||
@@ -210,10 +211,17 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
||||
sumPlot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
sumPlot->plotZoomedByUser.connect( this, &RimSummaryMultiPlot::onSubPlotZoomed );
|
||||
sumPlot->titleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
sumPlot->axisChangedReloadRequired.connect( this, &RimSummaryMultiPlot::onSubPlotAxisReloadRequired );
|
||||
|
||||
bool isMinMaxOverridden = m_axisRangeAggregation() != AxisRangeAggregation::NONE;
|
||||
setAutoValueStatesForPlot( sumPlot, isMinMaxOverridden, m_autoAdjustAppearance() );
|
||||
|
||||
auto plots = summaryPlots();
|
||||
if ( !plots.empty() && m_linkTimeAxis )
|
||||
{
|
||||
sumPlot->copyAxisPropertiesFromOther( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, *plots.front() );
|
||||
}
|
||||
|
||||
RimMultiPlot::insertPlot( plot, index );
|
||||
}
|
||||
|
||||
@@ -447,11 +455,7 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
}
|
||||
else if ( changedField == &m_linkTimeAxis )
|
||||
{
|
||||
auto plots = summaryPlots();
|
||||
if ( !plots.empty() )
|
||||
{
|
||||
syncTimeAxisRanges( plots.front() );
|
||||
}
|
||||
updateTimeAxisRangesFromFirstPlot();
|
||||
}
|
||||
else if ( changedField == &m_linkSubPlotAxes || changedField == &m_axisRangeAggregation ||
|
||||
changedField == &m_linkTimeAxis )
|
||||
@@ -717,6 +721,7 @@ void RimSummaryMultiPlot::initAfterRead()
|
||||
plot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
plot->plotZoomedByUser.connect( this, &RimSummaryMultiPlot::onSubPlotZoomed );
|
||||
plot->titleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
plot->axisChangedReloadRequired.connect( this, &RimSummaryMultiPlot::onSubPlotAxisReloadRequired );
|
||||
}
|
||||
updateStepDimensionFromDefault();
|
||||
}
|
||||
@@ -751,6 +756,8 @@ void RimSummaryMultiPlot::zoomAll()
|
||||
|
||||
updateZoom();
|
||||
|
||||
updateTimeAxisRangesFromFirstPlot();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -758,6 +765,20 @@ void RimSummaryMultiPlot::zoomAll()
|
||||
RimMultiPlot::zoomAll();
|
||||
|
||||
syncAxisRanges();
|
||||
|
||||
updateTimeAxisRangesFromFirstPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::updateTimeAxisRangesFromFirstPlot()
|
||||
{
|
||||
if ( m_linkTimeAxis && !summaryPlots().empty() )
|
||||
{
|
||||
setAutoScaleXEnabled( false );
|
||||
syncTimeAxisRanges( summaryPlots().front() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -894,15 +915,15 @@ void RimSummaryMultiPlot::syncAxisRanges()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::syncTimeAxisRanges( RimSummaryPlot* summaryPlot )
|
||||
void RimSummaryMultiPlot::syncTimeAxisRanges( RimSummaryPlot* sourceSummaryPlot )
|
||||
{
|
||||
if ( m_linkTimeAxis )
|
||||
if ( sourceSummaryPlot && m_linkTimeAxis() )
|
||||
{
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
if ( plot != summaryPlot )
|
||||
if ( plot != sourceSummaryPlot )
|
||||
{
|
||||
plot->copyAxisPropertiesFromOther( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, *summaryPlot );
|
||||
plot->copyAxisPropertiesFromOther( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, *sourceSummaryPlot );
|
||||
plot->updateAll();
|
||||
}
|
||||
}
|
||||
@@ -925,16 +946,28 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
return values;
|
||||
};
|
||||
|
||||
auto findMinMaxForSummaryCase = [readValues]( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr ) {
|
||||
auto values = readValues( summaryCase, addr );
|
||||
if ( values.empty() ) return std::make_pair( HUGE_VAL, -HUGE_VAL );
|
||||
auto findMinMaxForSummaryCase =
|
||||
[readValues]( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr, bool onlyPositiveValues ) {
|
||||
auto values = readValues( summaryCase, addr );
|
||||
if ( onlyPositiveValues )
|
||||
{
|
||||
std::vector<double> positiveValues;
|
||||
|
||||
auto minMaxPair = std::minmax_element( values.begin(), values.end() );
|
||||
double caseMinimum = *minMaxPair.first;
|
||||
double caseMaximum = *minMaxPair.second;
|
||||
for ( const auto& v : values )
|
||||
{
|
||||
if ( v > 0.0 ) positiveValues.push_back( v );
|
||||
}
|
||||
|
||||
return std::make_pair( caseMinimum, caseMaximum );
|
||||
};
|
||||
values = positiveValues;
|
||||
}
|
||||
if ( values.empty() ) return std::make_pair( HUGE_VAL, -HUGE_VAL );
|
||||
|
||||
auto minMaxPair = std::minmax_element( values.begin(), values.end() );
|
||||
double caseMinimum = *minMaxPair.first;
|
||||
double caseMaximum = *minMaxPair.second;
|
||||
|
||||
return std::make_pair( caseMinimum, caseMaximum );
|
||||
};
|
||||
|
||||
auto summaryCasesForCurve = []( RimSummaryCurve* curve, AxisRangeAggregation axisRangeAggregation ) {
|
||||
std::vector<RimSummaryCase*> summaryCases;
|
||||
@@ -1019,14 +1052,15 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
|
||||
auto findMinMaxForAddressesInSummaryCases =
|
||||
[findMinMaxForSummaryCase]( const std::vector<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases ) {
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
bool onlyPositiveValues ) {
|
||||
double minimum = HUGE_VAL;
|
||||
double maximum = -HUGE_VAL;
|
||||
for ( auto summaryCase : summaryCases )
|
||||
{
|
||||
for ( const auto& addr : addresses )
|
||||
{
|
||||
auto [caseMinimum, caseMaximum] = findMinMaxForSummaryCase( summaryCase, addr );
|
||||
auto [caseMinimum, caseMaximum] = findMinMaxForSummaryCase( summaryCase, addr, onlyPositiveValues );
|
||||
minimum = std::min( minimum, caseMinimum );
|
||||
maximum = std::max( maximum, caseMaximum );
|
||||
}
|
||||
@@ -1049,7 +1083,10 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
std::vector<RimSummaryCase*> summaryCases = summaryCasesForCurve( curve, m_axisRangeAggregation() );
|
||||
std::vector<RifEclipseSummaryAddress> addresses = addressesForCurve( curve, m_axisRangeAggregation() );
|
||||
|
||||
auto [minimum, maximum] = findMinMaxForAddressesInSummaryCases( addresses, summaryCases );
|
||||
bool onlyPositiveValues = axis->isLogarithmicScaleEnabled();
|
||||
|
||||
auto [minimum, maximum] =
|
||||
findMinMaxForAddressesInSummaryCases( addresses, summaryCases, onlyPositiveValues );
|
||||
|
||||
if ( axisRanges.count( axis->plotAxisType() ) == 0 )
|
||||
{
|
||||
@@ -1381,6 +1418,28 @@ void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitte
|
||||
syncAxisRanges();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::onSubPlotAxisReloadRequired( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot )
|
||||
{
|
||||
if ( !summaryPlot ) return;
|
||||
|
||||
if ( m_linkTimeAxis() )
|
||||
{
|
||||
syncTimeAxisRanges( summaryPlot );
|
||||
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
plot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1411,7 +1470,10 @@ std::pair<double, double> RimSummaryMultiPlot::adjustedMinMax( const RimPlotAxis
|
||||
return { adjustedMin, adjustedMax };
|
||||
}
|
||||
|
||||
return { min, max };
|
||||
auto adjustedMin = RiaNumericalTools::roundToClosestPowerOfTenFloor( min );
|
||||
auto adjustedMax = RiaNumericalTools::roundToClosestPowerOfTenCeil( max );
|
||||
|
||||
return { adjustedMin, adjustedMax };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar() override;
|
||||
|
||||
void syncAxisRanges();
|
||||
void syncTimeAxisRanges( RimSummaryPlot* summaryPlot );
|
||||
void syncTimeAxisRanges( RimSummaryPlot* sourceSummaryPlot );
|
||||
|
||||
void handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
|
||||
@@ -148,6 +148,9 @@ private:
|
||||
void onSubPlotChanged( const caf::SignalEmitter* emitter );
|
||||
void onSubPlotZoomed( const caf::SignalEmitter* emitter );
|
||||
void onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot );
|
||||
void onSubPlotAxisReloadRequired( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot );
|
||||
|
||||
void updateTimeAxisRangesFromFirstPlot();
|
||||
|
||||
void updateReadOnlyState();
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ RimSummaryPlot::RimSummaryPlot( bool isCrossPlot )
|
||||
, plotZoomedByUser( this )
|
||||
, titleChanged( this )
|
||||
, m_isValid( true )
|
||||
, axisChangedReloadRequired( this )
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" );
|
||||
|
||||
@@ -144,6 +145,7 @@ RimSummaryPlot::RimSummaryPlot( bool isCrossPlot )
|
||||
{
|
||||
auto* timeAxisProperties = new RimSummaryTimeAxisProperties;
|
||||
timeAxisProperties->settingsChanged.connect( this, &RimSummaryPlot::axisSettingsChanged );
|
||||
timeAxisProperties->requestLoadDataAndUpdate.connect( this, &RimSummaryPlot::axisSettingsChangedReloadRequired );
|
||||
|
||||
m_axisProperties.push_back( timeAxisProperties );
|
||||
}
|
||||
@@ -1740,24 +1742,20 @@ void RimSummaryPlot::updateZoomFromParentPlot()
|
||||
|
||||
for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties )
|
||||
{
|
||||
if ( !axisProperties ) continue;
|
||||
|
||||
auto [axisMin, axisMax] = plotWidget()->axisRange( axisProperties->plotAxisType() );
|
||||
if ( axisProperties->isAxisInverted() ) std::swap( axisMin, axisMax );
|
||||
|
||||
auto propertyAxis = dynamic_cast<RimPlotAxisProperties*>( axisProperties );
|
||||
|
||||
if ( propertyAxis )
|
||||
if ( auto propertyAxis = dynamic_cast<RimPlotAxisProperties*>( axisProperties ) )
|
||||
{
|
||||
propertyAxis->setAutoValueVisibleRangeMax( axisMax );
|
||||
propertyAxis->setAutoValueVisibleRangeMin( axisMin );
|
||||
axisProperties->setVisibleRangeMax( axisMax );
|
||||
axisProperties->setVisibleRangeMin( axisMin );
|
||||
}
|
||||
else
|
||||
{
|
||||
axisProperties->setVisibleRangeMax( axisMax );
|
||||
axisProperties->setVisibleRangeMin( axisMin );
|
||||
}
|
||||
|
||||
axisProperties->setVisibleRangeMax( axisMax );
|
||||
axisProperties->setVisibleRangeMin( axisMin );
|
||||
|
||||
axisProperties->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
@@ -1868,6 +1866,14 @@ void RimSummaryPlot::axisSettingsChanged( const caf::SignalEmitter* emitter )
|
||||
updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::axisSettingsChangedReloadRequired( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
axisChangedReloadRequired.send( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2568,6 +2574,7 @@ void RimSummaryPlot::initAfterRead()
|
||||
if ( timeAxis )
|
||||
{
|
||||
timeAxis->settingsChanged.connect( this, &RimSummaryPlot::axisSettingsChanged );
|
||||
timeAxis->requestLoadDataAndUpdate.connect( this, &RimSummaryPlot::axisSettingsChangedReloadRequired );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
caf::Signal<RimSummaryPlot*> axisChanged;
|
||||
caf::Signal<> plotZoomedByUser;
|
||||
caf::Signal<> titleChanged;
|
||||
caf::Signal<RimSummaryPlot*> axisChangedReloadRequired;
|
||||
|
||||
public:
|
||||
RimSummaryPlot( bool isCrossPlot = false );
|
||||
@@ -282,6 +283,7 @@ private:
|
||||
|
||||
void connectAxisSignals( RimPlotAxisProperties* axis );
|
||||
void axisSettingsChanged( const caf::SignalEmitter* emitter );
|
||||
void axisSettingsChangedReloadRequired( const caf::SignalEmitter* emitter );
|
||||
void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic );
|
||||
void axisPositionChanged( const caf::SignalEmitter* emitter,
|
||||
RimPlotAxisProperties* axisProperties,
|
||||
|
||||
@@ -71,6 +71,7 @@ CAF_PDM_SOURCE_INIT( RimSummaryTimeAxisProperties, "SummaryTimeAxisProperties" )
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
||||
: requestLoadDataAndUpdate( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Time Axis", ":/BottomAxis16x16.png" );
|
||||
|
||||
@@ -472,7 +473,7 @@ void RimSummaryTimeAxisProperties::setTimeMode( TimeModeType val )
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// https://www.unitconverters.net/time-converter.html
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimSummaryTimeAxisProperties::fromTimeTToDisplayUnitScale()
|
||||
{
|
||||
@@ -490,9 +491,13 @@ double RimSummaryTimeAxisProperties::fromTimeTToDisplayUnitScale()
|
||||
case DAYS:
|
||||
scale = 1.0 / ( 60.0 * 60.0 * 24.0 );
|
||||
break;
|
||||
case MONTHS:
|
||||
scale = 3.805175038E-7;
|
||||
break;
|
||||
case YEARS:
|
||||
scale = 1.0 / 31556952.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
CVF_ASSERT( false );
|
||||
break;
|
||||
@@ -502,7 +507,7 @@ double RimSummaryTimeAxisProperties::fromTimeTToDisplayUnitScale()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// https://www.unitconverters.net/time-converter.html
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimSummaryTimeAxisProperties::fromDaysToDisplayUnitScale()
|
||||
{
|
||||
@@ -520,6 +525,9 @@ double RimSummaryTimeAxisProperties::fromDaysToDisplayUnitScale()
|
||||
break;
|
||||
case DAYS:
|
||||
break;
|
||||
case MONTHS:
|
||||
scale = 1.0 / 30.416666667;
|
||||
break;
|
||||
case YEARS:
|
||||
scale = 1.0 / 365.2425;
|
||||
break;
|
||||
@@ -712,21 +720,12 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
updateDateVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
else if ( changedField == &m_timeMode )
|
||||
else if ( changedField == &m_timeMode || changedField == &m_timeUnit || changedField == &m_dateFormat ||
|
||||
changedField == &m_timeFormat )
|
||||
{
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
else if ( changedField == &m_timeUnit )
|
||||
{
|
||||
updateTimeVisibleRange(); // Use the stored max min dates to update the visible time range to new unit
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
updateDateVisibleRange();
|
||||
}
|
||||
else if ( changedField == &m_dateFormat || changedField == &m_timeFormat )
|
||||
{
|
||||
updateTimeVisibleRange(); // Use the stored max min dates to update the visible time range to new unit
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
updateDateVisibleRange();
|
||||
// Changing these settings requires a full update of the plot
|
||||
requestLoadDataAndUpdate.send();
|
||||
return;
|
||||
}
|
||||
|
||||
rimSummaryPlot->updateAxes();
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
typedef caf::AppEnum<RiaDefines::DateFormatComponents> DateFormatEnum;
|
||||
typedef caf::AppEnum<RiaDefines::TimeFormatComponents> TimeFormatEnum;
|
||||
|
||||
caf::Signal<> requestLoadDataAndUpdate;
|
||||
|
||||
public:
|
||||
RimSummaryTimeAxisProperties();
|
||||
|
||||
|
||||
Reference in new issue
Block a user