Files
ResInsight/ApplicationLibCode/UnitTests/RigEnsembleFractureStatisticsCalculator-Test.cpp
T
Kristian Bendiksen d96159fb7c #7750 Histogram Plot: Add logarithmic binning and user-defined bin range
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.
2026-08-13 07:19:18 +02:00

54 lines
2.8 KiB
C++

#include "gtest/gtest.h"
#include "RigEnsembleFractureStatisticsCalculator.h"
#include "RigStimPlanFractureDefinition.h"
#include <QStringList>
//--------------------------------------------------------------------------------------------------
/// A fracture definition without any conductivity result must not be indexed out of range
//--------------------------------------------------------------------------------------------------
TEST( RigEnsembleFractureStatisticsCalculatorTest, NoConductivityResultNames )
{
cvf::ref<RigStimPlanFractureDefinition> definition = new RigStimPlanFractureDefinition;
EXPECT_TRUE( definition->conductivityResultNames().isEmpty() );
std::vector<cvf::ref<RigStimPlanFractureDefinition>> definitions = { definition };
for ( auto propertyType : RigEnsembleFractureStatisticsCalculator::propertyTypes() )
{
if ( propertyType == RigEnsembleFractureStatisticsCalculator::PropertyType::FORMATION_DIP ) continue;
auto values = RigEnsembleFractureStatisticsCalculator::calculateProperty( definitions, propertyType );
EXPECT_TRUE( values.empty() );
}
}
//--------------------------------------------------------------------------------------------------
/// The default binning arguments must produce an invalid histogram for empty input, for both the
/// default and the custom binning code paths
//--------------------------------------------------------------------------------------------------
TEST( RigEnsembleFractureStatisticsCalculatorTest, EmptyDefinitionsProduceInvalidHistogram )
{
std::vector<cvf::ref<RigStimPlanFractureDefinition>> definitions;
{
RigHistogramData histogramData =
RigEnsembleFractureStatisticsCalculator::createStatisticsData( definitions,
RigEnsembleFractureStatisticsCalculator::PropertyType::HEIGHT,
50 );
EXPECT_FALSE( histogramData.isHistogramVectorValid() );
}
{
RigHistogramData histogramData =
RigEnsembleFractureStatisticsCalculator::createStatisticsData( definitions,
RigEnsembleFractureStatisticsCalculator::PropertyType::HEIGHT,
50,
RigHistogramCalculator::BinningMode::LOGARITHMIC,
std::make_pair( 1.0, 100.0 ),
RigHistogramCalculator::OutOfRangeHandling::INCLUDE_IN_BOUNDARY_BINS );
EXPECT_FALSE( histogramData.isHistogramVectorValid() );
}
}