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.time.TimeScale;
  28. import org.orekit.utils.CartesianDerivativesFilter;
  29. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

  53.     /**
  54.      * Contains the information about a single satellite from an {@link EphemerisFile}.
  55.      *
  56.      * <p> A satellite ephemeris consists of one or more {@link EphemerisSegment}s.
  57.      * Segments are typically used to split up an ephemeris at discontinuous events, such
  58.      * as a maneuver.
  59.      *
  60.      * @author Evan Ward
  61.      * @see EphemerisFile
  62.      * @see EphemerisSegment
  63.      */
  64.     interface SatelliteEphemeris {

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

  72.         /**
  73.          * Get the standard gravitational parameter for the satellite.
  74.          *
  75.          * @return the gravitational parameter use in {@link #getPropagator()}, in m^3 /
  76.          * s^2.
  77.          */
  78.         double getMu();

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

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

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

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

  133.     }

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

  145.         /**
  146.          * Get the standard gravitational parameter for the satellite.
  147.          *
  148.          * @return the gravitational parameter use in {@link #getPropagator()}, in m^3 /
  149.          * s^2.
  150.          */
  151.         double getMu();

  152.         /**
  153.          * Get the name of the center of the coordinate system the ephemeris is provided
  154.          * in. This may be a natural origin, such as the center of the Earth, another
  155.          * satellite, etc.
  156.          *
  157.          * @return the name of the frame center
  158.          */
  159.         String getFrameCenterString();

  160.         /**
  161.          * Get the defining frame for this ephemeris segment.
  162.          *
  163.          * @return the frame identifier, as specified in the ephemeris file, or {@code
  164.          * null} if the ephemeris file does not specify a frame.
  165.          */
  166.         String getFrameString();

  167.         /**
  168.          * Get the reference frame for this ephemeris segment. The defining frame for
  169.          * {@link #getCoordinates()}.
  170.          *
  171.          * @return the reference frame for this segment. Never {@code null}.
  172.          */
  173.         Frame getFrame();

  174.         /**
  175.          * Get the inertial reference frame for this ephemeris segment. Defines the
  176.          * propagation frame for {@link #getPropagator()}.
  177.          *
  178.          * <p>The default implementation returns {@link #getFrame()} if it is inertial.
  179.          * Otherwise it returns {@link Frame#getRoot()}. Implementors are encouraged to
  180.          * override this default implementation if a more suitable inertial frame is
  181.          * available.
  182.          *
  183.          * @return an reference frame that is inertial, i.e. {@link
  184.          * Frame#isPseudoInertial()} is {@code true}. May be the same as {@link
  185.          * #getFrame()} if it is inertial.
  186.          */
  187.         default Frame getInertialFrame() {
  188.             final Frame frame = getFrame();
  189.             if (frame.isPseudoInertial()) {
  190.                 return frame;
  191.             }
  192.             return Frame.getRoot();
  193.         }

  194.         /**
  195.          * Get the time scale for this ephemeris segment.
  196.          *
  197.          * @return the time scale identifier, as specified in the ephemeris file, or
  198.          * {@code null} if the ephemeris file does not specify a time scale.
  199.          */
  200.         String getTimeScaleString();

  201.         /**
  202.          * Get the time scale for this ephemeris segment.
  203.          *
  204.          * @return the time scale for this segment. Never {@code null}.
  205.          */
  206.         TimeScale getTimeScale();

  207.         /**
  208.          * Get the number of samples to use in interpolation.
  209.          *
  210.          * @return the number of points to use for interpolation.
  211.          */
  212.         int getInterpolationSamples();

  213.         /**
  214.          * Get which derivatives of position are available in this ephemeris segment.
  215.          *
  216.          * <p> While {@link #getCoordinates()} always returns position, velocity, and
  217.          * acceleration the return value from this method indicates which of those are in
  218.          * the ephemeris file and are actually valid.
  219.          *
  220.          * @return a value indicating if the file contains velocity and/or acceleration
  221.          * data.
  222.          */
  223.         CartesianDerivativesFilter getAvailableDerivatives();

  224.         /**
  225.          * Get the coordinates for this ephemeris segment in {@link #getFrame()}.
  226.          *
  227.          * @return a list of state vectors in chronological order. The coordinates are not
  228.          * necessarily evenly spaced in time. The value of {@link
  229.          * #getAvailableDerivatives()} indicates if the velocity or accelerations were
  230.          * specified in the file. Any position, velocity, or acceleration coordinates that
  231.          * are not specified in the ephemeris file are zero in the returned values.
  232.          */
  233.         List<? extends TimeStampedPVCoordinates> getCoordinates();

  234.         /**
  235.          * Get the start date of this ephemeris segment.
  236.          *
  237.          * <p> The date returned by this method is equivalent to {@code
  238.          * getPropagator().getMinDate()}.
  239.          *
  240.          * @return ephemeris segment start date.
  241.          */
  242.         AbsoluteDate getStart();

  243.         /**
  244.          * Get the end date of this ephemeris segment.
  245.          *
  246.          * <p> The date returned by this method is equivalent to {@code
  247.          * getPropagator().getMaxDate()}.
  248.          *
  249.          * @return ephemeris segment end date.
  250.          */
  251.         AbsoluteDate getStop();

  252.         /**
  253.          * View this ephemeris segment as a propagator.
  254.          *
  255.          * <p>In order to view the ephemeris for this satellite as a {@link Propagator}
  256.          * several conditions must be met. An Orekit {@link Frame} and {@link TimeScale}
  257.          * must be constructable from the frame and time scale specification in the
  258.          * ephemeris file. This condition is met when {@link EphemerisSegment#getFrame()}
  259.          * and {@link EphemerisSegment#getTimeScale()} return normally. Additionally,
  260.          * {@link #getMu()} must return a valid value. If these conditions are not met an
  261.          * {@link OrekitException} may be thrown by this method or by one of the methods
  262.          * of the returned {@link Propagator}.
  263.          *
  264.          * <p> Each call to this method creates a new propagator.
  265.          *
  266.          * @return a propagator for this ephemeris segment.
  267.          */
  268.         default BoundedPropagator getPropagator() {
  269.             return new EphemerisSegmentPropagator(this);
  270.         }

  271.     }

  272. }