mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve ensemble cross plot statistics
* Support cross plot in plot templates * Fix source stepping for cross plots * Show cross plot data in "Show Plot Data" * Use bin size and realization count when computing cross plot statistics
This commit is contained in:
@@ -31,13 +31,6 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCrossPlotStatisticsCase::RimEnsembleCrossPlotStatisticsCase()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -113,7 +106,7 @@ void RimEnsembleCrossPlotStatisticsCase::calculate( const std::vector<RimSummary
|
||||
const RifEclipseSummaryAddress& inputAddressY,
|
||||
bool includeIncompleteCurves,
|
||||
int binCount,
|
||||
int sampleCountThreshold )
|
||||
int realizationCountThreshold )
|
||||
{
|
||||
if ( !inputAddressX.isValid() || !inputAddressY.isValid() ) return;
|
||||
if ( sumCases.empty() ) return;
|
||||
@@ -126,13 +119,22 @@ void RimEnsembleCrossPlotStatisticsCase::calculate( const std::vector<RimSummary
|
||||
m_adrX = inputAddressX;
|
||||
m_adrY = inputAddressY;
|
||||
|
||||
std::vector<std::pair<double, double>> pairs;
|
||||
struct SampleData
|
||||
{
|
||||
double xValue;
|
||||
double yValue;
|
||||
int realizationId;
|
||||
};
|
||||
|
||||
std::vector<SampleData> sampleData;
|
||||
|
||||
auto [minTimeStep, maxTimeStep] = RimEnsembleStatisticsCase::findMinMaxTimeStep( sumCases, inputAddressX );
|
||||
RiaDefines::DateTimePeriod period = RimEnsembleStatisticsCase::findBestResamplingPeriod( minTimeStep, maxTimeStep );
|
||||
|
||||
for ( const auto& sumCase : sumCases )
|
||||
{
|
||||
int realizationId = sumCase->caseId();
|
||||
|
||||
const auto& reader = sumCase->summaryReader();
|
||||
if ( reader )
|
||||
{
|
||||
@@ -155,52 +157,72 @@ void RimEnsembleCrossPlotStatisticsCase::calculate( const std::vector<RimSummary
|
||||
auto [resampledTimeStepsY, resampledValuesY] =
|
||||
RiaSummaryTools::resampledValuesForPeriod( inputAddressY, timeSteps, valuesY, period );
|
||||
|
||||
size_t minimumCount = std::min( resampledValuesX.size(), resampledValuesY.size() );
|
||||
size_t upperLimit = std::min( resampledValuesX.size(), resampledValuesY.size() );
|
||||
|
||||
for ( size_t i = 0; i < minimumCount; i++ )
|
||||
for ( size_t i = 0; i < upperLimit; i++ )
|
||||
{
|
||||
pairs.emplace_back( std::make_pair( resampledValuesX[i], resampledValuesY[i] ) );
|
||||
sampleData.push_back( { .xValue = resampledValuesX[i], .yValue = resampledValuesY[i], .realizationId = realizationId } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort on X values
|
||||
std::sort( pairs.begin(), pairs.end(), []( const auto& lhs, const auto& rhs ) { return lhs.first < rhs.first; } );
|
||||
if ( sampleData.empty() ) return;
|
||||
|
||||
const auto p = std::minmax_element( pairs.begin(), pairs.end() );
|
||||
auto minX = p.first->first;
|
||||
auto maxX = p.second->first;
|
||||
auto rangeX = maxX - minX;
|
||||
auto deltaRangeX = rangeX / binCount;
|
||||
// Sort on X values
|
||||
std::sort( sampleData.begin(), sampleData.end(), []( const auto& lhs, const auto& rhs ) { return lhs.xValue < rhs.xValue; } );
|
||||
|
||||
auto minX = sampleData.front().xValue;
|
||||
auto maxX = sampleData.back().xValue;
|
||||
auto rangeX = maxX - minX;
|
||||
auto deltaRangeX = rangeX / binCount;
|
||||
|
||||
double currentX = minX;
|
||||
|
||||
std::vector<double> binnedYValues;
|
||||
for ( auto v : pairs )
|
||||
std::map<int, std::vector<double>> yValuesPerRealization;
|
||||
for ( auto v : sampleData )
|
||||
{
|
||||
if ( v.first < currentX + deltaRangeX )
|
||||
if ( v.xValue < currentX + deltaRangeX )
|
||||
{
|
||||
binnedYValues.emplace_back( v.second );
|
||||
yValuesPerRealization[v.realizationId].emplace_back( v.yValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add statistics for current bin if sample count is above threshold
|
||||
// TODO: Add option to skip bin if unique realization count is below threshold
|
||||
|
||||
if ( static_cast<int>( binnedYValues.size() ) > sampleCountThreshold )
|
||||
if ( static_cast<int>( yValuesPerRealization.size() ) > realizationCountThreshold )
|
||||
{
|
||||
std::vector<double> meanYPerRealization;
|
||||
|
||||
for ( const auto& [id, values] : yValuesPerRealization )
|
||||
{
|
||||
if ( values.empty() ) continue;
|
||||
|
||||
double sum = 0.0;
|
||||
for ( double value : values )
|
||||
{
|
||||
sum += value;
|
||||
}
|
||||
|
||||
meanYPerRealization.emplace_back( sum / values.size() );
|
||||
}
|
||||
|
||||
double p10, p50, p90, mean;
|
||||
RigStatisticsMath::calculateStatisticsCurves( binnedYValues, &p10, &p50, &p90, &mean, RigStatisticsMath::PercentileStyle::SWITCHED );
|
||||
RigStatisticsMath::calculateStatisticsCurves( meanYPerRealization,
|
||||
&p10,
|
||||
&p50,
|
||||
&p90,
|
||||
&mean,
|
||||
RigStatisticsMath::PercentileStyle::SWITCHED );
|
||||
m_p10Data.push_back( p10 );
|
||||
m_p50Data.push_back( p50 );
|
||||
m_p90Data.push_back( p90 );
|
||||
m_meanData.push_back( mean );
|
||||
|
||||
m_binnedXValues.emplace_back( currentX );
|
||||
// Use middle of bin as X value
|
||||
m_binnedXValues.emplace_back( currentX + deltaRangeX / 2.0 );
|
||||
}
|
||||
|
||||
currentX += deltaRangeX;
|
||||
binnedYValues.clear();
|
||||
yValuesPerRealization.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,12 @@ class RifEclipseSummaryAddress;
|
||||
class RimEnsembleCrossPlotStatisticsCase : public RimSummaryCase, public RifSummaryReaderInterface
|
||||
{
|
||||
public:
|
||||
RimEnsembleCrossPlotStatisticsCase();
|
||||
|
||||
void calculate( const std::vector<RimSummaryCase*>& sumCases,
|
||||
const RifEclipseSummaryAddress& inputAddressX,
|
||||
const RifEclipseSummaryAddress& inputAddressY,
|
||||
bool includeIncompleteCurves,
|
||||
int binCount,
|
||||
int sampleCountThreshold );
|
||||
int realizationCountThreshold );
|
||||
|
||||
bool hasP10Data() const;
|
||||
bool hasP50Data() const;
|
||||
|
||||
@@ -350,7 +350,7 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change
|
||||
{
|
||||
RimSummaryAddress* summaryAddress = new RimSummaryAddress();
|
||||
|
||||
RifEclipseSummaryAddress candidateAdr = parentCurveSet()->summaryAddress();
|
||||
RifEclipseSummaryAddress candidateAdr = parentCurveSet()->summaryAddressY();
|
||||
|
||||
auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.vectorName() );
|
||||
candidateAdr.setVectorName( nativeQuantityName );
|
||||
|
||||
@@ -410,7 +410,7 @@ void RimEnsembleCurveSet::deleteCurve( RimSummaryCurve* curve )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::setSummaryAddress( RifEclipseSummaryAddress address )
|
||||
void RimEnsembleCurveSet::setSummaryAddressY( RifEclipseSummaryAddress address )
|
||||
{
|
||||
m_yValuesSummaryAddress->setAddress( address );
|
||||
RimSummaryAddress* summaryAddress = new RimSummaryAddress();
|
||||
@@ -423,7 +423,7 @@ void RimEnsembleCurveSet::setSummaryAddress( RifEclipseSummaryAddress address )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::setCurveAddress( RiaSummaryCurveAddress address )
|
||||
{
|
||||
setSummaryAddress( address.summaryAddressY() );
|
||||
setSummaryAddressY( address.summaryAddressY() );
|
||||
setSummaryAddressX( address.summaryAddressX() );
|
||||
|
||||
if ( address.summaryAddressX().category() == SummaryCategory::SUMMARY_TIME )
|
||||
@@ -455,9 +455,9 @@ bool RimEnsembleCurveSet::isXAxisSummaryVector() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::setSummaryAddressAndStatisticsFlag( RifEclipseSummaryAddress address )
|
||||
void RimEnsembleCurveSet::setSummaryAddressYAndStatisticsFlag( RifEclipseSummaryAddress address )
|
||||
{
|
||||
setSummaryAddress( address );
|
||||
setSummaryAddressY( address );
|
||||
m_statistics->setShowStatisticsCurves( !address.isHistoryVector() );
|
||||
m_statistics->updateAllRequiredEditors();
|
||||
}
|
||||
@@ -465,7 +465,7 @@ void RimEnsembleCurveSet::setSummaryAddressAndStatisticsFlag( RifEclipseSummaryA
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddress() const
|
||||
RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddressY() const
|
||||
{
|
||||
return m_yValuesSummaryAddress->address();
|
||||
}
|
||||
@@ -477,10 +477,10 @@ RiaSummaryCurveAddress RimEnsembleCurveSet::curveAddress() const
|
||||
{
|
||||
if ( m_xAxisType() == RiaDefines::HorizontalAxisType::TIME )
|
||||
{
|
||||
return RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(), summaryAddress() );
|
||||
return RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(), summaryAddressY() );
|
||||
}
|
||||
|
||||
return RiaSummaryCurveAddress( m_xAddressSelector->summaryAddress(), summaryAddress() );
|
||||
return RiaSummaryCurveAddress( m_xAddressSelector->summaryAddress(), summaryAddressY() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -742,7 +742,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
if ( !m_xAddressSelector->ensemble() )
|
||||
{
|
||||
m_xAddressSelector->setEnsemble( summaryCaseCollection() );
|
||||
m_xAddressSelector->setAddress( summaryAddress() );
|
||||
m_xAddressSelector->setAddress( summaryAddressY() );
|
||||
}
|
||||
|
||||
if ( !m_xAddressSelector->plotAxisProperties() )
|
||||
@@ -2015,14 +2015,14 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
|
||||
{
|
||||
m_ensembleStatCaseXY->calculate( statCases,
|
||||
m_xAddressSelector->summaryAddress(),
|
||||
summaryAddress(),
|
||||
summaryAddressY(),
|
||||
m_statistics->includeIncompleteCurves(),
|
||||
m_statistics->crossPlotCurvesBinCount(),
|
||||
m_statistics->crossPlotCurvesSampleCountThresholdPerBin() );
|
||||
m_statistics->crossPlotRealizationCountThresholdPerBin() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ensembleStatCaseY->calculate( statCases, summaryAddress(), m_statistics->includeIncompleteCurves() );
|
||||
m_ensembleStatCaseY->calculate( statCases, summaryAddressY(), m_statistics->includeIncompleteCurves() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2203,12 +2203,12 @@ std::vector<std::pair<RigEnsembleParameter, double>> RimEnsembleCurveSet::ensemb
|
||||
{
|
||||
if ( sortingMode == ParameterSorting::ABSOLUTE_VALUE )
|
||||
{
|
||||
return ensemble->correlationSortedEnsembleParameters( summaryAddress() );
|
||||
return ensemble->correlationSortedEnsembleParameters( summaryAddressY() );
|
||||
}
|
||||
|
||||
if ( sortingMode == ParameterSorting::ALPHABETICALLY )
|
||||
{
|
||||
auto parameters = ensemble->parameterCorrelationsAllTimeSteps( summaryAddress() );
|
||||
auto parameters = ensemble->parameterCorrelationsAllTimeSteps( summaryAddressY() );
|
||||
std::sort( parameters.begin(),
|
||||
parameters.end(),
|
||||
[]( const auto& lhs, const auto& rhs ) { return lhs.first.name < rhs.first.name; } );
|
||||
|
||||
@@ -113,10 +113,10 @@ public:
|
||||
void addCurve( RimSummaryCurve* curve );
|
||||
void deleteCurve( RimSummaryCurve* curve );
|
||||
|
||||
void setSummaryAddress( RifEclipseSummaryAddress address );
|
||||
void setSummaryAddressY( RifEclipseSummaryAddress address );
|
||||
void setCurveAddress( RiaSummaryCurveAddress address );
|
||||
void setSummaryAddressAndStatisticsFlag( RifEclipseSummaryAddress address );
|
||||
RifEclipseSummaryAddress summaryAddress() const;
|
||||
void setSummaryAddressYAndStatisticsFlag( RifEclipseSummaryAddress address );
|
||||
RifEclipseSummaryAddress summaryAddressY() const;
|
||||
RiaSummaryCurveAddress curveAddress() const;
|
||||
std::vector<RimSummaryCurve*> curves() const;
|
||||
|
||||
|
||||
@@ -262,10 +262,10 @@ std::vector<RimEnsembleCurveSet*> RimEnsembleCurveSetCollection::curveSetsForSou
|
||||
{
|
||||
// Add corresponding history/summary curve with or without H
|
||||
|
||||
std::string vectorName = m_curveSetForSourceStepping->summaryAddress().vectorName();
|
||||
std::string vectorName = m_curveSetForSourceStepping->summaryAddressY().vectorName();
|
||||
|
||||
std::string candidateName;
|
||||
if ( m_curveSetForSourceStepping->summaryAddress().isHistoryVector() )
|
||||
if ( m_curveSetForSourceStepping->summaryAddressY().isHistoryVector() )
|
||||
{
|
||||
candidateName = vectorName.substr( 0, vectorName.size() - 1 );
|
||||
}
|
||||
@@ -276,7 +276,7 @@ std::vector<RimEnsembleCurveSet*> RimEnsembleCurveSetCollection::curveSetsForSou
|
||||
|
||||
for ( const auto& c : curveSets() )
|
||||
{
|
||||
if ( c->summaryAddress().vectorName() == candidateName )
|
||||
if ( c->summaryAddressY().vectorName() == candidateName )
|
||||
{
|
||||
steppingCurveSets.push_back( c );
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ RimEnsembleStatistics::RimEnsembleStatistics( RimEnsembleCurveSetInterface* pare
|
||||
CAF_PDM_InitField( &m_includeIncompleteCurves, "IncludeIncompleteCurves", false, "Include Incomplete Curves" );
|
||||
|
||||
CAF_PDM_InitField( &m_crossPlotCurvesBinCount, "CrossPlotCurvesBinCount", 100, "Bin Count" );
|
||||
CAF_PDM_InitField( &m_crossPlotCurvesStatisticsSampleCountThresholdPerBin,
|
||||
"CrossPlotCurvesStatisticsSampleCountThresholdPerBin",
|
||||
100,
|
||||
"Sample Threshold per Bin" );
|
||||
CAF_PDM_InitField( &m_crossPlotCurvesStatisticsRealizationCountThresholdPerBin,
|
||||
"CrossPlotCurvesStatisticsRealizationCountThresholdPerBin",
|
||||
10,
|
||||
"Realization Count Threshold per Bin" );
|
||||
|
||||
CAF_PDM_InitField( &m_warningLabel, "WarningLabel", QString( "Warning: Ensemble time range mismatch" ), "" );
|
||||
|
||||
@@ -96,9 +96,9 @@ int RimEnsembleStatistics::crossPlotCurvesBinCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimEnsembleStatistics::crossPlotCurvesSampleCountThresholdPerBin() const
|
||||
int RimEnsembleStatistics::crossPlotRealizationCountThresholdPerBin() const
|
||||
{
|
||||
return m_crossPlotCurvesStatisticsSampleCountThresholdPerBin;
|
||||
return m_crossPlotCurvesStatisticsRealizationCountThresholdPerBin;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -182,7 +182,7 @@ void RimEnsembleStatistics::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
|
||||
|
||||
auto crossPlotGroup = uiOrdering.addNewGroup( "Cross Plot" );
|
||||
crossPlotGroup->add( &m_crossPlotCurvesBinCount );
|
||||
crossPlotGroup->add( &m_crossPlotCurvesStatisticsSampleCountThresholdPerBin );
|
||||
crossPlotGroup->add( &m_crossPlotCurvesStatisticsRealizationCountThresholdPerBin );
|
||||
|
||||
if ( m_showColorField ) uiOrdering.add( &m_color );
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
bool includeIncompleteCurves() const { return m_includeIncompleteCurves; }
|
||||
|
||||
int crossPlotCurvesBinCount() const;
|
||||
int crossPlotCurvesSampleCountThresholdPerBin() const;
|
||||
int crossPlotRealizationCountThresholdPerBin() const;
|
||||
|
||||
void disableP10Curve( bool disable );
|
||||
void disableP50Curve( bool disable );
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
|
||||
// Ensemble cross plot settings
|
||||
caf::PdmField<int> m_crossPlotCurvesBinCount;
|
||||
caf::PdmField<int> m_crossPlotCurvesStatisticsSampleCountThresholdPerBin;
|
||||
caf::PdmField<int> m_crossPlotCurvesStatisticsRealizationCountThresholdPerBin;
|
||||
|
||||
caf::PdmField<QString> m_warningLabel;
|
||||
|
||||
|
||||
@@ -30,26 +30,6 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define DOUBLE_INF std::numeric_limits<double>::infinity()
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RimEnsembleStatisticsCase::timeSteps() const
|
||||
{
|
||||
return m_timeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -33,10 +33,6 @@ class RifEclipseSummaryAddress;
|
||||
class RimEnsembleStatisticsCase : public RimSummaryCase, public RifSummaryReaderInterface
|
||||
{
|
||||
public:
|
||||
RimEnsembleStatisticsCase();
|
||||
|
||||
const std::vector<time_t>& timeSteps() const;
|
||||
|
||||
bool hasP10Data() const;
|
||||
bool hasP50Data() const;
|
||||
bool hasP90Data() const;
|
||||
|
||||
@@ -43,7 +43,7 @@ RimCustomObjectiveFunctionWeight* RimObjectiveFunctionTools::addWeight( RimCusto
|
||||
}
|
||||
else
|
||||
{
|
||||
candidateAdr = newWeight->parentCurveSet()->summaryAddress();
|
||||
candidateAdr = newWeight->parentCurveSet()->summaryAddressY();
|
||||
}
|
||||
|
||||
auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.vectorName() );
|
||||
|
||||
@@ -81,7 +81,7 @@ std::vector<RifEclipseSummaryAddress> RimSummaryAddressModifier::createEclipseSu
|
||||
RifEclipseSummaryAddress RimSummaryAddressModifier::address() const
|
||||
{
|
||||
if ( m_curve ) return m_curve->summaryAddressY();
|
||||
if ( m_curveSet ) return m_curveSet->summaryAddress();
|
||||
if ( m_curveSet ) return m_curveSet->summaryAddressY();
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -92,7 +92,7 @@ RifEclipseSummaryAddress RimSummaryAddressModifier::address() const
|
||||
void RimSummaryAddressModifier::setAddress( const RifEclipseSummaryAddress& address )
|
||||
{
|
||||
if ( m_curve ) m_curve->setSummaryAddressY( address );
|
||||
if ( m_curveSet ) m_curveSet->setSummaryAddressAndStatisticsFlag( address );
|
||||
if ( m_curveSet ) m_curveSet->setSummaryAddressYAndStatisticsFlag( address );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -141,6 +141,8 @@ QString RimSummaryCurvesData::createTextForExport( const std::vector<RimSummaryC
|
||||
RiaDefines::DateTimePeriod resamplingPeriod,
|
||||
bool showTimeAsLongString )
|
||||
{
|
||||
if ( curves.empty() && asciiCurves.empty() && gridCurves.empty() ) return {};
|
||||
|
||||
QString out;
|
||||
|
||||
RimSummaryCurvesData summaryCurvesGridData;
|
||||
@@ -176,6 +178,47 @@ QString RimSummaryCurvesData::createTextForExport( const std::vector<RimSummaryC
|
||||
return out;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryCurvesData::createTextForCrossPlotCurves( const std::vector<RimSummaryCurve*>& curves )
|
||||
{
|
||||
QString text;
|
||||
|
||||
for ( const auto& curve : curves )
|
||||
{
|
||||
const auto curveAddress = curve->curveAddress();
|
||||
const auto xAddress = curveAddress.summaryAddressX();
|
||||
const auto yAddress = curveAddress.summaryAddressY();
|
||||
|
||||
const auto xValues = curve->valuesX();
|
||||
const auto yValues = curve->valuesY();
|
||||
|
||||
if ( xValues.size() == yValues.size() )
|
||||
{
|
||||
text += curve->curveExportDescription( {} ) + "\n";
|
||||
|
||||
text +=
|
||||
QString( "%1\t%2\n" ).arg( QString::fromStdString( xAddress.vectorName() ) ).arg( QString::fromStdString( yAddress.vectorName() ) );
|
||||
|
||||
for ( size_t i = 0; i < xValues.size(); i++ )
|
||||
{
|
||||
QString line;
|
||||
line += QString::number( xValues[i], 'g', RimSummaryPlot::precision() );
|
||||
line += "\t";
|
||||
line += QString::number( yValues[i], 'g', RimSummaryPlot::precision() );
|
||||
line += "\n";
|
||||
|
||||
text += line;
|
||||
}
|
||||
}
|
||||
|
||||
text += "\n";
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
RiaDefines::DateTimePeriod resamplingPeriod,
|
||||
bool showTimeAsLongString );
|
||||
|
||||
static QString createTextForCrossPlotCurves( const std::vector<RimSummaryCurve*>& curves );
|
||||
|
||||
private:
|
||||
static void populateSummaryCurvesData( std::vector<RimSummaryCurve*> curves, SummaryCurveType curveType, RimSummaryCurvesData* curvesData );
|
||||
static void populateTimeHistoryCurvesData( std::vector<RimGridTimeHistoryCurve*> curves, RimSummaryCurvesData* curvesData );
|
||||
|
||||
@@ -1591,7 +1591,7 @@ void RimSummaryMultiPlot::appendCurveByStepping( int direction )
|
||||
|
||||
for ( auto curveSet : plot->curveSets() )
|
||||
{
|
||||
auto address = curveSet->summaryAddress();
|
||||
auto address = curveSet->summaryAddressY();
|
||||
auto sumEns = curveSet->summaryCaseCollection();
|
||||
int sumEnsId = sumEns->ensembleId();
|
||||
if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE )
|
||||
|
||||
@@ -120,8 +120,7 @@ struct RimSummaryPlot::CurveInfo
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot::RimSummaryPlot()
|
||||
: RimPlot()
|
||||
, curvesChanged( this )
|
||||
: curvesChanged( this )
|
||||
, axisChanged( this )
|
||||
, plotZoomedByUser( this )
|
||||
, titleChanged( this )
|
||||
@@ -336,13 +335,29 @@ QString RimSummaryPlot::asciiDataForPlotExport() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves = descendantsIncludingThisOfType<RimSummaryCurve>();
|
||||
std::vector<RimSummaryCurve*> allCurves = descendantsIncludingThisOfType<RimSummaryCurve>();
|
||||
|
||||
std::vector<RimSummaryCurve*> crossPlotCurves;
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
for ( auto c : allCurves )
|
||||
{
|
||||
if ( c->axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
|
||||
{
|
||||
crossPlotCurves.push_back( c );
|
||||
}
|
||||
else
|
||||
{
|
||||
curves.push_back( c );
|
||||
}
|
||||
}
|
||||
|
||||
auto gridCurves = m_gridTimeHistoryCurves.childrenByType();
|
||||
auto asciiCurves = m_asciiDataCurves.childrenByType();
|
||||
|
||||
QString text = RimSummaryCurvesData::createTextForExport( curves, asciiCurves, gridCurves, resamplingPeriod, showTimeAsLongString );
|
||||
|
||||
text += RimSummaryCurvesData::createTextForCrossPlotCurves( crossPlotCurves );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -828,7 +843,7 @@ void RimSummaryPlot::applyDefaultCurveAppearances( std::vector<RimEnsembleCurveS
|
||||
{
|
||||
cvf::Color3f curveColor = cvf::Color3f::ORANGE;
|
||||
|
||||
const auto adr = curveSet->summaryAddress();
|
||||
const auto adr = curveSet->summaryAddressY();
|
||||
if ( adr.isHistoryVector() )
|
||||
{
|
||||
curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor();
|
||||
@@ -932,9 +947,11 @@ void RimSummaryPlot::updateNumericalAxis( RiaDefines::PlotAxis plotAxis )
|
||||
}
|
||||
if ( summaryCurve->axisX() == riuPlotAxis )
|
||||
{
|
||||
curveDefs.push_back( RiaSummaryCurveDefinition( summaryCurve->summaryCaseX(),
|
||||
summaryCurve->summaryAddressX(),
|
||||
summaryCurve->isEnsembleCurve() ) );
|
||||
RiaSummaryCurveDefinition def;
|
||||
def.setSummaryCaseX( summaryCurve->summaryCaseX() );
|
||||
def.setSummaryAddressX( summaryCurve->summaryAddressX() );
|
||||
|
||||
curveDefs.push_back( def );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -942,7 +959,7 @@ void RimSummaryPlot::updateNumericalAxis( RiaDefines::PlotAxis plotAxis )
|
||||
{
|
||||
if ( curveSet->axisY() == riuPlotAxis )
|
||||
{
|
||||
RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() );
|
||||
RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddressY() );
|
||||
curveDefs.push_back( def );
|
||||
}
|
||||
if ( curveSet->axisX() == riuPlotAxis )
|
||||
@@ -1041,15 +1058,13 @@ void RimSummaryPlot::updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisPrope
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateZoomForAxis( RimPlotAxisPropertiesInterface* axisProperties )
|
||||
{
|
||||
RimSummaryTimeAxisProperties* timeAxisProps = dynamic_cast<RimSummaryTimeAxisProperties*>( axisProperties );
|
||||
if ( timeAxisProps )
|
||||
if ( auto timeAxisProps = dynamic_cast<RimSummaryTimeAxisProperties*>( axisProperties ) )
|
||||
{
|
||||
updateZoomForTimeAxis( timeAxisProps );
|
||||
return;
|
||||
}
|
||||
|
||||
RimPlotAxisProperties* axisProps = dynamic_cast<RimPlotAxisProperties*>( axisProperties );
|
||||
if ( axisProps )
|
||||
if ( auto axisProps = dynamic_cast<RimPlotAxisProperties*>( axisProperties ) )
|
||||
{
|
||||
updateZoomForNumericalAxis( axisProps );
|
||||
return;
|
||||
@@ -2503,7 +2518,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAd
|
||||
|
||||
for ( auto& curve : curveSets() )
|
||||
{
|
||||
const auto addr = curve->summaryAddress();
|
||||
const auto addr = curve->summaryAddressY();
|
||||
dataVectorMap[addr].insert( curve->summaryCaseCollection() );
|
||||
}
|
||||
|
||||
@@ -2651,15 +2666,15 @@ RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurve( const RiaSummaryCurveA
|
||||
auto* curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddressAndStatisticsFlag( address.summaryAddressY() );
|
||||
curveSet->setSummaryAddressYAndStatisticsFlag( address.summaryAddressY() );
|
||||
curveSet->setCurveAddress( address );
|
||||
|
||||
cvf::Color3f curveColor =
|
||||
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(),
|
||||
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddressY(),
|
||||
static_cast<int>(
|
||||
ensembleCurveSetCollection()->curveSetCount() ) );
|
||||
|
||||
auto adr = curveSet->summaryAddress();
|
||||
auto adr = curveSet->summaryAddressY();
|
||||
if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor();
|
||||
|
||||
curveSet->setColor( curveColor );
|
||||
|
||||
@@ -362,17 +362,26 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
bool triggerLoadDataAndUpdate = false;
|
||||
|
||||
auto updateEnsembleAddresses = [&doZoomAll, &oldValue, &newValue]( const std::vector<RimEnsembleCurveSet*>& curveSets )
|
||||
auto updateEnsembleAddresses =
|
||||
[&doZoomAll, &oldValue, &newValue]( const std::vector<RimEnsembleCurveSet*>& curveSets, SummaryCategory categoryToUpdate )
|
||||
{
|
||||
for ( auto curveSet : curveSets )
|
||||
{
|
||||
auto curveAdr = curveSet->curveAddress();
|
||||
|
||||
auto yAddressToModify = curveAdr.summaryAddressY();
|
||||
RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, yAddressToModify );
|
||||
|
||||
auto xAddressToModify = curveAdr.summaryAddressX();
|
||||
RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, xAddressToModify );
|
||||
|
||||
if ( categoryToUpdate != SummaryCategory::SUMMARY_INVALID )
|
||||
{
|
||||
RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, categoryToUpdate, yAddressToModify );
|
||||
RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, categoryToUpdate, xAddressToModify );
|
||||
}
|
||||
else
|
||||
{
|
||||
RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, yAddressToModify );
|
||||
RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, xAddressToModify );
|
||||
}
|
||||
|
||||
curveSet->setCurveAddress( RiaSummaryCurveAddress( xAddressToModify, yAddressToModify ) );
|
||||
curveSet->updateConnectedEditors();
|
||||
@@ -451,7 +460,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
if ( dataSourceSteppingObject() )
|
||||
{
|
||||
updateEnsembleAddresses( dataSourceSteppingObject()->curveSets() );
|
||||
updateEnsembleAddresses( dataSourceSteppingObject()->curveSets(), SummaryCategory::SUMMARY_INVALID );
|
||||
}
|
||||
|
||||
m_vectorName.uiCapability()->updateConnectedEditors();
|
||||
@@ -516,7 +525,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
if ( dataSourceSteppingObject() )
|
||||
{
|
||||
updateEnsembleAddresses( dataSourceSteppingObject()->curveSets() );
|
||||
updateEnsembleAddresses( dataSourceSteppingObject()->curveSets(), summaryCategoryToModify );
|
||||
}
|
||||
|
||||
triggerLoadDataAndUpdate = true;
|
||||
@@ -675,7 +684,7 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::addressesForCur
|
||||
{
|
||||
for ( auto curveSet : dataSourceSteppingObject()->curveSets() )
|
||||
{
|
||||
addresses.insert( curveSet->summaryAddress() );
|
||||
addresses.insert( curveSet->summaryAddressY() );
|
||||
}
|
||||
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
|
||||
Reference in New Issue
Block a user