Search in sources :

Example 1 with PolynomialSplineFunction

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);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Frame(org.orekit.frames.Frame) HashMap(java.util.HashMap) Function(java.util.function.Function) PolynomialSplineFunction(org.hipparchus.analysis.polynomials.PolynomialSplineFunction) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) OrekitException(org.orekit.errors.OrekitException) Map(java.util.Map) BodiesElements(org.orekit.data.BodiesElements) FastMath(org.hipparchus.util.FastMath) SplineInterpolator(org.hipparchus.analysis.interpolation.SplineInterpolator) SplineInterpolator(org.hipparchus.analysis.interpolation.SplineInterpolator) PolynomialSplineFunction(org.hipparchus.analysis.polynomials.PolynomialSplineFunction) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)1 SplineInterpolator (org.hipparchus.analysis.interpolation.SplineInterpolator)1 PolynomialSplineFunction (org.hipparchus.analysis.polynomials.PolynomialSplineFunction)1 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1 FastMath (org.hipparchus.util.FastMath)1 GeodeticPoint (org.orekit.bodies.GeodeticPoint)1 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)1 BodiesElements (org.orekit.data.BodiesElements)1 OrekitException (org.orekit.errors.OrekitException)1 Frame (org.orekit.frames.Frame)1