diff --git a/src/main/java/org/orekit/rugged/linesensor/SensorPixel.java b/src/main/java/org/orekit/rugged/linesensor/SensorPixel.java index 3f5248cd7705ab2838cb942bf2b7f2555f8772cf..9ade99169a6518405d498a229aee2af0cb148a64 100644 --- a/src/main/java/org/orekit/rugged/linesensor/SensorPixel.java +++ b/src/main/java/org/orekit/rugged/linesensor/SensorPixel.java @@ -70,7 +70,7 @@ public class SensorPixel implements Serializable { format.setMaximumFractionDigits(6); return "{Line: " + format.format(getLineNumber()) + - " , Pixel: " + + ", Pixel: " + format.format(getPixelNumber()) + "}"; } diff --git a/src/main/java/org/orekit/rugged/refraction/AtmosphericOptimizationGrid.java b/src/main/java/org/orekit/rugged/refraction/AtmosphericOptimizationGrid.java new file mode 100644 index 0000000000000000000000000000000000000000..eb2a57c882125887f6bb52a2cdd6802e55ad9ea6 --- /dev/null +++ b/src/main/java/org/orekit/rugged/refraction/AtmosphericOptimizationGrid.java @@ -0,0 +1,99 @@ +package org.orekit.rugged.refraction; + +import org.orekit.rugged.errors.RuggedException; +import org.orekit.rugged.errors.RuggedMessages; +import org.orekit.rugged.linesensor.SensorPixel; + +public class AtmosphericOptimizationGrid { + + private double pixelStart = Double.POSITIVE_INFINITY; + private double lineStart = Double.POSITIVE_INFINITY; + private int pixelColumns = Integer.MAX_VALUE; + private int lineRows = Integer.MAX_VALUE; + + + public AtmosphericOptimizationGrid(final SensorPixel sensorPixelStart, + final int pixelColumns, final int lineRows) throws RuggedException { + + this.pixelStart = sensorPixelStart.getPixelNumber(); + this.lineStart = sensorPixelStart.getLineNumber(); + this.pixelColumns = pixelColumns; + this.lineRows = lineRows; + // TODO change rugged message + if (this.pixelColumns == 0 || this.lineRows == 0) { +// throw new RuggedException(RuggedMessages.EMPTY_TILE, this.pixelColumns, this.lineRows); + throw new RuggedException(RuggedMessages.INTERNAL_ERROR); + + } + } + + /** Check if the sensorPixel (pixel, line) is inside the grid. + * @param sensorPixel the sensor pixel + * @return true if the sensorPixel is inside the grid + */ + public Boolean isInsideGrid(final SensorPixel sensorPixel) { + + Boolean isInside = true; + if (sensorPixel.getPixelNumber() < pixelStart || sensorPixel.getPixelNumber() > (pixelStart + pixelColumns) || + sensorPixel.getLineNumber() < lineStart || sensorPixel.getLineNumber() > (lineStart + lineRows)) { + isInside = false; + } + return isInside; + } + + /** + * @return the pixelStart + */ + public double getPixelStart() { + return pixelStart; + } + + /** + * @param pixelStart the pixelStart to set + */ + public void setPixelStart(final double pixelStart) { + this.pixelStart = pixelStart; + } + + /** + * @return the lineStart + */ + public double getLineStart() { + return lineStart; + } + + /** + * @param lineStart the lineStart to set + */ + public void setLineStart(final double lineStart) { + this.lineStart = lineStart; + } + + /** + * @return the pixelColumns + */ + public int getPixelColumns() { + return pixelColumns; + } + + /** + * @param pixelColumns the pixelColumns to set + */ + public void setPixelColumns(final int pixelColumns) { + this.pixelColumns = pixelColumns; + } + + /** + * @return the lineRows + */ + public int getLineRows() { + return lineRows; + } + + /** + * @param lineRows the lineRows to set + */ + public void setLineRows(final int lineRows) { + this.lineRows = lineRows; + } +} diff --git a/src/main/java/org/orekit/rugged/refraction/AtmosphericRefraction.java b/src/main/java/org/orekit/rugged/refraction/AtmosphericRefraction.java index 8ff9e3e291b4eeb624fdf98802179b6d10b33fcc..08dca18c59024aa9125fc207b5903f022ce27986 100644 --- a/src/main/java/org/orekit/rugged/refraction/AtmosphericRefraction.java +++ b/src/main/java/org/orekit/rugged/refraction/AtmosphericRefraction.java @@ -20,14 +20,26 @@ package org.orekit.rugged.refraction; import org.hipparchus.geometry.euclidean.threed.Vector3D; import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.intersection.IntersectionAlgorithm; +import org.orekit.rugged.linesensor.SensorPixel; import org.orekit.rugged.utils.NormalizedGeodeticPoint; /** * Interface for atmospheric refraction model. * @author Sergio Esteves + * @author Guylaine Prat * @since 2.0 */ -public interface AtmosphericRefraction { +public abstract class AtmosphericRefraction { + + /** + * Flag to tell if we must compute the correction with an optimization grid + */ + private boolean isOptimized = false; + + /** + * The current optimization grid + */ + private AtmosphericOptimizationGrid optimizationGrid; /** Apply correction to the intersected point with an atmospheric refraction model. * @param satPos satellite position, in <em>body frame</em> @@ -37,10 +49,61 @@ public interface AtmosphericRefraction { * @return corrected point with the effect of atmospheric refraction * @throws RuggedException if there is no refraction data at altitude of rawIntersection or see * {@link org.orekit.rugged.utils.ExtendedEllipsoid#pointAtAltitude(Vector3D, Vector3D, double)} or see - * {@link IntersectionAlgorithm#refineIntersection(ExtendedEllipsoid, Vector3D, Vector3D, NormalizedGeodeticPoint)} + * {@link org.orekit.rugged.intersection.IntersectionAlgorithm#refineIntersection(org.orekit.rugged.utils.ExtendedEllipsoid, Vector3D, Vector3D, NormalizedGeodeticPoint)} */ - NormalizedGeodeticPoint applyCorrection(Vector3D satPos, Vector3D satLos, NormalizedGeodeticPoint rawIntersection, + public abstract NormalizedGeodeticPoint applyCorrection(Vector3D satPos, Vector3D satLos, NormalizedGeodeticPoint rawIntersection, IntersectionAlgorithm algorithm) throws RuggedException; + + // TODO to be implemented + public void setOptimizationGrid() throws RuggedException { + + this.isOptimized = true; + + // TODO default value to compute/initialize here ... + final SensorPixel sensorPixelStart = new SensorPixel(Double.NaN, Double.NaN); + final int pixelColumns = Integer.MAX_VALUE; + final int lineRows = Integer.MAX_VALUE; + + + // Set the grid for optimization + this.optimizationGrid = new AtmosphericOptimizationGrid(sensorPixelStart, pixelColumns, lineRows); + + //TODO add check of input : see SimpleTile + + }; + + public void setOptimizationGrid(final SensorPixel sensorPixelStart, + final int pixelColumns, final int lineRows) throws RuggedException { + + this.isOptimized = true; + + // Set the grid for optimization + this.optimizationGrid = new AtmosphericOptimizationGrid(sensorPixelStart, pixelColumns, lineRows); + + //TODO add check of input : see SimpleTile + + }; + + /** Tell if the computation must be optimized + * @return the isOptimized + */ + public boolean isOptimized() { + return isOptimized; + } + + /** + * @return the optimizationGrid + */ + public AtmosphericOptimizationGrid getOptimizationGrid() { + return optimizationGrid; + } + + /** + * @param optimizationGrid the optimizationGrid to set + */ + public void setOptimizationGrid(final AtmosphericOptimizationGrid optimizationGrid) { + this.optimizationGrid = optimizationGrid; + } } diff --git a/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java b/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java index 1a26f7db50258851524b6d517a06f0ea3a5fa4a2..61836a5516364f6cd87cb03bc061b5b6b9d568ea 100644 --- a/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java +++ b/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java @@ -32,10 +32,12 @@ import org.orekit.rugged.utils.NormalizedGeodeticPoint; /** * Atmospheric refraction model based on multiple layers with associated refractive index. - * @author Sergio Esteves, Luc Maisonobe + * @author Sergio Esteves + * @author Luc Maisonobe + * @author Guylaine Prat * @since 2.0 */ -public class MultiLayerModel implements AtmosphericRefraction { +public class MultiLayerModel extends AtmosphericRefraction { /** Observed body ellipsoid. */ private final ExtendedEllipsoid ellipsoid; @@ -86,6 +88,7 @@ public class MultiLayerModel implements AtmosphericRefraction { (l1, l2) -> Double.compare(l2.getLowestAltitude(), l1.getLowestAltitude())); atmosphereLowestAltitude = this.refractionLayers.get(this.refractionLayers.size() - 1).getLowestAltitude(); } + /** {@inheritDoc} */ @Override diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java index cee4a93d34a72dddb89c866f0de983d5d1c2f429..8ed549b35d2f5e875ab1961055a6a218bed6277b 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java @@ -68,6 +68,7 @@ import org.orekit.rugged.linesensor.LinearLineDatation; import org.orekit.rugged.linesensor.SensorPixel; import org.orekit.rugged.los.FixedRotation; import org.orekit.rugged.los.LOSBuilder; +import org.orekit.rugged.los.PixelLOS; import org.orekit.rugged.los.TimeDependentLOS; import org.orekit.rugged.raster.RandomLandscapeUpdater; import org.orekit.rugged.raster.TileUpdater; @@ -102,19 +103,19 @@ public class RuggedTest { public void testMayonVolcanoTiming() throws RuggedException, OrekitException, URISyntaxException { - long t0 = System.currentTimeMillis(); - int dimension = 2000; + final long t0 = System.currentTimeMillis(); + final int dimension = 2000; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); - BodyShape earth = TestUtils.createEarth(); - NormalizedSphericalHarmonicsProvider gravityField = TestUtils.createGravityField(); - Orbit orbit = TestUtils.createOrbit(gravityField.getMu()); + final BodyShape earth = TestUtils.createEarth(); + final NormalizedSphericalHarmonicsProvider gravityField = TestUtils.createGravityField(); + final Orbit orbit = TestUtils.createOrbit(gravityField.getMu()); // Mayon Volcano location according to Wikipedia: 13°15′24″N 123°41′6″E - GeodeticPoint summit = + final GeodeticPoint summit = new GeodeticPoint(FastMath.toRadians(13.25667), FastMath.toRadians(123.685), 2463.0); - VolcanicConeElevationUpdater updater = + final VolcanicConeElevationUpdater updater = new VolcanicConeElevationUpdater(summit, FastMath.toRadians(30.0), 16.0, FastMath.toRadians(1.0), 1201); @@ -123,23 +124,23 @@ public class RuggedTest { // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, centered at +Z, ±10° aperture, 960 pixels - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(10.0), dimension).build(); // linear datation model: at reference time we get line 1000, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - Propagator propagator = TestUtils.createPropagator(earth, gravityField, orbit); + final Propagator propagator = TestUtils.createPropagator(earth, gravityField, orbit); propagator.propagate(lineDatation.getDate(firstLine).shiftedBy(-1.0)); propagator.setEphemerisMode(); propagator.propagate(lineDatation.getDate(lastLine).shiftedBy(+1.0)); - Propagator ephemeris = propagator.getGeneratedEphemeris(); + final Propagator ephemeris = propagator.getGeneratedEphemeris(); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -152,14 +153,14 @@ public class RuggedTest { try { - int size = (lastLine - firstLine) * los.getNbPixels() * 3 * Integer.SIZE / 8; - RandomAccessFile out = new RandomAccessFile(tempFolder.newFile(), "rw"); - MappedByteBuffer buffer = out.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); + final int size = (lastLine - firstLine) * los.getNbPixels() * 3 * Integer.SIZE / 8; + final RandomAccessFile out = new RandomAccessFile(tempFolder.newFile(), "rw"); + final MappedByteBuffer buffer = out.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); - long t1 = System.currentTimeMillis(); + final long t1 = System.currentTimeMillis(); int pixels = 0; for (double line = firstLine; line < lastLine; line++) { - GeodeticPoint[] gp = rugged.directLocation("line", line); + final GeodeticPoint[] gp = rugged.directLocation("line", line); for (int i = 0; i < gp.length; ++i) { final int latCode = (int) FastMath.rint(FastMath.scalb(gp[i].getLatitude(), 29)); final int lonCode = (int) FastMath.rint(FastMath.scalb(gp[i].getLongitude(), 29)); @@ -173,16 +174,16 @@ public class RuggedTest { System.out.format(Locale.US, "%5.0f%n", line); } } - long t2 = System.currentTimeMillis(); + final long t2 = System.currentTimeMillis(); out.close(); - int sizeM = size / (1024 * 1024); + final int sizeM = size / (1024 * 1024); System.out.format(Locale.US, "%n%n%5dx%5d:%n" + " Orekit initialization and DEM creation : %5.1fs%n" + " direct location and %3dM grid writing: %5.1fs (%.1f px/s)%n", lastLine - firstLine, los.getNbPixels(), 1.0e-3 * (t1 - t0), sizeM, 1.0e-3 * (t2 - t1), pixels / (1.0e-3 * (t2 - t1))); - } catch (IOException ioe) { + } catch (final IOException ioe) { Assert.fail(ioe.getLocalizedMessage()); } @@ -192,31 +193,31 @@ public class RuggedTest { public void testLightTimeCorrection() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 400; + final int dimension = 400; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:21:15.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:21:15.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, centered at +Z, ±10° aperture, 960 pixels - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(10.0), dimension).build(); // linear datation model: at reference time we get line 200, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - RuggedBuilder builder = new RuggedBuilder(). + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final RuggedBuilder builder = new RuggedBuilder(). setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID). setEllipsoid(EllipsoidId.IERS2003, BodyRotatingFrameId.ITRF). setTimeSpan(minDate, maxDate, 0.001, 5.0). @@ -233,7 +234,7 @@ public class RuggedTest { try { rugged.getLineSensor("dummy"); Assert.fail("an exception should have been thrown"); - } catch (RuggedException re) { + } catch (final RuggedException re) { Assert.assertEquals(RuggedMessages.UNKNOWN_SENSOR, re.getSpecifier()); Assert.assertEquals("dummy", re.getParts()[0]); } @@ -250,16 +251,16 @@ public class RuggedTest { builder.setLightTimeCorrection(true); builder.setAberrationOfLightCorrection(false); rugged = builder.build(); - GeodeticPoint[] gpWithLightTimeCorrection = rugged.directLocation("line", 200); + final GeodeticPoint[] gpWithLightTimeCorrection = rugged.directLocation("line", 200); builder.setLightTimeCorrection(false); builder.setAberrationOfLightCorrection(false); rugged = builder.build(); - GeodeticPoint[] gpWithoutLightTimeCorrection = rugged.directLocation("line", 200); + final GeodeticPoint[] gpWithoutLightTimeCorrection = rugged.directLocation("line", 200); for (int i = 0; i < gpWithLightTimeCorrection.length; ++i) { - Vector3D pWith = earth.transform(gpWithLightTimeCorrection[i]); - Vector3D pWithout = earth.transform(gpWithoutLightTimeCorrection[i]); + final Vector3D pWith = earth.transform(gpWithLightTimeCorrection[i]); + final Vector3D pWithout = earth.transform(gpWithoutLightTimeCorrection[i]); Assert.assertTrue(Vector3D.distance(pWith, pWithout) > 1.23); Assert.assertTrue(Vector3D.distance(pWith, pWithout) < 1.27); } @@ -270,32 +271,32 @@ public class RuggedTest { public void testAberrationOfLightCorrection() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 400; + final int dimension = 400; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:46:35.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:46:35.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, centered at +Z, ±10° aperture, 960 pixels - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(10.0), dimension).build(); // linear datation model: at reference time we get line 200, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - RuggedBuilder builder = new RuggedBuilder(). - + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final RuggedBuilder builder = new RuggedBuilder(). + setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). setTimeSpan(minDate, maxDate, 0.001, 5.0). @@ -308,52 +309,52 @@ public class RuggedTest { setLightTimeCorrection(false). setAberrationOfLightCorrection(true); Rugged rugged = builder.build(); - GeodeticPoint[] gpWithAberrationOfLightCorrection = rugged.directLocation("line", 200); + final GeodeticPoint[] gpWithAberrationOfLightCorrection = rugged.directLocation("line", 200); builder.setLightTimeCorrection(false); builder.setAberrationOfLightCorrection(false); rugged = builder.build(); - GeodeticPoint[] gpWithoutAberrationOfLightCorrection = rugged.directLocation("line", 200); + final GeodeticPoint[] gpWithoutAberrationOfLightCorrection = rugged.directLocation("line", 200); for (int i = 0; i < gpWithAberrationOfLightCorrection.length; ++i) { - Vector3D pWith = earth.transform(gpWithAberrationOfLightCorrection[i]); - Vector3D pWithout = earth.transform(gpWithoutAberrationOfLightCorrection[i]); + final Vector3D pWith = earth.transform(gpWithAberrationOfLightCorrection[i]); + final Vector3D pWithout = earth.transform(gpWithoutAberrationOfLightCorrection[i]); Assert.assertTrue(Vector3D.distance(pWith, pWithout) > 20.0); Assert.assertTrue(Vector3D.distance(pWith, pWithout) < 20.5); } } - + @Test public void testAtmosphericRefractionCorrection() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 400; + final int dimension = 400; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:46:35.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:46:35.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, centered at +Z, ±10° aperture, 960 pixels - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(10.0), dimension).build(); // linear datation model: at reference time we get line 200, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - RuggedBuilder builder = new RuggedBuilder(). - + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final RuggedBuilder builder = new RuggedBuilder(). + setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). setTimeSpan(minDate, maxDate, 0.001, 5.0). @@ -365,12 +366,26 @@ public class RuggedTest { addLineSensor(lineSensor). setLightTimeCorrection(false). setAberrationOfLightCorrection(false); - - Rugged rugged = builder.build(); - GeodeticPoint[] gpWithoutAtmosphericRefractionCorrection = rugged.directLocation("line", 200); + final Rugged rugged = builder.build(); + + // WITHOUT atmospheric correction + // ============================== + // Compute the direct location for a whole line + final GeodeticPoint[] gpWithoutAtmosphericRefractionCorrection = rugged.directLocation("line", 200); + + // Compute the direct location for a single sensor pixel cell + final Vector3D sensorPosition = lineSensor.getPosition(); + final double lineNumber = 150.; + final double pixelNumber = 420; + final AbsoluteDate dateOnePixel = lineSensor.getDate(lineNumber); + final Vector3D losOnePixel = lineSensor.getLOS(dateOnePixel, pixelNumber); + final GeodeticPoint gpWithoutCorrectionOnePixel = rugged.directLocation(dateOnePixel, sensorPosition, losOnePixel); + + // WITH atmospheric correction + // =========================== // With a user defined multi layers model - List<ConstantRefractionLayer> refractionLayers = new ArrayList<ConstantRefractionLayer>(); + final List<ConstantRefractionLayer> refractionLayers = new ArrayList<ConstantRefractionLayer>(); refractionLayers.add(new ConstantRefractionLayer(100000.00, 1.000000)); refractionLayers.add(new ConstantRefractionLayer( 50000.00, 1.000000)); refractionLayers.add(new ConstantRefractionLayer( 40000.00, 1.000001)); @@ -387,16 +402,45 @@ public class RuggedTest { refractionLayers.add(new ConstantRefractionLayer( 0.00, 1.000278)); refractionLayers.add(new ConstantRefractionLayer( -1000.00, 1.000306)); - AtmosphericRefraction atmosphericRefractionCustom = new MultiLayerModel(rugged.getEllipsoid(), refractionLayers); + + // without optimization of computation + // ----------------------------------- + final AtmosphericRefraction atmosphericRefractionCustom = new MultiLayerModel(rugged.getEllipsoid(), refractionLayers); builder.setRefractionCorrection(atmosphericRefractionCustom); - rugged = builder.build(); - GeodeticPoint[] gpWithAtmosphericCustomRefractionCorrection = rugged.directLocation("line", 200); + final Rugged ruggedWithout = builder.build(); + final GeodeticPoint[] gpWithAtmosphericCustomRefractionCorrection = ruggedWithout.directLocation("line", 200); + + // Compute the direct location for a single sensor pixel cell + final SensorPixel sensorPixel = new SensorPixel(lineNumber, pixelNumber); + final PixelLOS pixelLOS = new PixelLOS(sensorPixel, losOnePixel); + final GeodeticPoint gpWithCorrectionOnePixel = ruggedWithout.directLocation(dateOnePixel, sensorPosition, pixelLOS); + + // with optimization of computation + // -------------------------------- + final AtmosphericRefraction atmosphericRefractionWith = new MultiLayerModel(rugged.getEllipsoid(), refractionLayers); + // set the grid for optimization + final SensorPixel sensorPixelStart = new SensorPixel(lineNumber, pixelNumber); + final int pixelColumns = 10; + final int lineRows = 10; + atmosphericRefractionWith.setOptimizationGrid(sensorPixelStart, pixelColumns, lineRows); + + builder.setRefractionCorrection(atmosphericRefractionWith); + final Rugged ruggedWith = builder.build(); + + final double atmosphericMargin = 1.; // the atmospheric refraction bends the light around 1-2 meters + + // Compare the whole line cells for (int i = 0; i < gpWithAtmosphericCustomRefractionCorrection.length; ++i) { - Vector3D pWith = earth.transform(gpWithAtmosphericCustomRefractionCorrection[i]); - Vector3D pWithout = earth.transform(gpWithoutAtmosphericRefractionCorrection[i]); - Assert.assertTrue(Vector3D.distance(pWith, pWithout) < 1.); + final Vector3D pWith = earth.transform(gpWithAtmosphericCustomRefractionCorrection[i]); + final Vector3D pWithout = earth.transform(gpWithoutAtmosphericRefractionCorrection[i]); + Assert.assertTrue(Vector3D.distance(pWith, pWithout) < atmosphericMargin); } + + // Compare one pixel cell + final Vector3D pWith = earth.transform(gpWithCorrectionOnePixel); + final Vector3D pWithout = earth.transform(gpWithoutCorrectionOnePixel); + Assert.assertTrue(Vector3D.distance(pWith, pWithout) < atmosphericMargin); } @@ -404,37 +448,37 @@ public class RuggedTest { public void testFlatBodyCorrection() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 200; + final int dimension = 200; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension).build(); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - RuggedBuilder builder = new RuggedBuilder(). + final RuggedBuilder builder = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). setTimeSpan(minDate, maxDate, 0.001, 5.0). @@ -444,16 +488,16 @@ public class RuggedTest { TestUtils.orbitToQ(orbit, earth, minDate.shiftedBy(-1.0), maxDate.shiftedBy(+1.0), 0.25), 2, AngularDerivativesFilter.USE_R). addLineSensor(lineSensor); - GeodeticPoint[] gpWithFlatBodyCorrection = + final GeodeticPoint[] gpWithFlatBodyCorrection = builder.setAlgorithm(AlgorithmId.DUVENHAGE).build().directLocation("line", 100); - GeodeticPoint[] gpWithoutFlatBodyCorrection = + final GeodeticPoint[] gpWithoutFlatBodyCorrection = builder.setAlgorithm(AlgorithmId.DUVENHAGE_FLAT_BODY).build().directLocation("line", 100); - StreamingStatistics stats = new StreamingStatistics(); + final StreamingStatistics stats = new StreamingStatistics(); for (int i = 0; i < gpWithFlatBodyCorrection.length; ++i) { - Vector3D pWith = earth.transform(gpWithFlatBodyCorrection[i]); - Vector3D pWithout = earth.transform(gpWithoutFlatBodyCorrection[i]); + final Vector3D pWith = earth.transform(gpWithFlatBodyCorrection[i]); + final Vector3D pWithout = earth.transform(gpWithoutFlatBodyCorrection[i]); stats.addValue(Vector3D.distance(pWith, pWithout)); } Assert.assertEquals( 0.004, stats.getMin(), 1.0e-3); @@ -466,37 +510,37 @@ public class RuggedTest { public void testLocationsinglePoint() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 200; + final int dimension = 200; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension).build(); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -507,10 +551,10 @@ public class RuggedTest { TestUtils.orbitToQ(orbit, earth, minDate.shiftedBy(-1.0), maxDate.shiftedBy(+1.0), 0.25), 2, AngularDerivativesFilter.USE_R). addLineSensor(lineSensor).build(); - GeodeticPoint[] gpLine = rugged.directLocation("line", 100); + final GeodeticPoint[] gpLine = rugged.directLocation("line", 100); for (int i = 0; i < gpLine.length; ++i) { - GeodeticPoint gpPixel = + final GeodeticPoint gpPixel = rugged.directLocation(lineSensor.getDate(100), lineSensor.getPosition(), lineSensor.getLOS(lineSensor.getDate(100), i)); Assert.assertEquals(gpLine[i].getLatitude(), gpPixel.getLatitude(), 1.0e-10); @@ -524,37 +568,37 @@ public class RuggedTest { public void testLocationsinglePointNoCorrections() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 200; + final int dimension = 200; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension).build(); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -568,10 +612,10 @@ public class RuggedTest { setLightTimeCorrection(false). addLineSensor(lineSensor). build(); - GeodeticPoint[] gpLine = rugged.directLocation("line", 100); + final GeodeticPoint[] gpLine = rugged.directLocation("line", 100); for (int i = 0; i < gpLine.length; ++i) { - GeodeticPoint gpPixel = + final GeodeticPoint gpPixel = rugged.directLocation(lineSensor.getDate(100), lineSensor.getPosition(), lineSensor.getLOS(lineSensor.getDate(100), i)); Assert.assertEquals(gpLine[i].getLatitude(), gpPixel.getLatitude(), 1.0e-10); @@ -585,37 +629,37 @@ public class RuggedTest { public void testBasicScan() throws RuggedException, OrekitException, URISyntaxException { - int dimension = 200; + final int dimension = 200; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension).build(); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine); - AbsoluteDate maxDate = lineSensor.getDate(lastLine); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xe12ef744f224cf43l, FastMath.toRadians(1.0), 257); - RuggedBuilder builder = new RuggedBuilder(). + final RuggedBuilder builder = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). setTimeSpan(minDate, maxDate, 0.001, 5.0). @@ -625,16 +669,16 @@ public class RuggedTest { TestUtils.orbitToQ(orbit, earth, minDate.shiftedBy(-1.0), maxDate.shiftedBy(+1.0), 0.25), 2, AngularDerivativesFilter.USE_R). addLineSensor(lineSensor); - GeodeticPoint[] gpDuvenhage = + final GeodeticPoint[] gpDuvenhage = builder.setAlgorithm(AlgorithmId.DUVENHAGE).build().directLocation("line", 100); - GeodeticPoint[] gpBasicScan = + final GeodeticPoint[] gpBasicScan = builder.setAlgorithm(AlgorithmId.BASIC_SLOW_EXHAUSTIVE_SCAN_FOR_TESTS_ONLY).build().directLocation("line", 100); - double[] data = new double[gpDuvenhage.length]; + final double[] data = new double[gpDuvenhage.length]; for (int i = 0; i < gpDuvenhage.length; ++i) { - Vector3D pDuvenhage = earth.transform(gpDuvenhage[i]); - Vector3D pBasicScan = earth.transform(gpBasicScan[i]); + final Vector3D pDuvenhage = earth.transform(gpDuvenhage[i]); + final Vector3D pBasicScan = earth.transform(gpBasicScan[i]); data[i] = Vector3D.distance(pDuvenhage, pBasicScan); } Assert.assertEquals(0.0, new Percentile(99).evaluate(data), 5.1e-4); @@ -648,43 +692,43 @@ public class RuggedTest { public void testInverseLocationTiming() throws RuggedException, OrekitException, URISyntaxException { - long t0 = System.currentTimeMillis(); - int dimension = 2000; - int nbSensors = 3; + final long t0 = System.currentTimeMillis(); + final int dimension = 2000; + final int nbSensors = 3; - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); - List<LineSensor> sensors = new ArrayList<LineSensor>(); + final List<LineSensor> sensors = new ArrayList<LineSensor>(); for (int i = 0; i < nbSensors; ++i) { // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking roughly at 50° roll (sensor-dependent), 2.6" per pixel - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0 - 0.001 * i), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension).build(); // linear datation model: at reference time we get roughly middle line, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, i + dimension / 2, 1.0 / 1.5e-3); + final LineDatation lineDatation = new LinearLineDatation(crossing, i + dimension / 2, 1.0 / 1.5e-3); sensors.add(new LineSensor("line-" + i, lineDatation, position, los)); } - int firstLine = 0; - int lastLine = dimension; - AbsoluteDate minDate = sensors.get(0).getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = sensors.get(sensors.size() - 1).getDate(lastLine).shiftedBy(+1.0); + final int firstLine = 0; + final int lastLine = dimension; + final AbsoluteDate minDate = sensors.get(0).getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = sensors.get(sensors.size() - 1).getDate(lastLine).shiftedBy(+1.0); - TileUpdater updater = + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - RuggedBuilder builder = new RuggedBuilder(). + final RuggedBuilder builder = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -696,32 +740,32 @@ public class RuggedTest { 2, AngularDerivativesFilter.USE_R); builder.setLightTimeCorrection(true); builder.setAberrationOfLightCorrection(true); - for (LineSensor lineSensor : sensors) { + for (final LineSensor lineSensor : sensors) { builder.addLineSensor(lineSensor); } - Rugged rugged = builder.build(); + final Rugged rugged = builder.build(); - double lat0 = FastMath.toRadians(-22.9); - double lon0 = FastMath.toRadians(142.4); - double delta = FastMath.toRadians(0.5); + final double lat0 = FastMath.toRadians(-22.9); + final double lon0 = FastMath.toRadians(142.4); + final double delta = FastMath.toRadians(0.5); try { - long size = nbSensors * dimension * dimension * 2l * Integer.SIZE / 8l; - RandomAccessFile out = new RandomAccessFile(tempFolder.newFile(), "rw"); - MappedByteBuffer buffer = out.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); + final long size = nbSensors * dimension * dimension * 2l * Integer.SIZE / 8l; + final RandomAccessFile out = new RandomAccessFile(tempFolder.newFile(), "rw"); + final MappedByteBuffer buffer = out.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); - long t1 = System.currentTimeMillis(); + final long t1 = System.currentTimeMillis(); int goodPixels = 0; int badPixels = 0; for (final LineSensor lineSensor : sensors) { for (int i = 0; i < dimension; ++i) { - double latitude = lat0 + (i * delta) / dimension; + final double latitude = lat0 + (i * delta) / dimension; if (i %100 == 0) { System.out.println(lineSensor.getName() + " " + i); } for (int j = 0; j < dimension; ++j) { - double longitude = lon0 + (j * delta) / dimension; - SensorPixel sp = rugged.inverseLocation(lineSensor.getName(), latitude, longitude, + final double longitude = lon0 + (j * delta) / dimension; + final SensorPixel sp = rugged.inverseLocation(lineSensor.getName(), latitude, longitude, firstLine, lastLine); if (sp == null) { ++badPixels; @@ -738,9 +782,9 @@ public class RuggedTest { } } - long t2 = System.currentTimeMillis(); + final long t2 = System.currentTimeMillis(); out.close(); - int sizeM = (int) (size / (1024l * 1024l)); + final int sizeM = (int) (size / (1024l * 1024l)); System.out.format(Locale.US, "%n%n%5dx%5d, %d sensors:%n" + " Orekit initialization and DEM creation : %5.1fs%n" + @@ -749,7 +793,7 @@ public class RuggedTest { 1.0e-3 * (t1 - t0), sizeM, 1.0e-3 * (t2 - t1), (badPixels + goodPixels) / (1.0e-3 * (t2 - t1)), (100.0 * goodPixels) / (goodPixels + badPixels)); - } catch (IOException ioe) { + } catch (final IOException ioe) { Assert.fail(ioe.getLocalizedMessage()); } } @@ -771,7 +815,7 @@ public class RuggedTest { checkDateLocation(2000, true, false, 8.0e-7); checkDateLocation(2000, true, true, 3.0e-6); } - + @Test public void testLineDatation() throws RuggedException, OrekitException, URISyntaxException { @@ -783,14 +827,14 @@ public class RuggedTest { @Test public void testInverseLocNearLineEnd() throws OrekitException, RuggedException, URISyntaxException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); - Vector3D offset = Vector3D.ZERO; - TimeScale gps = TimeScalesFactory.getGPS(); - Frame eme2000 = FramesFactory.getEME2000(); - Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); - ArrayList<TimeStampedAngularCoordinates> satelliteQList = new ArrayList<TimeStampedAngularCoordinates>(); - ArrayList<TimeStampedPVCoordinates> satellitePVList = new ArrayList<TimeStampedPVCoordinates>(); + final Vector3D offset = Vector3D.ZERO; + final TimeScale gps = TimeScalesFactory.getGPS(); + final Frame eme2000 = FramesFactory.getEME2000(); + final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); + final ArrayList<TimeStampedAngularCoordinates> satelliteQList = new ArrayList<TimeStampedAngularCoordinates>(); + final ArrayList<TimeStampedPVCoordinates> satellitePVList = new ArrayList<TimeStampedPVCoordinates>(); TestUtils.addSatelliteQ(gps, satelliteQList, "2009-12-11T16:58:42.592937", -0.340236d, 0.333952d, -0.844012d, -0.245684d); TestUtils.addSatelliteQ(gps, satelliteQList, "2009-12-11T16:59:06.592937", -0.354773d, 0.329336d, -0.837871d, -0.252281d); @@ -816,8 +860,8 @@ public class RuggedTest { TestUtils.addSatellitePV(gps, eme2000, itrf, satellitePVList, "2009-12-11T17:01:56.992937", -1198331.706d, -6154056.146d, 3466192.446d, -1920.64d, -3249.148d, -6433.531d); TestUtils.addSatellitePV(gps, eme2000, itrf, satellitePVList, "2009-12-11T17:02:18.592937", -1249311.381d, -6220723.191d, 3326367.397d, -1896.952d, -3101.26d, -6513.056d); - TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - RuggedBuilder builder = new RuggedBuilder(). + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); + final RuggedBuilder builder = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -826,7 +870,7 @@ public class RuggedTest { satellitePVList, 8, CartesianDerivativesFilter.USE_PV, satelliteQList, 8, AngularDerivativesFilter.USE_R); - List<Vector3D> lineOfSight = new ArrayList<Vector3D>(); + final List<Vector3D> lineOfSight = new ArrayList<Vector3D>(); lineOfSight.add(new Vector3D(-0.011204, 0.181530, 1d).normalize()); lineOfSight.add(new Vector3D(-0.011204, 0.181518, 1d).normalize()); lineOfSight.add(new Vector3D(-0.011204, 0.181505, 1d).normalize()); @@ -856,27 +900,27 @@ public class RuggedTest { lineOfSight.add(new Vector3D(-0.011204, 0.149599, 1d).normalize()); lineOfSight.add(new Vector3D(-0.011204, 0.149586, 1d).normalize()); - AbsoluteDate absDate = new AbsoluteDate("2009-12-11T16:58:51.593", gps); - LinearLineDatation lineDatation = new LinearLineDatation(absDate, 1d, 638.5696040868454); - LineSensor lineSensor = new LineSensor("perfect-line", lineDatation, offset, + final AbsoluteDate absDate = new AbsoluteDate("2009-12-11T16:58:51.593", gps); + final LinearLineDatation lineDatation = new LinearLineDatation(absDate, 1d, 638.5696040868454); + final LineSensor lineSensor = new LineSensor("perfect-line", lineDatation, offset, new LOSBuilder(lineOfSight).build()); builder.addLineSensor(lineSensor); - Rugged rugged = builder.build(); - GeodeticPoint point1 = new GeodeticPoint(0.7053784581520293, -1.7354535645320581, 691.856741468848); - SensorPixel sensorPixel1 = rugged.inverseLocation(lineSensor.getName(), point1, 1, 131328); + final Rugged rugged = builder.build(); + final GeodeticPoint point1 = new GeodeticPoint(0.7053784581520293, -1.7354535645320581, 691.856741468848); + final SensorPixel sensorPixel1 = rugged.inverseLocation(lineSensor.getName(), point1, 1, 131328); Assert.assertEquals( 2.01474, sensorPixel1.getLineNumber(), 1.0e-5); Assert.assertEquals( 2.09271, sensorPixel1.getPixelNumber(), 1.0e-5); - GeodeticPoint point2 = new GeodeticPoint(0.704463899881073, -1.7303503789334154, 648.9200602492216); - SensorPixel sensorPixel2 = rugged.inverseLocation(lineSensor.getName(), point2, 1, 131328); + final GeodeticPoint point2 = new GeodeticPoint(0.704463899881073, -1.7303503789334154, 648.9200602492216); + final SensorPixel sensorPixel2 = rugged.inverseLocation(lineSensor.getName(), point2, 1, 131328); Assert.assertEquals( 2.02185, sensorPixel2.getLineNumber(), 1.0e-5); Assert.assertEquals( 27.53008, sensorPixel2.getPixelNumber(), 1.0e-5); - GeodeticPoint point3 = new GeodeticPoint(0.7009593480939814, -1.7314283804521957, 588.3075485689468); - SensorPixel sensorPixel3 = rugged.inverseLocation(lineSensor.getName(), point3, 1, 131328); + final GeodeticPoint point3 = new GeodeticPoint(0.7009593480939814, -1.7314283804521957, 588.3075485689468); + final SensorPixel sensorPixel3 = rugged.inverseLocation(lineSensor.getName(), point3, 1, 131328); Assert.assertEquals(2305.26101, sensorPixel3.getLineNumber(), 1.0e-5); Assert.assertEquals( 27.18381, sensorPixel3.getPixelNumber(), 1.0e-5); - GeodeticPoint point4 = new GeodeticPoint(0.7018731669637096, -1.73651769725183, 611.2759403696498); - SensorPixel sensorPixel4 = rugged.inverseLocation(lineSensor.getName(), point4, 1, 131328); + final GeodeticPoint point4 = new GeodeticPoint(0.7018731669637096, -1.73651769725183, 611.2759403696498); + final SensorPixel sensorPixel4 = rugged.inverseLocation(lineSensor.getName(), point4, 1, 131328); Assert.assertEquals(2305.25436, sensorPixel4.getLineNumber(), 1.0e-5); Assert.assertEquals( 1.54447, sensorPixel4.getPixelNumber(), 1.0e-5); @@ -885,14 +929,14 @@ public class RuggedTest { @Test public void testInverseLoc() throws OrekitException, RuggedException, URISyntaxException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); - Vector3D offset = Vector3D.ZERO; - TimeScale gps = TimeScalesFactory.getGPS(); - Frame eme2000 = FramesFactory.getEME2000(); - Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); - ArrayList<TimeStampedAngularCoordinates> satelliteQList = new ArrayList<TimeStampedAngularCoordinates>(); - ArrayList<TimeStampedPVCoordinates> satellitePVList = new ArrayList<TimeStampedPVCoordinates>(); + final Vector3D offset = Vector3D.ZERO; + final TimeScale gps = TimeScalesFactory.getGPS(); + final Frame eme2000 = FramesFactory.getEME2000(); + final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); + final ArrayList<TimeStampedAngularCoordinates> satelliteQList = new ArrayList<TimeStampedAngularCoordinates>(); + final ArrayList<TimeStampedPVCoordinates> satellitePVList = new ArrayList<TimeStampedPVCoordinates>(); TestUtils.addSatelliteQ(gps, satelliteQList, "2013-07-07T17:16:27", -0.327993d, -0.715194d, -0.56313d, 0.252592d); TestUtils.addSatelliteQ(gps, satelliteQList, "2013-07-07T17:16:29", -0.328628d, -0.71494d, -0.562769d, 0.25329d); @@ -946,16 +990,16 @@ public class RuggedTest { TestUtils.addSatellitePV(gps, eme2000, itrf, satellitePVList, "2013-07-07T17:20:30.857531", -912495.948d, -6327504.159d, 3233100.411d, -1700.825d, -3108.095d, -6563.77d); TestUtils.addSatellitePV(gps, eme2000, itrf, satellitePVList, "2013-07-07T17:20:39.857531", -931933.933d, -6354591.778d, 3173886.968d, -1693.833d, -3045.116d, -6595.024d); - List<Vector3D> lineOfSight = new ArrayList<Vector3D>(); + final List<Vector3D> lineOfSight = new ArrayList<Vector3D>(); lineOfSight.add(new Vector3D(0.0046536264d, -0.1851800945d, 1d)); lineOfSight.add(new Vector3D(0.0000001251d, -0.0002815246d, 1d)); lineOfSight.add(new Vector3D(0.0046694108d, 0.1853863933d, 1d)); - AbsoluteDate absDate = new AbsoluteDate("2013-07-07T17:16:36.857", gps); - LinearLineDatation lineDatation = new LinearLineDatation(absDate, 0.03125d, 19.95565693384045); - LineSensor lineSensor = new LineSensor("QUICK_LOOK", lineDatation, offset, + final AbsoluteDate absDate = new AbsoluteDate("2013-07-07T17:16:36.857", gps); + final LinearLineDatation lineDatation = new LinearLineDatation(absDate, 0.03125d, 19.95565693384045); + final LineSensor lineSensor = new LineSensor("QUICK_LOOK", lineDatation, offset, new LOSBuilder(lineOfSight).build()); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). setTimeSpan(satellitePVList.get(0).getDate(), @@ -967,16 +1011,16 @@ public class RuggedTest { build(); GeodeticPoint[] temp = rugged.directLocation("QUICK_LOOK", -250); - GeodeticPoint first = temp[0]; - double minLon = first.getLongitude(); - double minLat = first.getLatitude(); + final GeodeticPoint first = temp[0]; + final double minLon = first.getLongitude(); + final double minLat = first.getLatitude(); temp = rugged.directLocation("QUICK_LOOK", 350); - GeodeticPoint last = temp[temp.length - 1]; - double maxLon = last.getLongitude(); - double maxLat = last.getLatitude(); + final GeodeticPoint last = temp[temp.length - 1]; + final double maxLon = last.getLongitude(); + final double maxLat = last.getLatitude(); - GeodeticPoint gp = new GeodeticPoint((minLat + maxLat) / 2d, (minLon + maxLon) / 2d, 0d); - SensorPixel sensorPixel = rugged.inverseLocation("QUICK_LOOK", gp, -250, 350); + final GeodeticPoint gp = new GeodeticPoint((minLat + maxLat) / 2d, (minLon + maxLon) / 2d, 0d); + final SensorPixel sensorPixel = rugged.inverseLocation("QUICK_LOOK", gp, -250, 350); Assert.assertNotNull(sensorPixel); @@ -986,36 +1030,36 @@ public class RuggedTest { public void testInverseLocCurvedLine() throws RuggedException, URISyntaxException, OrekitException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); - int dimension = 200; + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final int dimension = 200; // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at nadir, 2.6" per pixel, 3" sagitta - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSCurvedLine(Vector3D.PLUS_K, Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSCurvedLine(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), FastMath.toRadians(3.0 / 3600.0), dimension); // linear datation model: at reference time we get the middle line, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("curved", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("curved", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.3, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -1028,50 +1072,50 @@ public class RuggedTest { addLineSensor(lineSensor). build(); - int lineNumber = 97; - GeodeticPoint[] gp = rugged.directLocation("curved", lineNumber); + final int lineNumber = 97; + final GeodeticPoint[] gp = rugged.directLocation("curved", lineNumber); for (int i = 0; i < gp.length; ++i) { - SensorPixel pixel = rugged.inverseLocation("curved", gp[i], firstLine, lastLine); + final SensorPixel pixel = rugged.inverseLocation("curved", gp[i], firstLine, lastLine); Assert.assertEquals(lineNumber, pixel.getLineNumber(), 5.0e-4); Assert.assertEquals(i, pixel.getPixelNumber(), 3.1e-7); } } - private void checkInverseLocation(int dimension, boolean lightTimeCorrection, boolean aberrationOfLightCorrection, - double maxLineError, double maxPixelError) + private void checkInverseLocation(final int dimension, final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection, + final double maxLineError, final double maxPixelError) throws RuggedException, OrekitException, URISyntaxException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension).build(); // linear datation model: at reference time we get the middle line, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.3, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -1086,13 +1130,13 @@ public class RuggedTest { addLineSensor(lineSensor). build(); - double referenceLine = 0.87654 * dimension; - GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); + final double referenceLine = 0.87654 * dimension; + final GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); for (double p = 0; p < gp.length - 1; p += 1.0) { - int i = (int) FastMath.floor(p); - double d = p - i; - SensorPixel sp = rugged.inverseLocation("line", + final int i = (int) FastMath.floor(p); + final double d = p - i; + final SensorPixel sp = rugged.inverseLocation("line", (1 - d) * gp[i].getLatitude() + d * gp[i + 1].getLatitude(), (1 - d) * gp[i].getLongitude() + d * gp[i + 1].getLongitude(), 0, dimension); @@ -1113,16 +1157,16 @@ public class RuggedTest { 0, dimension)); // point out of line (20 lines before first line) - GeodeticPoint[] gp0 = rugged.directLocation("line", 0); - GeodeticPoint[] gp1 = rugged.directLocation("line", 1); + final GeodeticPoint[] gp0 = rugged.directLocation("line", 0); + final GeodeticPoint[] gp1 = rugged.directLocation("line", 1); Assert.assertNull(rugged.inverseLocation("line", 21 * gp0[dimension / 2].getLatitude() - 20 * gp1[dimension / 2].getLatitude(), 21 * gp0[dimension / 2].getLongitude() - 20 * gp1[dimension / 2].getLongitude(), 0, dimension)); // point out of line (20 lines after last line) - GeodeticPoint[] gp2 = rugged.directLocation("line", dimension - 2); - GeodeticPoint[] gp3 = rugged.directLocation("line", dimension - 1); + final GeodeticPoint[] gp2 = rugged.directLocation("line", dimension - 2); + final GeodeticPoint[] gp3 = rugged.directLocation("line", dimension - 1); Assert.assertNull(rugged.inverseLocation("line", -20 * gp2[dimension / 2].getLatitude() + 21 * gp3[dimension / 2].getLatitude(), -20 * gp2[dimension / 2].getLongitude() + 21 * gp3[dimension / 2].getLongitude(), @@ -1169,28 +1213,28 @@ public class RuggedTest { * @throws RuggedException * @throws OrekitException */ - private void doTestInverseLocationDerivatives(int dimension, - boolean lightTimeCorrection, - boolean aberrationOfLightCorrection, - double lineTolerance, - double pixelTolerance, - double lineDerivativeRelativeTolerance, - double pixelDerivativeRelativeTolerance) + private void doTestInverseLocationDerivatives(final int dimension, + final boolean lightTimeCorrection, + final boolean aberrationOfLightCorrection, + final double lineTolerance, + final double pixelTolerance, + final double lineDerivativeRelativeTolerance, + final double pixelDerivativeRelativeTolerance) throws RuggedException, OrekitException { try { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel - Vector3D position = new Vector3D(1.5, 0, -0.2); - LOSBuilder losBuilder = + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final LOSBuilder losBuilder = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), @@ -1198,21 +1242,21 @@ public class RuggedTest { FastMath.toRadians(dimension * 2.6 / 3600.0), dimension); losBuilder.addTransform(new FixedRotation("roll", Vector3D.MINUS_I, 0.0)); losBuilder.addTransform(new FixedRotation("pitch", Vector3D.MINUS_J, 0.0)); - TimeDependentLOS los = losBuilder.build(); + final TimeDependentLOS los = losBuilder.build(); // linear datation model: at reference time we get the middle line, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); + final AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); - TileUpdater updater = + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.3, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -1228,35 +1272,35 @@ public class RuggedTest { build(); // we want to adjust sensor roll and pitch angles - ParameterDriver rollDriver = + final ParameterDriver rollDriver = lineSensor.getParametersDrivers(). filter(driver -> driver.getName().equals("roll")).findFirst().get(); rollDriver.setSelected(true); - ParameterDriver pitchDriver = + final ParameterDriver pitchDriver = lineSensor.getParametersDrivers(). filter(driver -> driver.getName().equals("pitch")).findFirst().get(); pitchDriver.setSelected(true); // prepare generator final Observables measurements = new Observables(1); - GroundOptimizationProblemBuilder optimizationPbBuilder = new GroundOptimizationProblemBuilder(Collections.singletonList(lineSensor), + final GroundOptimizationProblemBuilder optimizationPbBuilder = new GroundOptimizationProblemBuilder(Collections.singletonList(lineSensor), measurements, rugged); - - java.lang.reflect.Method getGenerator = GroundOptimizationProblemBuilder.class.getSuperclass().getDeclaredMethod("getGenerator"); + + final java.lang.reflect.Method getGenerator = GroundOptimizationProblemBuilder.class.getSuperclass().getDeclaredMethod("getGenerator"); getGenerator.setAccessible(true); - - DSGenerator generator = (DSGenerator) getGenerator.invoke(optimizationPbBuilder); - double referenceLine = 0.87654 * dimension; - GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); + final DSGenerator generator = (DSGenerator) getGenerator.invoke(optimizationPbBuilder); - Method inverseLoc = Rugged.class.getDeclaredMethod("inverseLocationDerivatives", + final double referenceLine = 0.87654 * dimension; + final GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); + + final Method inverseLoc = Rugged.class.getDeclaredMethod("inverseLocationDerivatives", String.class, GeodeticPoint.class, Integer.TYPE, Integer.TYPE, DSGenerator.class); inverseLoc.setAccessible(true); - int referencePixel = (3 * dimension) / 4; - DerivativeStructure[] result = + final int referencePixel = (3 * dimension) / 4; + final DerivativeStructure[] result = (DerivativeStructure[]) inverseLoc.invoke(rugged, "line", gp[referencePixel], 0, dimension, generator); @@ -1266,68 +1310,68 @@ public class RuggedTest { Assert.assertEquals(1, result[0].getOrder()); // check the partial derivatives - DSFactory factory = new DSFactory(1, 1); - double h = 1.0e-6; - FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, h); + final DSFactory factory = new DSFactory(1, 1); + final double h = 1.0e-6; + final FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, h); - UnivariateDifferentiableFunction lineVSroll = - differentiator.differentiate((double roll) -> { + final UnivariateDifferentiableFunction lineVSroll = + differentiator.differentiate((final double roll) -> { try { rollDriver.setValue(roll); pitchDriver.setValue(0); return rugged.inverseLocation("line", gp[referencePixel], 0, dimension).getLineNumber(); - } catch (OrekitException e) { + } catch (final OrekitException e) { throw new OrekitExceptionWrapper(e); - } catch (RuggedException e) { + } catch (final RuggedException e) { throw new RuggedExceptionWrapper(e); } }); - double dLdR = lineVSroll.value(factory.variable(0, 0.0)).getPartialDerivative(1); + final double dLdR = lineVSroll.value(factory.variable(0, 0.0)).getPartialDerivative(1); Assert.assertEquals(dLdR, result[0].getPartialDerivative(1, 0), dLdR * lineDerivativeRelativeTolerance); - UnivariateDifferentiableFunction lineVSpitch = - differentiator.differentiate((double pitch) -> { + final UnivariateDifferentiableFunction lineVSpitch = + differentiator.differentiate((final double pitch) -> { try { rollDriver.setValue(0); pitchDriver.setValue(pitch); return rugged.inverseLocation("line", gp[referencePixel], 0, dimension).getLineNumber(); - } catch (OrekitException e) { + } catch (final OrekitException e) { throw new OrekitExceptionWrapper(e); - } catch (RuggedException e) { + } catch (final RuggedException e) { throw new RuggedExceptionWrapper(e); } }); - double dLdP = lineVSpitch.value(factory.variable(0, 0.0)).getPartialDerivative(1); + final double dLdP = lineVSpitch.value(factory.variable(0, 0.0)).getPartialDerivative(1); Assert.assertEquals(dLdP, result[0].getPartialDerivative(0, 1), dLdP * lineDerivativeRelativeTolerance); - UnivariateDifferentiableFunction pixelVSroll = - differentiator.differentiate((double roll) -> { + final UnivariateDifferentiableFunction pixelVSroll = + differentiator.differentiate((final double roll) -> { try { rollDriver.setValue(roll); pitchDriver.setValue(0); return rugged.inverseLocation("line", gp[referencePixel], 0, dimension).getPixelNumber(); - } catch (OrekitException e) { + } catch (final OrekitException e) { throw new OrekitExceptionWrapper(e); - } catch (RuggedException e) { + } catch (final RuggedException e) { throw new RuggedExceptionWrapper(e); } }); - double dXdR = pixelVSroll.value(factory.variable(0, 0.0)).getPartialDerivative(1); + final double dXdR = pixelVSroll.value(factory.variable(0, 0.0)).getPartialDerivative(1); Assert.assertEquals(dXdR, result[1].getPartialDerivative(1, 0), dXdR * pixelDerivativeRelativeTolerance); - UnivariateDifferentiableFunction pixelVSpitch = - differentiator.differentiate((double pitch) -> { + final UnivariateDifferentiableFunction pixelVSpitch = + differentiator.differentiate((final double pitch) -> { try { rollDriver.setValue(0); pitchDriver.setValue(pitch); return rugged.inverseLocation("line", gp[referencePixel], 0, dimension).getPixelNumber(); - } catch (OrekitException e) { + } catch (final OrekitException e) { throw new OrekitExceptionWrapper(e); - } catch (RuggedException e) { + } catch (final RuggedException e) { throw new RuggedExceptionWrapper(e); } }); - double dXdP = pixelVSpitch.value(factory.variable(0, 0.0)).getPartialDerivative(1); + final double dXdP = pixelVSpitch.value(factory.variable(0, 0.0)).getPartialDerivative(1); Assert.assertEquals(dXdP, result[1].getPartialDerivative(0, 1), dXdP * pixelDerivativeRelativeTolerance); } catch (InvocationTargetException | NoSuchMethodException | @@ -1339,40 +1383,40 @@ public class RuggedTest { } - private void checkDateLocation(int dimension, boolean lightTimeCorrection, boolean aberrationOfLightCorrection, - double maxDateError) + private void checkDateLocation(final int dimension, final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection, + final double maxDateError) throws RuggedException, OrekitException, URISyntaxException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); final BodyShape earth = TestUtils.createEarth(); final Orbit orbit = TestUtils.createOrbit(Constants.EIGEN5C_EARTH_MU); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension).build(); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); - - TileUpdater updater = + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); + + final TileUpdater updater = new RandomLandscapeUpdater(0.0, 9000.0, 0.5, 0xf0a401650191f9f6l, FastMath.toRadians(1.0), 257); - Rugged rugged = new RuggedBuilder(). + final Rugged rugged = new RuggedBuilder(). setDigitalElevationModel(updater, 8). setAlgorithm(AlgorithmId.DUVENHAGE). setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF). @@ -1387,13 +1431,13 @@ public class RuggedTest { addLineSensor(lineSensor). build(); - double referenceLine = 0.87654 * dimension; - GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); + final double referenceLine = 0.87654 * dimension; + final GeodeticPoint[] gp = rugged.directLocation("line", referenceLine); for (double p = 0; p < gp.length - 1; p += 1.0) { - int i = (int) FastMath.floor(p); - double d = p - i; - AbsoluteDate date = rugged.dateLocation("line", + final int i = (int) FastMath.floor(p); + final double d = p - i; + final AbsoluteDate date = rugged.dateLocation("line", (1 - d) * gp[i].getLatitude() + d * gp[i + 1].getLatitude(), (1 - d) * gp[i].getLongitude() + d * gp[i + 1].getLongitude(), 0, dimension); @@ -1401,100 +1445,100 @@ public class RuggedTest { } // point out of line (20 lines before first line) - GeodeticPoint[] gp0 = rugged.directLocation("line", 0); - GeodeticPoint[] gp1 = rugged.directLocation("line", 1); + final GeodeticPoint[] gp0 = rugged.directLocation("line", 0); + final GeodeticPoint[] gp1 = rugged.directLocation("line", 1); Assert.assertNull(rugged.dateLocation("line", 21 * gp0[dimension / 2].getLatitude() - 20 * gp1[dimension / 2].getLatitude(), 21 * gp0[dimension / 2].getLongitude() - 20 * gp1[dimension / 2].getLongitude(), 0, dimension)); // point out of line (20 lines after last line) - GeodeticPoint[] gp2 = rugged.directLocation("line", dimension - 2); - GeodeticPoint[] gp3 = rugged.directLocation("line", dimension - 1); + final GeodeticPoint[] gp2 = rugged.directLocation("line", dimension - 2); + final GeodeticPoint[] gp3 = rugged.directLocation("line", dimension - 1); Assert.assertNull(rugged.dateLocation("line", -20 * gp2[dimension / 2].getLatitude() + 21 * gp3[dimension / 2].getLatitude(), -20 * gp2[dimension / 2].getLongitude() + 21 * gp3[dimension / 2].getLongitude(), 0, dimension)); - + } - private void checkLineDatation(int dimension, double maxLineError) + private void checkLineDatation(final int dimension, final double maxLineError) throws RuggedException, OrekitException, URISyntaxException { - String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); + final String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); - AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); + final AbsoluteDate crossing = new AbsoluteDate("2012-01-01T12:30:00.000", TimeScalesFactory.getUTC()); // one line sensor // position: 1.5m in front (+X) and 20 cm above (-Z) of the S/C center of mass // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel - Vector3D position = new Vector3D(1.5, 0, -0.2); - TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, + final Vector3D position = new Vector3D(1.5, 0, -0.2); + final TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, FastMath.toRadians(50.0), RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension).build(); // linear datation model: at reference time we get the middle line, and the rate is one line every 1.5ms - LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); - int firstLine = 0; - int lastLine = dimension; - LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); - AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); - AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); + final LineDatation lineDatation = new LinearLineDatation(crossing, dimension / 2, 1.0 / 1.5e-3); + final int firstLine = 0; + final int lastLine = dimension; + final LineSensor lineSensor = new LineSensor("line", lineDatation, position, los); + final AbsoluteDate minDate = lineSensor.getDate(firstLine).shiftedBy(-1.0); + final AbsoluteDate maxDate = lineSensor.getDate(lastLine).shiftedBy(+1.0); // Recompute the lines from the date with the appropriate shift of date - double recomputedFirstLine = lineSensor.getLine(minDate.shiftedBy(+1.0)); - double recomputedLastLine = lineSensor.getLine(maxDate.shiftedBy(-1.0)); + final double recomputedFirstLine = lineSensor.getLine(minDate.shiftedBy(+1.0)); + final double recomputedLastLine = lineSensor.getLine(maxDate.shiftedBy(-1.0)); Assert.assertEquals(firstLine, recomputedFirstLine, maxLineError); Assert.assertEquals(lastLine, recomputedLastLine, maxLineError); } - + @Test public void testDistanceBetweenLOS() throws RuggedException { - - InitInterRefiningTest refiningTest = new InitInterRefiningTest(); + + final InitInterRefiningTest refiningTest = new InitInterRefiningTest(); refiningTest.initRefiningTest(); - + final SensorPixel realPixelA = new SensorPixel(2005.015883575199, 18004.968656395424); final SensorPixel realPixelB = new SensorPixel(4798.487736488162, 13952.2195710654); - double[] distancesBetweenLOS = refiningTest.computeDistancesBetweenLOS(realPixelA, realPixelB); - - double expectedDistanceBetweenLOS = 3.88800245; - double expectedDistanceToTheGround = 6368020.559109; + final double[] distancesBetweenLOS = refiningTest.computeDistancesBetweenLOS(realPixelA, realPixelB); + + final double expectedDistanceBetweenLOS = 3.88800245; + final double expectedDistanceToTheGround = 6368020.559109; Assert.assertEquals(expectedDistanceBetweenLOS, distancesBetweenLOS[0], 1.e-8); Assert.assertEquals(expectedDistanceToTheGround, distancesBetweenLOS[1], 1.e-5); } - + @Test public void testDistanceBetweenLOSDerivatives() throws RuggedException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - - InitInterRefiningTest refiningTest = new InitInterRefiningTest(); + + final InitInterRefiningTest refiningTest = new InitInterRefiningTest(); refiningTest.initRefiningTest(); final SensorPixel realPixelA = new SensorPixel(2005.015883575199, 18004.968656395424); final SensorPixel realPixelB = new SensorPixel(4798.487736488162, 13952.2195710654); // Expected distances between LOS and to the ground - double expectedDistanceBetweenLOS = 3.88800245; - double expectedDistanceToTheGround = 6368020.559109; + final double expectedDistanceBetweenLOS = 3.88800245; + final double expectedDistanceToTheGround = 6368020.559109; // Expected derivatives for // minimum distance between LOS - double[] expectedDminDerivatives = {3.88800245, -153874.01319097, -678866.03112033, 191294.06938169, 668600.16715270} ; + final double[] expectedDminDerivatives = {3.88800245, -153874.01319097, -678866.03112033, 191294.06938169, 668600.16715270} ; // minimum distance to the ground - double[] expectedDcentralBodyDerivatives = {6368020.55910153, 7007767.46926062, -1577060.82402054, -6839286.39593802, 1956452.66636262}; + final double[] expectedDcentralBodyDerivatives = {6368020.55910153, 7007767.46926062, -1577060.82402054, -6839286.39593802, 1956452.66636262}; - DerivativeStructure[] distancesBetweenLOSwithDS = refiningTest.computeDistancesBetweenLOSDerivatives(realPixelA, realPixelB, expectedDistanceBetweenLOS, expectedDistanceToTheGround); + final DerivativeStructure[] distancesBetweenLOSwithDS = refiningTest.computeDistancesBetweenLOSDerivatives(realPixelA, realPixelB, expectedDistanceBetweenLOS, expectedDistanceToTheGround); // Minimum distance between LOS - DerivativeStructure dMin = distancesBetweenLOSwithDS[0]; + final DerivativeStructure dMin = distancesBetweenLOSwithDS[0]; // Minimum distance to the ground - DerivativeStructure dCentralBody = distancesBetweenLOSwithDS[1]; + final DerivativeStructure dCentralBody = distancesBetweenLOSwithDS[1]; Assert.assertEquals(expectedDistanceBetweenLOS, dMin.getValue(), 1.e-8); Assert.assertEquals(expectedDistanceToTheGround, dCentralBody.getValue() , 1.e-5); @@ -1509,7 +1553,7 @@ public class RuggedTest { } } - + @Before public void setUp() throws OrekitException, URISyntaxException { TestUtils.clearFactories();