From f08e9b0cfffef2d81b0d82f777ea84dfdd5983ea Mon Sep 17 00:00:00 2001 From: Bryan Cazabonne Date: Tue, 7 Dec 2021 11:43:09 +0100 Subject: [PATCH 1/2] Fixed handling of multiple historical eccentricities for a same station. Fixes #867 --- src/changes/changes.xml | 3 + .../org/orekit/errors/OrekitMessages.java | 3 +- .../org/orekit/files/sinex/SinexLoader.java | 51 ++++++++-- .../java/org/orekit/files/sinex/Station.java | 92 +++++++++++++++++-- .../localization/OrekitMessages_da.utf8 | 3 + .../localization/OrekitMessages_de.utf8 | 3 + .../localization/OrekitMessages_el.utf8 | 3 + .../localization/OrekitMessages_en.utf8 | 3 + .../localization/OrekitMessages_es.utf8 | 3 + .../localization/OrekitMessages_fr.utf8 | 3 + .../localization/OrekitMessages_gl.utf8 | 3 + .../localization/OrekitMessages_it.utf8 | 3 + .../localization/OrekitMessages_no.utf8 | 2 + .../localization/OrekitMessages_ro.utf8 | 3 + .../org/orekit/errors/OrekitMessagesTest.java | 2 +- .../orekit/files/sinex/SinexLoaderTest.java | 88 ++++++++++++++++++ .../sinex/ecc_xyz-small-multiple-ecc.snx | 46 ++++++++++ 17 files changed, 298 insertions(+), 16 deletions(-) create mode 100644 src/test/resources/sinex/ecc_xyz-small-multiple-ecc.snx diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 20099d221..115f408ba 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -21,6 +21,9 @@ + + Fixed handling of multiple historical eccentricities for a same station. + Fixed writing of whitespace characters in CPF writer. diff --git a/src/main/java/org/orekit/errors/OrekitMessages.java b/src/main/java/org/orekit/errors/OrekitMessages.java index f3b1c60d0..736c14cca 100644 --- a/src/main/java/org/orekit/errors/OrekitMessages.java +++ b/src/main/java/org/orekit/errors/OrekitMessages.java @@ -330,7 +330,8 @@ public enum OrekitMessages implements Localizable { MISSING_VELOCITY("missing velocity data"), ATTEMPT_TO_GENERATE_MALFORMED_FILE("attempt to generate file {0} with a formatting error"), FIND_ROOT("{0} failed to find root between {1} (g={2,number,0.0##############E0}) and {3} (g={4,number,0.0##############E0})\nLast iteration at {5} (g={6,number,0.0##############E0})"), - BACKWARD_PROPAGATION_NOT_ALLOWED("backward propagation not allowed here"); + BACKWARD_PROPAGATION_NOT_ALLOWED("backward propagation not allowed here"), + NO_STATION_ECCENTRICITY_FOR_EPOCH("no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2}"); // CHECKSTYLE: resume JavadocVariable check diff --git a/src/main/java/org/orekit/files/sinex/SinexLoader.java b/src/main/java/org/orekit/files/sinex/SinexLoader.java index 78084b75f..4a1dd9865 100644 --- a/src/main/java/org/orekit/files/sinex/SinexLoader.java +++ b/src/main/java/org/orekit/files/sinex/SinexLoader.java @@ -55,6 +55,9 @@ import org.orekit.utils.Constants; */ public class SinexLoader { + /** 00:000:00000 epoch. */ + private static final String DEFAULT_EPOCH = "00:000:00000"; + /** Pattern for delimiting regular expressions. */ private static final Pattern SEPARATOR = Pattern.compile(":"); @@ -173,6 +176,7 @@ public class SinexLoader { boolean inEcc = false; boolean inEpoch = false; boolean inEstimate = false; + boolean firstEcc = true; Vector3D position = Vector3D.ZERO; Vector3D velocity = Vector3D.ZERO; @@ -230,17 +234,42 @@ public class SinexLoader { // add the station to the map addStation(station); } else if (inEcc) { + // read antenna eccentricities data final Station station = getStation(parseString(line, 1, 4)); - // check if start and end dates have been set - if (station.getValidFrom() == null) { - station.setValidFrom(stringEpochToAbsoluteDate(parseString(line, 16, 12))); - station.setValidUntil(stringEpochToAbsoluteDate(parseString(line, 29, 12))); + + // check if it is the first eccentricity entry for this station + if (station.getEccentricitiesTimeSpanMap().getTransitions().size() == 1) { + // we are parsing eccentricity data for a new station + firstEcc = true; } + + // start and end of validity for the current entry + final AbsoluteDate start = stringEpochToAbsoluteDate(parseString(line, 16, 12)); + final AbsoluteDate end = stringEpochToAbsoluteDate(parseString(line, 29, 12)); + + // reference system UNE or XYZ station.setEccRefSystem(ReferenceSystem.getEccRefSystem(parseString(line, 42, 3))); - station.setEccentricities(new Vector3D(parseDouble(line, 46, 8), - parseDouble(line, 55, 8), - parseDouble(line, 64, 8))); + + // eccentricity vector + final Vector3D eccStation = new Vector3D(parseDouble(line, 46, 8), + parseDouble(line, 55, 8), + parseDouble(line, 64, 8)); + + // special implementation for the first entry + if (firstEcc) { + // we want null values outside validity limits of the station + station.addStationEccentricitiesValidBefore(eccStation, end); + station.addStationEccentricitiesValidBefore(null, start); + // we parsed the first entry, set the flag to false + firstEcc = false; + } else { + station.addStationEccentricitiesValidBefore(eccStation, end); + } + + // update the last known eccentricities entry + station.setEccentricities(eccStation); + } else if (inEpoch) { // read epoch data final Station station = getStation(parseString(line, 1, 4)); @@ -343,6 +372,13 @@ public class SinexLoader { * @return the corresponding AbsoluteDate */ private AbsoluteDate stringEpochToAbsoluteDate(final String stringDate) { + + // Deal with 00:000:00000 epochs + if (DEFAULT_EPOCH.equals(stringDate)) { + // Data is still available, return a dummy date at infinity in the future direction + return AbsoluteDate.FUTURE_INFINITY; + } + // Date components final String[] fields = SEPARATOR.split(stringDate); @@ -365,6 +401,7 @@ public class SinexLoader { return new AbsoluteDate(new DateComponents(year, 1, 1), utc). shiftedBy(Constants.JULIAN_DAY * (day - 1)). shiftedBy(secInDay); + } } diff --git a/src/main/java/org/orekit/files/sinex/Station.java b/src/main/java/org/orekit/files/sinex/Station.java index b2640d9b3..5dbf1b6e2 100644 --- a/src/main/java/org/orekit/files/sinex/Station.java +++ b/src/main/java/org/orekit/files/sinex/Station.java @@ -20,10 +20,21 @@ import java.util.HashMap; import java.util.Map; import org.hipparchus.geometry.euclidean.threed.Vector3D; +import org.orekit.errors.OrekitException; +import org.orekit.errors.OrekitMessages; import org.orekit.time.AbsoluteDate; +import org.orekit.utils.TimeSpanMap; /** * Station model. + *

