mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
parent
67abe959db
commit
4f05c0d6b9
@ -37,33 +37,6 @@ RigFemNativeVisibleCellsStatCalc::RigFemNativeVisibleCellsStatCalc(RigGeoMechCas
|
||||
m_resultsData = femCase->femPartResults();
|
||||
}
|
||||
|
||||
class MinMaxAccumulator
|
||||
{
|
||||
public:
|
||||
MinMaxAccumulator(double initMin, double initMax): max(initMax), min(initMin) {}
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL) // TODO
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
double max;
|
||||
double min;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -77,32 +50,6 @@ void RigFemNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepInd
|
||||
}
|
||||
|
||||
|
||||
class PosNegAccumulator
|
||||
{
|
||||
public:
|
||||
PosNegAccumulator(double initPos, double initNeg): pos(initPos), neg(initNeg) {}
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < pos && value > 0)
|
||||
{
|
||||
pos = value;
|
||||
}
|
||||
|
||||
if (value > neg && value < 0)
|
||||
{
|
||||
neg = value;
|
||||
}
|
||||
}
|
||||
|
||||
double pos;
|
||||
double neg;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -115,26 +62,6 @@ void RigFemNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex,
|
||||
|
||||
}
|
||||
|
||||
class SumCountAccumulator
|
||||
{
|
||||
public:
|
||||
SumCountAccumulator(double initSum, size_t initCount): valueSum(initSum), sampleCount(initCount) {}
|
||||
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL || value != value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
valueSum += value;
|
||||
++sampleCount;
|
||||
}
|
||||
|
||||
double valueSum;
|
||||
size_t sampleCount;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "RigStatisticsDataCache.h"
|
||||
#include "RigFemNativeVisibleCellsStatCalc.h"
|
||||
#include "RigEclipseNativeVisibleCellsStatCalc.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -174,6 +175,65 @@ void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView)
|
||||
{
|
||||
double min = HUGE_VAL, max = HUGE_VAL;
|
||||
double p10 = HUGE_VAL, p90 = HUGE_VAL;
|
||||
double mean = HUGE_VAL;
|
||||
const std::vector<size_t>* histogram = NULL;
|
||||
|
||||
bool isResultsInfoRelevant = reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult();
|
||||
|
||||
if (showHistogram() || showInfoText())
|
||||
{
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex();
|
||||
if (m_statisticsCellRange == ALL_CELLS)
|
||||
{
|
||||
if (m_statisticsTimeRange == ALL_TIMESTEPS)
|
||||
{
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
|
||||
histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex));
|
||||
}
|
||||
else if (m_statisticsTimeRange == CURRENT_TIMESTEP )
|
||||
{
|
||||
int timeStepIdx = reservoirView->currentTimeStep();
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean);
|
||||
histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx));
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
}
|
||||
else if ( m_statisticsCellRange == VISIBLE_CELLS)
|
||||
{
|
||||
updateVisCellStatsIfNeeded();
|
||||
if (m_statisticsTimeRange == ALL_TIMESTEPS)
|
||||
{
|
||||
// TODO: Only valid if we have no dynamic property filter
|
||||
m_visibleCellStatistics->meanCellScalarValues(mean);
|
||||
m_visibleCellStatistics->minMaxCellScalarValues(min, max);
|
||||
m_visibleCellStatistics->p10p90CellScalarValues(p10, p90);
|
||||
|
||||
histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram());
|
||||
}
|
||||
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
|
||||
{
|
||||
int currentTimeStep = reservoirView->currentTimeStep();
|
||||
m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, mean);
|
||||
m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, min, max);
|
||||
m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, p10, p90);
|
||||
|
||||
histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showInfoText())
|
||||
{
|
||||
QString caseName;
|
||||
@ -217,39 +277,17 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView)
|
||||
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
|
||||
}
|
||||
|
||||
if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult())
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
|
||||
// Wait until regression tests confirm new statisticks is ok :
|
||||
//infoText += QString("<br>Statistics for: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText();
|
||||
|
||||
if (m_statisticsCellRange == ALL_CELLS)
|
||||
{
|
||||
double min = HUGE_VAL, max = HUGE_VAL;
|
||||
double p10 = HUGE_VAL, p90 = HUGE_VAL;
|
||||
double mean = HUGE_VAL;
|
||||
|
||||
size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex();
|
||||
|
||||
if (m_statisticsTimeRange == ALL_TIMESTEPS)
|
||||
{
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
|
||||
}
|
||||
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
|
||||
{
|
||||
int timeStepIdx = reservoirView->currentTimeStep();
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean);
|
||||
}
|
||||
|
||||
infoText += QString("<table border=0 cellspacing=5 >"
|
||||
"<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
|
||||
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5 </td></tr>"
|
||||
"</table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
|
||||
}
|
||||
infoText += QString("<table border=0 cellspacing=5 >"
|
||||
"<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
|
||||
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5 </td></tr>"
|
||||
"</table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
|
||||
|
||||
if (reservoirView->faultResultSettings()->hasValidCustomResult())
|
||||
{
|
||||
@ -309,41 +347,11 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView)
|
||||
|
||||
if (showHistogram())
|
||||
{
|
||||
if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult())
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
if (m_statisticsCellRange == ALL_CELLS)
|
||||
{
|
||||
double min = HUGE_VAL, max = HUGE_VAL;
|
||||
double p10 = HUGE_VAL, p90 = HUGE_VAL;
|
||||
double mean = HUGE_VAL;
|
||||
const std::vector<size_t>* histogram = NULL;
|
||||
|
||||
size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex();
|
||||
|
||||
if (m_statisticsTimeRange == ALL_TIMESTEPS)
|
||||
{
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
|
||||
histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex));
|
||||
}
|
||||
else if (m_statisticsTimeRange == CURRENT_TIMESTEP )
|
||||
{
|
||||
int timeStepIdx = reservoirView->currentTimeStep();
|
||||
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max);
|
||||
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90);
|
||||
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean);
|
||||
histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx));
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
reservoirView->viewer()->showHistogram(true);
|
||||
reservoirView->viewer()->setHistogram(min, max, *histogram);
|
||||
reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
|
||||
}
|
||||
reservoirView->viewer()->showHistogram(true);
|
||||
reservoirView->viewer()->setHistogram(min, max, *histogram);
|
||||
reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -511,15 +519,14 @@ void Rim3dOverlayInfoConfig::updateVisCellStatsIfNeeded()
|
||||
calc = new RigFemNativeVisibleCellsStatCalc(geoMechView->geoMechCase()->geoMechData(),
|
||||
resAddress,
|
||||
geoMechView->currentTotalCellVisibility().p());
|
||||
m_visibleCellStatistics = new RigStatisticsDataCache(calc.p());
|
||||
m_isVisCellStatUpToDate = true;
|
||||
|
||||
}
|
||||
else if (eclipseView)
|
||||
{
|
||||
// RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress();
|
||||
// cvf::ref<RigEclipseNativeVisibleCellsStatCalc> calc = new RigEclipseNativeVisibleCellsStatCalc(geoMechView->geoMechCase()->geoMechData(),
|
||||
// resAddress,
|
||||
// geoMechView->currentTotalCellVisibility().p());
|
||||
size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex();
|
||||
calc = new RigEclipseNativeVisibleCellsStatCalc(eclipseView->currentGridCellResults()->cellResults(),
|
||||
scalarIndex,
|
||||
eclipseView->currentTotalCellVisibility().p());
|
||||
}
|
||||
|
||||
m_visibleCellStatistics = new RigStatisticsDataCache(calc.p());
|
||||
|
@ -35,6 +35,7 @@ ${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h
|
||||
${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
|
||||
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h
|
||||
@ -68,6 +69,7 @@ ${CEE_CURRENT_LIST_DIR}RigNNCData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp
|
||||
|
@ -0,0 +1,91 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "RigEclipseNativeVisibleCellsStatCalc.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigEclipseNativeVisibleCellsStatCalc::RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
|
||||
size_t scalarResultIndex,
|
||||
const cvf::UByteArray* cellVisibilities)
|
||||
: m_caseData(cellResultsData),
|
||||
m_scalarResultIndex(scalarResultIndex),
|
||||
m_cellVisibilities(cellVisibilities)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
|
||||
{
|
||||
MinMaxAccumulator acc(min, max);
|
||||
traverseCells(acc, timeStepIndex);
|
||||
min = acc.min;
|
||||
max = acc.max;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
|
||||
{
|
||||
PosNegAccumulator acc(pos, neg);
|
||||
traverseCells(acc, timeStepIndex);
|
||||
pos = acc.pos;
|
||||
neg = acc.neg;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeVisibleCellsStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
|
||||
{
|
||||
SumCountAccumulator acc(valueSum, sampleCount);
|
||||
traverseCells(acc, timeStepIndex);
|
||||
valueSum = acc.valueSum;
|
||||
sampleCount = acc.sampleCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeVisibleCellsStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
|
||||
{
|
||||
traverseCells(histogramCalculator, timeStepIndex);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigEclipseNativeVisibleCellsStatCalc::timeStepCount()
|
||||
{
|
||||
return m_caseData->timeStepCount(m_scalarResultIndex);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,72 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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 "cvfArray.h"
|
||||
|
||||
class RigCaseCellResultsData;
|
||||
|
||||
|
||||
class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
|
||||
size_t scalarResultIndex,
|
||||
const cvf::UByteArray* cellVisibilities);
|
||||
|
||||
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
||||
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
||||
virtual void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount);
|
||||
virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator);
|
||||
virtual size_t timeStepCount();
|
||||
|
||||
private:
|
||||
RigCaseCellResultsData* m_caseData;
|
||||
size_t m_scalarResultIndex;
|
||||
cvf::cref<cvf::UByteArray> m_cellVisibilities;
|
||||
|
||||
template <typename StatisticsAccumulator>
|
||||
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
|
||||
{
|
||||
std::vector<double>& values = m_caseData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
|
||||
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
|
||||
size_t cellCount = actCellInfo->reservoirCellCount();
|
||||
|
||||
CVF_TIGHT_ASSERT(cellCount == m_cellVisibilities->size());
|
||||
|
||||
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
|
||||
{
|
||||
if (!(*m_cellVisibilities)[cIdx]) continue;
|
||||
|
||||
size_t cellResultIndex = actCellInfo->cellResultIndex(cIdx);
|
||||
|
||||
if (cellResultIndex != cvf::UNDEFINED_SIZE_T) accumulator.addValue(values[cellResultIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -263,7 +263,7 @@ void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded(size_t timeStepI
|
||||
double min;
|
||||
double max;
|
||||
size_t nBins = 100;
|
||||
this->minMaxCellScalarValues(min, max);
|
||||
this->minMaxCellScalarValues(timeStepIndex, min, max);
|
||||
|
||||
RigHistogramCalculator histCalc(min, max, nBins, &m_statsPrTs[timeStepIndex].m_histogram);
|
||||
|
||||
|
@ -56,3 +56,78 @@ private:
|
||||
size_t m_observationCount;
|
||||
std::vector<size_t>* m_histogram;
|
||||
};
|
||||
|
||||
|
||||
class MinMaxAccumulator
|
||||
{
|
||||
public:
|
||||
MinMaxAccumulator(double initMin, double initMax): max(initMax), min(initMin) {}
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL) // TODO
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
double max;
|
||||
double min;
|
||||
};
|
||||
|
||||
|
||||
class PosNegAccumulator
|
||||
{
|
||||
public:
|
||||
PosNegAccumulator(double initPos, double initNeg): pos(initPos), neg(initNeg) {}
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < pos && value > 0)
|
||||
{
|
||||
pos = value;
|
||||
}
|
||||
|
||||
if (value > neg && value < 0)
|
||||
{
|
||||
neg = value;
|
||||
}
|
||||
}
|
||||
|
||||
double pos;
|
||||
double neg;
|
||||
};
|
||||
|
||||
|
||||
class SumCountAccumulator
|
||||
{
|
||||
public:
|
||||
SumCountAccumulator(double initSum, size_t initCount): valueSum(initSum), sampleCount(initCount) {}
|
||||
|
||||
void addValue(double value)
|
||||
{
|
||||
if (value == HUGE_VAL || value != value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
valueSum += value;
|
||||
++sampleCount;
|
||||
}
|
||||
|
||||
double valueSum;
|
||||
size_t sampleCount;
|
||||
};
|
||||
|
@ -105,3 +105,38 @@ void RiuSimpleHistogramWidget::setHistogramData(double min, double max, const st
|
||||
if (m_maxHistogramCount < m_histogramData[colIdx]) m_maxHistogramCount = m_histogramData[colIdx] ;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSimpleHistogramWidget::setPercentiles(double pmin, double pmax)
|
||||
{
|
||||
m_minPercentile = pmin;
|
||||
m_maxPercentile = pmax;
|
||||
}
|
||||
|
||||
#define xBorder 1
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuSimpleHistogramWidget::xPosFromColIdx(size_t colIdx)
|
||||
{
|
||||
return (int)(m_x + xBorder + (m_width - 2*xBorder) * colIdx/m_histogramData.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuSimpleHistogramWidget::xPosFromDomainValue(double value)
|
||||
{
|
||||
double range = m_max - m_min;
|
||||
return (range == 0.0) ? (int)(m_x + xBorder) : (int)(m_x + xBorder + (m_width - 2*xBorder) * (value - m_min)/(m_max - m_min));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuSimpleHistogramWidget::yPosFromCount(size_t colHeight)
|
||||
{
|
||||
return (int)(m_y + m_height - 1 - (m_height - 3) * colHeight/m_maxHistogramCount);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
RiuSimpleHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||
|
||||
void setHistogramData(double min, double max, const std::vector<size_t>& histogram);
|
||||
void setPercentiles(double pmin, double pmax) {m_minPercentile = pmin; m_maxPercentile = pmax;}
|
||||
void setPercentiles(double pmin, double pmax);
|
||||
void setMean(double mean) {m_mean = mean;}
|
||||
|
||||
protected:
|
||||
@ -19,10 +19,10 @@ protected:
|
||||
private:
|
||||
void draw(QPainter *painter,int x, int y, int width, int height );
|
||||
|
||||
int xPosFromColIdx(size_t colIdx) { return (int)(m_x + 1 + (m_width - 2 ) * colIdx/m_histogramData.size());}
|
||||
int yPosFromCount(size_t colHeight) { return (int)(m_y + m_height - 1 - (m_height - 3 ) * colHeight/m_maxHistogramCount);}
|
||||
int xPosFromColIdx(size_t colIdx);
|
||||
int yPosFromCount(size_t colHeight);
|
||||
|
||||
int xPosFromDomainValue(double value) { double range = m_max - m_min; return (range == 0.0) ? (int)(m_x + 1) : (int)(m_x + 1 + (m_width - 2 ) * (value - m_min)/(m_max - m_min));}
|
||||
int xPosFromDomainValue(double value);
|
||||
|
||||
std::vector<size_t> m_histogramData;
|
||||
double m_max;
|
||||
|
Loading…
Reference in New Issue
Block a user