Sinex.java

  1. /* Copyright 2002-2025 CS GROUP
  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.sinex;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.frames.EopHistoryLoader;
  20. import org.orekit.frames.ITRFVersion;
  21. import org.orekit.gnss.GnssSignal;
  22. import org.orekit.gnss.SatInSystem;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.time.ChronologicalComparator;
  25. import org.orekit.time.TimeScales;

  26. import java.util.Collections;
  27. import java.util.Map;
  28. import java.util.SortedSet;
  29. import java.util.TreeSet;

  30. /**
  31.  * Container for Solution INdependent EXchange (SINEX) files.
  32.  * @author Bryan Cazabonne
  33.  * @author Luc Maisonobe
  34.  * @since 13.0
  35.  */
  36. public class Sinex extends AbstractSinex {

  37.     /** Satellites phase centers. */
  38.     private final Map<SatInSystem, Map<GnssSignal, Vector3D>> satellitesPhaseCenters;

  39.     /** Station data. */
  40.     private final Map<String, Station> stations;

  41.     /** Earth Orientation Parameters data. */
  42.     private final Map<AbsoluteDate, SinexEopEntry> eop;

  43.     /** Simple constructor.
  44.      * @param timeScales time scales
  45.      * @param creationDate SINEX file creation date
  46.      * @param startDate start time of the data used in the Sinex solution
  47.      * @param endDate end time of the data used in the Sinex solution
  48.      * @param satellitesPhaseCenters satellites phase centers
  49.      * @param stations station data
  50.      * @param eop Earth Orientation Parameters data
  51.      */
  52.     public Sinex(final TimeScales timeScales,
  53.                  final AbsoluteDate creationDate, final AbsoluteDate startDate, final AbsoluteDate endDate,
  54.                  final Map<SatInSystem, Map<GnssSignal, Vector3D>> satellitesPhaseCenters,
  55.                  final Map<String, Station> stations, final Map<AbsoluteDate, SinexEopEntry> eop) {
  56.         super(timeScales, creationDate, startDate, endDate);
  57.         this.satellitesPhaseCenters = satellitesPhaseCenters;
  58.         this.stations               = stations;
  59.         this.eop                    = eop;
  60.     }

  61.     /** Get the parsed satellites phase centers.
  62.      * @return unmodifiable view of parsed satellites phase centers
  63.      */
  64.     public Map<SatInSystem, Map<GnssSignal, Vector3D>> getSatellitesPhaseCenters() {
  65.         return Collections.unmodifiableMap(satellitesPhaseCenters);
  66.     }

  67.     /** Get the parsed station data.
  68.      * @return unmodifiable view of parsed station data
  69.      */
  70.     public Map<String, Station> getStations() {
  71.         return Collections.unmodifiableMap(stations);
  72.     }

  73.     /** Get the parsed EOP data.
  74.      * @param itrfVersion ITRF version corresponding to the entries
  75.      * @return loader for EOP data
  76.      */
  77.     public EopHistoryLoader getEopLoader(final ITRFVersion itrfVersion) {
  78.         return (converter, history) -> {

  79.             // first set up all entries explicitly present in the parsed files
  80.             final SortedSet<SinexEopEntry> sorted = new TreeSet<>(new ChronologicalComparator());
  81.             sorted.addAll(eop.values());

  82.             // copy first and last entries according to files validity
  83.             sorted.add(sorted.first().toNewEpoch(getFileEpochStartTime()));
  84.             sorted.add(sorted.last().toNewEpoch(getFileEpochEndTime()));

  85.             if (sorted.size() < 4) {
  86.                 // insert extra entries after first and before last to allow interpolation
  87.                 sorted.add(sorted.first().toNewEpoch(getFileEpochStartTime().shiftedBy(1.0)));
  88.                 sorted.add(sorted.last().toNewEpoch(getFileEpochEndTime().shiftedBy(-1.0)));
  89.             }

  90.             // convert to regular EOP history
  91.             sorted.forEach(e -> history.add(e.toEopEntry(converter, itrfVersion, getTimeScales().getUTC())));

  92.         };
  93.     }

  94. }