From b57cabe9185f3d451fd892ec8dce2109e7e73aae Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Mon, 9 Feb 2015 11:07:53 +0100 Subject: [PATCH] Added dump for observation transforms. --- .../java/org/orekit/rugged/errors/Dump.java | 39 +++++++++++++++++++ .../org/orekit/rugged/errors/DumpManager.java | 16 ++++++++ .../utils/SpacecraftToObservedBody.java | 5 +++ 3 files changed, 60 insertions(+) diff --git a/src/main/java/org/orekit/rugged/errors/Dump.java b/src/main/java/org/orekit/rugged/errors/Dump.java index d58f2936..4f66dd14 100644 --- a/src/main/java/org/orekit/rugged/errors/Dump.java +++ b/src/main/java/org/orekit/rugged/errors/Dump.java @@ -24,11 +24,14 @@ import java.util.Locale; import java.util.TimeZone; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.OpenIntToDoubleHashMap; import org.orekit.errors.OrekitException; +import org.orekit.frames.Transform; import org.orekit.rugged.api.AlgorithmId; import org.orekit.rugged.raster.Tile; import org.orekit.rugged.utils.ExtendedEllipsoid; +import org.orekit.rugged.utils.SpacecraftToObservedBody; import org.orekit.time.AbsoluteDate; import org.orekit.time.DateTimeComponents; import org.orekit.time.TimeScalesFactory; @@ -51,6 +54,9 @@ class Dump { /** Flag for dumped ellipsoid. */ private boolean ellipsoidDumped; + /** Flags for dumped observation transforms. */ + private boolean[] tranformsDumped; + /** Simple constructor. * @param writer writer to the dump file */ @@ -59,6 +65,7 @@ class Dump { this.tiles = new ArrayList<DumpedTileData>(); this.algorithmDumped = false; this.ellipsoidDumped = false; + this.tranformsDumped = null; dumpHeader(); } @@ -142,6 +149,38 @@ class Dump { lightTimeCorrection, aberrationOfLightCorrection); } + /** Dump an observation transform transform. + * @param scToBody provider for observation + * @param index index of the transform + * @param transform transform + * @exception RuggedException if reference date cannot be converted to UTC + */ + public void dumpTransform(final SpacecraftToObservedBody scToBody, + final int index, final Transform transform) + throws RuggedException { + if (tranformsDumped == null) { + final AbsoluteDate minDate = scToBody.getMinDate(); + final AbsoluteDate maxDate = scToBody.getMaxDate(); + final double tStep = scToBody.getTStep(); + final int n = 1 + (int) FastMath.rint(maxDate.durationFrom(minDate) / tStep); + writer.format(Locale.US, + "spacecraft to observed body: min date = %s max date = %s tStep = %22.15e inertial frame = %s body frame = %s%n", + highAccuracyDate(minDate), highAccuracyDate(maxDate), tStep, + scToBody.getInertialFrameName(), scToBody.getBodyFrameName()); + tranformsDumped = new boolean[n]; + } + if (!tranformsDumped[index]) { + writer.format(Locale.US, + "transform: index = %d r = %22.15e %22.15e %22.15e %22.15e Ω = %22.15e %22.15e %22.15e ΩDot = %22.15e %22.15e %22.15e%n", + index, + transform.getRotation().getQ0(), transform.getRotation().getQ1(), + transform.getRotation().getQ2(), transform.getRotation().getQ2(), + transform.getRotationRate().getX(), transform.getRotationRate().getY(), transform.getRotationRate().getZ(), + transform.getRotationAcceleration().getX(), transform.getRotationAcceleration().getY(), transform.getRotationAcceleration().getZ()); + tranformsDumped[index] = true; + } + } + /** Get tile data. * @param tile tile to which the cell belongs * @return index of the tile diff --git a/src/main/java/org/orekit/rugged/errors/DumpManager.java b/src/main/java/org/orekit/rugged/errors/DumpManager.java index 8e62180f..b0937b8b 100644 --- a/src/main/java/org/orekit/rugged/errors/DumpManager.java +++ b/src/main/java/org/orekit/rugged/errors/DumpManager.java @@ -21,9 +21,11 @@ import java.io.IOException; import java.io.PrintWriter; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.orekit.frames.Transform; import org.orekit.rugged.api.AlgorithmId; import org.orekit.rugged.raster.Tile; import org.orekit.rugged.utils.ExtendedEllipsoid; +import org.orekit.rugged.utils.SpacecraftToObservedBody; import org.orekit.time.AbsoluteDate; /** @@ -144,4 +146,18 @@ public class DumpManager { } } + /** Dump an observation transform transform. + * @param scToBody provider for observation + * @param index index of the transform + * @param transform transform + * @exception RuggedException if reference date cannot be converted to UTC + */ + public static void dumpTransform(final SpacecraftToObservedBody scToBody, + final int index, final Transform transform) + throws RuggedException { + if (isActive()) { + DUMP.get().dumpTransform(scToBody, index, transform); + } + } + } diff --git a/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java b/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java index 99d7dcec..e6006dd6 100644 --- a/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java +++ b/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java @@ -24,6 +24,7 @@ import org.apache.commons.math3.util.FastMath; import org.orekit.errors.OrekitException; import org.orekit.frames.Frame; import org.orekit.frames.Transform; +import org.orekit.rugged.errors.DumpManager; import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedMessages; import org.orekit.time.AbsoluteDate; @@ -270,6 +271,10 @@ public class SpacecraftToObservedBody implements Serializable { final double s = date.durationFrom(list.get(0).getDate()) / tStep; final int index = FastMath.max(0, FastMath.min(list.size() - 1, (int) FastMath.rint(s))); + + // we always dump the body to inertial transform, regardless of the one really asked for + DumpManager.dumpTransform(this, index, bodyToInertial.get(index)); + final Transform close = list.get(index); return close.shiftedBy(date.durationFrom(close.getDate())); -- GitLab