mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6035 Add method for interpolating missing values (with extrapolation)
This commit is contained in:
@@ -77,3 +77,53 @@ TEST( RiaInterpolationToolsTest, ValidIntervalValueTooHigh )
|
||||
double res = RiaInterpolationTools::linear( x, y, 100.0 );
|
||||
EXPECT_DOUBLE_EQ( std::numeric_limits<double>::infinity(), res );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaInterpolationToolsTest, InterpolateMisssingValuesStraightLine )
|
||||
{
|
||||
double inf = std::numeric_limits<double>::infinity();
|
||||
std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
|
||||
std::vector<double> y = {0.0, 1.0, inf, inf, inf, 5.0};
|
||||
|
||||
RiaInterpolationTools::interpolateMissingValues( x, y );
|
||||
EXPECT_DOUBLE_EQ( y[2], 2.0 );
|
||||
EXPECT_DOUBLE_EQ( y[3], 3.0 );
|
||||
EXPECT_DOUBLE_EQ( y[4], 4.0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaInterpolationToolsTest, InterpolateMissingValuesStraightLineExtrapolateStart )
|
||||
{
|
||||
double inf = std::numeric_limits<double>::infinity();
|
||||
std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
|
||||
std::vector<double> y = {inf, inf, 2.0, inf, 4.0, 5.0};
|
||||
|
||||
RiaInterpolationTools::interpolateMissingValues( x, y );
|
||||
EXPECT_DOUBLE_EQ( y[0], 0.0 );
|
||||
EXPECT_DOUBLE_EQ( y[1], 1.0 );
|
||||
EXPECT_DOUBLE_EQ( y[2], 2.0 );
|
||||
EXPECT_DOUBLE_EQ( y[3], 3.0 );
|
||||
EXPECT_DOUBLE_EQ( y[4], 4.0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaInterpolationToolsTest, InterpolateMissingValuesStraightLineExtrapolateEnd )
|
||||
{
|
||||
double inf = std::numeric_limits<double>::infinity();
|
||||
std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
|
||||
std::vector<double> y = {0.0, inf, 2.0, inf, 4.0, inf};
|
||||
|
||||
RiaInterpolationTools::interpolateMissingValues( x, y );
|
||||
EXPECT_DOUBLE_EQ( y[0], 0.0 );
|
||||
EXPECT_DOUBLE_EQ( y[1], 1.0 );
|
||||
EXPECT_DOUBLE_EQ( y[2], 2.0 );
|
||||
EXPECT_DOUBLE_EQ( y[3], 3.0 );
|
||||
EXPECT_DOUBLE_EQ( y[4], 4.0 );
|
||||
EXPECT_DOUBLE_EQ( y[5], 5.0 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user