mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-05 21:53:27 -06:00
#7763 Improve extrapolation for when points are too close.
This commit is contained in:
parent
4de91e885b
commit
1ebe4ec2a1
@ -162,7 +162,11 @@ int RiaInterpolationTools::extrapolateRange( int start,
|
||||
std::vector<double> ys = { y[firstPoint], y[lastPoint] };
|
||||
for ( int index = start; index < end; index++ )
|
||||
{
|
||||
y[index] = extrapolate( xs, ys, x[index] );
|
||||
// Avoid excessive extrapolation when points are very close
|
||||
if ( almostEqual( xs[0], xs[1] ) || almostEqual( ys[0], ys[1] ) )
|
||||
y[index] = ys[0];
|
||||
else
|
||||
y[index] = extrapolate( xs, ys, x[index] );
|
||||
}
|
||||
|
||||
return end;
|
||||
|
@ -166,3 +166,27 @@ TEST( RiaInterpolationToolsTest, InterpolateMissingValuesStraightLineExtrapolate
|
||||
EXPECT_DOUBLE_EQ( y[4], 4.0 );
|
||||
EXPECT_DOUBLE_EQ( y[5], 5.0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaInterpolationToolsTest, InterpolateMissingValuesSmallDiffs )
|
||||
{
|
||||
double inf = std::numeric_limits<double>::infinity();
|
||||
std::vector<double> x = { 898.02149910694368,
|
||||
898.68522777852661,
|
||||
898.68522777852661,
|
||||
971.44605537010159,
|
||||
971.44605537010887,
|
||||
1074.7396805237731,
|
||||
1074.7396805237802 };
|
||||
std::vector<double> y = { inf, inf, inf, inf, inf, 590.65394902812329, 590.75823974609375 };
|
||||
|
||||
RiaInterpolationTools::interpolateMissingValues( x, y );
|
||||
EXPECT_DOUBLE_EQ( y[0], 590.65394902812329 );
|
||||
EXPECT_DOUBLE_EQ( y[1], 590.65394902812329 );
|
||||
EXPECT_DOUBLE_EQ( y[2], 590.65394902812329 );
|
||||
EXPECT_DOUBLE_EQ( y[3], 590.65394902812329 );
|
||||
EXPECT_DOUBLE_EQ( y[4], 590.65394902812329 );
|
||||
EXPECT_DOUBLE_EQ( y[5], 590.65394902812329 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user