EphemerisFile.java

  1. /* Contributed in the public domain.
  2.  * Licensed to CS Systèmes d'Information (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 an ID unique
  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.          * @throws OrekitException if any of the conditions are not met.
  126.          */
  127.         default BoundedPropagator getPropagator() throws OrekitException {
  128.             final List<BoundedPropagator> propagators = new ArrayList<>();
  129.             for (final EphemerisSegment 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.      * @author Evan Ward
  142.      * @see EphemerisFile
  143.      * @see SatelliteEphemeris
  144.      */
  145.     interface EphemerisSegment {

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

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

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

  168.         /**
  169.          * Get the reference frame for this ephemeris segment.
  170.          *
  171.          * @return the reference frame for this segment. Never {@code null}.
  172.          * @throws OrekitException if a frame cannot be created from {@link
  173.          *                         #getFrameString()} and there is no default frame.
  174.          */
  175.         Frame getFrame() throws OrekitException;

  176.         /**
  177.          * Get the time scale for this ephemeris segment.
  178.          *
  179.          * @return the time scale identifier, as specified in the ephemeris file, or
  180.          * {@code null} if the ephemeris file does not specify a time scale.
  181.          */
  182.         String getTimeScaleString();

  183.         /**
  184.          * Get the time scale for this ephemeris segment.
  185.          *
  186.          * @return the time scale for this segment. Never {@code null}.
  187.          * @throws OrekitException if a time scale can not be constructed based on {@link
  188.          *                         #getTimeScaleString()} and there is no default time
  189.          *                         scale.
  190.          */
  191.         TimeScale getTimeScale() throws OrekitException;

  192.         /**
  193.          * Get the number of samples to use in interpolation.
  194.          *
  195.          * @return the number of points to use for interpolation.
  196.          */
  197.         int getInterpolationSamples();

  198.         /**
  199.          * Get which derivatives of position are available in this ephemeris segment.
  200.          *
  201.          * <p> While {@link #getCoordinates()} always returns position, velocity, and
  202.          * acceleration the return value from this method indicates which of those are in
  203.          * the ephemeris file and are actually valid.
  204.          *
  205.          * @return a value indicating if the file contains velocity and/or acceleration
  206.          * data.
  207.          */
  208.         CartesianDerivativesFilter getAvailableDerivatives();

  209.         /**
  210.          * Get the coordinates for this ephemeris segment.
  211.          *
  212.          * @return a list of state vectors in chronological order. The coordinates are not
  213.          * necessarily evenly spaced in time. The value of {@link
  214.          * #getAvailableDerivatives()} indicates if the velocity or accelerations were
  215.          * specified in the file. Any position, velocity, or acceleration coordinates that
  216.          * are not specified in the ephemeris file are zero in the returned values.
  217.          */
  218.         List<? extends TimeStampedPVCoordinates> getCoordinates();

  219.         /**
  220.          * Get the start date of this ephemeris segment.
  221.          *
  222.          * <p> The date returned by this method is equivalent to {@code
  223.          * getPropagator().getMinDate()}.
  224.          *
  225.          * @return ephemeris segment start date.
  226.          */
  227.         AbsoluteDate getStart();

  228.         /**
  229.          * Get the end date of this ephemeris segment.
  230.          *
  231.          * <p> The date returned by this method is equivalent to {@code
  232.          * getPropagator().getMaxDate()}.
  233.          *
  234.          * @return ephemeris segment end date.
  235.          */
  236.         AbsoluteDate getStop();

  237.         /**
  238.          * View this ephemeris segment as a propagator.
  239.          *
  240.          * <p>In order to view the ephemeris for this satellite as a {@link Propagator}
  241.          * several conditions must be met. An Orekit {@link Frame} and {@link TimeScale}
  242.          * must be constructable from the frame and time scale specification in the
  243.          * ephemeris file. This condition is met when {@link EphemerisSegment#getFrame()}
  244.          * and {@link EphemerisSegment#getTimeScale()} return normally. Additionally,
  245.          * {@link #getMu()} must return a valid value. If these conditions are not met an
  246.          * {@link OrekitException} may be thrown by this method or by one of the methods
  247.          * of the returned {@link Propagator}.
  248.          *
  249.          * <p> Each call to this method creates a new propagator.
  250.          *
  251.          * @return a propagator for this ephemeris segment.
  252.          * @throws OrekitException if any of the conditions are not met.
  253.          */
  254.         default BoundedPropagator getPropagator() throws OrekitException {
  255.             return new EphemerisSegmentPropagator(this);
  256.         }

  257.     }

  258. }