Commit 06492c67 authored by Luc Maisonobe's avatar Luc Maisonobe

Merge branch 'issue-517' into release-9.3

parents e50af9aa cb1eb853
......@@ -221,7 +221,8 @@ public enum OrekitMessages implements Localizable {
CORRUPTED_FILE("file {0} is corrupted"),
VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_LOADED("Vienna coefficients ah or aw or zh or zw could not be loaded from {0}"),
VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE("Vienna coefficients ah or aw or zh or zw not available for date {0}"),
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE("file {0} does not contain Vienna coefficients ah, aw, zh or zw");
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE("file {0} does not contain Vienna coefficients ah, aw, zh or zw"),
IRREGULAR_OR_INCOMPLETE_GRID("irregular or incomplete grid in file {0}");
// CHECKSTYLE: resume JavadocVariable check
......
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = Vienna coefficients ah or
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = file {0} does not contain Vienna coefficients ah, aw, zh or zw
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = irregular or incomplete grid in file {0}
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = les coefficients du modèl
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = {0} ne contiant pas de coefficients du modèle de Vienne ah, aw, zh ou zw
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = grille incomplète ou irrégulière dans le fichier {0}
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -510,3 +510,6 @@ VIENNA_ACOEF_OR_ZENITH_DELAY_NOT_AVAILABLE_FOR_DATE = <MISSING TRANSLATION>
# file {0} does not contain Vienna coefficients ah, aw, zh or zw
NO_VIENNA_ACOEF_OR_ZENITH_DELAY_IN_FILE = <MISSING TRANSLATION>
# irregular or incomplete grid in file {0}
IRREGULAR_OR_INCOMPLETE_GRID = <MISSING TRANSLATION>
......@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Assert;
import org.orekit.bodies.CelestialBodyFactory;
......@@ -32,6 +33,7 @@ import org.orekit.frames.EOPEntry;
import org.orekit.frames.EOPHistoryLoader;
import org.orekit.frames.FramesFactory;
import org.orekit.frames.ITRFVersion;
import org.orekit.models.earth.GlobalPressureTemperature2Model;
import org.orekit.orbits.FieldCartesianOrbit;
import org.orekit.orbits.FieldCircularOrbit;
import org.orekit.orbits.FieldEquinoctialOrbit;
......@@ -79,6 +81,7 @@ public class Utils {
clearFactoryMaps(c);
}
}
clearAtomicReference(GlobalPressureTemperature2Model.class);
FramesFactory.clearEOPHistoryLoaders();
FramesFactory.setEOPContinuityThreshold(5 * Constants.JULIAN_DAY);
TimeScalesFactory.clearUTCTAIOffsetsLoaders();
......@@ -87,6 +90,7 @@ public class Utils {
DataProvidersManager.getInstance().clearProviders();
DataProvidersManager.getInstance().clearFilters();
DataProvidersManager.getInstance().clearLoadedDataNames();
}
public static void setDataRoot(String root) {
......@@ -125,7 +129,7 @@ public class Utils {
try {
for (Field field : factoryClass.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) &&
cachedFieldsClass.isAssignableFrom(field.getType())) {
cachedFieldsClass.isAssignableFrom(field.getType())) {
field.setAccessible(true);
field.set(null, null);
}
......@@ -135,6 +139,20 @@ public class Utils {
}
}
private static void clearAtomicReference(Class<?> factoryClass) {
try {
for (Field field : factoryClass.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) &&
AtomicReference.class.isAssignableFrom(field.getType())) {
field.setAccessible(true);
((AtomicReference<?>) field.get(null)).set(null);
}
}
} catch (IllegalAccessException iae) {
Assert.fail(iae.getMessage());
}
}
public static List<EOPEntry> buildEOPList(IERSConventions conventions, ITRFVersion version,
double[][] data) {
IERSConventions.NutationCorrectionConverter converter =
......
......@@ -31,7 +31,7 @@ public class OrekitMessagesTest {
@Test
public void testMessageNumber() {
Assert.assertEquals(171, OrekitMessages.values().length);
Assert.assertEquals(172, OrekitMessages.values().length);
}
@Test
......
......@@ -61,7 +61,8 @@ public class GlobalPressureTemperature2ModelTest {
final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC());
final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12),
ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true)));
final GlobalPressureTemperature2Model model = new GlobalPressureTemperature2Model(latitude, longitude, geoid);
final GlobalPressureTemperature2Model model =
new GlobalPressureTemperature2Model("gpt2_5_extract.grd", latitude, longitude, geoid);
model.weatherParameters(height, date);
......@@ -156,20 +157,15 @@ public class GlobalPressureTemperature2ModelTest {
final double latitude = FastMath.toRadians(14.0);
final double longitude = FastMath.toRadians(67.5);
final double height = 0.0;
// Date is not used here
final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12),
ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true)));
final String fileName = "corrupted-bad-data-gpt2_5.grd";
final GlobalPressureTemperature2Model model = new GlobalPressureTemperature2Model(fileName, latitude, longitude, geoid);
try {
model.weatherParameters(height, date);
new GlobalPressureTemperature2Model(fileName, latitude, longitude, geoid);
Assert.fail("An exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, oe.getSpecifier());
Assert.assertEquals(6, ((Integer) oe.getParts()[0]).intValue());
......@@ -177,4 +173,29 @@ public class GlobalPressureTemperature2ModelTest {
}
}
@Test
public void testCorruptedIrregularGrid() {
Utils.setDataRoot("regular-data:potential:gpt2-grid");
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
final double latitude = FastMath.toRadians(14.0);
final double longitude = FastMath.toRadians(68.5);
// Date is not used here
final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12),
ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true)));
final String fileName = "corrupted-irregular-grid-gpt2_5.grd";
try {
new GlobalPressureTemperature2Model(fileName, latitude, longitude, geoid);
Assert.fail("An exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.IRREGULAR_OR_INCOMPLETE_GRID, oe.getSpecifier());
Assert.assertTrue(((String) oe.getParts()[0]).endsWith(fileName));
}
}
}
% This is not an original GPT2 grid, it has been edited for test purposes and should not be used except for test
% lat lon p:a0 A1 B1 A2 B2 T:a0 A1 B1 A2 B2 Q:a0 A1 B1 A2 B2 dT:a0 A1 B1 A2 B2 undu Hs h:a0 A1 B1 A2 B2 w:a0 A1 B1 A2 B2
17.5 67.5 100913 30 -28 9 -14 283.4 -9.1 -2.9 -0.0 0.3 6.02 -2.61 -1.33 0.29 0.32 -4.6 1.0 -0.3 -0.1 -0.0 41.28 52.71 1.2352 -0.0211 -0.0108 0.0008 0.0009 0.5583 -0.0126 -0.0125 0.0040 0.0012
17.5 72.5 100434 46 -48 -8 -16 282.7 -10.0 -3.0 0.0 0.2 5.88 -2.85 -1.38 0.39 0.36 -4.3 1.1 -0.2 -0.2 0.1 34.11 93.18 1.2344 -0.0225 -0.0111 0.0010 0.0007 0.5578 -0.0120 -0.0115 0.0049 0.0017
12.5 67.4999 89942 -161 -172 56 16 281.0 -8.4 -3.1 0.1 0.1 5.13 -2.91 -1.20 0.34 0.34 -6.5 0.6 -0.2 0.2 -0.1 47.30 1024.64 1.2395 -0.0209 -0.0110 0.0010 0.0008 0.5243 -0.0055 -0.0101 0.0041 0.0011
12.5 72.5 99762 183 -97 41 -6 284.8 -10.5 -2.7 -0.3 0.1 6.21 -3.28 -1.34 0.41 0.22 -5.4 1.6 -0.0 0.0 0.1 44.86 160.75 1.2406 -0.0219 -0.0106 0.0008 0.0005 0.5649 -0.0088 -0.0096 0.0044 0.0026
This diff is collapsed.
This diff is collapsed.
% This is not an original GPT2 grid, it has been edited for test purposes and should not be used except for test
% lat lon p:a0 A1 B1 A2 B2 T:a0 A1 B1 A2 B2 Q:a0 A1 B1 A2 B2 dT:a0 A1 B1 A2 B2 undu Hs h:a0 A1 B1 A2 B2 w:a0 A1 B1 A2 B2
52.5 12.5 100913 30 -28 9 -14 283.4 -9.1 -2.9 -0.0 0.3 6.02 -2.61 -1.33 0.29 0.32 -4.6 1.0 -0.3 -0.1 -0.0 41.28 52.71 1.2352 -0.0211 -0.0108 0.0008 0.0009 0.5583 -0.0126 -0.0125 0.0040 0.0012
52.5 17.5 100434 46 -48 -8 -16 282.7 -10.0 -3.0 0.0 0.2 5.88 -2.85 -1.38 0.39 0.36 -4.3 1.1 -0.2 -0.2 0.1 34.11 93.18 1.2344 -0.0225 -0.0111 0.0010 0.0007 0.5578 -0.0120 -0.0115 0.0049 0.0017
47.5 12.5 89942 -161 -172 56 16 281.0 -8.4 -3.1 0.1 0.1 5.13 -2.91 -1.20 0.34 0.34 -6.5 0.6 -0.2 0.2 -0.1 47.30 1024.64 1.2395 -0.0209 -0.0110 0.0010 0.0008 0.5243 -0.0055 -0.0101 0.0041 0.0011
47.5 17.5 99762 183 -97 41 -6 284.8 -10.5 -2.7 -0.3 0.1 6.21 -3.28 -1.34 0.41 0.22 -5.4 1.6 -0.0 0.0 0.1 44.86 160.75 1.2406 -0.0219 -0.0106 0.0008 0.0005 0.5649 -0.0088 -0.0096 0.0044 0.0026
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment