mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2659 Ensemble statistics. First version
This commit is contained in:
parent
b73c8e0565
commit
69accdc4c6
@ -25,6 +25,7 @@
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -474,6 +475,17 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::importedAddress(const std::st
|
||||
return addr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress RifEclipseSummaryAddress::ensembleStatisticsAddress(const std::string& quantityName)
|
||||
{
|
||||
RifEclipseSummaryAddress addr;
|
||||
addr.m_variableCategory = SUMMARY_ENSEMBLE_STATISTICS;
|
||||
addr.m_quantityName = quantityName;
|
||||
return addr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -775,6 +787,14 @@ bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAd
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool operator!=(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second)
|
||||
{
|
||||
return !operator==(first, second);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -23,6 +23,12 @@
|
||||
|
||||
class QTextStream;
|
||||
|
||||
|
||||
#define ENSEMBLE_STAT_P10_QUANTITY_NAME "P10"
|
||||
#define ENSEMBLE_STAT_P50_QUANTITY_NAME "P50"
|
||||
#define ENSEMBLE_STAT_P90_QUANTITY_NAME "P90"
|
||||
#define ENSEMBLE_STAT_MEAN_QUANTITY_NAME "MEAN"
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
@ -50,7 +56,8 @@ public:
|
||||
SUMMARY_BLOCK,
|
||||
SUMMARY_BLOCK_LGR,
|
||||
SUMMARY_CALCULATED,
|
||||
SUMMARY_IMPORTED
|
||||
SUMMARY_IMPORTED,
|
||||
SUMMARY_ENSEMBLE_STATISTICS
|
||||
};
|
||||
|
||||
enum SummaryIdentifierType
|
||||
@ -134,6 +141,7 @@ public:
|
||||
static RifEclipseSummaryAddress blockLgrAddress(const std::string& quantityName, const std::string& lgrName, int i, int j, int k);
|
||||
static RifEclipseSummaryAddress calculatedAddress(const std::string& quantityName);
|
||||
static RifEclipseSummaryAddress importedAddress(const std::string& quantityName);
|
||||
static RifEclipseSummaryAddress ensembleStatisticsAddress(const std::string& quantityName);
|
||||
|
||||
// Access methods
|
||||
|
||||
@ -191,6 +199,7 @@ private:
|
||||
};
|
||||
|
||||
bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second);
|
||||
bool operator!=(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second);
|
||||
|
||||
bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second);
|
||||
|
||||
|
@ -34,6 +34,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilterCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatistics.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -71,6 +72,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilterCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatistics.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -25,10 +25,14 @@
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigTimeHistoryCurveMerger.h"
|
||||
|
||||
#include "RimEnsembleCurveFilter.h"
|
||||
#include "RimEnsembleCurveFilterCollection.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimEnsembleCurveSetColorManager.h"
|
||||
#include "RimEnsembleStatistics.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
@ -137,6 +141,10 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
|
||||
CAF_PDM_InitFieldNoDefault(&m_curveFilters, "CurveFilters", "Curve Filters", "", "", "");
|
||||
m_curveFilters = new RimEnsembleCurveFilterCollection();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_statistics, "Statistics", "Statistics", "", "", "");
|
||||
m_statistics = new RimEnsembleStatistics();
|
||||
m_statistics.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensemble Curve Set"), "Curve Set Name", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", "");
|
||||
@ -153,6 +161,9 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
|
||||
|
||||
m_qwtPlotCurveForLegendText = new QwtPlotCurve;
|
||||
m_qwtPlotCurveForLegendText->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true);
|
||||
|
||||
m_ensembleStatCase.reset(new RimEnsembleStatisticsCase(this));
|
||||
m_ensembleStatCase->createSummaryReaderInterface();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -200,6 +211,7 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address();
|
||||
|
||||
updateAllCurves();
|
||||
updateStatisticsCurves(true);
|
||||
|
||||
if (updateParentPlot)
|
||||
{
|
||||
@ -288,9 +300,45 @@ std::vector<RimSummaryCurve*> RimEnsembleCurveSet::curves() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::deleteAllCurves()
|
||||
void RimEnsembleCurveSet::deleteEnsembleCurves()
|
||||
{
|
||||
m_curves.deleteAllChildObjects();
|
||||
std::vector<int> curvesIndexesToDelete;
|
||||
for (int c = 0; c < m_curves.size(); c++)
|
||||
{
|
||||
RimSummaryCurve* curve = m_curves[c];
|
||||
if (curve->summaryAddressY().category() != RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS)
|
||||
curvesIndexesToDelete.push_back(c);
|
||||
}
|
||||
|
||||
while (curvesIndexesToDelete.size() > 0)
|
||||
{
|
||||
int currIndex = curvesIndexesToDelete.back();
|
||||
delete m_curves[currIndex];
|
||||
m_curves.erase(currIndex);
|
||||
curvesIndexesToDelete.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::deleteStatisticsCurves()
|
||||
{
|
||||
std::vector<int> curvesIndexesToDelete;
|
||||
for (int c = 0; c < m_curves.size(); c++)
|
||||
{
|
||||
RimSummaryCurve* curve = m_curves[c];
|
||||
if (curve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS)
|
||||
curvesIndexesToDelete.push_back(c);
|
||||
}
|
||||
|
||||
while (curvesIndexesToDelete.size() > 0)
|
||||
{
|
||||
int currIndex = curvesIndexesToDelete.back();
|
||||
delete m_curves[currIndex];
|
||||
m_curves.erase(currIndex);
|
||||
curvesIndexesToDelete.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -380,6 +428,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection());
|
||||
|
||||
updateAllCurves();
|
||||
updateStatisticsCurves(true);
|
||||
|
||||
updateTextInPlot = true;
|
||||
}
|
||||
@ -388,7 +437,8 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
// Empty address cache
|
||||
m_allAddressesCache.clear();
|
||||
updateAllCurves();
|
||||
|
||||
updateStatisticsCurves(true);
|
||||
|
||||
updateTextInPlot = true;
|
||||
}
|
||||
else if (changedField == &m_color)
|
||||
@ -524,6 +574,9 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* statGroup = uiOrdering.addNewGroup("Statistics");
|
||||
|
||||
m_statistics->defineUiOrdering(uiConfigName, *statGroup);
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
@ -818,7 +871,7 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
firstAncestorOrThisOfType(plot);
|
||||
CVF_ASSERT(plot);
|
||||
|
||||
deleteAllCurves();
|
||||
deleteEnsembleCurves();
|
||||
m_qwtPlotCurveForLegendText->detach();
|
||||
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
@ -862,6 +915,57 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
updateCurveColors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateStatisticsCurves(bool calculate = true)
|
||||
{
|
||||
using SAddr = RifEclipseSummaryAddress;
|
||||
|
||||
if (calculate)
|
||||
{
|
||||
// Calculate
|
||||
m_ensembleStatCase->calculate(m_yValuesSummaryGroup, m_yValuesCurveVariable->address());
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
CVF_ASSERT(plot);
|
||||
|
||||
std::vector<RifEclipseSummaryAddress> addresses;
|
||||
if (m_statistics->isActive())
|
||||
{
|
||||
if (m_statistics->showP10Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P10_QUANTITY_NAME));
|
||||
if (m_statistics->showP50Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P50_QUANTITY_NAME));
|
||||
if (m_statistics->showP90Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P90_QUANTITY_NAME));
|
||||
if (m_statistics->showMeanCurve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_MEAN_QUANTITY_NAME));
|
||||
}
|
||||
|
||||
deleteStatisticsCurves();
|
||||
for (auto address : addresses)
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
curve->setParentQwtPlotNoReplot(plot->qwtPlot());
|
||||
m_curves.push_back(curve);
|
||||
curve->setSymbol(RimPlotCurve::SYMBOL_ELLIPSE);
|
||||
curve->setSymbolSkipDinstance(50);
|
||||
curve->setLineStyle(RimPlotCurve::STYLE_SOLID);
|
||||
curve->setSummaryCaseY(m_ensembleStatCase.get());
|
||||
curve->setSummaryAddressY(address);
|
||||
curve->setZOrder(1000);
|
||||
|
||||
curve->updateCurveVisibility(false);
|
||||
curve->loadDataAndUpdate(false);
|
||||
}
|
||||
|
||||
if (plot->qwtPlot())
|
||||
{
|
||||
plot->qwtPlot()->updateLegend();
|
||||
plot->qwtPlot()->replot();
|
||||
plot->updateAxes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1035,3 +1139,244 @@ void RimEnsembleCurveSet::updateLegendMappingMode()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEnsembleStatisticsReader::RifEnsembleStatisticsReader(RimEnsembleStatisticsCase* ensStatCase)
|
||||
{
|
||||
CVF_ASSERT(ensStatCase);
|
||||
|
||||
m_ensembleStatCase = ensStatCase;
|
||||
|
||||
m_allResultAddresses = std::vector<RifEclipseSummaryAddress>(
|
||||
{
|
||||
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P10_QUANTITY_NAME),
|
||||
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P50_QUANTITY_NAME),
|
||||
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P90_QUANTITY_NAME),
|
||||
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_MEAN_QUANTITY_NAME)
|
||||
});
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RifEnsembleStatisticsReader::timeSteps(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
return m_ensembleStatCase->timeSteps();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEnsembleStatisticsReader::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const
|
||||
{
|
||||
if (!validateAddress(resultAddress)) return false;
|
||||
|
||||
const std::vector<double>* sourceData = nullptr;
|
||||
if (resultAddress.quantityName() == ENSEMBLE_STAT_P10_QUANTITY_NAME) sourceData = &m_ensembleStatCase->p10();
|
||||
else if (resultAddress.quantityName() == ENSEMBLE_STAT_P50_QUANTITY_NAME) sourceData = &m_ensembleStatCase->p50();
|
||||
else if (resultAddress.quantityName() == ENSEMBLE_STAT_P90_QUANTITY_NAME) sourceData = &m_ensembleStatCase->p90();
|
||||
else if (resultAddress.quantityName() == ENSEMBLE_STAT_MEAN_QUANTITY_NAME) sourceData = &m_ensembleStatCase->mean();
|
||||
|
||||
if (!sourceData) return false;
|
||||
|
||||
values->clear();
|
||||
values->reserve(sourceData->size());
|
||||
for (auto val : *sourceData) values->push_back(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RifEnsembleStatisticsReader::unitName(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
return "(RifEnsembleStatisticsReader::unitName)";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEnsembleStatisticsReader::validateAddress(const RifEclipseSummaryAddress& address) const
|
||||
{
|
||||
return address.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS &&
|
||||
!address.quantityName().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase(RimEnsembleCurveSet* curveSet)
|
||||
{
|
||||
m_curveSet = curveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RimEnsembleStatisticsCase::timeSteps() const
|
||||
{
|
||||
return m_timeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimEnsembleStatisticsCase::p10() const
|
||||
{
|
||||
return m_p10Data;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimEnsembleStatisticsCase::p50() const
|
||||
{
|
||||
return m_p50Data;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimEnsembleStatisticsCase::p90() const
|
||||
{
|
||||
return m_p90Data;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimEnsembleStatisticsCase::mean() const
|
||||
{
|
||||
return m_meanData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimEnsembleStatisticsCase::caseName()
|
||||
{
|
||||
return "Ensemble Statistics";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatisticsCase::createSummaryReaderInterface()
|
||||
{
|
||||
m_statisticsReader.reset(new RifEnsembleStatisticsReader(this));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSummaryReaderInterface* RimEnsembleStatisticsCase::summaryReader()
|
||||
{
|
||||
return m_statisticsReader.get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimEnsembleCurveSet* RimEnsembleStatisticsCase::curveSet() const
|
||||
{
|
||||
return m_curveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatisticsCase::calculate(const RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& inputAddress)
|
||||
{
|
||||
RigTimeHistoryCurveMerger curveMerger;
|
||||
int caseCount = (int)ensemble->allSummaryCases().size();
|
||||
|
||||
{
|
||||
for (const auto& sumCase : ensemble->allSummaryCases())
|
||||
{
|
||||
const auto& reader = sumCase->summaryReader();
|
||||
if (reader)
|
||||
{
|
||||
std::vector<time_t> timeSteps = reader->timeSteps(inputAddress);
|
||||
std::vector<double> values;
|
||||
reader->values(inputAddress, &values);
|
||||
|
||||
curveMerger.addCurveData(values, timeSteps);
|
||||
}
|
||||
}
|
||||
curveMerger.computeInterpolatedValues();
|
||||
}
|
||||
|
||||
const std::vector<time_t>& allTimeSteps = curveMerger.allTimeSteps();
|
||||
std::vector<std::vector<double>> allValues;
|
||||
{
|
||||
for (int c = 0; c < caseCount; c++)
|
||||
{
|
||||
allValues.push_back(curveMerger.interpolatedCurveValuesForAllTimeSteps(c));
|
||||
}
|
||||
}
|
||||
|
||||
clearData();
|
||||
m_timeSteps = allTimeSteps;
|
||||
|
||||
for (int t = 0; t < (int)allTimeSteps.size(); t++)
|
||||
{
|
||||
std::vector<double> valuesForTimeSteps;
|
||||
valuesForTimeSteps.reserve(caseCount);
|
||||
|
||||
for (int c = 0; c < caseCount; c++)
|
||||
{
|
||||
valuesForTimeSteps.push_back(allValues[c][t]);
|
||||
}
|
||||
|
||||
{
|
||||
double min, max, range, mean, stdev;
|
||||
RigStatisticsMath::calculateBasicStatistics(valuesForTimeSteps, &min, &max, nullptr, &range, &mean, &stdev);
|
||||
|
||||
std::vector<size_t> histogram;
|
||||
RigHistogramCalculator histCalc(min, max, 100, &histogram);
|
||||
histCalc.addData(valuesForTimeSteps);
|
||||
|
||||
double p10, p50, p90;
|
||||
p10 = histCalc.calculatePercentil(0.1);
|
||||
p50 = histCalc.calculatePercentil(0.5);
|
||||
p90 = histCalc.calculatePercentil(0.9);
|
||||
|
||||
m_p10Data.push_back(p10);
|
||||
m_p50Data.push_back(p50);
|
||||
m_p90Data.push_back(p90);
|
||||
m_meanData.push_back(mean);
|
||||
}
|
||||
|
||||
}
|
||||
m_addressUsedInLastCalculation = inputAddress;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatisticsCase::calculate()
|
||||
{
|
||||
auto inputAddress = m_curveSet->summaryAddress();
|
||||
auto ensemble = m_curveSet->summaryCaseCollection();
|
||||
if (m_statisticsReader && ensemble && inputAddress.isValid())
|
||||
{
|
||||
calculate(ensemble, inputAddress);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatisticsCase::clearData()
|
||||
{
|
||||
m_timeSteps.clear();
|
||||
m_p10Data.clear();
|
||||
m_p50Data.clear();
|
||||
m_p90Data.clear();
|
||||
m_meanData.clear();
|
||||
m_addressUsedInLastCalculation = RifEclipseSummaryAddress();
|
||||
}
|
||||
|
@ -20,10 +20,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
@ -48,7 +50,70 @@ class RimSummaryFilter;
|
||||
class RimSummaryPlotSourceStepping;
|
||||
class RimSummaryCurveAutoName;
|
||||
class RimEnsembleCurveFilterCollection;
|
||||
class RimEnsembleStatistics;
|
||||
class QKeyEvent;
|
||||
class RimEnsembleStatisticsCase;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RifEnsembleStatisticsReader : public RifSummaryReaderInterface
|
||||
{
|
||||
public:
|
||||
RifEnsembleStatisticsReader(RimEnsembleStatisticsCase* ensStatCase);
|
||||
|
||||
virtual const std::vector<time_t>& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const override;
|
||||
virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
|
||||
private:
|
||||
bool validateAddress(const RifEclipseSummaryAddress& address) const;
|
||||
|
||||
private:
|
||||
RimEnsembleStatisticsCase * m_ensembleStatCase;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimEnsembleStatisticsCase : public RimSummaryCase
|
||||
{
|
||||
public:
|
||||
RimEnsembleStatisticsCase(RimEnsembleCurveSet* curveSet);
|
||||
|
||||
const std::vector<time_t>& timeSteps() const;
|
||||
const std::vector<double>& p10() const;
|
||||
const std::vector<double>& p50() const;
|
||||
const std::vector<double>& p90() const;
|
||||
const std::vector<double>& mean() const;
|
||||
|
||||
virtual QString caseName() override;
|
||||
virtual void createSummaryReaderInterface() override;
|
||||
virtual RifSummaryReaderInterface* summaryReader() override;
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override {}
|
||||
|
||||
const RimEnsembleCurveSet* curveSet() const;
|
||||
|
||||
void calculate();
|
||||
void calculate(const RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& inputAddress);
|
||||
|
||||
private:
|
||||
void clearData();
|
||||
|
||||
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;
|
||||
std::vector<double> m_p90Data;
|
||||
std::vector<double> m_meanData;
|
||||
|
||||
RifEclipseSummaryAddress m_addressUsedInLastCalculation;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -78,7 +143,8 @@ public:
|
||||
RifEclipseSummaryAddress summaryAddress() const;
|
||||
std::vector<RimSummaryCurve*> curves() const;
|
||||
|
||||
void deleteAllCurves();
|
||||
void deleteEnsembleCurves();
|
||||
void deleteStatisticsCurves();
|
||||
|
||||
RimRegularLegendConfig* legendConfig();
|
||||
void onLegendDefinitionChanged();
|
||||
@ -91,6 +157,7 @@ public:
|
||||
EnsembleParameter::Type currentEnsembleParameterType() const;
|
||||
|
||||
void updateAllCurves();
|
||||
void updateStatisticsCurves(bool calculate);
|
||||
RimEnsembleCurveSet* clone() const;
|
||||
void showCurves(bool show);
|
||||
|
||||
@ -148,6 +215,7 @@ private:
|
||||
|
||||
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
|
||||
caf::PdmChildField<RimEnsembleCurveFilterCollection*> m_curveFilters;
|
||||
caf::PdmChildField<RimEnsembleStatistics*> m_statistics;
|
||||
|
||||
caf::PdmField<bool> m_isUsingAutoName;
|
||||
caf::PdmField<QString> m_userDefinedName;
|
||||
@ -157,5 +225,7 @@ private:
|
||||
std::set<RifEclipseSummaryAddress> m_allAddressesCache;
|
||||
|
||||
QwtPlotCurve* m_qwtPlotCurveForLegendText;
|
||||
|
||||
std::unique_ptr<RimEnsembleStatisticsCase> m_ensembleStatCase;
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,105 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimEnsembleStatistics.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigTimeHistoryCurveMerger.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimEnsembleStatistics, "RimEnsembleStatistics");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleStatistics::RimEnsembleStatistics()
|
||||
{
|
||||
CAF_PDM_InitObject("Ensemble Curve Filter", ":/EnsembleCurveSet16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_active, "Active", "Active", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_showP10Curve, "ShowP10Curve", "P10", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_showP50Curve, "ShowP50Curve", "P50", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_showP90Curve, "ShowP90Curve", "P90", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_showMeanCurve, "ShowPMeanCurve", "Mean", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleStatistics::isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimEnsembleStatistics::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_active ||
|
||||
changedField == &m_showP10Curve ||
|
||||
changedField == &m_showP50Curve ||
|
||||
changedField == &m_showP90Curve ||
|
||||
changedField == &m_showMeanCurve)
|
||||
{
|
||||
if (!parentCurveSet()) return;
|
||||
|
||||
parentCurveSet()->updateStatisticsCurves(false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&m_active);
|
||||
uiOrdering.add(&m_showP10Curve);
|
||||
uiOrdering.add(&m_showP50Curve);
|
||||
uiOrdering.add(&m_showP90Curve);
|
||||
uiOrdering.add(&m_showMeanCurve);
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* RimEnsembleStatistics::parentCurveSet() const
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet;
|
||||
firstAncestorOrThisOfType(curveSet);
|
||||
return curveSet;
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryCaseCollection;
|
||||
class RimEnsembleStatisticsCase;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimEnsembleStatistics : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimEnsembleStatistics();
|
||||
|
||||
bool isActive() const;
|
||||
bool showP10Curve() const { return m_showP10Curve; };
|
||||
bool showP50Curve() const { return m_showP50Curve; };
|
||||
bool showP90Curve() const { return m_showP90Curve; };
|
||||
bool showMeanCurve() const { return m_showMeanCurve; };
|
||||
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
RimEnsembleCurveSet* parentCurveSet() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_active;
|
||||
caf::PdmField<bool> m_showP10Curve;
|
||||
caf::PdmField<bool> m_showP50Curve;
|
||||
caf::PdmField<bool> m_showP90Curve;
|
||||
caf::PdmField<bool> m_showMeanCurve;
|
||||
|
||||
RimSummaryCaseCollection* m_ensemble;
|
||||
};
|
||||
|
@ -889,8 +889,9 @@ void RimSummaryCurve::calculateCurveInterpolationFromAddress()
|
||||
{
|
||||
if (m_yValuesCurveVariable())
|
||||
{
|
||||
auto category = m_yValuesCurveVariable()->address().category();
|
||||
QString quantityName = QString::fromUtf8(m_yValuesCurveVariable()->address().quantityName().c_str());
|
||||
if (quantityName.endsWith("T"))
|
||||
if (quantityName.endsWith("T") || category == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS)
|
||||
{
|
||||
m_curveInterpolation = INTERPOLATION_POINT_TO_POINT;
|
||||
}
|
||||
|
@ -76,6 +76,14 @@ std::vector<double>& RigTimeHistoryCurveMerger::interpolatedCurveValuesForAllTim
|
||||
return m_interpolatedValuesForAllCurves[curveIdx];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RigTimeHistoryCurveMerger::interploatedCurveCount() const
|
||||
{
|
||||
return static_cast<int>(m_interpolatedValuesForAllCurves.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
RigCurveDataTools::CurveIntervals validIntervalsForAllTimeSteps() const;
|
||||
const std::vector<time_t>& allTimeSteps() const;
|
||||
const std::vector<double>& interpolatedCurveValuesForAllTimeSteps(size_t curveIdx) const;
|
||||
int interploatedCurveCount() const;
|
||||
|
||||
// Non-const access is not required by any clients, but the expression parser has no available const interface
|
||||
// for specifying a data source for an expression variable. Allow non-const access to avoid copy of the contained
|
||||
|
Loading…
Reference in New Issue
Block a user