mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-26 00:06:49 -06:00
#2659 Ensemble statistics. Disable statistic curves if not possible to calculate percentile
This commit is contained in:
parent
17ee25d0b2
commit
ee195e909b
@ -958,9 +958,12 @@ void RimEnsembleCurveSet::updateStatisticsCurves(bool calculate = true)
|
||||
{
|
||||
RifEclipseSummaryAddress dataAddress = m_yValuesCurveVariable->address();
|
||||
|
||||
if (m_statistics->showP10Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P10_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showP50Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P50_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showP90Curve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P90_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showP10Curve() && m_ensembleStatCase->hasP10Data())
|
||||
addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P10_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showP50Curve() && m_ensembleStatCase->hasP50Data())
|
||||
addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P50_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showP90Curve() && m_ensembleStatCase->hasP90Data())
|
||||
addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_P90_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
if (m_statistics->showMeanCurve()) addresses.push_back(SAddr::ensembleStatisticsAddress(ENSEMBLE_STAT_MEAN_QUANTITY_NAME, dataAddress.quantityName()));
|
||||
}
|
||||
|
||||
@ -1077,6 +1080,30 @@ void RimEnsembleCurveSet::disableStatisticCurves()
|
||||
m_disableStatisticCurves = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleCurveSet::hasP10Data() const
|
||||
{
|
||||
return m_ensembleStatCase->hasP10Data();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleCurveSet::hasP50Data() const
|
||||
{
|
||||
return m_ensembleStatCase->hasP50Data();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleCurveSet::hasP90Data() const
|
||||
{
|
||||
return m_ensembleStatCase->hasP90Data();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -107,6 +107,10 @@ public:
|
||||
std::vector<RimSummaryCase*> filterEnsembleCases(const RimSummaryCaseCollection* ensemble);
|
||||
void disableStatisticCurves();
|
||||
|
||||
bool hasP10Data() const;
|
||||
bool hasP50Data() const;
|
||||
bool hasP90Data() const;
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* objectToggleField();
|
||||
|
@ -53,6 +53,38 @@ bool RimEnsembleStatistics::isActive() const
|
||||
return m_active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::disableP10Curve(bool disable)
|
||||
{
|
||||
m_showP10Curve.uiCapability()->setUiReadOnly(disable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::disableP50Curve(bool disable)
|
||||
{
|
||||
m_showP50Curve.uiCapability()->setUiReadOnly(disable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::disableP90Curve(bool disable)
|
||||
{
|
||||
m_showP90Curve.uiCapability()->setUiReadOnly(disable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::disableMeanCurve(bool disable)
|
||||
{
|
||||
m_showMeanCurve.uiCapability()->setUiReadOnly(disable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -90,6 +122,8 @@ void RimEnsembleStatistics::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleStatistics::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
auto curveSet = parentCurveSet();
|
||||
|
||||
uiOrdering.add(&m_active);
|
||||
|
||||
auto group = uiOrdering.addNewGroup("Curves");
|
||||
@ -99,10 +133,10 @@ void RimEnsembleStatistics::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
|
||||
group->add(&m_showMeanCurve);
|
||||
group->add(&m_color);
|
||||
|
||||
m_showP10Curve.uiCapability()->setUiReadOnly(!m_active);
|
||||
m_showP50Curve.uiCapability()->setUiReadOnly(!m_active);
|
||||
m_showP90Curve.uiCapability()->setUiReadOnly(!m_active);
|
||||
m_showMeanCurve.uiCapability()->setUiReadOnly(!m_active);
|
||||
disableP10Curve(!m_active || !curveSet->hasP10Data());
|
||||
disableP50Curve(!m_active || !curveSet->hasP50Data());
|
||||
disableP90Curve(!m_active || !curveSet->hasP90Data());
|
||||
disableMeanCurve(!m_active);
|
||||
m_color.uiCapability()->setUiReadOnly(!m_active);
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
|
@ -41,19 +41,24 @@ 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; };
|
||||
bool showP10Curve() const { return m_showP10Curve; }
|
||||
bool showP50Curve() const { return m_showP50Curve; }
|
||||
bool showP90Curve() const { return m_showP90Curve; }
|
||||
bool showMeanCurve() const { return m_showMeanCurve; }
|
||||
cvf::Color3f color() const { return m_color; }
|
||||
|
||||
void disableP10Curve(bool disable);
|
||||
void disableP50Curve(bool disable);
|
||||
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;
|
||||
|
||||
private:
|
||||
RimEnsembleCurveSet* parentCurveSet() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_active;
|
||||
caf::PdmField<bool> m_showP10Curve;
|
||||
caf::PdmField<bool> m_showP50Curve;
|
||||
|
@ -30,6 +30,11 @@
|
||||
#include <set>
|
||||
#include <limits>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define DOUBLE_INF std::numeric_limits<double>::infinity()
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -169,9 +174,9 @@ void RimEnsembleStatisticsCase::calculate(const std::vector<RimSummaryCase*> sum
|
||||
double p10, p50, p90, mean;
|
||||
calculateStatistics(valuesAtTimeStep, &p10, &p50, &p90, &mean);
|
||||
|
||||
m_p10Data.push_back(p10);
|
||||
m_p50Data.push_back(p50);
|
||||
m_p90Data.push_back(p90);
|
||||
if (p10 != DOUBLE_INF) m_p10Data.push_back(p10);
|
||||
if (p50 != DOUBLE_INF) m_p50Data.push_back(p50);
|
||||
if (p90 != DOUBLE_INF) m_p90Data.push_back(p90);
|
||||
m_meanData.push_back(mean);
|
||||
}
|
||||
m_addressUsedInLastCalculation = inputAddress;
|
||||
@ -257,13 +262,17 @@ void RimEnsembleStatisticsCase::calculateStatistics(const std::vector<double>& v
|
||||
|
||||
int valueCount = (int)sortedValues.size();
|
||||
double percentiles[] = { 0.1, 0.5, 0.9 };
|
||||
double pValues[] = { 0, 0, 0 };
|
||||
double pValues[] = { DOUBLE_INF, DOUBLE_INF, DOUBLE_INF };
|
||||
|
||||
for (int i = P10; i <= P90; i++)
|
||||
{
|
||||
// Check valid params
|
||||
if ((percentiles[i] < 1.0 / ((double)valueCount + 1)) || (percentiles[i] > (double)valueCount / ((double)valueCount + 1))) continue;
|
||||
|
||||
double rank = percentiles[i] * (valueCount + 1) - 1;
|
||||
double rankInt;
|
||||
double rankFrac = std::modf(rank, &rankInt);
|
||||
|
||||
if (rankInt < valueCount - 1)
|
||||
{
|
||||
pValues[i] = sortedValues[rankInt] + rankFrac * (sortedValues[rankInt + 1] - sortedValues[rankInt]);
|
||||
|
@ -41,6 +41,10 @@ public:
|
||||
const std::vector<double>& p90() const;
|
||||
const std::vector<double>& mean() const;
|
||||
|
||||
bool hasP10Data() const {return !m_p10Data.empty(); }
|
||||
bool hasP50Data() const { return !m_p50Data.empty(); }
|
||||
bool hasP90Data() const { return !m_p90Data.empty(); }
|
||||
|
||||
virtual QString caseName() override;
|
||||
virtual void createSummaryReaderInterface() override;
|
||||
virtual RifSummaryReaderInterface* summaryReader() override;
|
||||
|
Loading…
Reference in New Issue
Block a user