Commit abbc1cb3 authored by Bryan Cazabonne's avatar Bryan Cazabonne

Added weather model Global Pressure and Temperature 2.

parent 00056592
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="TBD" date="TBD" description="TBD">
<action dev="bryan" type="add" issue="512">
Added weather model Global Pressure and Temperature 2.
</action>
<action dev="bryan" type="add" issue="511">
Added weather model Global Pressure and Temperature.
</action>
......
/* Copyright 2002-2019 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.models.earth;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.Utils;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.forces.gravity.potential.GRGSFormatReader;
import org.orekit.forces.gravity.potential.GravityFieldFactory;
import org.orekit.frames.FramesFactory;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.IERSConventions;
public class GlobalPressureTemperature2ModelTest {
private static double epsilon = 1.0e-12;
@Before
public void setUp() throws OrekitException {
Utils.setDataRoot("regular-data:potential");
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
}
@Test
public void testWeatherParameters() {
// Site Vienna: latitude: 48.20°N
// longitude: 16.37°E
// height: 156 m
//
// Date: 2 August 2012
//
// Expected outputs are given by the Department of Geodesy and Geoinformation of the Vienna University.
// Expected parameters : temperature -> 22.12 °C
// pressure -> 1002.56 hPa
// e -> 15.63 hPa
// ah -> 0.0012647
// aw -> 0.0005726
//
// We test the fiability of our implementation by comparing our output values with
// the ones obtained by the Vienna University.
final double latitude = 48.20;
final double longitude = 16.37;
final double height = 156.0;
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);
Utils.setDataRoot("gpt2-grid");
model.computeWeatherParameters(height, date);
final double a[] = model.getA();
final double temperature = model.getTemperature() - 273.15;
final double pressure = model.getPressure();
final double e = model.getWaterVaporPressure();
Assert.assertEquals(22.12, temperature, 2.3e-1);
Assert.assertEquals(1002.56, pressure, 4.0e-1);
Assert.assertEquals(0.0012647, a[0], 1.1e-7);
Assert.assertEquals(0.0005726, a[1], 8.6e-8);
Assert.assertEquals(15.63, e, 5.0e-2);
}
@Test
public void testEquality() {
// Commons parameters
final Geoid geoid = new Geoid(GravityFieldFactory.getNormalizedProvider(12, 12),
ReferenceEllipsoid.getWgs84(FramesFactory.getITRF(IERSConventions.IERS_2010, true)));
final AbsoluteDate date = AbsoluteDate.createMJDDate(56141, 0.0, TimeScalesFactory.getUTC());
final double latitude = 45.0;
final double height = 0.0;
double longitude1;
GlobalPressureTemperature2Model model1;
double longitude2;
GlobalPressureTemperature2Model model2;
// Test longitude = 181° and longitude = -179°
longitude1 = 181.0;
longitude2 = -179.0;
model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
Utils.setDataRoot("gpt2-grid");
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
Assert.assertEquals(model1.getWaterVaporPressure(), model2.getWaterVaporPressure(), epsilon);
Assert.assertEquals(model1.getA()[0], model2.getA()[0], epsilon);
Assert.assertEquals(model1.getA()[1], model2.getA()[1], epsilon);
// Test longitude = 180° and longitude = -180°
longitude1 = 180.0;
longitude2 = -180.0;
model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
Assert.assertEquals(model1.getWaterVaporPressure(), model2.getWaterVaporPressure(), epsilon);
Assert.assertEquals(model1.getA()[0], model2.getA()[0], epsilon);
Assert.assertEquals(model1.getA()[1], model2.getA()[1], epsilon);
// Test longitude = 0° and longitude = 360°
longitude1 = 0.0;
longitude2 = 360.0;
model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
Assert.assertEquals(model1.getWaterVaporPressure(), model2.getWaterVaporPressure(), epsilon);
Assert.assertEquals(model1.getA()[0], model2.getA()[0], epsilon);
Assert.assertEquals(model1.getA()[1], model2.getA()[1], epsilon);
}
@Test
public void testCorruptedFileBadData() {
final double latitude = 14.0;
final double longitude = 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);
Utils.setDataRoot("gpt2-grid");
try {
model.computeWeatherParameters(height, date);
Assert.fail("An exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, oe.getSpecifier());
}
}
}
This diff is collapsed.
This diff is collapsed.
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