+ * Since Orekit 11.1, this class handles multiple site antenna + * eccentricity. The {@link #getEccentricities()} method + * provides the last known eccentricity values. + * The {@link #getEccentricities(AbsoluteDate)} method can be + * used to access the site antenna eccentricity values for a + * given epoch. + *

* @author Bryan Cazabonne * @since 10.3 */ @@ -44,9 +55,12 @@ public class Station { /** Eccentricity reference system. */ private ReferenceSystem eccRefSystem; - /** Site antenna eccentricity (m). */ + /** Latest site antenna eccentricities (m). */ private Vector3D eccentricities; + /** TimeSpanMap of site antenna eccentricities. */ + private TimeSpanMap eccentricitiesTimeSpanMap; + /** Station position. */ private Vector3D position; @@ -60,9 +74,10 @@ public class Station { * Constructor. */ public Station() { - this.eccentricities = Vector3D.ZERO; - this.position = Vector3D.ZERO; - this.velocity = Vector3D.ZERO; + this.eccentricities = Vector3D.ZERO; + this.eccentricitiesTimeSpanMap = new TimeSpanMap<>(null); + this.position = Vector3D.ZERO; + this.velocity = Vector3D.ZERO; } /** @@ -102,6 +117,9 @@ public class Station { * @return start of validity */ public AbsoluteDate getValidFrom() { + if (validFrom == null) { + validFrom = eccentricitiesTimeSpanMap.getTransitions().first().getDate(); + } return validFrom; } @@ -118,6 +136,9 @@ public class Station { * @return end of validity */ public AbsoluteDate getValidUntil() { + if (validUntil == null) { + validUntil = eccentricitiesTimeSpanMap.getTransitions().last().getDate(); + } return validUntil; } @@ -146,9 +167,10 @@ public class Station { } /** - * Get the station antenna eccentricities. + * Get the last known station antenna eccentricities. *

- * Vector convention: X-Y-Z or UP-NORTH-EAST + * Vector convention: X-Y-Z or UP-NORTH-EAST. + * See {@link #getEccRefSystem()} method. *

* @return station antenna eccentricities (m) */ @@ -157,13 +179,69 @@ public class Station { } /** - * Set the station antenna eccentricities. + * Set the last known station antenna eccentricities. * @param eccentricities the eccenticities to set (m) */ public void setEccentricities(final Vector3D eccentricities) { this.eccentricities = eccentricities; } + /** + * Get the station antenna eccentricities for the given epoch. + *

+ * Vector convention: X-Y-Z or UP-NORTH-EAST. + * See {@link #getEccRefSystem()} method. + *

+ * If there is no eccentricity values for the given epoch, an + * exception is thrown. It is possible to access the last known + * values using the {@link #getEccentricities()} method. + * @param date epoch + * @return station antenna eccentricities (m) + * @since 11.1 + */ + public Vector3D getEccentricities(final AbsoluteDate date) { + final Vector3D eccAtEpoch = eccentricitiesTimeSpanMap.get(date); + // If the entry is null, there is no valid eccentricity values for the input epoch + if (eccAtEpoch == null) { + // Throw an exception + throw new OrekitException(OrekitMessages.NO_STATION_ECCENTRICITY_FOR_EPOCH, date, getValidFrom(), getValidUntil()); + } + return eccAtEpoch; + } + + /** + * Get the TimeSpanMap of site antenna eccentricities. + * @return the TimeSpanMap of site antenna eccentricities + * @since 11.1 + */ + public TimeSpanMap getEccentricitiesTimeSpanMap() { + return eccentricitiesTimeSpanMap; + } + + /** Add a station eccentricity vector entry valid before a limit date.
+ * Using addStationEccentricitiesValidBefore(entry, t) will make entry + * valid in ]-∞, t[ (note the open bracket). + * @param entry station eccentricity vector entry + * @param latestValidityDate date before which the entry is valid + * (must be different from all dates already used for transitions) + * @since 11.1 + */ + public void addStationEccentricitiesValidBefore(final Vector3D entry, final AbsoluteDate latestValidityDate) { + eccentricitiesTimeSpanMap.addValidBefore(entry, latestValidityDate); + } + + /** Add a station eccentricity vector entry valid after a limit date.
+ * Using addStationEccentricitiesValidAfter(entry, t) will make entry + * valid in [t, +∞[ (note the closed bracket). + * @param entry station eccentricity vector entry + * @param earliestValidityDate date after which the entry is valid + * (must be different from all dates already used for transitions) + * @since 11.1 + */ + public void addStationEccentricitiesValidAfter(final Vector3D entry, final AbsoluteDate earliestValidityDate) { + eccentricitiesTimeSpanMap.addValidAfter(entry, earliestValidityDate); + } + /** * Get the station position. * @return the station position (m) diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_da.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_da.utf8 index f0860d963..a78c561cd 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_da.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_da.utf8 @@ -750,3 +750,6 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = + diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_de.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_de.utf8 index cc391f2db..4afa1bc2d 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_de.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_de.utf8 @@ -750,3 +750,6 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_el.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_el.utf8 index bd5bbf59a..a7fb9595e 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_el.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_el.utf8 @@ -749,3 +749,6 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_en.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_en.utf8 index 30206a5e2..e41659de2 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_en.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_en.utf8 @@ -746,3 +746,6 @@ FIND_ROOT = {0} failed to find root between {1} (g={2,number,0.0##############E0 # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = backward propagation not allowed here + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_es.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_es.utf8 index 94084bd81..dfb55dee8 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_es.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_es.utf8 @@ -746,3 +746,6 @@ FIND_ROOT = {0} ha fallado buscando una solución entre {1} (g={2,number,0.0#### # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_fr.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_fr.utf8 index c3987fdb8..584e0a08c 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_fr.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_fr.utf8 @@ -746,3 +746,6 @@ FIND_ROOT = {0} n''a pas réussi à trouver une solution entre {1} (g={2,number, # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = la propagation à rebours n''a pas été autorisée ici + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = pas d''excentricité station pour la date {0}, l''intervalle de validité est entre {1} et {2} diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_gl.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_gl.utf8 index 66b278dd4..8b2e90ee1 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_gl.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_gl.utf8 @@ -751,3 +751,6 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_it.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_it.utf8 index e9e873248..23173df11 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_it.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_it.utf8 @@ -753,3 +753,6 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_no.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_no.utf8 index b440c61f7..0d4ab207e 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_no.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_no.utf8 @@ -754,3 +754,5 @@ FIND_ROOT = # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/main/resources/assets/org/orekit/localization/OrekitMessages_ro.utf8 b/src/main/resources/assets/org/orekit/localization/OrekitMessages_ro.utf8 index de061c85c..124e49856 100644 --- a/src/main/resources/assets/org/orekit/localization/OrekitMessages_ro.utf8 +++ b/src/main/resources/assets/org/orekit/localization/OrekitMessages_ro.utf8 @@ -746,3 +746,6 @@ FIND_ROOT = {0} nu a găsit rădăcina între {1} (g={2,number,0.0############## # backward propagation not allowed here BACKWARD_PROPAGATION_NOT_ALLOWED = + +# no station eccentricity values for the given epoch {0}, validity interval is between {1} and {2} +NO_STATION_ECCENTRICITY_FOR_EPOCH = diff --git a/src/test/java/org/orekit/errors/OrekitMessagesTest.java b/src/test/java/org/orekit/errors/OrekitMessagesTest.java index 89541a0bd..2ee949519 100644 --- a/src/test/java/org/orekit/errors/OrekitMessagesTest.java +++ b/src/test/java/org/orekit/errors/OrekitMessagesTest.java @@ -30,7 +30,7 @@ public class OrekitMessagesTest { @Test public void testMessageNumber() { - Assert.assertEquals(249, OrekitMessages.values().length); + Assert.assertEquals(250, OrekitMessages.values().length); } @Test diff --git a/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java b/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java index f2c5ee943..9c0bffd0b 100644 --- a/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java +++ b/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java @@ -142,6 +142,94 @@ public class SinexLoaderTest { } + @Test + public void testIssue867() { + + // Load file (it corresponds to a small version of the real entier file) + SinexLoader loader = new SinexLoader("ecc_xyz-small-multiple-ecc.snx"); + Assert.assertEquals(4, loader.getStations().size()); + + // Verify station 7236 + final Station station7236 = loader.getStation("7236"); + final Vector3D refStation7236 = Vector3D.ZERO; + Assert.assertEquals(0.0, refStation7236.distance(station7236.getEccentricities(new AbsoluteDate("1995-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, station7236.getValidFrom().durationFrom(new AbsoluteDate("1988-01-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); + Assert.assertEquals(0.0, station7236.getValidUntil().durationFrom(new AbsoluteDate("1999-09-30T23:59:59.000", TimeScalesFactory.getUTC())), 1.0e-15); + + // Verify station 7237 + final Station station7237 = loader.getStation("7237"); + final Vector3D refStation7237 = Vector3D.ZERO; + Assert.assertEquals(0.0, refStation7237.distance(station7237.getEccentricities(new AbsoluteDate("1995-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7237.distance(station7237.getEccentricities(new AbsoluteDate("2021-12-06T17:30:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7237.distance(station7237.getEccentricities(new AbsoluteDate("2999-12-06T17:30:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, station7237.getValidFrom().durationFrom(new AbsoluteDate("1988-01-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); + Assert.assertTrue(station7237.getValidUntil() == AbsoluteDate.FUTURE_INFINITY); + + // Verify station 7090 + final Station station7090 = loader.getStation("7090"); + Vector3D refStation7090 = new Vector3D(-1.2030, 2.5130, -1.5440); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1982-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1984-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1985-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1986-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1987-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.1990, 2.5070, -1.5400); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1988-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1990-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1991-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1992-01-01T12:00:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2060, 2.5010, -1.5530); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1992-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1995-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("1998-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2048, 2.5019, -1.5516); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2002-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2058, 2.5026, -1.5522); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2005-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2069, 2.5034, -1.5505); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2008-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2043, 2.5040, -1.5509); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2012-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + refStation7090 = new Vector3D(-1.2073, 2.5034, -1.5509); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2015-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2021-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2999-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, station7090.getValidFrom().durationFrom(new AbsoluteDate("1979-07-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); + Assert.assertEquals(0.0, station7090.getValidFrom().durationFrom(new AbsoluteDate("1979-07-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); + Assert.assertTrue(station7090.getValidUntil() == AbsoluteDate.FUTURE_INFINITY); + Assert.assertTrue(station7090.getValidUntil() == AbsoluteDate.FUTURE_INFINITY); + + // Verify station 7092 + final Station station7092 = loader.getStation("7092"); + Vector3D refStation7092 = new Vector3D(-3.0380, 0.6290, 0.4980); + Assert.assertEquals(0.0, refStation7092.distance(station7092.getEccentricities(new AbsoluteDate("1980-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); + Assert.assertEquals(0.0, station7092.getValidFrom().durationFrom(new AbsoluteDate("1979-08-15T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); + Assert.assertEquals(0.0, station7092.getValidUntil().durationFrom(new AbsoluteDate("1980-10-31T23:59:59.000", TimeScalesFactory.getUTC())), 1.0e-15); + + } + + @Test + public void testNoEccentricityEntryForEpoch() { + + // Load file (it corresponds to a small version of the real entier file) + SinexLoader loader = new SinexLoader("ecc_xyz-small-multiple-ecc.snx"); + + // Station 7236 + final Station station7236 = loader.getStation("7236"); + + // Epoch of exception + final AbsoluteDate exceptionEpoch = new AbsoluteDate("1987-01-11T00:00:00.000", TimeScalesFactory.getUTC()); + + // Test the exception + try { + station7236.getEccentricities(exceptionEpoch); + Assert.fail("an exception should have been thrown"); + } catch (OrekitException oe) { + Assert.assertEquals(OrekitMessages.NO_STATION_ECCENTRICITY_FOR_EPOCH, oe.getSpecifier()); + } + + } + @Test public void testCorruptedFile() { try { diff --git a/src/test/resources/sinex/ecc_xyz-small-multiple-ecc.snx b/src/test/resources/sinex/ecc_xyz-small-multiple-ecc.snx new file mode 100644 index 000000000..7b75df15f --- /dev/null +++ b/src/test/resources/sinex/ecc_xyz-small-multiple-ecc.snx @@ -0,0 +1,46 @@ +%=SNX 2.02 JCT 20:111:61200 JCT 68:041:00000 20:111:61200 L 00549 0 X ++FILE/REFERENCE + DESCRIPTION XYZ 200420 ILRS eccentricities file + OUTPUT ILRS SINEX Formatted Eccentricity File + CONTACT epavlis@UMBC.edu + SOFTWARE JCET's eccCDDIS2snx + HARDWARE Apple MacBook Pro + INPUT Official Eccentricity file from CDDIS (110707) + INPUT and previous version slrecc.191030.ILRS.xyz.snx + INPUT Numerous emails/reports from Van Husson’s review +-FILE/REFERENCE ++INPUT/HISTORY + =SNX 2.02 JCT 20:111:61200 JCT 68:041:00000 20:111:61200 L 00549 0 X +-INPUT/HISTORY ++SITE/ID +*Code PT __DOMES__ T _STATION DESCRIPTION__ APPROX_LON_ APPROX_LAT_ _APP_H_ CDP-SOD_ + 7236 A 21602S003 L Wuhan WUH. FIXED 114 20 46.5 30 32 30.4 39.4 72362901 + 7237 A 21611S001 L Changchun CHALAS 125 26 36.4 43 47 25.8 274.9 72371901 + 7090 A 50107M001 L Yarragadee MOBLAS-5 115 20 48.2 -29 -2-47.3 242.0 70900501 + 7092 A 50505M001 L Kwajalein MOBLAS-8 167 28 32.5 9 23 37.6 31.3 70920801 +-SITE/ID ++SITE/ECCENTRICITY +*SITE PT SOLN T DATA_START__ DATA_END____ XYZ X_______ Y_______ Z_______ CDP-SOD_ + 7236 A 1 L 88:001:00000 99:273:86399 XYZ 0.0000 0.0000 0.0000 72362901 + 7237 A 1 L 88:001:00000 00:000:00000 XYZ 0.0000 0.0000 0.0000 72371901 + 7090 A 1 L 79:182:00000 83:207:86399 XYZ -1.2030 2.5130 -1.5440 70900501 + 7090 A 1 L 83:208:00000 84:323:86399 XYZ -1.2030 2.5130 -1.5440 70900502 + 7090 A 1 L 84:324:00000 85:247:86399 XYZ -1.2030 2.5130 -1.5440 70900503 + 7090 A 1 L 85:248:00000 87:106:86399 XYZ -1.2030 2.5130 -1.5440 70900504 + 7090 A 1 L 87:113:00000 87:224:86399 XYZ -1.2030 2.5130 -1.5440 70900505 + 7090 A 1 L 87:225:00000 87:237:86399 XYZ -1.1990 2.5070 -1.5400 70900506 + 7090 A 1 L 87:238:00000 89:216:86399 XYZ -1.1990 2.5070 -1.5400 70900507 + 7090 A 1 L 89:217:00000 90:316:86399 XYZ -1.1990 2.5070 -1.5400 70900508 + 7090 A 1 L 90:317:00000 91:157:86399 XYZ -1.1990 2.5070 -1.5400 70900509 + 7090 A 1 L 91:158:00000 92:008:86399 XYZ -1.1990 2.5070 -1.5400 70900510 + 7090 A 1 L 92:021:00000 92:083:86399 XYZ -1.2060 2.5010 -1.5530 70900511 + 7090 A 1 L 92:084:00000 92:195:86399 XYZ -1.2060 2.5010 -1.5530 70900512 + 7090 A 1 L 92:203:00000 98:233:86399 XYZ -1.2060 2.5010 -1.5530 70900513 + 7090 A 1 L 98:234:00000 03:330:86399 XYZ -1.2048 2.5019 -1.5516 70900513 + 7090 A 1 L 03:331:00000 07:150:86399 XYZ -1.2058 2.5026 -1.5522 70900513 + 7090 A 1 L 07:151:00000 10:195:86399 XYZ -1.2069 2.5034 -1.5505 70900513 + 7090 A 1 L 10:196:00000 14:079:86399 XYZ -1.2043 2.5040 -1.5509 70900513 + 7090 A 1 L 14:080:00000 00:000:00000 XYZ -1.2073 2.5034 -1.5509 70900513 + 7092 A 1 L 79:227:00000 80:305:86399 XYZ -3.0380 0.6290 0.4980 70920801 +-SITE/ECCENTRICITY +%ENDSNX \ No newline at end of file -- GitLab From fdd5142979804dbeb573698f084e354547232ff9 Mon Sep 17 00:00:00 2001 From: Bryan Cazabonne Date: Tue, 7 Dec 2021 14:01:31 +0100 Subject: [PATCH 2/2] Removed duplicated assertions. --- src/test/java/org/orekit/files/sinex/SinexLoaderTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java b/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java index 9c0bffd0b..45f5c93df 100644 --- a/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java +++ b/src/test/java/org/orekit/files/sinex/SinexLoaderTest.java @@ -195,8 +195,6 @@ public class SinexLoaderTest { Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2021-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); Assert.assertEquals(0.0, refStation7090.distance(station7090.getEccentricities(new AbsoluteDate("2999-07-05T07:50:00.000", TimeScalesFactory.getUTC()))), 1.0e-15); Assert.assertEquals(0.0, station7090.getValidFrom().durationFrom(new AbsoluteDate("1979-07-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); - Assert.assertEquals(0.0, station7090.getValidFrom().durationFrom(new AbsoluteDate("1979-07-01T00:00:00.000", TimeScalesFactory.getUTC())), 1.0e-15); - Assert.assertTrue(station7090.getValidUntil() == AbsoluteDate.FUTURE_INFINITY); Assert.assertTrue(station7090.getValidUntil() == AbsoluteDate.FUTURE_INFINITY); // Verify station 7092 -- GitLab