Skip to content

Commit

Permalink
Remove use of ensemble statistics reader
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 22, 2023
1 parent 05f1936 commit df5345a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 70 deletions.
24 changes: 13 additions & 11 deletions ApplicationLibCode/FileInterface/RifEnsembleStatisticsReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ std::string RifEnsembleStatisticsReader::unitName( const RifEclipseSummaryAddres
std::string retval;

// The stat case does not have a unit set, so pick up the unit from one of the input cases, if possible
auto cases = m_ensembleStatCase->curveSet()->summaryCaseCollection()->allSummaryCases();
if ( cases.size() > 0 )
{
QString qName = QString::fromStdString( resultAddress.vectorName() );
std::string orgQName = qName.split( ":" )[1].toStdString();

RifEclipseSummaryAddress address = RifEclipseSummaryAddress( resultAddress );
address.setVectorName( orgQName );

retval = cases[0]->summaryReader()->unitName( address );
}
/*
auto cases = m_ensembleStatCase->curveSet()->summaryCaseCollection()->allSummaryCases();
if ( cases.size() > 0 )
{
QString qName = QString::fromStdString( resultAddress.vectorName() );
std::string orgQName = qName.split( ":" )[1].toStdString();
RifEclipseSummaryAddress address = RifEclipseSummaryAddress( resultAddress );
address.setVectorName( orgQName );
retval = cases[0]->summaryReader()->unitName( address );
}
*/

return retval;
}
Expand Down
26 changes: 12 additions & 14 deletions ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()

m_summaryAddressNameTools = new RimSummaryCurveAutoName;

m_ensembleStatCase.reset( new RimEnsembleStatisticsCase( this ) );
m_ensembleStatCase->createSummaryReaderInterface();
m_ensembleStatCase->createRftReaderInterface();
m_ensembleStatCaseY.reset( new RimEnsembleStatisticsCase() );

m_disableStatisticCurves = false;
m_isCurveSetFiltered = false;
Expand Down Expand Up @@ -1945,7 +1943,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
else
statCases = group->allSummaryCases();
}
m_ensembleStatCase->calculate( statCases, m_statistics->includeIncompleteCurves() );
m_ensembleStatCaseY->calculate( statCases, summaryAddress(), m_statistics->includeIncompleteCurves() );
}

std::vector<RiaSummaryCurveAddress> addresses;
Expand All @@ -1971,19 +1969,19 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
return RiaSummaryCurveAddress( xStatAddress, yStatAddress );
};

if ( m_statistics->showP10Curve() && m_ensembleStatCase->hasP10Data() )
if ( m_statistics->showP10Curve() && m_ensembleStatCaseY->hasP10Data() )
{
addresses.push_back( getStatisticsAddress( m_xAxisType(), ENSEMBLE_STAT_P10_QUANTITY_NAME, dataAddressX, dataAddressY ) );
}
if ( m_statistics->showP50Curve() && m_ensembleStatCase->hasP50Data() )
if ( m_statistics->showP50Curve() && m_ensembleStatCaseY->hasP50Data() )
{
addresses.push_back( getStatisticsAddress( m_xAxisType(), ENSEMBLE_STAT_P50_QUANTITY_NAME, dataAddressX, dataAddressY ) );
}
if ( m_statistics->showP90Curve() && m_ensembleStatCase->hasP90Data() )
if ( m_statistics->showP90Curve() && m_ensembleStatCaseY->hasP90Data() )
{
addresses.push_back( getStatisticsAddress( m_xAxisType(), ENSEMBLE_STAT_P90_QUANTITY_NAME, dataAddressX, dataAddressY ) );
}
if ( m_statistics->showMeanCurve() && m_ensembleStatCase->hasMeanData() )
if ( m_statistics->showMeanCurve() && m_ensembleStatCaseY->hasMeanData() )
{
addresses.push_back( getStatisticsAddress( m_xAxisType(), ENSEMBLE_STAT_MEAN_QUANTITY_NAME, dataAddressX, dataAddressY ) );
}
Expand Down Expand Up @@ -2011,14 +2009,14 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
curve->setSymbolLabel( QString::fromStdString( address.summaryAddressY().ensembleStatisticsVectorName() ) );
}
curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
curve->setSummaryCaseY( m_ensembleStatCase.get() );
curve->setSummaryCaseY( m_ensembleStatCaseY.get() );
curve->setSummaryAddressYAndApplyInterpolation( address.summaryAddressY() );
curve->setLeftOrRightAxisY( axisY() );

