mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 15:26:48 -06:00
#3077 Ensemble statistics. Option to base stat calc on filtered cases or all cases
This commit is contained in:
parent
0c1c454cdc
commit
bcf7938427
@ -427,8 +427,19 @@ EnsembleParameter::Type RimEnsembleCurveSet::currentEnsembleParameterType() cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateAllCurves()
|
||||
{
|
||||
updateEnsembleCurves();
|
||||
updateStatisticsCurves(true);
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
RimSummaryAddress* addr = m_yValuesCurveVariable();
|
||||
|
||||
if (group && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
{
|
||||
std::vector<RimSummaryCase*> allCases = group->allSummaryCases();
|
||||
std::vector<RimSummaryCase*> filteredCases = filterEnsembleCases(allCases);
|
||||
|
||||
m_isCurveSetFiltered = filteredCases.size() < allCases.size();
|
||||
|
||||
updateEnsembleCurves(filteredCases);
|
||||
updateStatisticsCurves(m_statistics->basedOnFilteredCases() ? filteredCases : allCases);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -561,14 +572,16 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
|
||||
{
|
||||
{
|
||||
QString curveDataGroupName = "Summary Vector";
|
||||
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y");
|
||||
//caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y");
|
||||
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Summary Vector Y");
|
||||
curveDataGroup->add(&m_yValuesSummaryGroup);
|
||||
curveDataGroup->add(&m_yValuesSelectedVariableDisplayField);
|
||||
curveDataGroup->add(&m_plotAxis);
|
||||
curveDataGroup->add(&m_yPushButtonSelectSummaryAddress);
|
||||
|
||||
QString curveVarSelectionGroupName = "Vector Selection Filter Y";
|
||||
caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroupWithKeyword("Vector Selection Filter", curveVarSelectionGroupName);
|
||||
//caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroupWithKeyword("Vector Selection Filter", curveVarSelectionGroupName);
|
||||
caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroup(curveVarSelectionGroupName);
|
||||
curveVarSelectionGroup->setCollapsedByDefault(true);
|
||||
m_yValuesSummaryFilter->uiOrdering(uiConfigName, *curveVarSelectionGroup);
|
||||
curveVarSelectionGroup->add(&m_yValuesUiFilterResultSelection);
|
||||
@ -902,7 +915,7 @@ void RimEnsembleCurveSet::updateQwtPlotAxis()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateEnsembleCurves()
|
||||
void RimEnsembleCurveSet::updateEnsembleCurves(const std::vector<RimSummaryCase*>& sumCases)
|
||||
{
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
@ -912,14 +925,12 @@ void RimEnsembleCurveSet::updateEnsembleCurves()
|
||||
m_qwtPlotCurveForLegendText->detach();
|
||||
deleteStatisticsCurves();
|
||||
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
RimSummaryAddress* addr = m_yValuesCurveVariable();
|
||||
if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
if (plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
{
|
||||
if(m_showCurves)
|
||||
{
|
||||
const auto filteredCases = filterEnsembleCases(group);
|
||||
for (auto& sumCase : filteredCases)
|
||||
for (auto& sumCase : sumCases)
|
||||
{
|
||||
RimSummaryCurve* curve = new RimSummaryCurve();
|
||||
curve->setSummaryCaseY(sumCase);
|
||||
@ -939,8 +950,6 @@ void RimEnsembleCurveSet::updateEnsembleCurves()
|
||||
m_yValuesSummaryFilter->updateFromAddress(addr->address());
|
||||
|
||||
if (plot->qwtPlot()) m_qwtPlotCurveForLegendText->attach(plot->qwtPlot());
|
||||
|
||||
m_isCurveSetFiltered = filteredCases.size() < group->allSummaryCases().size();
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
@ -959,7 +968,7 @@ void RimEnsembleCurveSet::updateEnsembleCurves()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateStatisticsCurves(bool calculate = true)
|
||||
void RimEnsembleCurveSet::updateStatisticsCurves(const std::vector<RimSummaryCase*>& sumCases)
|
||||
{
|
||||
using SAddr = RifEclipseSummaryAddress;
|
||||
|
||||
@ -968,10 +977,15 @@ void RimEnsembleCurveSet::updateStatisticsCurves(bool calculate = true)
|
||||
|
||||
if (m_disableStatisticCurves || !group || addr->address().category() == RifEclipseSummaryAddress::SUMMARY_INVALID) return;
|
||||
|
||||
if (calculate)
|
||||
// Calculate
|
||||
{
|
||||
// Calculate
|
||||
m_ensembleStatCase->calculate();
|
||||
std::vector<RimSummaryCase*> statCases = sumCases;
|
||||
if (statCases.empty())
|
||||
{
|
||||
if (m_statistics->basedOnFilteredCases()) statCases = filterEnsembleCases(group->allSummaryCases());
|
||||
else statCases = group->allSummaryCases();
|
||||
}
|
||||
m_ensembleStatCase->calculate(statCases);
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
@ -1027,6 +1041,14 @@ void RimEnsembleCurveSet::updateStatisticsCurves(bool calculate = true)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateStatisticsCurves()
|
||||
{
|
||||
updateStatisticsCurves(std::vector<RimSummaryCase*>());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1091,18 +1113,15 @@ std::vector<QString> RimEnsembleCurveSet::ensembleParameterNames() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RimEnsembleCurveSet::filterEnsembleCases(const RimSummaryCaseCollection* ensemble)
|
||||
std::vector<RimSummaryCase*> RimEnsembleCurveSet::filterEnsembleCases(const std::vector<RimSummaryCase*>& sumCases)
|
||||
{
|
||||
if (!ensemble) return std::vector<RimSummaryCase*>();
|
||||
|
||||
auto sumCases = ensemble->allSummaryCases();
|
||||
auto filteredCases = sumCases;
|
||||
|
||||
for (auto& filter : m_curveFilters->filters())
|
||||
{
|
||||
sumCases = filter->applyFilter(sumCases);
|
||||
filteredCases = filter->applyFilter(filteredCases);
|
||||
}
|
||||
|
||||
return sumCases;
|
||||
return filteredCases;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -98,15 +98,15 @@ public:
|
||||
EnsembleParameter::Type currentEnsembleParameterType() const;
|
||||
|
||||
void updateAllCurves();
|
||||
void updateEnsembleCurves();
|
||||
void updateStatisticsCurves(bool calculate);
|
||||
void updateStatisticsCurves();
|
||||
|
||||
RimEnsembleCurveSet* clone() const;
|
||||
void showCurves(bool show);
|
||||
|
||||
void updateAllTextInPlot();
|
||||
std::vector<QString> ensembleParameterNames() const;
|
||||
|
||||
std::vector<RimSummaryCase*> filterEnsembleCases(const RimSummaryCaseCollection* ensemble);
|
||||
std::vector<RimSummaryCase*> filterEnsembleCases(const std::vector<RimSummaryCase*>& sumCases);
|
||||
void disableStatisticCurves();
|
||||
bool isFiltered() const;
|
||||
|
||||
@ -115,6 +115,9 @@ public:
|
||||
bool hasP90Data() const;
|
||||
|
||||
private:
|
||||
void updateEnsembleCurves(const std::vector<RimSummaryCase*>& sumCases);
|
||||
void updateStatisticsCurves(const std::vector<RimSummaryCase*>& sumCases);
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* objectToggleField();
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
@ -38,6 +38,7 @@ RimEnsembleStatistics::RimEnsembleStatistics()
|
||||
CAF_PDM_InitObject("Ensemble Curve Filter", ":/EnsembleCurveSet16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_active, "Active", true, "Show statistics curves", "", "", "");
|
||||
CAF_PDM_InitField(&m_basedOnFilteredCases, "BasedOnFilteredCases", false, "Based on Filtered Cases", "", "", "");
|
||||
CAF_PDM_InitField(&m_showP10Curve, "ShowP10Curve", true, "P90", "", "", ""); // Yes, P90
|
||||
CAF_PDM_InitField(&m_showP50Curve, "ShowP50Curve", true, "P50", "", "", "");
|
||||
CAF_PDM_InitField(&m_showP90Curve, "ShowP90Curve", true, "P10", "", "", ""); // Yes, P10
|
||||
@ -86,23 +87,13 @@ void RimEnsembleStatistics::disableMeanCurve(bool disable)
|
||||
m_showMeanCurve.uiCapability()->setUiReadOnly(disable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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_basedOnFilteredCases ||
|
||||
changedField == &m_showP10Curve ||
|
||||
changedField == &m_showP50Curve ||
|
||||
changedField == &m_showP90Curve ||
|
||||
@ -113,7 +104,7 @@ void RimEnsembleStatistics::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
auto curveSet = parentCurveSet();
|
||||
if (!curveSet) return;
|
||||
|
||||
curveSet->updateStatisticsCurves(false);
|
||||
curveSet->updateStatisticsCurves();
|
||||
|
||||
if (changedField == &m_active) curveSet->updateConnectedEditors();
|
||||
}
|
||||
@ -127,6 +118,7 @@ void RimEnsembleStatistics::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
|
||||
auto curveSet = parentCurveSet();
|
||||
|
||||
uiOrdering.add(&m_active);
|
||||
uiOrdering.add(&m_basedOnFilteredCases);
|
||||
uiOrdering.add(&m_showCurveLabels);
|
||||
uiOrdering.add(&m_color);
|
||||
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
RimEnsembleStatistics();
|
||||
|
||||
bool isActive() const;
|
||||
bool basedOnFilteredCases() const { return m_basedOnFilteredCases; }
|
||||
bool showP10Curve() const { return m_showP10Curve; }
|
||||
bool showP50Curve() const { return m_showP50Curve; }
|
||||
bool showP90Curve() const { return m_showP90Curve; }
|
||||
@ -53,7 +54,6 @@ public:
|
||||
void disableP90Curve(bool disable);
|
||||
void disableMeanCurve(bool disable);
|
||||
|
||||
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;
|
||||
|
||||
@ -61,6 +61,7 @@ private:
|
||||
RimEnsembleCurveSet* parentCurveSet() const;
|
||||
|
||||
caf::PdmField<bool> m_active;
|
||||
caf::PdmField<bool> m_basedOnFilteredCases;
|
||||
caf::PdmField<bool> m_showP10Curve;
|
||||
caf::PdmField<bool> m_showP50Curve;
|
||||
caf::PdmField<bool> m_showP90Curve;
|
||||
|
@ -118,13 +118,12 @@ const RimEnsembleCurveSet* RimEnsembleStatisticsCase::curveSet() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatisticsCase::calculate()
|
||||
void RimEnsembleStatisticsCase::calculate(const std::vector<RimSummaryCase*>& sumCases)
|
||||
{
|
||||
auto inputAddress = m_curveSet->summaryAddress();
|
||||
auto ensemble = m_curveSet->summaryCaseCollection();
|
||||
if (m_statisticsReader && ensemble && inputAddress.isValid())
|
||||
if (m_statisticsReader && inputAddress.isValid())
|
||||
{
|
||||
calculate(validSummaryCases(ensemble->allSummaryCases(), inputAddress), inputAddress);
|
||||
calculate(validSummaryCases(sumCases, inputAddress), inputAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +210,7 @@ std::vector<RimSummaryCase*> RimEnsembleStatisticsCase::validSummaryCases(const
|
||||
const auto& reader = sumCase->summaryReader();
|
||||
if (reader)
|
||||
{
|
||||
std::vector<time_t> timeSteps = reader->timeSteps(inputAddress);
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps(inputAddress);
|
||||
if (!timeSteps.empty())
|
||||
{
|
||||
time_t firstTimeStep = timeSteps.front();
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
const RimEnsembleCurveSet* curveSet() const;
|
||||
|
||||
void calculate();
|
||||
void calculate(const std::vector<RimSummaryCase*>& sumCases);
|
||||
|
||||
private:
|
||||
void calculate(const std::vector<RimSummaryCase*> sumCases, const RifEclipseSummaryAddress& inputAddress);
|
||||
|
Loading…
Reference in New Issue
Block a user