mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
#14698 Guard against NaN/Inf in ensemble parameter correlation
Realizations whose calculated summary vector value is NaN or Inf at the selected timestep are now excluded from the Pearson correlation computation instead of propagating NaN through the whole result, which corrupted the correlation tornado plot. Also guard the final correlation value against NaN, since the previous check only compared against +Infinity. RigEnsembleParameter::stdDeviation() sums squared parameter values, which can overflow to +Inf for extreme (but finite) magnitudes, turning normalizedStdDeviation() into NaN. Since NaN compares false against the variation epsilon, such parameters were silently treated as having no variation and dropped from parameterCorrelations(), producing an empty tornado plot for that parameter and calculated vector combination. Fall back to a range-based variation estimate when the standard deviation calculation overflows, so the parameter is retained and the Pearson correlation guard above can take over instead.
This commit is contained in:
1 parent
d81e1e69f4
commit
aee80deb30
2 files changed
+12
-3
No files matched your search
@@ -569,7 +569,7 @@ std::vector<std::pair<RigEnsembleParameter, double>>
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( closestValue != std::numeric_limits<double>::infinity() )
|
||||
if ( std::isfinite( closestValue ) )
|
||||
{
|
||||
caseValuesAtTimestep.push_back( closestValue );
|
||||
|
||||
@@ -591,7 +591,7 @@ std::vector<std::pair<RigEnsembleParameter, double>>
|
||||
{
|
||||
double correlation = 0.0;
|
||||
double pearson = RigStatisticsTools::pearsonCorrelation( parameterValuesPair.second, caseValuesAtTimestep );
|
||||
if ( pearson != std::numeric_limits<double>::infinity() ) correlation = pearson;
|
||||
if ( std::isfinite( pearson ) ) correlation = pearson;
|
||||
correlationResults.push_back( std::make_pair( parameterValuesPair.first, correlation ) );
|
||||
}
|
||||
return correlationResults;
|
||||
|
||||
@@ -58,7 +58,16 @@ double RigEnsembleParameter::normalizedStdDeviation() const
|
||||
}
|
||||
|
||||
double normalisedStdDev = stdDeviation() / maxAbs;
|
||||
if ( normalisedStdDev < eps )
|
||||
if ( !std::isfinite( normalisedStdDev ) )
|
||||
{
|
||||
// stdDeviation() sums squared values, which can overflow to NaN/Inf for parameter values with
|
||||
// extreme (but finite) magnitudes. Fall back to a range-based variation estimate so the
|
||||
// parameter is not silently treated as having no variation and dropped from correlation
|
||||
// analysis.
|
||||
normalisedStdDev = ( maxValue - minValue ) / maxAbs;
|
||||
}
|
||||
|
||||
if ( !std::isfinite( normalisedStdDev ) || normalisedStdDev < eps )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user