Commit e306b4ce authored by Luc Maisonobe's avatar Luc Maisonobe

User radians in API for Vienna model loading.

parent fad54278
...@@ -91,10 +91,10 @@ public class ViennaModelCoefficientsLoader implements DataLoader { ...@@ -91,10 +91,10 @@ public class ViennaModelCoefficientsLoader implements DataLoader {
/** The hydrostatic and wet zenith delays loaded. */ /** The hydrostatic and wet zenith delays loaded. */
private double[] zenithDelay; private double[] zenithDelay;
/** Geodetic site latitude, degrees.*/ /** Geodetic site latitude, radians.*/
private double latitude; private double latitude;
/** Geodetic site longitude, degrees.*/ /** Geodetic site longitude, radians.*/
private double longitude; private double longitude;
/** Vienna tropospheric model type.*/ /** Vienna tropospheric model type.*/
...@@ -102,8 +102,8 @@ public class ViennaModelCoefficientsLoader implements DataLoader { ...@@ -102,8 +102,8 @@ public class ViennaModelCoefficientsLoader implements DataLoader {
/** Constructor with supported names given by user. /** Constructor with supported names given by user.
* @param supportedNames Supported names * @param supportedNames Supported names
* @param latitude geodetic latitude of the station, in degrees * @param latitude geodetic latitude of the station, in radians
* @param longitude geodetic latitude of the station, in degrees * @param longitude geodetic latitude of the station, in radians
* @param type the type of Vienna tropospheric model (one or three) * @param type the type of Vienna tropospheric model (one or three)
*/ */
public ViennaModelCoefficientsLoader(final String supportedNames, final double latitude, public ViennaModelCoefficientsLoader(final String supportedNames, final double latitude,
...@@ -114,14 +114,14 @@ public class ViennaModelCoefficientsLoader implements DataLoader { ...@@ -114,14 +114,14 @@ public class ViennaModelCoefficientsLoader implements DataLoader {
this.type = type; this.type = type;
this.latitude = latitude; this.latitude = latitude;
// Normalize longitude between 0° and 360° // Normalize longitude between 0 and 2π
final double lon = MathUtils.normalizeAngle(FastMath.toRadians(longitude), FastMath.PI); this.longitude = MathUtils.normalizeAngle(longitude, FastMath.PI);
this.longitude = FastMath.toDegrees(lon);
} }
/** Constructor with default supported names. /** Constructor with default supported names.
* @param latitude geodetic latitude of the station, in degrees * @param latitude geodetic latitude of the station, in radians
* @param longitude geodetic latitude of the station, in degrees * @param longitude geodetic latitude of the station, in radians
* @param type the type of Vienna tropospheric model (one or three) * @param type the type of Vienna tropospheric model (one or three)
*/ */
public ViennaModelCoefficientsLoader(final double latitude, final double longitude, public ViennaModelCoefficientsLoader(final double latitude, final double longitude,
...@@ -262,16 +262,16 @@ public class ViennaModelCoefficientsLoader implements DataLoader { ...@@ -262,16 +262,16 @@ public class ViennaModelCoefficientsLoader implements DataLoader {
// Latitudes list // Latitudes list
for (double lat = Double.valueOf(range_line[2]); lat <= Double.valueOf(range_line[3]); lat = lat + Double.valueOf(range_line[6])) { for (double lat = Double.valueOf(range_line[2]); lat <= Double.valueOf(range_line[3]); lat = lat + Double.valueOf(range_line[6])) {
latitudes.add(lat); latitudes.add(FastMath.toRadians(lat));
} }
// Longitude list // Longitude list
for (double lon = Double.valueOf(range_line[4]); lon <= Double.valueOf(range_line[5]); lon = lon + Double.valueOf(range_line[7])) { for (double lon = Double.valueOf(range_line[4]); lon <= Double.valueOf(range_line[5]); lon = lon + Double.valueOf(range_line[7])) {
longitudes.add(lon); longitudes.add(FastMath.toRadians(lon));
// For VFM1 files, header specify that longitudes end at 360° // For VFM1 files, header specify that longitudes end at 360°
// In reality they end at 357.5°. That is why we stop the loop when the longitude // In reality they end at 357.5°. That is why we stop the loop when the longitude
// is equal to 357.5°. // reaches 357.5°.
if (type == ViennaModelType.VIENNA_ONE && lon == 357.5) { if (type == ViennaModelType.VIENNA_ONE && lon >= 357.5) {
break; break;
} }
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
package org.orekit.models.earth; package org.orekit.models.earth;
import org.hipparchus.util.FastMath;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.orekit.Utils; import org.orekit.Utils;
...@@ -25,7 +26,7 @@ import org.orekit.time.DateTimeComponents; ...@@ -25,7 +26,7 @@ import org.orekit.time.DateTimeComponents;
public class ViennaModelCoefficientsLoaderTest { public class ViennaModelCoefficientsLoaderTest {
private static double epsilon = 1.0e-16; private static double epsilon = 5.0e-16;
@Test @Test
/** /**
...@@ -36,8 +37,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -36,8 +37,8 @@ public class ViennaModelCoefficientsLoaderTest {
Utils.setDataRoot("vmf1-tropospheric-coefficients"); Utils.setDataRoot("vmf1-tropospheric-coefficients");
final double latitude = 14.0; final double latitude = FastMath.toRadians(14.0);
final double longitude = 67.5; final double longitude = FastMath.toRadians(67.5);
ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_ONE); ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_ONE);
DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 19, 18, 0, 0.0); DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 19, 18, 0, 0.0);
tropoLoader.loadViennaCoefficients(dateTimeComponents); tropoLoader.loadViennaCoefficients(dateTimeComponents);
...@@ -61,8 +62,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -61,8 +62,8 @@ public class ViennaModelCoefficientsLoaderTest {
Utils.setDataRoot("vmf3-5x5-tropospheric-coefficients"); Utils.setDataRoot("vmf3-5x5-tropospheric-coefficients");
final double latitude = 77.5; final double latitude = FastMath.toRadians(77.5);
final double longitude = 2.5; final double longitude = FastMath.toRadians(2.5);
ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_THREE); ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_THREE);
DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0); DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0);
tropoLoader.loadViennaCoefficients(dateTimeComponents); tropoLoader.loadViennaCoefficients(dateTimeComponents);
...@@ -86,8 +87,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -86,8 +87,8 @@ public class ViennaModelCoefficientsLoaderTest {
Utils.setDataRoot("vmf3-1x1-tropospheric-coefficients"); Utils.setDataRoot("vmf3-1x1-tropospheric-coefficients");
final double latitude = 19.5; final double latitude = FastMath.toRadians(19.5);
final double longitude = 276.5; final double longitude = FastMath.toRadians(276.5);
ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_THREE); ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_THREE);
DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0); DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0);
tropoLoader.loadViennaCoefficients(dateTimeComponents); tropoLoader.loadViennaCoefficients(dateTimeComponents);
...@@ -108,7 +109,7 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -108,7 +109,7 @@ public class ViennaModelCoefficientsLoaderTest {
// Commons parameters // Commons parameters
Utils.setDataRoot("vmf3-1x1-tropospheric-coefficients"); Utils.setDataRoot("vmf3-1x1-tropospheric-coefficients");
DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0); DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 25, 0, 0, 0.0);
final double latitude = 45.0; final double latitude = FastMath.toRadians(45.0);
double longitude1; double longitude1;
ViennaModelCoefficientsLoader model1; ViennaModelCoefficientsLoader model1;
...@@ -117,8 +118,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -117,8 +118,8 @@ public class ViennaModelCoefficientsLoaderTest {
ViennaModelCoefficientsLoader model2; ViennaModelCoefficientsLoader model2;
// Test longitude = 181° and longitude = -179° // Test longitude = 181° and longitude = -179°
longitude1 = 181.0; longitude1 = FastMath.toRadians(181.0);
longitude2 = -179.0; longitude2 = FastMath.toRadians(-179.0);
model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE); model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE);
model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE); model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE);
...@@ -132,8 +133,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -132,8 +133,8 @@ public class ViennaModelCoefficientsLoaderTest {
Assert.assertEquals(model1.getZenithDelay()[1], model2.getZenithDelay()[1], epsilon); Assert.assertEquals(model1.getZenithDelay()[1], model2.getZenithDelay()[1], epsilon);
// Test longitude = 180° and longitude = -180° // Test longitude = 180° and longitude = -180°
longitude1 = 180.0; longitude1 = FastMath.toRadians(180.0);
longitude2 = -180.0; longitude2 = FastMath.toRadians(-180.0);
model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE); model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE);
model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE); model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE);
...@@ -147,8 +148,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -147,8 +148,8 @@ public class ViennaModelCoefficientsLoaderTest {
Assert.assertEquals(model1.getZenithDelay()[1], model2.getZenithDelay()[1], epsilon); Assert.assertEquals(model1.getZenithDelay()[1], model2.getZenithDelay()[1], epsilon);
// Test longitude = 0° and longitude = 360° // Test longitude = 0° and longitude = 360°
longitude1 = 0.0; longitude1 = FastMath.toRadians(0.0);
longitude2 = 360.0; longitude2 = FastMath.toRadians(360.0);
model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE); model1 = new ViennaModelCoefficientsLoader(latitude, longitude1, ViennaModelType.VIENNA_THREE);
model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE); model2 = new ViennaModelCoefficientsLoader(latitude, longitude2, ViennaModelType.VIENNA_THREE);
...@@ -169,8 +170,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -169,8 +170,8 @@ public class ViennaModelCoefficientsLoaderTest {
*/ */
public void testCorruptedFileBadData() { public void testCorruptedFileBadData() {
final double latitude = 14.0; final double latitude = FastMath.toRadians(14.0);
final double longitude = 67.5; final double longitude = FastMath.toRadians(67.5);
Utils.setDataRoot("vmf1-tropospheric-coefficients"); Utils.setDataRoot("vmf1-tropospheric-coefficients");
final String fileName = "corrupted-bad-data-VMFG_20181119.H18"; final String fileName = "corrupted-bad-data-VMFG_20181119.H18";
...@@ -193,8 +194,8 @@ public class ViennaModelCoefficientsLoaderTest { ...@@ -193,8 +194,8 @@ public class ViennaModelCoefficientsLoaderTest {
public void testAbsentFile() { public void testAbsentFile() {
Utils.setDataRoot("vmf1-tropospheric-coefficients"); Utils.setDataRoot("vmf1-tropospheric-coefficients");
final double latitude = 14.0; final double latitude = FastMath.toRadians(14.0);
final double longitude = 67.5; final double longitude = FastMath.toRadians(67.5);
ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_ONE); ViennaModelCoefficientsLoader tropoLoader = new ViennaModelCoefficientsLoader(latitude, longitude, ViennaModelType.VIENNA_ONE);
DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 19, 1, 0, 0); DateTimeComponents dateTimeComponents = new DateTimeComponents(2018, 11, 19, 1, 0, 0);
......
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