diff --git a/src/main/java/org/orekit/rugged/api/Rugged.java b/src/main/java/org/orekit/rugged/api/Rugged.java index 7bc5468bd0dd760848cd8691e56e6d7980716913..008a0bbd05b6ad07d2c03ba2db7aeb765f511575 100644 --- a/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/src/main/java/org/orekit/rugged/api/Rugged.java @@ -26,6 +26,7 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.util.FastMath; import org.orekit.bodies.GeodeticPoint; 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.rugged.intersection.IntersectionAlgorithm; @@ -197,6 +198,9 @@ public class Rugged { final GeodeticPoint[] gp = new GeodeticPoint[sensor.getNbPixels()]; for (int i = 0; i < sensor.getNbPixels(); ++i) { + DumpManager.dumpDirectLocation(date, sensor.getPosition(), sensor.getLos(date, i), + lightTimeCorrection, aberrationOfLightCorrection); + final Vector3D obsLInert = scToInert.transformVector(sensor.getLos(date, i)); final Vector3D lInert; if (aberrationOfLightCorrection) { @@ -260,6 +264,8 @@ public class Rugged { public GeodeticPoint directLocation(final AbsoluteDate date, final Vector3D position, final Vector3D los) throws RuggedException { + DumpManager.dumpDirectLocation(date, position, los, lightTimeCorrection, aberrationOfLightCorrection); + // compute the approximate transform between spacecraft and observed body final Transform scToInert = scToBody.getScToInertial(date); final Transform inertToBody = scToBody.getInertialToBody(date); diff --git a/src/main/java/org/orekit/rugged/errors/Dump.java b/src/main/java/org/orekit/rugged/errors/Dump.java index 421f9f1db04e841203e5041a5d4ee718395fe759..d58f29369698694fc2b88163d77a621f709a55b0 100644 --- a/src/main/java/org/orekit/rugged/errors/Dump.java +++ b/src/main/java/org/orekit/rugged/errors/Dump.java @@ -23,10 +23,15 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.util.OpenIntToDoubleHashMap; +import org.orekit.errors.OrekitException; import org.orekit.rugged.api.AlgorithmId; import org.orekit.rugged.raster.Tile; import org.orekit.rugged.utils.ExtendedEllipsoid; +import org.orekit.time.AbsoluteDate; +import org.orekit.time.DateTimeComponents; +import org.orekit.time.TimeScalesFactory; /** * Dump data class. @@ -117,6 +122,26 @@ class Dump { } } + /** Dump a direct location computation. + * @param date computation date + * @param date date of the location + * @param position pixel position in spacecraft frame + * @param los normalized line-of-sight in spacecraft frame + * @param lightTimeCorrection flag for light time correction + * @param aberrationOfLightCorrection flag for aberration of light correction + * @exception RuggedException if date cannot be converted to UTC + */ + public void dumpDirectLocation(final AbsoluteDate date, final Vector3D position, final Vector3D los, + final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection) + throws RuggedException { + writer.format(Locale.US, + "direct location: date = %s position = %22.15e %22.15e %22.15e los = %22.15e %22.15e %22.15e ligthTime = %b aberration = %b%n", + highAccuracyDate(date), + position.getX(), position.getY(), position.getZ(), + los.getX(), los.getY(), los.getZ(), + lightTimeCorrection, aberrationOfLightCorrection); + } + /** Get tile data. * @param tile tile to which the cell belongs * @return index of the tile @@ -137,6 +162,23 @@ class Dump { } + /** Convert a date to string with high accuracy. + * @param date computation date + * @return converted date + * @exception RuggedException if date cannot be converted to UTC + */ + private String highAccuracyDate(final AbsoluteDate date) + throws RuggedException { + try { + final DateTimeComponents dt = date.getComponents(TimeScalesFactory.getUTC()); + return String.format(Locale.US, "%04d-%02d-%02dT%02d:%02d:%017.14fZ", + dt.getDate().getYear(), dt.getDate().getMonth(), dt.getDate().getDay(), + dt.getTime().getHour(), dt.getTime().getMinute(), dt.getTime().getSecond()); + } catch (OrekitException oe) { + throw new RuggedException(oe, oe.getSpecifier(), oe.getParts()); + } + } + /** Deactivate dump. */ public void deactivate() { diff --git a/src/main/java/org/orekit/rugged/errors/DumpManager.java b/src/main/java/org/orekit/rugged/errors/DumpManager.java index 454cfdc6bef3ee73138f7ead6163e0691d08a334..8e62180f55b4f6631c2cff29ef89ae0aafcaaa42 100644 --- a/src/main/java/org/orekit/rugged/errors/DumpManager.java +++ b/src/main/java/org/orekit/rugged/errors/DumpManager.java @@ -20,9 +20,11 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.orekit.rugged.api.AlgorithmId; import org.orekit.rugged.raster.Tile; import org.orekit.rugged.utils.ExtendedEllipsoid; +import org.orekit.time.AbsoluteDate; /** * Class managing debug dumps. @@ -125,4 +127,21 @@ public class DumpManager { } } + /** Dump a direct location computation. + * @param date computation date + * @param date date of the location + * @param position pixel position in spacecraft frame + * @param los normalized line-of-sight in spacecraft frame + * @param lightTimeCorrection flag for light time correction + * @param aberrationOfLightCorrection flag for aberration of light correction + * @exception RuggedException if date cannot be converted to UTC + */ + public static void dumpDirectLocation(final AbsoluteDate date, final Vector3D position, final Vector3D los, + final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection) + throws RuggedException { + if (isActive()) { + DUMP.get().dumpDirectLocation(date, position, los, lightTimeCorrection, aberrationOfLightCorrection); + } + } + }