Minor refactor

This commit is contained in:
Magne Sjaastad 2015-10-26 10:17:15 +01:00
parent f3f2cf1590
commit 1e9f77274a
2 changed files with 33 additions and 22 deletions

View File

@ -173,20 +173,7 @@ void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& p
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigStatisticsDataCache::cellScalarValuesHistogram()
{
if (m_histogram.size() == 0)
{
double min;
double max;
size_t nBins = 100;
this->minMaxCellScalarValues(min, max);
RigHistogramCalculator histCalc(min, max, nBins, &m_histogram);
m_statisticsCalculator->addDataToHistogramCalculator(histCalc);
m_p10 = histCalc.calculatePercentil(0.1);
m_p90 = histCalc.calculatePercentil(0.9);
}
computeStatisticsIfNeeded();
return m_histogram;
}
@ -197,7 +184,7 @@ const std::vector<size_t>& RigStatisticsDataCache::cellScalarValuesHistogram()
void RigStatisticsDataCache::p10p90CellScalarValues(double& p10, double& p90)
{
// First make sure they are calculated
const std::vector<size_t>& histogr = this->cellScalarValuesHistogram();
computeStatisticsIfNeeded();
p10 = m_p10;
p90 = m_p90;
@ -217,3 +204,24 @@ void RigStatisticsDataCache::meanCellScalarValues(double& meanValue)
meanValue = m_meanValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::computeStatisticsIfNeeded()
{
if (m_histogram.size() == 0)
{
double min;
double max;
size_t nBins = 100;
this->minMaxCellScalarValues(min, max);
RigHistogramCalculator histCalc(min, max, nBins, &m_histogram);
m_statisticsCalculator->addDataToHistogramCalculator(histCalc);
m_p10 = histCalc.calculatePercentil(0.1);
m_p90 = histCalc.calculatePercentil(0.9);
}
}

View File

@ -47,20 +47,23 @@ public:
const std::vector<size_t>& cellScalarValuesHistogram();
private:
double m_minValue;
double m_maxValue;
void computeStatisticsIfNeeded();
private:
double m_minValue;
double m_maxValue;
bool m_isMaxMinCalculated;
double m_posClosestToZero;
double m_negClosestToZero;
double m_posClosestToZero;
double m_negClosestToZero;
bool m_isClosestToZeroCalculated;
double m_p10;
double m_p90;
double m_p10;
double m_p90;
double m_meanValue;
bool m_isMeanCalculated;
std::vector<size_t> m_histogram;
std::vector<size_t> m_histogram;
std::vector<std::pair<double, double> > m_maxMinValuesPrTs; ///< Max min values for each time step
std::vector<bool> m_isMaxMinPrTsCalculated;