Commit ab2bbfa3 authored by Bryan Cazabonne's avatar Bryan Cazabonne

Added interface for surface meteorology models.

parent 66a2867d
......@@ -69,7 +69,7 @@ import org.orekit.utils.Constants;
* @author Bryan Cazabonne
*
*/
public class GlobalPressureTemperature2Model implements DataLoader {
public class GlobalPressureTemperature2Model implements DataLoader, WeatherModel {
/** Default supported files name pattern. */
public static final String DEFAULT_SUPPORTED_NAMES = "gpt2_5.grd";
......@@ -182,12 +182,8 @@ public class GlobalPressureTemperature2Model implements DataLoader {
return supportedNames;
}
/** This method computes the values of the pressure and the temperature
* depending the position of the station.
* @param stationHeight the height of the station in m
* @param currentDate current date
*/
public void computeWeatherParameters(final double stationHeight, final AbsoluteDate currentDate) {
@Override
public void weatherParameters(final double stationHeight, final AbsoluteDate currentDate) {
this.date = currentDate;
this.height = stationHeight;
DataProvidersManager.getInstance().feed(supportedNames, this);
......
......@@ -41,7 +41,7 @@ import org.orekit.time.TimeScalesFactory;
* @author Bryan Cazabonne
*
*/
public class GlobalPressureTemperatureModel {
public class GlobalPressureTemperatureModel implements WeatherModel {
/** Temperature gradient (°C/m). */
private static final double TEMPERATURE_GRADIENT = -6.5e-3;
......@@ -94,12 +94,8 @@ public class GlobalPressureTemperatureModel {
return pressure;
}
/** This method computes the values of the pressure and the temperature
* depending the position of the station.
* @param height the height of the station in m
* @param date current date
*/
public void computeTemperatureAndPressure(final double height, final AbsoluteDate date) {
@Override
public void weatherParameters(final double height, final AbsoluteDate date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(TimeScalesFactory.getUTC());
......
/* 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.orekit.time.AbsoluteDate;
/** Defines a surface meteorology model that can be used to
* compute the different weather parameters (pressure, temperature, ...).
* @author Bryan Cazabonne
* @since 9.3
*/
public interface WeatherModel {
/** Calculates the weather parameters of the model.
* In order to obtain the correct values of the parameters
* this method has to be call just after the construction of the model.
* @param stationHeight the height of the station in m
* @param currentDate current date
*/
void weatherParameters(double stationHeight, AbsoluteDate currentDate);
}
......@@ -1286,8 +1286,8 @@ public class OrbitDeterminationTest {
final GlobalPressureTemperatureModel weather = new GlobalPressureTemperatureModel(stationLatitudes[i],
stationLongitudes[i],
body.getBodyFrame());
weather.computeTemperatureAndPressure(stationAltitudes[i], parser.getDate(ParameterKey.ORBIT_DATE,
TimeScalesFactory.getUTC()));
weather.weatherParameters(stationAltitudes[i], parser.getDate(ParameterKey.ORBIT_DATE,
TimeScalesFactory.getUTC()));
final double temperature = weather.getTemperature();
final double pressure = weather.getPressure();
troposphericModel = new EstimatedTroposphericModel(temperature, pressure, mappingModel,
......
......@@ -1797,8 +1797,8 @@ public class KalmanOrbitDeterminationTest {
final GlobalPressureTemperatureModel weather = new GlobalPressureTemperatureModel(stationLatitudes[i],
stationLongitudes[i],
body.getBodyFrame());
weather.computeTemperatureAndPressure(stationAltitudes[i], parser.getDate(ParameterKey.ORBIT_DATE,
TimeScalesFactory.getUTC()));
weather.weatherParameters(stationAltitudes[i], parser.getDate(ParameterKey.ORBIT_DATE,
TimeScalesFactory.getUTC()));
final double temperature = weather.getTemperature();
final double pressure = weather.getPressure();
troposphericModel = new EstimatedTroposphericModel(temperature, pressure, mappingModel,
......
......@@ -67,7 +67,7 @@ public class GlobalPressureTemperature2ModelTest {
final GlobalPressureTemperature2Model model = new GlobalPressureTemperature2Model(latitude, longitude, geoid);
Utils.setDataRoot("gpt2-grid");
model.computeWeatherParameters(height, date);
model.weatherParameters(height, date);
final double a[] = model.getA();
final double temperature = model.getTemperature() - 273.15;
......@@ -107,8 +107,8 @@ public class GlobalPressureTemperature2ModelTest {
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
Utils.setDataRoot("gpt2-grid");
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
model1.weatherParameters(height, date);
model2.weatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
......@@ -123,8 +123,8 @@ public class GlobalPressureTemperature2ModelTest {
model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
model1.weatherParameters(height, date);
model2.weatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
......@@ -139,8 +139,8 @@ public class GlobalPressureTemperature2ModelTest {
model1 = new GlobalPressureTemperature2Model(latitude, longitude1, geoid);
model2 = new GlobalPressureTemperature2Model(latitude, longitude2, geoid);
model1.computeWeatherParameters(height, date);
model2.computeWeatherParameters(height, date);
model1.weatherParameters(height, date);
model2.weatherParameters(height, date);
Assert.assertEquals(model1.getTemperature(), model2.getTemperature(), epsilon);
Assert.assertEquals(model1.getPressure(), model2.getPressure(), epsilon);
......@@ -168,7 +168,7 @@ public class GlobalPressureTemperature2ModelTest {
Utils.setDataRoot("gpt2-grid");
try {
model.computeWeatherParameters(height, date);
model.weatherParameters(height, date);
Assert.fail("An exception should have been thrown");
} catch (OrekitException oe) {
......
......@@ -68,7 +68,7 @@ public class GlobalPressureTemperatureModelTest {
final GlobalPressureTemperatureModel model = new GlobalPressureTemperatureModel(latitude, longitude,
FramesFactory.getITRF(IERSConventions.IERS_2010, true));
model.computeTemperatureAndPressure(height, date);
model.weatherParameters(height, date);
final double computedTemperature = model.getTemperature() - 273.15;
final double computedPressure = model.getPressure();
......@@ -116,7 +116,7 @@ public class GlobalPressureTemperatureModelTest {
final GlobalPressureTemperatureModel model = new GlobalPressureTemperatureModel(latitude, longitude,
FramesFactory.getITRF(IERSConventions.IERS_2010, true));
model.computeTemperatureAndPressure(height, date);
model.weatherParameters(height, date);
final double computedTemperature = model.getTemperature() - 273.15;
final double computedPressure = model.getPressure();
......
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