Commit af6f6da4 authored by Bryan Cazabonne's avatar Bryan Cazabonne

DiscreteTroposphericModel no longer MappingFunction extension.

parent 623196b1
......@@ -16,11 +16,16 @@
*/
package org.orekit.models.earth.troposphere;
import java.util.List;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.util.MathArrays;
import org.orekit.bodies.FieldGeodeticPoint;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Defines a tropospheric model, used to calculate the path delay imposed to
* electro-magnetic signals between an orbital satellite and a ground station.
......@@ -37,7 +42,7 @@ import org.orekit.time.FieldAbsoluteDate;
* </ul>
* @author Bryan Cazabonne
*/
public interface DiscreteTroposphericModel extends MappingFunction {
public interface DiscreteTroposphericModel {
/** Calculates the tropospheric path delay for the signal path from a ground
* station to a satellite.
......@@ -89,4 +94,35 @@ public interface DiscreteTroposphericModel extends MappingFunction {
*/
<T extends RealFieldElement<T>> T[] computeZenithDelay(FieldGeodeticPoint<T> point, T[] parameters, FieldAbsoluteDate<T> date);
/** Get the drivers for tropospheric model parameters.
* @return drivers for tropospheric model parameters
*/
List<ParameterDriver> getParametersDrivers();
/** Get tropospheric model parameters.
* @return tropospheric model parameters
*/
default double[] getParameters() {
final List<ParameterDriver> drivers = getParametersDrivers();
final double[] parameters = new double[drivers.size()];
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = drivers.get(i).getValue();
}
return parameters;
}
/** Get tropospheric model parameters.
* @param field field to which the elements belong
* @param <T> type of the elements
* @return tropospheric model parameters
*/
default <T extends RealFieldElement<T>> T[] getParameters(final Field<T> field) {
final List<ParameterDriver> drivers = getParametersDrivers();
final T[] parameters = MathArrays.buildArray(field, drivers.size());
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = field.getZero().add(drivers.get(i).getValue());
}
return parameters;
}
}
......@@ -96,20 +96,6 @@ public class EstimatedTroposphericModel implements DiscreteTroposphericModel {
this(273.15 + 18.0, 1013.25, model, totalDelay);
}
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
return model.mappingFactors(elevation, point, parameters, date);
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
return model.mappingFactors(elevation, point, parameters, date);
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
......@@ -122,7 +108,7 @@ public class EstimatedTroposphericModel implements DiscreteTroposphericModel {
final double[] parameters, final AbsoluteDate date) {
// Mapping functions
final double[] mf = mappingFactors(elevation, point, parameters, date);
final double[] mf = model.mappingFactors(elevation, point, date);
// Zenith delays
final double[] delays = computeZenithDelay(point, parameters, date);
// Total delay
......@@ -135,7 +121,7 @@ public class EstimatedTroposphericModel implements DiscreteTroposphericModel {
final T[] parameters, final FieldAbsoluteDate<T> date) {
// Mapping functions
final T[] mf = mappingFactors(elevation, point, parameters, date);
final T[] mf = model.mappingFactors(elevation, point, date);
// Zenith delays
final T[] delays = computeZenithDelay(point, parameters, date);
// Total delay
......
......@@ -179,28 +179,6 @@ public class FixedTroposphericDelay implements DiscreteTroposphericModel {
return delay;
}
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
return new double[] {
1.0,
1.0
};
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T one = field.getOne();
final T[] factors = MathArrays.buildArray(field, 2);
factors[0] = one;
factors[1] = one;
return factors;
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
......
......@@ -16,9 +16,6 @@
*/
package org.orekit.models.earth.troposphere;
import java.util.Collections;
import java.util.List;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.util.CombinatoricsUtils;
......@@ -34,7 +31,6 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateTimeComponents;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.TimeScale;
import org.orekit.utils.ParameterDriver;
/** The Global Mapping Function model for radio techniques.
* This model is an empirical mapping function. It only needs the
......@@ -87,7 +83,7 @@ public class GlobalMappingFunctionModel implements MappingFunction {
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
final AbsoluteDate date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(utc);
final int dofyear = dtc.getDate().getDayOfYear();
......@@ -179,7 +175,7 @@ public class GlobalMappingFunctionModel implements MappingFunction {
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final FieldAbsoluteDate<T> date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(utc);
final int dofyear = dtc.getDate().getDayOfYear();
......@@ -275,12 +271,6 @@ public class GlobalMappingFunctionModel implements MappingFunction {
return function;
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
return Collections.emptyList();
}
/** Computes the P<sub>nm</sub>(sin(&#934)) coefficients of Eq. 3 (Boehm et al, 2006).
* The computation of the Legendre polynomials is performed following:
* Heiskanen and Moritz, Physical Geodesy, 1967, eq. 1-62
......
......@@ -16,16 +16,11 @@
*/
package org.orekit.models.earth.troposphere;
import java.util.List;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.util.MathArrays;
import org.orekit.bodies.FieldGeodeticPoint;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Interface for mapping functions used in the tropospheric delay computation.
* @author Bryan Cazabonne
......@@ -40,11 +35,10 @@ public interface MappingFunction {
* </ul>
* @param elevation the elevation of the satellite, in radians
* @param point station location
* @param parameters tropospheric model parameters.
* @param date current date
* @return a two components array containing the hydrostatic and wet mapping functions.
*/
double[] mappingFactors(double elevation, GeodeticPoint point, double[] parameters, AbsoluteDate date);
double[] mappingFactors(double elevation, GeodeticPoint point, AbsoluteDate date);
/** This method allows the computation of the hydrostatic and
* wet mapping functions. The resulting element is an array having the following form:
......@@ -54,41 +48,10 @@ public interface MappingFunction {
* </ul>
* @param elevation the elevation of the satellite, in radians
* @param point station location
* @param parameters tropospheric model parameters
* @param date current date
* @param <T> type of the elements
* @return a two components array containing the hydrostatic and wet mapping functions.
*/
<T extends RealFieldElement<T>> T[] mappingFactors(T elevation, FieldGeodeticPoint<T> point, T[] parameters, FieldAbsoluteDate<T> date);
/** Get the drivers for tropospheric model parameters.
* @return drivers for tropospheric model parameters
*/
List<ParameterDriver> getParametersDrivers();
<T extends RealFieldElement<T>> T[] mappingFactors(T elevation, FieldGeodeticPoint<T> point, FieldAbsoluteDate<T> date);
/** Get tropospheric model parameters.
* @return tropospheric model parameters
*/
default double[] getParameters() {
final List<ParameterDriver> drivers = getParametersDrivers();
final double[] parameters = new double[drivers.size()];
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = drivers.get(i).getValue();
}
return parameters;
}
/** Get tropospheric model parameters.
* @param field field to which the elements belong
* @param <T> type of the elements
* @return tropospheric model parameters
*/
default <T extends RealFieldElement<T>> T[] getParameters(final Field<T> field) {
final List<ParameterDriver> drivers = getParametersDrivers();
final T[] parameters = MathArrays.buildArray(field, drivers.size());
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = field.getZero().add(drivers.get(i).getValue());
}
return parameters;
}
}
......@@ -134,28 +134,6 @@ public class MariniMurrayModel implements DiscreteTroposphericModel {
return delay;
}
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
return new double[] {
1.0,
1.0
};
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T one = field.getOne();
final T[] factors = MathArrays.buildArray(field, 2);
factors[0] = one;
factors[1] = one;
return factors;
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
......
......@@ -40,7 +40,7 @@ import org.orekit.utils.ParameterDriver;
*
* @author Bryan Cazabonne
*/
public class MendesPavlisModel implements DiscreteTroposphericModel {
public class MendesPavlisModel implements DiscreteTroposphericModel, MappingFunction {
/** Coefficients for the dispertion equation for the hydrostatic component [µm<sup>-2</sup>]. */
private static final double[] K_COEFFICIENTS = {
......@@ -113,7 +113,7 @@ public class MendesPavlisModel implements DiscreteTroposphericModel {
// Zenith delay
final double[] zenithDelay = computeZenithDelay(point, parameters, date);
// Mapping function
final double[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final double[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return zenithDelay[0] * mappingFunction[0] + zenithDelay[1] * mappingFunction[1];
}
......@@ -125,7 +125,7 @@ public class MendesPavlisModel implements DiscreteTroposphericModel {
// Zenith delay
final T[] delays = computeZenithDelay(point, parameters, date);
// Mapping function
final T[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final T[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return delays[0].multiply(mappingFunction[0]).add(delays[1].multiply(mappingFunction[1]));
}
......@@ -227,7 +227,7 @@ public class MendesPavlisModel implements DiscreteTroposphericModel {
*/
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
final AbsoluteDate date) {
final double sinE = FastMath.sin(elevation);
final double T2degree = T0 - 273.15;
......@@ -271,7 +271,7 @@ public class MendesPavlisModel implements DiscreteTroposphericModel {
*/
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T sinE = FastMath.sin(elevation);
......
......@@ -16,9 +16,6 @@
*/
package org.orekit.models.earth.troposphere;
import java.util.Collections;
import java.util.List;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.analysis.UnivariateFunction;
......@@ -33,7 +30,6 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateTimeComponents;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.TimeScale;
import org.orekit.utils.ParameterDriver;
/** The Niell Mapping Function model for radio wavelengths.
* This model is an empirical mapping function. It only needs the
......@@ -165,7 +161,7 @@ public class NiellMappingFunctionModel implements MappingFunction {
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
final AbsoluteDate date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(utc);
final int dofyear = dtc.getDate().getDayOfYear();
......@@ -207,7 +203,7 @@ public class NiellMappingFunctionModel implements MappingFunction {
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T zero = field.getZero();
......@@ -250,10 +246,4 @@ public class NiellMappingFunctionModel implements MappingFunction {
return function;
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
return Collections.emptyList();
}
}
......@@ -427,28 +427,6 @@ public class SaastamoinenModel implements DiscreteTroposphericModel {
return delay;
}
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
return new double[] {
1.0,
1.0
};
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T one = field.getOne();
final T[] factors = MathArrays.buildArray(field, 2);
factors[0] = one;
factors[1] = one;
return factors;
}
/** {@inheritDoc} */
@Override
public List<ParameterDriver> getParametersDrivers() {
......
......@@ -213,28 +213,6 @@ public class TimeSpanEstimatedTroposphericModel implements DiscreteTroposphericM
return outParameters;
}
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
// Extract the proper parameters valid at date from the input array
final double[] extractedParameters = extractParameters(parameters, date);
// Compute and return the mapping factors
return getTroposphericModel(date).mappingFactors(elevation, point,
extractedParameters, date);
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
// Extract the proper parameters valid at date from the input array
final T[] extractedParameters = extractParameters(parameters, date);
// Compute and return the mapping factors
return getTroposphericModel(date.toAbsoluteDate()).mappingFactors(elevation, point,
extractedParameters, date);
}
/** {@inheritDoc} */
@Override
public double pathDelay(final double elevation, final GeodeticPoint point,
......
......@@ -48,7 +48,7 @@ import org.orekit.utils.ParameterDriver;
*
* @author Bryan Cazabonne
*/
public class ViennaOneModel implements DiscreteTroposphericModel {
public class ViennaOneModel implements DiscreteTroposphericModel, MappingFunction {
/** The a coefficient for the computation of the wet and hydrostatic mapping functions.*/
private final double[] coefficientsA;
......@@ -97,7 +97,7 @@ public class ViennaOneModel implements DiscreteTroposphericModel {
// zenith delay
final double[] delays = computeZenithDelay(point, parameters, date);
// mapping function
final double[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final double[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return delays[0] * mappingFunction[0] + delays[1] * mappingFunction[1];
}
......@@ -109,7 +109,7 @@ public class ViennaOneModel implements DiscreteTroposphericModel {
// zenith delay
final T[] delays = computeZenithDelay(point, parameters, date);
// mapping function
final T[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final T[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return delays[0].multiply(mappingFunction[0]).add(delays[1].multiply(mappingFunction[1]));
}
......@@ -135,7 +135,7 @@ public class ViennaOneModel implements DiscreteTroposphericModel {
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
final AbsoluteDate date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(utc);
final int dofyear = dtc.getDate().getDayOfYear();
......@@ -189,7 +189,7 @@ public class ViennaOneModel implements DiscreteTroposphericModel {
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T zero = field.getZero();
......
......@@ -55,7 +55,7 @@ import org.orekit.utils.ParameterDriver;
*
* @author Bryan Cazabonne
*/
public class ViennaThreeModel implements DiscreteTroposphericModel {
public class ViennaThreeModel implements DiscreteTroposphericModel, MappingFunction {
/** The a coefficient for the computation of the wet and hydrostatic mapping functions.*/
private final double[] coefficientsA;
......@@ -97,7 +97,7 @@ public class ViennaThreeModel implements DiscreteTroposphericModel {
/** {@inheritDoc} */
@Override
public double[] mappingFactors(final double elevation, final GeodeticPoint point,
final double[] parameters, final AbsoluteDate date) {
final AbsoluteDate date) {
// Day of year computation
final DateTimeComponents dtc = date.getComponents(utc);
final int dofyear = dtc.getDate().getDayOfYear();
......@@ -182,7 +182,7 @@ public class ViennaThreeModel implements DiscreteTroposphericModel {
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> T[] mappingFactors(final T elevation, final FieldGeodeticPoint<T> point,
final T[] parameters, final FieldAbsoluteDate<T> date) {
final FieldAbsoluteDate<T> date) {
final Field<T> field = date.getField();
final T zero = field.getZero();
......@@ -274,7 +274,7 @@ public class ViennaThreeModel implements DiscreteTroposphericModel {
// zenith delay
final double[] delays = computeZenithDelay(point, parameters, date);
// mapping function
final double[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final double[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return delays[0] * mappingFunction[0] + delays[1] * mappingFunction[1];
}
......@@ -286,7 +286,7 @@ public class ViennaThreeModel implements DiscreteTroposphericModel {
// zenith delay
final T[] delays = computeZenithDelay(point, parameters, date);
// mapping function
final T[] mappingFunction = mappingFactors(elevation, point, parameters, date);
final T[] mappingFunction = mappingFactors(elevation, point, date);
// Tropospheric path delay
return delays[0].multiply(mappingFunction[0]).add(delays[1].multiply(mappingFunction[1]));
}
......
......@@ -98,7 +98,7 @@ public class FieldGlobalMappingFunctionModelTest {
final MappingFunction model = new GlobalMappingFunctionModel();
final T[] computedMapping = model.mappingFactors(zero.add(elevation), point, model.getParameters(field), date);
final T[] computedMapping = model.mappingFactors(zero.add(elevation), point, date);
Assert.assertEquals(expectedHydro, computedMapping[0].getReal(), 1.0e-6);
Assert.assertEquals(expectedWet, computedMapping[1].getReal(), 1.0e-6);
......@@ -120,7 +120,7 @@ public class FieldGlobalMappingFunctionModelTest {
// mapping functions shall decline with increasing elevation angle
for (double elev = 10d; elev < 90d; elev += 8d) {
final T[] factors = model.mappingFactors(zero.add(FastMath.toRadians(elev)), point, model.getParameters(field), date);
final T[] factors = model.mappingFactors(zero.add(FastMath.toRadians(elev)), point, date);
Assert.assertTrue(Precision.compareTo(factors[0].getReal(), lastFactors[0].getReal(), 1.0e-6) < 0);
Assert.assertTrue(Precision.compareTo(factors[1].getReal(), lastFactors[1].getReal(), 1.0e-6) < 0);
lastFactors[0] = factors[0];
......@@ -176,7 +176,7 @@ public class FieldGlobalMappingFunctionModelTest {
// Compute mapping factors state derivatives
final FieldGeodeticPoint<DerivativeStructure> dsPoint = new FieldGeodeticPoint<>(zero.add(latitude), zero.add(longitude), zero.add(height));
final DerivativeStructure[] factors = model.mappingFactors(dsElevation, dsPoint, model.getParameters(field), dsDate);
final DerivativeStructure[] factors = model.mappingFactors(dsElevation, dsPoint, dsDate);
final double[] compMFH = factors[0].getAllDerivatives();
final double[] compMFW = factors[1].getAllDerivatives();
......@@ -195,42 +195,42 @@ public class FieldGlobalMappingFunctionModelTest {
SpacecraftState stateM4 = shiftState(state, orbitType, angleType, -4 * steps[i], i);
final Vector3D positionM4 = stateM4.getPVCoordinates().getPosition();
final double elevationM4 = station.getBaseFrame().getElevation(positionM4, stateM4.getFrame(), stateM4.getDate());
double[] delayM4 = model.mappingFactors(elevationM4, point, model.getParameters(), stateM4.getDate());
double[] delayM4 = model.mappingFactors(elevationM4, point, stateM4.getDate());
SpacecraftState stateM3 = shiftState(state, orbitType, angleType, -3 * steps[i], i);
final Vector3D positionM3 = stateM3.getPVCoordinates().getPosition();
final double elevationM3 = station.getBaseFrame().getElevation(positionM3, stateM3.getFrame(), stateM3.getDate());
double[] delayM3 = model.mappingFactors(elevationM3, point, model.getParameters(), stateM3.getDate());
double[] delayM3 = model.mappingFactors(elevationM3, point, stateM3.getDate());
SpacecraftState stateM2 = shiftState(state, orbitType, angleType, -2 * steps[i], i);
final Vector3D positionM2 = stateM2.getPVCoordinates().getPosition();
final double elevationM2 = station.getBaseFrame().getElevation(positionM2, stateM2.getFrame(), stateM2.getDate());