use of org.hipparchus.analysis.polynomials.PolynomialSplineFunction in project Orekit by CS-SI.
the class OceanLoading method spline.
/**
* Get a spline function for interpolating between main tide data.
* @param rates rates for the tides species
* @param data data for the tides species
* @param selector data selector
* @return spline function for interpolating the selected data
*/
private UnivariateFunction spline(final double[] rates, final MainTideData[] data, final Function<MainTideData, Double> selector) {
final double[] y = new double[data.length];
for (int i = 0; i < y.length; ++i) {
y[i] = selector.apply(data[i]);
}
final PolynomialSplineFunction psf = new SplineInterpolator().interpolate(rates, y);
// as per HARDISP program EVAL subroutine, if spline evaluation is outside of range,
// the closest value is used. This occurs for example for long period tides.
// The main tides have rates 0.0821°/h, 0.5444°/h and 1.0980°/h. However,
// tide 55565 has rate 0.0022°/h, which is below the min rate and tide 75565 has
// rate 1.1002°/h, which is above max rate
final double[] knots = psf.getKnots();
final double minRate = knots[0];
final double valueAtMinRate = psf.value(minRate);
final double maxRate = knots[knots.length - 1];
final double valueAtMaxRate = psf.value(maxRate);
return t -> (t < minRate) ? valueAtMinRate : (t > maxRate) ? valueAtMaxRate : psf.value(t);
}
Aggregations