mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
Add BinningMode (Linear/Logarithmic) and OutOfRangeHandling (Exclude/Include in Boundary Bins) to RigHistogramCalculator, with defaulted constructor arguments so existing callers are unaffected. All four histogram plot data sources get shared options for binning mode and an optional user-defined bin range through new PDM fields on RimHistogramDataSource. The grid statistics data source computes non-default histograms through a new non-caching RigStatisticsDataCache::computeHistogram() pass-through, leaving the cached statistics used by the 3D overlay and the P10/P90/mean annotation lines untouched. Selecting logarithmic binning enables logarithmic scale on the plot X axis once, via a new signal handled by RimHistogramCurve. Also fix the bin index computation to use uniform bins of width range/nBins, consistent with calculatePercentil() and the bin edges drawn by the plots. The previous divisor (nBins - 1) shifted counts by up to one bin width relative to the drawn bars and slightly biased histogram-based percentile estimates.
131 lines
4.7 KiB
C++
131 lines
4.7 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) Statoil ASA
|
|
// Copyright (C) Ceetron Solutions AS
|
|
//
|
|
// 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 "RigStatisticsCalculator.h"
|
|
|
|
#include "cvfObject.h"
|
|
|
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
|
#include <vector>
|
|
|
|
//==================================================================================================
|
|
///
|
|
//==================================================================================================
|
|
class RigStatisticsDataCache : public cvf::Object
|
|
{
|
|
public:
|
|
explicit RigStatisticsDataCache( RigStatisticsCalculator* statisticsCalculator );
|
|
|
|
void clearAllStatistics();
|
|
|
|
static size_t defaultNumBins();
|
|
void setNumBins( size_t numBins );
|
|
|
|
void minMaxCellScalarValues( double& min, double& max );
|
|
void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max );
|
|
|
|
void posNegClosestToZero( double& pos, double& neg );
|
|
void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg );
|
|
|
|
void p10p90CellScalarValues( double& p10, double& p90 );
|
|
void p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 );
|
|
|
|
void meanCellScalarValues( double& meanValue );
|
|
void meanCellScalarValues( size_t timeStepIndex, double& meanValue );
|
|
|
|
void sumCellScalarValues( double& sumValue );
|
|
void sumCellScalarValues( size_t timeStepIndex, double& sumValue );
|
|
|
|
const std::vector<size_t>& cellScalarValuesHistogram();
|
|
const std::vector<size_t>& cellScalarValuesHistogram( size_t timeStepIndex );
|
|
|
|
// Fills the supplied histogram calculator from the underlying data. Nothing is cached.
|
|
void computeHistogram( RigHistogramCalculator& histogramCalculator );
|
|
void computeHistogram( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator );
|
|
|
|
const std::vector<int>& uniqueCellScalarValues();
|
|
const std::vector<int>& uniqueCellScalarValues( size_t timeStepIndex );
|
|
|
|
void mobileVolumeWeightedMean( double& mean );
|
|
void mobileVolumeWeightedMean( size_t timeStepIndex, double& mean );
|
|
|
|
void setUniqueCellScalarValues( const std::set<int>& uniqueValuesOverride );
|
|
|
|
private:
|
|
void computeHistogramStatisticsIfNeeded();
|
|
void computeHistogramStatisticsIfNeeded( size_t timeStepIndex );
|
|
|
|
void computeUniqueValuesIfNeeded();
|
|
void computeUniqueValuesIfNeeded( size_t timeStepIndex );
|
|
|
|
private:
|
|
struct StatisticsValues
|
|
{
|
|
StatisticsValues()
|
|
{
|
|
m_minValue = HUGE_VAL;
|
|
m_maxValue = -HUGE_VAL;
|
|
m_isMaxMinCalculated = false;
|
|
m_meanValue = HUGE_VAL;
|
|
m_isMeanCalculated = false;
|
|
m_posClosestToZero = HUGE_VAL;
|
|
m_negClosestToZero = -HUGE_VAL;
|
|
m_isClosestToZeroCalculated = false;
|
|
m_p10 = HUGE_VAL;
|
|
m_p90 = HUGE_VAL;
|
|
m_isp10p90Calculated = false;
|
|
m_valueSum = 0.0;
|
|
m_isValueSumCalculated = false;
|
|
m_volumeWeightedMean = HUGE_VAL;
|
|
m_isVolumeWeightedMeanCalculated = false;
|
|
}
|
|
|
|
double m_minValue;
|
|
double m_maxValue;
|
|
bool m_isMaxMinCalculated;
|
|
|
|
double m_meanValue;
|
|
bool m_isMeanCalculated;
|
|
|
|
double m_posClosestToZero;
|
|
double m_negClosestToZero;
|
|
bool m_isClosestToZeroCalculated;
|
|
|
|
double m_p10;
|
|
double m_p90;
|
|
bool m_isp10p90Calculated;
|
|
|
|
double m_valueSum;
|
|
bool m_isValueSumCalculated;
|
|
|
|
double m_volumeWeightedMean;
|
|
bool m_isVolumeWeightedMeanCalculated;
|
|
|
|
std::vector<size_t> m_histogram;
|
|
std::vector<int> m_uniqueValues;
|
|
};
|
|
|
|
StatisticsValues m_statsAllTimesteps;
|
|
std::vector<StatisticsValues> m_statsPrTs;
|
|
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
|
|
size_t m_numBins;
|
|
};
|