EphemerisFile.java

  1. /* Contributed in the public domain.
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.files.general;

  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import java.util.Map;

  21. import org.orekit.errors.OrekitException;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.propagation.BoundedPropagator;
  24. import org.orekit.propagation.Propagator;
  25. import org.orekit.propagation.analytical.AggregateBoundedPropagator;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.CartesianDerivativesFilter;
  28. import org.orekit.utils.TimeStampedPVCoordinates;

  29. /**
  30.  * An interface for accessing the data stored in an ephemeris file and using the data to
  31.  * create a working {@link org.orekit.propagation.Propagator Propagator}.
  32.  *
  33.  * <p> An {@link EphemerisFile} consists of one or more satellites each with a unique ID
  34.  * within the file. The ephemeris for each satellite consists of one or more segments.
  35.  *
  36.  * <p> Some ephemeris file formats may supply additional information that is not available
  37.  * via this interface. In those cases it is recommended that the parser return a subclass
  38.  * of this interface to provide access to the additional information.
  39.  *
  40.  * @param <C> type of the Cartesian coordinates
  41.  * @param <S> type of the segment
  42.  * @author Evan Ward
  43.  * @see SatelliteEphemeris
  44.  * @see EphemerisSegment
  45.  */
  46. public interface EphemerisFile<C extends TimeStampedPVCoordinates,
  47.                                S extends EphemerisFile.EphemerisSegment<C>> {

  48.     /**
  49.      * Get the loaded ephemeris for each satellite in the file.
  50.      *
  51.      * @return a map from the satellite's ID to the information about that satellite
  52.      * contained in the file.
  53.      */
  54.     Map<String, ? extends SatelliteEphemeris<C, S>> getSatellites();

  55.     /**
  56.      * Contains the information about a single satellite from an {@link EphemerisFile}.
  57.      *
  58.      * <p> A satellite ephemeris consists of one or more {@link EphemerisSegment}s.
  59.      * Segments are typically used to split up an ephemeris at discontinuous events, such
  60.      * as a maneuver.
  61.      * @param <C> type of the Cartesian coordinates
  62.      * @param <S> type of the segment
  63.      * @author Evan Ward
  64.      * @see EphemerisFile
  65.      * @see EphemerisSegment
  66.      */
  67.     interface SatelliteEphemeris<C extends TimeStampedPVCoordinates,
  68.                                  S extends EphemerisSegment<C>> {

  69.         /**
  70.          * Get the satellite ID. The satellite ID is unique only within the same ephemeris
  71.          * file.
  72.          *
  73.          * @return the satellite's ID, never {@code null}.
  74.          */
  75.         String getId();

  76.         /**
  77.          * Get the standard gravitational parameter for the satellite.
  78.          *
  79.          * @return the gravitational parameter used in {@link #getPropagator()}, in m³/s².
  80.          */
  81.         double getMu();

  82.         /**
  83.          * Get the segments of the ephemeris.
  84.          *
  85.          * <p> Ephemeris segments are typically used to split an ephemeris around
  86.          * discontinuous events, such as maneuvers.
  87.          *
  88.          * @return the segments contained in the ephemeris file for this satellite.
  89.          */
  90.         List<S> getSegments();

  91.         /**
  92.          * Get the start date of the ephemeris.
  93.          *
  94.          * <p> The date returned by this method is equivalent to {@code
  95.          * getPropagator().getMinDate()}.
  96.          *
  97.          * @return ephemeris start date.
  98.          */
  99.         AbsoluteDate getStart();

  100.         /**
  101.          * Get the end date of the ephemeris.
  102.          *
  103.          * <p> The date returned by this method is equivalent to {@code getPropagator().getMaxDate()}.
  104.          *
  105.          * @return ephemeris end date.
  106.          */
  107.         AbsoluteDate getStop();

  108.         /**
  109.          * View this ephemeris as a propagator, combining data from all {@link
  110.          * #getSegments() segments}.
  111.          *
  112.          * <p>In order to view the ephemeris for this satellite as a {@link Propagator}
  113.          * several conditions must be met. An Orekit {@link Frame} must be constructable
  114.          * from the frame specification in the ephemeris file. This condition is met when
  115.          * {@link EphemerisSegment#getFrame()} return normally for all {@link
  116.          * #getSegments() segments}. If there are multiple segments they must be adjacent
  117.          * such that there are no duplicates or gaps in the ephemeris. The definition of
  118.          * adjacent depends on the ephemeris format as some formats define usable start
  119.          * and stop times that are different from the ephemeris data start and stop times.
  120.          * If these conditions are not met an {@link OrekitException} may be thrown by
  121.          * this method or by one of the methods of the returned {@link Propagator}.
  122.          *
  123.          * <p> Each call to this method creates a new propagator.
  124.          *
  125.          * @return a propagator for all the data in this ephemeris file.
  126.          */
  127.         default BoundedPropagator getPropagator() {
  128.             final List<BoundedPropagator> propagators = new ArrayList<>();
  129.             for (final EphemerisSegment<C> segment : this.getSegments()) {
  130.                 propagators.add(segment.getPropagator());
  131.             }
  132.             return new AggregateBoundedPropagator(propagators);
  133.         }

  134.     }

  135.     /**
  136.      * A segment of an ephemeris for a satellite.
  137.      *
  138.      * <p> Segments are typically used to split an ephemeris around discontinuous events
  139.      * such as maneuvers.
  140.      *
  141.      * @param <C> type of the Cartesian coordinates
  142.      * @author Evan Ward
  143.      * @see EphemerisFile
  144.      * @see SatelliteEphemeris
  145.      */
  146.     interface EphemerisSegment<C extends TimeStampedPVCoordinates> {

  147.         /**
  148.          * Get the standard gravitational parameter for the satellite.
  149.          *
  150.          * @return the gravitational parameter used in {@link #getPropagator()}, in m³/s².
  151.          */
  152.         double getMu();

  153.         /**
  154.          * Get the reference frame for this ephemeris segment. The defining frame for
  155.          * {@link #getCoordinates()}.
  156.          *
  157.          * @return the reference frame for this segment. Never {@code null}.
  158.          */
  159.         Frame getFrame();

  160.         /**
  161.          * Get the inertial reference frame for this ephemeris segment. Defines the
  162.          * propagation frame for {@link #getPropagator()}.
  163.          *
  164.          * <p>The default implementation returns {@link #getFrame()} if it is inertial.
  165.          * Otherwise it returns {@link Frame#getRoot()}. Implementors are encouraged to
  166.          * override this default implementation if a more suitable inertial frame is
  167.          * available.
  168.          *
  169.          * @return an reference frame that is inertial, i.e. {@link
  170.          * Frame#isPseudoInertial()} is {@code true}. May be the same as {@link
  171.          * #getFrame()} if it is inertial.
  172.          */
  173.         default Frame getInertialFrame() {
  174.             final Frame frame = getFrame();
  175.             if (frame.isPseudoInertial()) {
  176.                 return frame;
  177.             }
  178.             return Frame.getRoot();
  179.         }

  180.         /**
  181.          * Get the number of samples to use in interpolation.
  182.          *
  183.          * @return the number of points to use for interpolation.
  184.          */
  185.         int getInterpolationSamples();

  186.         /**
  187.          * Get which derivatives of position are available in this ephemeris segment.
  188.          *
  189.          * <p> While {@link #getCoordinates()} always returns position, velocity, and
  190.          * acceleration the return value from this method indicates which of those are in
  191.          * the ephemeris file and are actually valid.
  192.          *
  193.          * @return a value indicating if the file contains velocity and/or acceleration
  194.          * data.
  195.          */
  196.         CartesianDerivativesFilter getAvailableDerivatives();

  197.         /**
  198.          * Get the coordinates for this ephemeris segment in {@link #getFrame()}.
  199.          *
  200.          * @return a list of state vectors in chronological order. The coordinates are not
  201.          * necessarily evenly spaced in time. The value of {@link
  202.          * #getAvailableDerivatives()} indicates if the velocity or accelerations were
  203.          * specified in the file. Any position, velocity, or acceleration coordinates that
  204.          * are not specified in the ephemeris file are zero in the returned values.
  205.          */
  206.         List<C> getCoordinates();

  207.         /**
  208.          * Get the start date of this ephemeris segment.
  209.          *
  210.          * <p> The date returned by this method is equivalent to {@code
  211.          * getPropagator().getMinDate()}.
  212.          *
  213.          * @return ephemeris segment start date.
  214.          */
  215.         AbsoluteDate getStart();

  216.         /**
  217.          * Get the end date of this ephemeris segment.
  218.          *
  219.          * <p> The date returned by this method is equivalent to {@code
  220.          * getPropagator().getMaxDate()}.
  221.          *
  222.          * @return ephemeris segment end date.
  223.          */
  224.         AbsoluteDate getStop();

  225.         /**
  226.          * View this ephemeris segment as a propagator.
  227.          *
  228.          * <p>In order to view the ephemeris for this satellite as a {@link Propagator}
  229.          * several conditions must be met. An Orekit {@link Frame} must be constructable
  230.          * from the frame specification in the ephemeris file. This condition is met when
  231.          * {@link EphemerisSegment#getFrame()} return normally. Additionally,
  232.          * {@link #getMu()} must return a valid value. If these conditions are not met an
  233.          * {@link OrekitException} may be thrown by this method or by one of the methods
  234.          * of the returned {@link Propagator}.
  235.          *
  236.          * <p> Each call to this method creates a new propagator.
  237.          *
  238.          * @return a propagator for this ephemeris segment.
  239.          */
  240.         default BoundedPropagator getPropagator() {
  241.             return new EphemerisSegmentPropagator<>(this);
  242.         }

  243.     }

  244. }