Commit 39940d9e authored by Bryan Cazabonne's avatar Bryan Cazabonne

Changed API for angle unit.

parent 44425e5f
...@@ -89,10 +89,10 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel ...@@ -89,10 +89,10 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel
/** The hydrostatic and wet a coefficients loaded. */ /** The hydrostatic and wet a coefficients loaded. */
private double[] coefficientsA; private double[] coefficientsA;
/** 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;
/** Temperature site, in kelvins. */ /** Temperature site, in kelvins. */
...@@ -115,8 +115,8 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel ...@@ -115,8 +115,8 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel
/** 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 longitude geodetic latitude of the station, in degrees * @param longitude longitude geodetic latitude of the station, in radians
* @param geoid level surface of the gravity potential of a body * @param geoid level surface of the gravity potential of a body
*/ */
public GlobalPressureTemperature2Model(final String supportedNames, final double latitude, public GlobalPressureTemperature2Model(final String supportedNames, final double latitude,
...@@ -129,14 +129,13 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel ...@@ -129,14 +129,13 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel
this.geoid = geoid; this.geoid = geoid;
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 geoid level surface of the gravity potential of a body * @param geoid level surface of the gravity potential of a body
*/ */
public GlobalPressureTemperature2Model(final double latitude, final double longitude, final Geoid geoid) { public GlobalPressureTemperature2Model(final double latitude, final double longitude, final Geoid geoid) {
...@@ -307,30 +306,34 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel ...@@ -307,30 +306,34 @@ public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel
final BilinearInterpolatingFunction functionAH = new BilinearInterpolatingFunction(xVal, yVal, fvalAH); final BilinearInterpolatingFunction functionAH = new BilinearInterpolatingFunction(xVal, yVal, fvalAH);
final BilinearInterpolatingFunction functionAW = new BilinearInterpolatingFunction(xVal, yVal, fvalAW); final BilinearInterpolatingFunction functionAW = new BilinearInterpolatingFunction(xVal, yVal, fvalAW);
// Convert geodetic coordinates to degrees
final double lat = FastMath.toDegrees(latitude);
final double lon = FastMath.toDegrees(longitude);
// ah and aw coefficients // ah and aw coefficients
coefficientsA = new double[2]; coefficientsA = new double[2];
coefficientsA[0] = functionAH.value(latitude, longitude) * 0.001; coefficientsA[0] = functionAH.value(lat, lon) * 0.001;
coefficientsA[1] = functionAW.value(latitude, longitude) * 0.001; coefficientsA[1] = functionAW.value(lat, lon) * 0.001;
// Corrected height (can be negative) // Corrected height (can be negative)
final double undu = geoid.getUndulation(latitude, longitude, date); final double undu = geoid.getUndulation(lat, lon, date);
final double correctedheight = height - undu - functionHS.value(latitude, longitude); final double correctedheight = height - undu - functionHS.value(lat, lon);
// Temperature gradient [K/m] // Temperature gradient [K/m]
final double dTdH = functiondT.value(latitude, longitude) * 0.001; final double dTdH = functiondT.value(lat, lon) * 0.001;
// Specific humidity // Specific humidity
final double qv = functionqv0.value(latitude, longitude) * 0.001; final double qv = functionqv0.value(lat, lon) * 0.001;
// For the computation of the temperature and the pressure, we use // For the computation of the temperature and the pressure, we use
// the standard ICAO atmosphere formulas. // the standard ICAO atmosphere formulas.
// Temperature [K] // Temperature [K]
final double t0 = functionTemperature0.value(latitude, longitude); final double t0 = functionTemperature0.value(lat, lon);
this.temperature = t0 + dTdH * correctedheight; this.temperature = t0 + dTdH * correctedheight;
// Pressure [hPa] // Pressure [hPa]
final double p0 = functionPressure0.value(latitude, longitude); final double p0 = functionPressure0.value(lat, lon);
final double exponent = G / (dTdH * R); final double exponent = G / (dTdH * R);
this.pressure = p0 * FastMath.pow(1 - (dTdH / t0) * correctedheight, exponent) * 0.01; this.pressure = p0 * FastMath.pow(1 - (dTdH / t0) * correctedheight, exponent) * 0.01;
......
...@@ -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.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -58,8 +59,8 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -58,8 +59,8 @@ public class GlobalPressureTemperature2ModelTest {
// We test the fiability of our implementation by comparing our output values with // We test the fiability of our implementation by comparing our output values with
// the ones obtained by the Vienna University. // the ones obtained by the Vienna University.
final double latitude = 48.20; final double latitude = FastMath.toRadians(48.20);
final double longitude = 16.37; final double longitude = FastMath.toRadians(16.37);
final double height = 156.0; final double height = 156.0;
final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC()); final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC());
final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12), final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12),
...@@ -90,7 +91,7 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -90,7 +91,7 @@ public class GlobalPressureTemperature2ModelTest {
ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true))); ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true)));
final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC()); final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC());
final double latitude = 45.0; final double latitude = FastMath.toRadians(45.0);
final double height = 0.0; final double height = 0.0;
double longitude1; double longitude1;
...@@ -100,8 +101,8 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -100,8 +101,8 @@ public class GlobalPressureTemperature2ModelTest {
GlobalPressureTemperature2Model model2; GlobalPressureTemperature2Model 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 GlobalPressureTemperature2Model(latitude, longitude1, geoid); model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid); model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
...@@ -117,8 +118,8 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -117,8 +118,8 @@ public class GlobalPressureTemperature2ModelTest {
Assert.assertEquals(model1.getA()[1], model2.getA()[1], epsilon); Assert.assertEquals(model1.getA()[1], model2.getA()[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 GlobalPressureTemperature2Model(latitude, longitude1, geoid); model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid); model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
...@@ -133,8 +134,8 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -133,8 +134,8 @@ public class GlobalPressureTemperature2ModelTest {
Assert.assertEquals(model1.getA()[1], model2.getA()[1], epsilon); Assert.assertEquals(model1.getA()[1], model2.getA()[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 GlobalPressureTemperature2Model(latitude, longitude1, geoid); model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid); model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
...@@ -153,8 +154,8 @@ public class GlobalPressureTemperature2ModelTest { ...@@ -153,8 +154,8 @@ public class GlobalPressureTemperature2ModelTest {
@Test @Test
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);
final double height = 0.0; final double height = 0.0;
// Date is not used here // Date is not used here
......
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