use of org.orekit.errors.OrekitInternalError in project Orekit by CS-SI.
the class EOPHistory method getUT1MinusUTC.
/**
* Get the UT1-UTC value.
* <p>The data provided comes from the IERS files. It is smoothed data.</p>
* @param date date at which the value is desired
* @param <T> type of the field elements
* @return UT1-UTC in seconds (0 if date is outside covered range)
* @since 9.0
*/
public <T extends RealFieldElement<T>> T getUT1MinusUTC(final FieldAbsoluteDate<T> date) {
// check if there is data for date
final AbsoluteDate absDate = date.toAbsoluteDate();
if (!this.hasDataFor(absDate)) {
// no EOP data available for this date, we use a default 0.0 offset
return (tidalCorrection == null) ? date.getField().getZero() : tidalCorrection.value(date)[2];
}
// we have EOP data -> interpolate offset
try {
final FieldDUT1Interpolator<T> interpolator = new FieldDUT1Interpolator<>(date, absDate);
getNeighbors(absDate).forEach(interpolator);
T interpolated = interpolator.getInterpolated();
if (tidalCorrection != null) {
interpolated = interpolated.add(tidalCorrection.value(date)[2]);
}
return interpolated;
} catch (TimeStampedCacheException tce) {
// this should not happen because of date check above
throw new OrekitInternalError(tce);
}
}
use of org.orekit.errors.OrekitInternalError in project Orekit by CS-SI.
the class EOPHistory method getUT1MinusUTC.
/**
* Get the UT1-UTC value.
* <p>The data provided comes from the IERS files. It is smoothed data.</p>
* @param date date at which the value is desired
* @return UT1-UTC in seconds (0 if date is outside covered range)
*/
public double getUT1MinusUTC(final AbsoluteDate date) {
// check if there is data for date
if (!this.hasDataFor(date)) {
// no EOP data available for this date, we use a default 0.0 offset
return (tidalCorrection == null) ? 0.0 : tidalCorrection.value(date)[2];
}
// we have EOP data -> interpolate offset
try {
final DUT1Interpolator interpolator = new DUT1Interpolator(date);
getNeighbors(date).forEach(interpolator);
double interpolated = interpolator.getInterpolated();
if (tidalCorrection != null) {
interpolated += tidalCorrection.value(date)[2];
}
return interpolated;
} catch (TimeStampedCacheException tce) {
// this should not happen because of date check above
throw new OrekitInternalError(tce);
}
}
use of org.orekit.errors.OrekitInternalError in project Orekit by CS-SI.
the class KeplerianPropagator method writeReplace.
/**
* Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if an additional state provider is not serializable
*/
private Object writeReplace() throws NotSerializableException {
try {
// managed states providers
final List<AdditionalStateProvider> serializableProviders = new ArrayList<AdditionalStateProvider>();
for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
if (provider instanceof Serializable) {
serializableProviders.add(provider);
} else {
throw new NotSerializableException(provider.getClass().getName());
}
}
// states transitions
final AbsoluteDate[] transitionDates;
final SpacecraftState[] allStates;
final SortedSet<TimeSpanMap.Transition<SpacecraftState>> transitions = states.getTransitions();
if (transitions.size() == 1 && transitions.first().getBefore() == transitions.first().getAfter()) {
// the single entry is a dummy one, without a real transition
// we ignore it completely
transitionDates = null;
allStates = null;
} else {
transitionDates = new AbsoluteDate[transitions.size()];
allStates = new SpacecraftState[transitions.size() + 1];
int i = 0;
for (final TimeSpanMap.Transition<SpacecraftState> transition : transitions) {
if (i == 0) {
// state before the first transition
allStates[i] = transition.getBefore();
}
transitionDates[i] = transition.getDate();
allStates[++i] = transition.getAfter();
}
}
return new DataTransferObject(getInitialState().getOrbit(), getAttitudeProvider(), getInitialState().getMu(), getInitialState().getMass(), transitionDates, allStates, serializableProviders.toArray(new AdditionalStateProvider[serializableProviders.size()]));
} catch (OrekitException orekitException) {
// this should never happen
throw new OrekitInternalError(null);
}
}
use of org.orekit.errors.OrekitInternalError in project Orekit by CS-SI.
the class EOPHistory method interpolate.
/**
* Interpolate a single EOP component.
* <p>
* This method should be called <em>only</em> when {@link #hasDataFor(AbsoluteDate)} returns true.
* </p>
* @param date interpolation date
* @param aDate interpolation date, as an {@link AbsoluteDate}
* @param selector selector for EOP entry component
* @param <T> type of the field elements
* @return interpolated value
*/
private <T extends RealFieldElement<T>> T interpolate(final FieldAbsoluteDate<T> date, final AbsoluteDate aDate, final Function<EOPEntry, Double> selector) {
try {
final FieldHermiteInterpolator<T> interpolator = new FieldHermiteInterpolator<>();
final T[] y = MathArrays.buildArray(date.getField(), 1);
final T zero = date.getField().getZero();
// here, we attempt to get a constant date,
final FieldAbsoluteDate<T> central = new FieldAbsoluteDate<>(aDate, zero);
// for example removing derivatives
// if T was DerivativeStructure
getNeighbors(aDate).forEach(entry -> {
y[0] = zero.add(selector.apply(entry));
interpolator.addSamplePoint(central.durationFrom(entry.getDate()).negate(), y);
});
// here, we introduce derivatives again (in DerivativeStructure case)
return interpolator.value(date.durationFrom(central))[0];
} catch (TimeStampedCacheException tce) {
// this should not happen because of date check performed by caller
throw new OrekitInternalError(tce);
}
}
use of org.orekit.errors.OrekitInternalError in project Orekit by CS-SI.
the class SolidTidesFieldTest method testK1Example.
@Test
public void testK1Example() throws OrekitException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// the reference for this test is the example at the bottom of page 86, IERS conventions 2010 section 6.2.1
final PoissonSeriesParser k21Parser = new PoissonSeriesParser(18).withOptionalColumn(1).withDoodson(4, 3).withFirstDelaunay(10);
final String name = "/tides/tab6.5a-only-K1.txt";
final double pico = 1.0e-12;
final PoissonSeries c21Series = k21Parser.withSinCos(0, 17, pico, 18, pico).parse(getClass().getResourceAsStream(name), name);
final PoissonSeries s21Series = k21Parser.withSinCos(0, 18, -pico, 17, pico).parse(getClass().getResourceAsStream(name), name);
final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, false);
final TimeScalarFunction gmstFunction = IERSConventions.IERS_2010.getGMSTFunction(ut1);
Method getNA = IERSConventions.class.getDeclaredMethod("getNutationArguments", TimeScale.class);
getNA.setAccessible(true);
final FundamentalNutationArguments arguments = (FundamentalNutationArguments) getNA.invoke(IERSConventions.IERS_2010, ut1);
TimeVectorFunction deltaCSFunction = new TimeVectorFunction() {
public double[] value(final AbsoluteDate date) {
final BodiesElements elements = arguments.evaluateAll(date);
return new double[] { 0.0, c21Series.value(elements), s21Series.value(elements), 0.0, 0.0 };
}
public <T extends RealFieldElement<T>> T[] value(final FieldAbsoluteDate<T> date) {
// never called in this test
throw new OrekitInternalError(null);
}
};
SolidTidesField tf = new SolidTidesField(IERSConventions.IERS_2010.getLoveNumbers(), deltaCSFunction, IERSConventions.IERS_2010.getPermanentTide(), IERSConventions.IERS_2010.getSolidPoleTide(ut1.getEOPHistory()), FramesFactory.getITRF(IERSConventions.IERS_2010, false), Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, TideSystem.ZERO_TIDE, CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon());
Method frequencyDependentPart = SolidTidesField.class.getDeclaredMethod("frequencyDependentPart", AbsoluteDate.class, double[][].class, double[][].class);
frequencyDependentPart.setAccessible(true);
double[][] cachedCNM = new double[5][5];
double[][] cachedSNM = new double[5][5];
AbsoluteDate t0 = new AbsoluteDate(2003, 5, 6, 13, 43, 32.125, TimeScalesFactory.getUTC());
for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 300) {
AbsoluteDate date = t0.shiftedBy(dt);
for (int i = 0; i < cachedCNM.length; ++i) {
Arrays.fill(cachedCNM[i], 0.0);
Arrays.fill(cachedSNM[i], 0.0);
}
frequencyDependentPart.invoke(tf, date, cachedCNM, cachedSNM);
double thetaPlusPi = gmstFunction.value(date) + FastMath.PI;
Assert.assertEquals(470.9e-12 * FastMath.sin(thetaPlusPi) - 30.2e-12 * FastMath.cos(thetaPlusPi), cachedCNM[2][1], 2.0e-25);
Assert.assertEquals(470.9e-12 * FastMath.cos(thetaPlusPi) + 30.2e-12 * FastMath.sin(thetaPlusPi), cachedSNM[2][1], 2.0e-25);
}
}
Aggregations