if ( m_xAxisType() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
{
curve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
curve->setSummaryCaseX( m_ensembleStatCase.get() );
curve->setSummaryCaseX( m_ensembleStatCaseY.get() );
curve->setSummaryAddressX( address.summaryAddressX() );
curve->setTopOrBottomAxisX( m_xAddressSelector->plotAxisProperties()->plotAxis() );
}
Expand Down Expand Up @@ -2160,31 +2158,31 @@ bool RimEnsembleCurveSet::isFiltered() const
//--------------------------------------------------------------------------------------------------
bool RimEnsembleCurveSet::hasP10Data() const
{
return m_ensembleStatCase->hasP10Data();
return m_ensembleStatCaseY->hasP10Data();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEnsembleCurveSet::hasP50Data() const
{
return m_ensembleStatCase->hasP50Data();
return m_ensembleStatCaseY->hasP50Data();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEnsembleCurveSet::hasP90Data() const
{
return m_ensembleStatCase->hasP90Data();
return m_ensembleStatCaseY->hasP90Data();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEnsembleCurveSet::hasMeanData() const
{
return m_ensembleStatCase->hasMeanData();
return m_ensembleStatCaseY->hasMeanData();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
QPointer<RiuDraggableOverlayFrame> m_filterOverlayFrame;
QPointer<RiuDraggableOverlayFrame> m_objectiveFunctionOverlayFrame;

std::unique_ptr<RimEnsembleStatisticsCase> m_ensembleStatCase;
std::unique_ptr<RimEnsembleStatisticsCase> m_ensembleStatCaseY;
std::unique_ptr<RimEnsembleStatisticsCase> m_ensembleStatCaseX;

std::unique_ptr<RiaSummaryCurveDefinitionAnalyser> m_analyserOfSelectedCurveDefs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase( RimEnsembleCurveSet* curveSet )
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase()
{
m_curveSet = curveSet;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -56,83 +55,99 @@ const std::vector<time_t>& RimEnsembleStatisticsCase::timeSteps() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimEnsembleStatisticsCase::p10() const
std::vector<time_t> RimEnsembleStatisticsCase::timeSteps( const RifEclipseSummaryAddress& resultAddress ) const
{
return m_p10Data;
return m_timeSteps;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimEnsembleStatisticsCase::p50() const
bool RimEnsembleStatisticsCase::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
{
return m_p50Data;
const std::vector<double>* sourceData = nullptr;
auto quantityName = resultAddress.ensembleStatisticsVectorName();

if ( quantityName == ENSEMBLE_STAT_P10_QUANTITY_NAME )
sourceData = &p10();
else if ( quantityName == ENSEMBLE_STAT_P50_QUANTITY_NAME )
sourceData = &p50();
else if ( quantityName == ENSEMBLE_STAT_P90_QUANTITY_NAME )
sourceData = &p90();
else if ( quantityName == ENSEMBLE_STAT_MEAN_QUANTITY_NAME )
sourceData = &mean();

if ( !sourceData ) return false;

values->clear();
values->reserve( sourceData->size() );
for ( auto val : *sourceData )
values->push_back( val );
return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimEnsembleStatisticsCase::p90() const
std::string RimEnsembleStatisticsCase::unitName( const RifEclipseSummaryAddress& resultAddress ) const
{
return m_p90Data;
return "RimEnsembleStatisticsCase - Undefined Unit";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimEnsembleStatisticsCase::mean() const
const std::vector<double>& RimEnsembleStatisticsCase::p10() const
{
return m_meanData;
return m_p10Data;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEnsembleStatisticsCase::caseName() const
const std::vector<double>& RimEnsembleStatisticsCase::p50() const
{
return "Ensemble Statistics";
return m_p50Data;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleStatisticsCase::createSummaryReaderInterface()
const std::vector<double>& RimEnsembleStatisticsCase::p90() const
{
m_statisticsReader.reset( new RifEnsembleStatisticsReader( this ) );
return m_p90Data;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifSummaryReaderInterface* RimEnsembleStatisticsCase::summaryReader()
const std::vector<double>& RimEnsembleStatisticsCase::mean() const
{
if ( !m_statisticsReader )
{
createSummaryReaderInterface();
}
return m_statisticsReader.get();
return m_meanData;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimEnsembleCurveSet* RimEnsembleStatisticsCase::curveSet() const
QString RimEnsembleStatisticsCase::caseName() const
{
return m_curveSet;
return "Ensemble Statistics";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleStatisticsCase::calculate( const std::vector<RimSummaryCase*>& sumCases, bool includeIncompleteCurves )
void RimEnsembleStatisticsCase::createSummaryReaderInterface()
{
auto inputAddress = m_curveSet->summaryAddress();
if ( m_statisticsReader && inputAddress.isValid() )
{
const std::vector<RimSummaryCase*>& validCases = validSummaryCases( sumCases, inputAddress, includeIncompleteCurves );
// m_statisticsReader.reset( new RifEnsembleStatisticsReader( this ) );
}

calculate( validCases, inputAddress, includeIncompleteCurves );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifSummaryReaderInterface* RimEnsembleStatisticsCase::summaryReader()
{
return this;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -202,10 +217,6 @@ void RimEnsembleStatisticsCase::calculate( const std::vector<RimSummaryCase*>& s
//--------------------------------------------------------------------------------------------------
RiaDefines::EclipseUnitSystem RimEnsembleStatisticsCase::unitSystem() const
{
if ( m_curveSet )
{
return m_curveSet->summaryCaseCollection()->unitSystem();
}
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
#include "RiaDateTimeDefines.h"
#include "RiaDefines.h"

#include "RifSummaryReaderInterface.h"

#include "RimSummaryCase.h"

class RifEnsembleStatisticsReader;
class RimEnsembleCurveSet;
class RifEclipseSummaryAddress;

//==================================================================================================
///
//==================================================================================================
class RimEnsembleStatisticsCase : public RimSummaryCase
class RimEnsembleStatisticsCase : public RimSummaryCase, public RifSummaryReaderInterface
{
public:
RimEnsembleStatisticsCase( RimEnsembleCurveSet* curveSet );
RimEnsembleStatisticsCase();

const std::vector<time_t>& timeSteps() const;
const std::vector<double>& p10() const;
Expand All @@ -50,13 +50,14 @@ class RimEnsembleStatisticsCase : public RimSummaryCase
void createSummaryReaderInterface() override;
RifSummaryReaderInterface* summaryReader() override;

const RimEnsembleCurveSet* curveSet() const;

void calculate( const std::vector<RimSummaryCase*>& sumCases, bool includeIncompleteCurves );
void calculate( const std::vector<RimSummaryCase*>& sumCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves );
RiaDefines::EclipseUnitSystem unitSystem() const;

std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;

private:
void calculate( const std::vector<RimSummaryCase*>& sumCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves );
void clearData();
static std::vector<RimSummaryCase*> validSummaryCases( const std::vector<RimSummaryCase*>& allSumCases,
const RifEclipseSummaryAddress& inputAddress,
Expand All @@ -66,9 +67,6 @@ class RimEnsembleStatisticsCase : public RimSummaryCase
static RiaDefines::DateTimePeriod findBestResamplingPeriod( time_t minTimeStep, time_t maxTimeStep );

private:
std::unique_ptr<RifEnsembleStatisticsReader> m_statisticsReader;
RimEnsembleCurveSet* m_curveSet;

std::vector<time_t> m_timeSteps;
std::vector<double> m_p10Data;
std::vector<double> m_p50Data;
Expand Down

0 comments on commit df5345a

Please sign in to comment.