From c79cf4dd54b4200181216d490d8bc6f69bdd8a27 Mon Sep 17 00:00:00 2001 From: Guylaine Prat <guylaine.prat@c-s.fr> Date: Tue, 24 Oct 2017 10:33:11 +0200 Subject: [PATCH] Add comments --- .../java/RefiningPleiades/GroundRefining.java | 179 +++++----- .../java/RefiningPleiades/InterRefining.java | 307 ++++++++---------- .../java/RefiningPleiades/Refining.java | 152 ++++----- 3 files changed, 272 insertions(+), 366 deletions(-) diff --git a/src/tutorials/java/RefiningPleiades/GroundRefining.java b/src/tutorials/java/RefiningPleiades/GroundRefining.java index 0c1742c7..4703b072 100644 --- a/src/tutorials/java/RefiningPleiades/GroundRefining.java +++ b/src/tutorials/java/RefiningPleiades/GroundRefining.java @@ -1,4 +1,4 @@ -/* Copyright 2013-2016 CS Systèmes d'Information +/* Copyright 2013-2017 CS Systèmes d'Information * Licensed to CS Systèmes d'Information (CS) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -50,15 +50,15 @@ import org.orekit.utils.PVCoordinates; import org.orekit.utils.TimeStampedAngularCoordinates; import org.orekit.utils.TimeStampedPVCoordinates; - - /** * Class for testing refining (fulcrum points study) * with or without noisy measurements * @author Jonathan Guinet * @author Lucie Labat-Allee + * @author Guylaine Prat * @see SensorToGroundMapping * @see GroundMeasureGenerator + * @since 2.0 */ public class GroundRefining extends Refining { @@ -77,36 +77,22 @@ public class GroundRefining extends Refining { /** Ground measurements */ GroundMeasureGenerator measures; - - /** - * Constructor - */ - public GroundRefining() throws RuggedException, OrekitException { - - sensorName = "line"; - pleiadesViewingModel = new PleiadesViewingModel(sensorName); - orbitmodel = new OrbitModel(); - } - /** Main function - * @param args */ public static void main(String[] args) { - - try { - + + try { + // Initialize Orekit, assuming an orekit-data folder is in user home directory // --------------------------------------------------------------------------- File home = new File(System.getProperty("user.home")); File orekitData = new File(home, "COTS/orekit-data"); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(orekitData)); - // Initialize refining context // --------------------------- GroundRefining refining = new GroundRefining(); - // Sensor's definition: create Pleiades viewing model // -------------------------------------------------- System.out.format("**** Build Pleiades viewing model and orbit definition **** %n"); @@ -116,7 +102,6 @@ public class GroundRefining extends Refining { AbsoluteDate refDate = pleiadesViewingModel.getDatationReference(); LineSensor lineSensor = pleiadesViewingModel.getLineSensor(); - // Satellite position, velocity and attitude: create an orbit model // ---------------------------------------------------------------- OrbitModel orbitmodel = refining.getOrbitmodel(); @@ -131,12 +116,14 @@ public class GroundRefining extends Refining { orbitmodel.setLOFTransform(rollPoly, pitchPoly, yawPoly, minDate); // Satellite attitude - List<TimeStampedAngularCoordinates> satelliteQList = orbitmodel.orbitToQ(orbit, earth, minDate.shiftedBy(-0.0), maxDate.shiftedBy(+0.0), 0.25); + List<TimeStampedAngularCoordinates> satelliteQList = + orbitmodel.orbitToQ(orbit, earth, minDate.shiftedBy(-0.0), maxDate.shiftedBy(+0.0), 0.25); int nbQPoints = 2; // Position and velocities PVCoordinates PV = orbit.getPVCoordinates(earth.getBodyFrame()); - List<TimeStampedPVCoordinates> satellitePVList = orbitmodel.orbitToPV(orbit, earth, minDate.shiftedBy(-0.0), maxDate.shiftedBy(+0.0), 0.25); + List<TimeStampedPVCoordinates> satellitePVList = + orbitmodel.orbitToPV(orbit, earth, minDate.shiftedBy(-0.0), maxDate.shiftedBy(+0.0), 0.25); int nbPVPoints = 8; // Convert frame and coordinates type in one call @@ -147,7 +134,6 @@ public class GroundRefining extends Refining { FastMath.toDegrees(gp.getLatitude()), FastMath.toDegrees(gp.getLongitude())); - // Rugged initialization // --------------------- System.out.format("\n**** Rugged initialization **** %n"); @@ -156,24 +142,22 @@ public class GroundRefining extends Refining { ruggedBuilder.addLineSensor(lineSensor); ruggedBuilder.setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID); ruggedBuilder.setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF); - ruggedBuilder.setTimeSpan(minDate,maxDate, 0.001, 5.0). - setTrajectory(InertialFrameId.EME2000, - satellitePVList,nbPVPoints, CartesianDerivativesFilter.USE_PV, - satelliteQList,nbQPoints, AngularDerivativesFilter.USE_R); + ruggedBuilder.setTimeSpan(minDate,maxDate, 0.001, 5.0); + ruggedBuilder.setTrajectory(InertialFrameId.EME2000, satellitePVList,nbPVPoints, + CartesianDerivativesFilter.USE_PV, satelliteQList, + nbQPoints, AngularDerivativesFilter.USE_R); + ruggedBuilder.setName("Rugged_refining"); refining.setRugged(ruggedBuilder.build()); - // Compute ground sample distance (GSD) // ------------------------------------ double [] gsd = refining.computeGSD(lineSensor); System.out.format("GSD - X: %2.2f Y: %2.2f **** %n", gsd[0], gsd[1]); - // Initialize disruptions: // ----------------------- - // Introduce rotations around instrument axes (roll and pitch translations, scale factor) System.out.format("\n**** Add disruptions: roll and pitch rotations, scale factor **** %n"); double rollValue = FastMath.toRadians(-0.01); @@ -185,10 +169,8 @@ public class GroundRefining extends Refining { refining.applyDisruptions(refining.getRugged(), refining.getSensorName(), rollValue, pitchValue, factorValue); - // Generate measures (observations) from physical model disrupted // -------------------------------------------------------------- - int lineSampling = 1000; int pixelSampling = 1000; @@ -199,38 +181,27 @@ public class GroundRefining extends Refining { noise.setMean(mean); noise.setStandardDeviation(standardDeviation); - GroundMeasureGenerator measures = refining.generateNoisyPoints(lineSampling, pixelSampling, refining.getRugged(), refining.getSensorName(), refining.getPleiadesViewingModel().getDimension(), noise); - - // // To test with measures without noise - // GroundMeasureGenerator measures = refining.generatePoints(lineSampling, pixelSampling, - // refining.getRugged(), refining.getSensorName(), - // refining.getPleiadesViewingModel().getDimension()); - refining.setMeasures(measures); - // Compute ground truth residues // ----------------------------- System.out.format("\n**** Ground truth residuals **** %n"); refining.computeMetrics(measures.getGroundMapping(), refining.getRugged(), false); - // Initialize physical model without disruptions // --------------------------------------------- System.out.format("\n**** Initialize physical model without disruptions: reset Roll/Pitch/Factor **** %n"); refining.resetModel(refining.getRugged(), refining.getSensorName(), true); - // Compute initial residues // ------------------------ System.out.format("\n**** Initial Residuals **** %n"); refining.computeMetrics(measures.getGroundMapping(), refining.getRugged(), false); - // Start optimization // ------------------ System.out.format("\n**** Start optimization **** %n"); @@ -240,14 +211,12 @@ public class GroundRefining extends Refining { refining.optimization(maxIterations, convergenceThreshold, measures.getObservables(), refining.getRugged()); - // Check estimated values // ---------------------- System.out.format("\n**** Check parameters ajustement **** %n"); refining.paramsEstimation(refining.getRugged(), refining.getSensorName(), rollValue, pitchValue, factorValue); - // Compute statistics // ------------------ System.out.format("\n**** Compute Statistics **** %n"); @@ -258,7 +227,6 @@ public class GroundRefining extends Refining { // Residues computed in degrees refining.computeMetrics(measures.getGroundMapping(), refining.getRugged(), true); - } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); @@ -266,111 +234,116 @@ public class GroundRefining extends Refining { System.err.println(re.getLocalizedMessage()); System.exit(1); } + } + + /** Constructor */ + public GroundRefining() throws RuggedException, OrekitException { + sensorName = "line"; + pleiadesViewingModel = new PleiadesViewingModel(sensorName); + orbitmodel = new OrbitModel(); } + /** Estimate ground sample distance (GSD) + * @param LineSensor line sensor + * @return the GSD + */ + private double[] computeGSD(final LineSensor lineSensor) throws RuggedException { + + // Get position + Vector3D position = lineSensor.getPosition(); // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. + + // Get upper left geodetic point + AbsoluteDate firstLineDate = lineSensor.getDate(0); + Vector3D los = lineSensor.getLOS(firstLineDate,0); + GeodeticPoint upLeftPoint = rugged.directLocation(firstLineDate, position, los); + los = lineSensor.getLOS(firstLineDate,pleiadesViewingModel.dimension-1); + + // Get center geodetic point + AbsoluteDate lineDate = lineSensor.getDate(pleiadesViewingModel.dimension/2); + los = lineSensor.getLOS(lineDate,pleiadesViewingModel.dimension/2); + + // Get upper right geodetic point + int pixelPosition = pleiadesViewingModel.dimension-1; + los = lineSensor.getLOS(firstLineDate,pixelPosition); + GeodeticPoint upperRight = rugged.directLocation(firstLineDate, position, los); + + // Get lower left geodetic point + AbsoluteDate lineDate_y = lineSensor.getDate(pleiadesViewingModel.dimension-1); + los = lineSensor.getLOS(lineDate_y,0); + GeodeticPoint lowerLeft = rugged.directLocation(lineDate_y, position, los); + + double gsdX = DistanceTools.computeDistanceInMeter(upLeftPoint.getLongitude(), upLeftPoint.getLatitude(), + upperRight.getLongitude() , upperRight.getLatitude())/pleiadesViewingModel.dimension; + double gsdY = DistanceTools.computeDistanceInMeter(upLeftPoint.getLongitude(), upLeftPoint.getLatitude(), + lowerLeft.getLongitude() , lowerLeft.getLatitude())/pleiadesViewingModel.dimension; + + double [] gsd = {gsdX, gsdY}; + return gsd; + } + /** - * @return the pleiadesViewingModel + * Get the Pleiades viewing model + * @return the Pleiades viewing model */ public PleiadesViewingModel getPleiadesViewingModel() { return pleiadesViewingModel; } - /** - * @param pleiadesViewingModel the pleiadesViewingModel to set + * Set the Pleiades viewing model + * @param pleiadesViewingModel Pleiades viewing model to set */ public void setPleiadesViewingModel(PleiadesViewingModel pleiadesViewingModel) { this.pleiadesViewingModel = pleiadesViewingModel; } - /** - * @return the orbitmodel + * Get the orbit model + * @return the orbit model */ public OrbitModel getOrbitmodel() { return orbitmodel; } - /** - * @param orbitmodel the orbitmodel to set + * Set the orbit model + * @param orbitmodel the orbit model to set */ public void setOrbitmodel(OrbitModel orbitmodel) { this.orbitmodel = orbitmodel; } - /** - * @return the sensorName + * Get the sensor name + * @return the sensor name */ public String getSensorName() { return sensorName; } - /** - * @return the rugged + * Get the Rugged instance + * @return the rugged instance */ public Rugged getRugged() { return rugged; } - /** - * @param rugged the rugged to set + * Set the Rugged instance + * @param rugged the Rugged instance to set */ public void setRugged(Rugged rugged) { this.rugged = rugged; } - /** - * @param measure the measure to set + * Set the measures + * @param measures the measures to set */ public void setMeasures(GroundMeasureGenerator measures) { this.measures = measures; } - - - /** Estimate ground sample distance (GSD) - * @param LineSensor line sensor - * @return GSD - */ - private double[] computeGSD(final LineSensor lineSensor) throws RuggedException { - - // Get position - Vector3D position = lineSensor.getPosition(); // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. - - // Get upper left geodetic point - AbsoluteDate firstLineDate = lineSensor.getDate(0); - Vector3D los = lineSensor.getLOS(firstLineDate,0); - GeodeticPoint upLeftPoint = rugged.directLocation(firstLineDate, position, los); - los = lineSensor.getLOS(firstLineDate,pleiadesViewingModel.dimension-1); - - // Get center geodetic point - AbsoluteDate lineDate = lineSensor.getDate(pleiadesViewingModel.dimension/2); - los = lineSensor.getLOS(lineDate,pleiadesViewingModel.dimension/2); - // GeodeticPoint centerPoint = rugged.directLocation(lineDate, position, los); - // System.out.format(Locale.US, "center geodetic position : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", - // FastMath.toDegrees(centerPoint.getLatitude()), - // FastMath.toDegrees(centerPoint.getLongitude()),centerPoint.getAltitude()); - - // Get upper right geodetic point - int pixelPosition = pleiadesViewingModel.dimension-1; - los = lineSensor.getLOS(firstLineDate,pixelPosition); - GeodeticPoint upperRight = rugged.directLocation(firstLineDate, position, los); - - // Get lower left geodetic point - AbsoluteDate lineDate_y = lineSensor.getDate(pleiadesViewingModel.dimension-1); - los = lineSensor.getLOS(lineDate_y,0); - GeodeticPoint lowerLeft = rugged.directLocation(lineDate_y, position, los); - - double gsdX = DistanceTools.computeDistanceInMeter(upLeftPoint.getLongitude(), upLeftPoint.getLatitude(),upperRight.getLongitude() , upperRight.getLatitude())/pleiadesViewingModel.dimension; - double gsdY = DistanceTools.computeDistanceInMeter(upLeftPoint.getLongitude(), upLeftPoint.getLatitude(),lowerLeft.getLongitude() , lowerLeft.getLatitude())/pleiadesViewingModel.dimension; - - double [] gsd = {gsdX, gsdY}; - return gsd; - } } diff --git a/src/tutorials/java/RefiningPleiades/InterRefining.java b/src/tutorials/java/RefiningPleiades/InterRefining.java index 2770e384..9d17f7a2 100644 --- a/src/tutorials/java/RefiningPleiades/InterRefining.java +++ b/src/tutorials/java/RefiningPleiades/InterRefining.java @@ -1,4 +1,4 @@ -/* Copyright 2013-2016 CS Systèmes d'Information +/* Copyright 2013-2017 CS Systèmes d'Information * Licensed to CS Systèmes d'Information (CS) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -16,7 +16,6 @@ */ package RefiningPleiades; - import java.io.File; import java.util.Arrays; import java.util.Collection; @@ -54,89 +53,65 @@ import org.orekit.utils.PVCoordinates; import org.orekit.utils.TimeStampedAngularCoordinates; import org.orekit.utils.TimeStampedPVCoordinates; - - /** * Class for testing refining (liaison points study) * with or without noisy measurements * @author Jonathan Guinet * @author Lucie Labat-Allee + * @author Guylaine Prat * @see SensorToGroundMapping * @see GroundMeasureGenerator + * @since 2.0 */ public class InterRefining extends Refining { - /** Pleiades viewing model A */ - PleiadesViewingModel pleiadesViewingModelA; - - /** Pleiades viewing model B */ - PleiadesViewingModel pleiadesViewingModelB; - - /** Orbit model corresponding to viewing model A */ - OrbitModel orbitmodelA; - - /** Orbit model corresponding to viewing model B */ - OrbitModel orbitmodelB; - - /** Sensor name A corresponding to viewing model A */ - String sensorNameA; - - /** Sensor name A corresponding to viewing model B */ - String sensorNameB; - - /** RuggedA 's instance */ - Rugged ruggedA; - - /** RuggedB 's instance */ - Rugged ruggedB; + /** Pleiades viewing model A */ + PleiadesViewingModel pleiadesViewingModelA; - /** Inter-measurements (between both viewing models) */ - InterMeasureGenerator measures; + /** Pleiades viewing model B */ + PleiadesViewingModel pleiadesViewingModelB; + /** Orbit model corresponding to viewing model A */ + OrbitModel orbitmodelA; - /** - * Constructor - */ - public InterRefining() throws RuggedException, OrekitException { - - sensorNameA = "SensorA"; - final double incidenceAngleA = -5.0; - final String dateA = "2016-01-01T11:59:50.0"; - - pleiadesViewingModelA = new PleiadesViewingModel(sensorNameA, incidenceAngleA, dateA); - - sensorNameB = "SensorB"; - final double incidenceAngleB = 0.0; - final String dateB = "2016-01-01T12:02:50.0"; + /** Orbit model corresponding to viewing model B */ + OrbitModel orbitmodelB; - pleiadesViewingModelB = new PleiadesViewingModel(sensorNameB, incidenceAngleB, dateB); - - orbitmodelA = new OrbitModel(); - orbitmodelB = new OrbitModel(); - } + /** Sensor name A corresponding to viewing model A */ + String sensorNameA; + /** Sensor name A corresponding to viewing model B */ + String sensorNameB; - /** Main functions - * @param args - */ - public static void main(String[] args) { + /** RuggedA's instance */ + Rugged ruggedA; - try { + /** RuggedB's instance */ + Rugged ruggedB; - // Initialize Orekit, assuming an orekit-data folder is in user home directory - // --------------------------------------------------------------------------- - File home = new File(System.getProperty("user.home")); - File orekitData = new File(home, "COTS/orekit-data"); - DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(orekitData)); + /** Inter-measurements (between both viewing models) */ + InterMeasureGenerator measures; - // Initialize refining context - // --------------------------- - InterRefining refining = new InterRefining(); + /** Main function + */ + public static void main(String[] args) { + + try { + + // Initialize Orekit, assuming an orekit-data folder is in user home directory + // --------------------------------------------------------------------------- + File home = new File(System.getProperty("user.home")); + File orekitData = new File(home, "COTS/orekit-data"); + DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(orekitData)); + // Initialize refining context + // --------------------------- + InterRefining refining = new InterRefining(); - // Sensors's definition: create 2 Pleiades viewing models - // ------------------------------------------------------ + // Sensors's definition: creation of 2 Pleiades viewing models + // ----------------------------------------------------------- + System.out.format("**** Build Pleiades viewing model A and its orbit definition **** %n"); // 1/- Create First Pleiades Viewing Model @@ -176,7 +151,6 @@ public class InterRefining extends Refining { FastMath.toDegrees(gpA.getLatitude()), FastMath.toDegrees(gpA.getLongitude())); - // Rugged A initialization // --------------------- System.out.format("**** Rugged A initialization **** %n"); @@ -185,16 +159,20 @@ public class InterRefining extends Refining { ruggedBuilderA.addLineSensor(lineSensorA); ruggedBuilderA.setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID); ruggedBuilderA.setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF); - ruggedBuilderA.setTimeSpan(minDateA,maxDateA, 0.001, 5.0). - setTrajectory(InertialFrameId.EME2000, satellitePVListA, nbPVPoints, CartesianDerivativesFilter.USE_PV, - satelliteQListA, nbQPoints, AngularDerivativesFilter.USE_R) - .setLightTimeCorrection(false) - .setAberrationOfLightCorrection(false); + ruggedBuilderA.setTimeSpan(minDateA,maxDateA, 0.001, 5.0); + ruggedBuilderA.setTrajectory(InertialFrameId.EME2000, satellitePVListA, nbPVPoints, + CartesianDerivativesFilter.USE_PV, satelliteQListA, + nbQPoints, AngularDerivativesFilter.USE_R); + ruggedBuilderA.setLightTimeCorrection(false); + ruggedBuilderA.setAberrationOfLightCorrection(false); + ruggedBuilderA.setName("RuggedA"); + refining.setRuggedA(ruggedBuilderA.build()); - + System.out.format("\n**** Build Pleiades viewing model B and its orbit definition **** %n"); + // 2/- Create Second Pleiades Viewing Model PleiadesViewingModel pleiadesViewingModelB = refining.getPleiadesViewingModelB(); final AbsoluteDate minDateB = pleiadesViewingModelB.getMinDate(); @@ -208,7 +186,6 @@ public class InterRefining extends Refining { BodyShape earthB = orbitmodelB.createEarth(); NormalizedSphericalHarmonicsProvider gravityFieldB = orbitmodelB.createGravityField(); Orbit orbitB = orbitmodelB.createOrbit(gravityFieldB.getMu(), refDateB); - //orbitmodelB.setLOFTransform(rollPoly, pitchPoly, yawPoly, minDateB); // ----Satellite attitude List<TimeStampedAngularCoordinates> satelliteQListB = orbitmodelB.orbitToQ(orbitB, earthB, minDateB.shiftedBy(-0.0), maxDateB.shiftedBy(+0.0), 0.25); @@ -231,16 +208,17 @@ public class InterRefining extends Refining { ruggedBuilderB.addLineSensor(lineSensorB); ruggedBuilderB.setAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID); ruggedBuilderB.setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF); - ruggedBuilderB.setTimeSpan(minDateB,maxDateB, 0.001, 5.0). - setTrajectory(InertialFrameId.EME2000, satellitePVListB, nbPVPoints, CartesianDerivativesFilter.USE_PV, - satelliteQListB, nbQPoints, AngularDerivativesFilter.USE_R) - .setLightTimeCorrection(false) - .setAberrationOfLightCorrection(false); + ruggedBuilderB.setTimeSpan(minDateB,maxDateB, 0.001, 5.0); + ruggedBuilderB.setTrajectory(InertialFrameId.EME2000, satellitePVListB, nbPVPoints, + CartesianDerivativesFilter.USE_PV, satelliteQListB, + nbQPoints, AngularDerivativesFilter.USE_R); + ruggedBuilderB.setLightTimeCorrection(false); + ruggedBuilderB.setAberrationOfLightCorrection(false); + ruggedBuilderB.setName("RuggedB"); + refining.setRuggedB(ruggedBuilderB.build()); - - // Compute distance between LOS // ----------------------------- double distance = refining.computeDistance(lineSensorA, lineSensorB); @@ -269,17 +247,19 @@ public class InterRefining extends Refining { rollValueB, pitchValueB, factorValue); - // Generate measures (observations) from physical model disrupted // -------------------------------------------------------------- - int lineSampling = 1000; int pixelSampling = 1000; // Noise definition - final Noise noise = new Noise(0,2); /* distribution: gaussian(0), vector dimension:3 */ - final double[] mean = {5.0,0.0}; /* {pixelA mean, pixelB mean} */ - final double[] standardDeviation = {0.1,0.1}; /* {pixelB std, pixelB std} */ + // distribution: gaussian(0), vector dimension: 2 + final Noise noise = new Noise(0,2); + // {pixelA mean, pixelB mean} + final double[] mean = {5.0,0.0}; + // {pixelB std, pixelB std} + final double[] standardDeviation = {0.1,0.1}; + noise.setMean(mean); noise.setStandardDeviation(standardDeviation); @@ -292,36 +272,24 @@ public class InterRefining extends Refining { refining.getRuggedB(), refining.getSensorNameB(), refining.getPleiadesViewingModelB().getDimension(), noise); - - // // To test with measures without noise - // InterMeasureGenerator measures = refining.generatePoints(lineSampling, pixelSampling, - // refining.getRuggedA(), refining.getSensorNameA(), - // refining.getPleiadesViewingModelA().getDimension(), - // refining.getRuggedB(), refining.getSensorNameB(), - // refining.getPleiadesViewingModelB().getDimension()); - refining.setMeasures(measures); - // Compute ground truth residues // ----------------------------- System.out.format("\n**** Ground truth residuals **** %n"); refining.computeMetrics(measures.getInterMapping(), refining.getRuggedA(), refining.getRuggedB(), false); - // Initialize physical models without disruptions // ----------------------------------------------- System.out.format("\n**** Initialize physical models (A,B) without disruptions: reset Roll/Pitch/Factor **** %n"); refining.resetModel(refining.getRuggedA(), refining.getSensorNameA(), false); refining.resetModel(refining.getRuggedB(), refining.getSensorNameB(), false); - // Compute initial residues // ------------------------ System.out.format("\n**** Initial Residuals **** %n"); refining.computeMetrics(measures.getInterMapping(), refining.getRuggedA(), refining.getRuggedB(), false); - // Start optimization // ------------------ System.out.format("\n**** Start optimization **** %n"); @@ -333,7 +301,6 @@ public class InterRefining extends Refining { measures.getObservables(), refining.getRuggeds()); - // Check estimated values // ---------------------- System.out.format("\n**** Check parameters ajustement **** %n"); @@ -351,8 +318,6 @@ public class InterRefining extends Refining { System.out.format("\n**** Compute Statistics **** %n"); refining.computeMetrics(measures.getInterMapping(), refining.getRuggedA(), refining.getRuggedB(), false); - - } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); @@ -360,10 +325,76 @@ public class InterRefining extends Refining { System.err.println(re.getLocalizedMessage()); System.exit(1); } - } + /** Constructor */ + public InterRefining() throws RuggedException, OrekitException { + + sensorNameA = "SensorA"; + final double incidenceAngleA = -5.0; + final String dateA = "2016-01-01T11:59:50.0"; + + pleiadesViewingModelA = new PleiadesViewingModel(sensorNameA, incidenceAngleA, dateA); + + sensorNameB = "SensorB"; + final double incidenceAngleB = 0.0; + final String dateB = "2016-01-01T12:02:50.0"; + + pleiadesViewingModelB = new PleiadesViewingModel(sensorNameB, incidenceAngleB, dateB); + + orbitmodelA = new OrbitModel(); + orbitmodelB = new OrbitModel(); + } + + /** Estimate distance between LOS + * @param lineSensorA line sensor A + * @param lineSensorB line sensor B + * @return GSD + */ + private double computeDistance(final LineSensor lineSensorA, final LineSensor lineSensorB) throws RuggedException { + + Vector3D positionA = lineSensorA.getPosition(); + // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. + + + AbsoluteDate lineDateA = lineSensorA.getDate(pleiadesViewingModelA.dimension/2); + Vector3D losA = lineSensorA.getLOS(lineDateA,pleiadesViewingModelA.dimension/2); + GeodeticPoint centerPointA = ruggedA.directLocation(lineDateA, positionA, losA); + System.out.format(Locale.US, "\ncenter geodetic position A : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", + FastMath.toDegrees(centerPointA.getLatitude()), + FastMath.toDegrees(centerPointA.getLongitude()),centerPointA.getAltitude()); + + + Vector3D positionB = lineSensorB.getPosition(); + // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. + + AbsoluteDate lineDateB = lineSensorB.getDate(pleiadesViewingModelB.dimension/2); + Vector3D losB = lineSensorB.getLOS(lineDateB,pleiadesViewingModelB.dimension/2); + GeodeticPoint centerPointB = ruggedB.directLocation(lineDateB, positionB, losB); + System.out.format(Locale.US, "center geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", + FastMath.toDegrees(centerPointB.getLatitude()), + FastMath.toDegrees(centerPointB.getLongitude()),centerPointB.getAltitude()); + + + lineDateB = lineSensorB.getDate(0); + losB = lineSensorB.getLOS(lineDateB,0); + GeodeticPoint firstPointB = ruggedB.directLocation(lineDateB, positionB, losB); + System.out.format(Locale.US, "first geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", + FastMath.toDegrees(firstPointB.getLatitude()), + FastMath.toDegrees(firstPointB.getLongitude()),firstPointB.getAltitude()); + + lineDateB = lineSensorB.getDate(pleiadesViewingModelB.dimension-1); + losB = lineSensorB.getLOS(lineDateB,pleiadesViewingModelB.dimension-1); + GeodeticPoint lastPointB = ruggedB.directLocation(lineDateB, positionB, losB); + System.out.format(Locale.US, "last geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", + FastMath.toDegrees(lastPointB.getLatitude()), + FastMath.toDegrees(lastPointB.getLongitude()),lastPointB.getAltitude()); + double distance = DistanceTools.computeDistanceInMeter(centerPointA.getLongitude(), centerPointA.getLatitude(), + centerPointB.getLongitude(), centerPointB.getLatitude()); + + return distance; + } /** * @return the pleiadesViewingModelA @@ -372,8 +403,6 @@ public class InterRefining extends Refining { return pleiadesViewingModelA; } - - /** * @param pleiadesViewingModelA the pleiadesViewingModelA to set */ @@ -382,8 +411,6 @@ public class InterRefining extends Refining { this.pleiadesViewingModelA = pleiadesViewingModelA; } - - /** * @return the pleiadesViewingModelB */ @@ -391,8 +418,6 @@ public class InterRefining extends Refining { return pleiadesViewingModelB; } - - /** * @param pleiadesViewingModelB the pleiadesViewingModelB to set */ @@ -401,8 +426,6 @@ public class InterRefining extends Refining { this.pleiadesViewingModelB = pleiadesViewingModelB; } - - /** * @return the orbitmodelA */ @@ -410,8 +433,6 @@ public class InterRefining extends Refining { return orbitmodelA; } - - /** * @param orbitmodelA the orbitmodelA to set */ @@ -419,8 +440,6 @@ public class InterRefining extends Refining { this.orbitmodelA = orbitmodelA; } - - /** * @return the orbitmodelB */ @@ -428,8 +447,6 @@ public class InterRefining extends Refining { return orbitmodelB; } - - /** * @param orbitmodelB the orbitmodelB to set */ @@ -437,9 +454,6 @@ public class InterRefining extends Refining { this.orbitmodelB = orbitmodelB; } - - - /** * @return the sensorNameA */ @@ -447,8 +461,6 @@ public class InterRefining extends Refining { return sensorNameA; } - - /** * @return the sensorNameB */ @@ -456,7 +468,6 @@ public class InterRefining extends Refining { return sensorNameB; } - /** * @return the ruggedA */ @@ -464,8 +475,6 @@ public class InterRefining extends Refining { return ruggedA; } - - /** * @param ruggedA the ruggedA to set */ @@ -473,7 +482,6 @@ public class InterRefining extends Refining { this.ruggedA = ruggedA; } - /** * @return the ruggedB */ @@ -489,8 +497,6 @@ public class InterRefining extends Refining { return ruggedList; } - - /** * @param ruggedB the ruggedB to set */ @@ -498,63 +504,10 @@ public class InterRefining extends Refining { this.ruggedB = ruggedB; } - /** * @param measures the measures to set */ public void setMeasures(InterMeasureGenerator measures) { this.measures = measures; } - - - /** Estimate distance between LOS - * @param lineSensorA line sensor A - * @param lineSensorB line sensor B - * @return GSD - */ - private double computeDistance(final LineSensor lineSensorA, final LineSensor lineSensorB) throws RuggedException { - - Vector3D positionA = lineSensorA.getPosition(); // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. - - AbsoluteDate lineDateA = lineSensorA.getDate(pleiadesViewingModelA.dimension/2); - Vector3D losA = lineSensorA.getLOS(lineDateA,pleiadesViewingModelA.dimension/2); - GeodeticPoint centerPointA = ruggedA.directLocation(lineDateA, positionA, losA); - System.out.format(Locale.US, "\ncenter geodetic position A : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", - FastMath.toDegrees(centerPointA.getLatitude()), - FastMath.toDegrees(centerPointA.getLongitude()),centerPointA.getAltitude()); - - - Vector3D positionB = lineSensorB.getPosition(); // This returns a zero vector since we set the relative position of the sensor w.r.T the satellite to 0. - - AbsoluteDate lineDateB = lineSensorB.getDate(pleiadesViewingModelB.dimension/2); - Vector3D losB = lineSensorB.getLOS(lineDateB,pleiadesViewingModelB.dimension/2); - GeodeticPoint centerPointB = ruggedB.directLocation(lineDateB, positionB, losB); - System.out.format(Locale.US, "center geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", - FastMath.toDegrees(centerPointB.getLatitude()), - FastMath.toDegrees(centerPointB.getLongitude()),centerPointB.getAltitude()); - - - lineDateB = lineSensorB.getDate(0); - losB = lineSensorB.getLOS(lineDateB,0); - GeodeticPoint firstPointB = ruggedB.directLocation(lineDateB, positionB, losB); - System.out.format(Locale.US, "first geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", - FastMath.toDegrees(firstPointB.getLatitude()), - FastMath.toDegrees(firstPointB.getLongitude()),firstPointB.getAltitude()); - - lineDateB = lineSensorB.getDate(pleiadesViewingModelB.dimension-1); - losB = lineSensorB.getLOS(lineDateB,pleiadesViewingModelB.dimension-1); - GeodeticPoint lastPointB = ruggedB.directLocation(lineDateB, positionB, losB); - System.out.format(Locale.US, "last geodetic position B : φ = %8.10f °, λ = %8.10f °, h = %8.3f m%n", - FastMath.toDegrees(lastPointB.getLatitude()), - FastMath.toDegrees(lastPointB.getLongitude()),lastPointB.getAltitude()); - - double distance = DistanceTools.computeDistanceInMeter(centerPointA.getLongitude(), centerPointA.getLatitude(), - centerPointB.getLongitude(), centerPointB.getLatitude()); - - return distance; - } - - - - } diff --git a/src/tutorials/java/RefiningPleiades/Refining.java b/src/tutorials/java/RefiningPleiades/Refining.java index e100cfc1..5d71a81f 100644 --- a/src/tutorials/java/RefiningPleiades/Refining.java +++ b/src/tutorials/java/RefiningPleiades/Refining.java @@ -1,4 +1,4 @@ -/* Copyright 2013-2016 CS Systèmes d'Information +/* Copyright 2013-2017 Systèmes d'Information * Licensed to CS Systèmes d'Information (CS) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -36,40 +36,36 @@ import org.orekit.rugged.refining.measures.SensorToGroundMapping; import org.orekit.rugged.refining.measures.SensorToSensorMapping; import org.orekit.rugged.refining.metrics.LocalisationMetrics; - - /** - * Class for refining + * Class for refining problems common methods * @author Jonathan Guinet * @author Lucie Labat-Allee + * @author Guylaine Prat * @see SensorToGroundMapping * @see SensorToSensorMapping * @see GroundMeasureGenerator * @see InterMeasureGenerator + * @since 2.0 */ public class Refining { - /** * Constructor */ - public Refining() throws RuggedException, OrekitException { - + public Refining() throws RuggedException { } - - /** Apply disruptions on acquisition + /** Apply disruptions on acquisition for roll, pitch and scale factor * @param rugged Rugged instance * @param sensorName line sensor name - * @param rollValue rotation on roll value - * @param pitchValue rotation on pitch value - * @param factorValue scale factor - * @throws OrekitException + * @param rollValue rotation on roll value + * @param pitchValue rotation on pitch value + * @param factorValue scale factor * @throws RuggedException */ public void applyDisruptions(Rugged rugged, String sensorName, double rollValue, double pitchValue, double factorValue) - throws OrekitException, RuggedException { + throws OrekitException, RuggedException { final String commonFactorName = "factor"; @@ -92,24 +88,22 @@ public class Refining { findFirst().get().setValue(factorValue); } - - /** Generate measurements without noise + /** Generate measurements without noise (sensor to ground mapping) * @param lineSampling line sampling * @param pixelSampling pixel sampling * @param rugged Rugged instance * @param sensorName line sensor name - * @param dimension dimension - * @throws OrekitException - * @throws RuggedException + * @param dimension number of line of the sensor * @return ground measures generator (sensor to ground mapping) + * @throws RuggedException */ public GroundMeasureGenerator generatePoints(int lineSampling, int pixelSampling, Rugged rugged, String sensorName, - int dimension) throws OrekitException, RuggedException { + int dimension) throws RuggedException { GroundMeasureGenerator measures = new GroundMeasureGenerator(rugged, sensorName, dimension); - System.out.format("\n**** Generate measures (without noise) **** %n"); + System.out.format("\n**** Generate measures (without noise; sensor to ground mapping) **** %n"); // Generation measures without noise measures.createMeasure(lineSampling, pixelSampling); @@ -119,8 +113,7 @@ public class Refining { return measures; } - - /** Generate measurements without noise + /** Generate measurements without noise (sensor to sensor mapping) * @param lineSampling line sampling * @param pixelSampling pixel sampling * @param ruggedA Rugged instance of acquisition A @@ -129,24 +122,25 @@ public class Refining { * @param ruggedB Rugged instance of acquisition B * @param sensorNameB line sensor name B * @param dimensionB dimension for acquisition B - * @throws OrekitException - * @throws RuggedException * @return inter measures generator (sensor to sensor mapping) + * @throws RuggedException */ public InterMeasureGenerator generatePoints(int lineSampling, int pixelSampling, Rugged ruggedA, String sensorNameA, int dimensionA, - Rugged ruggedB, String sensorNameB, int dimensionB) throws OrekitException, RuggedException { + Rugged ruggedB, String sensorNameB, int dimensionB) throws RuggedException { - final double outlierValue = 1e+2; // outliers control - final double earthConstraintWeight = 0.1; // earth constraint weight + // Outliers control + final double outlierValue = 1e+2; + // Earth constraint weight + final double earthConstraintWeight = 0.1; - /* Generate measures with constraints on Earth distance and outliers control */ + // Generate measures with constraints on outliers control and Earth distance InterMeasureGenerator measures = new InterMeasureGenerator(ruggedA, sensorNameA, dimensionA, ruggedB, sensorNameB, dimensionB, outlierValue, earthConstraintWeight); - System.out.format("\n**** Generate measures (without noise) **** %n"); + System.out.format("\n**** Generate measures (without noise; sensor to sensor mapping) **** %n"); // Generation measures without noise measures.createMeasure(lineSampling, pixelSampling); @@ -156,27 +150,26 @@ public class Refining { return measures; } - - /** Generate noisy measurements + /** Generate noisy measurements (sensor to ground mapping) * @param lineSampling line sampling * @param pixelSampling pixel sampling * @param rugged Rugged instance * @param sensorName line sensor name * @param dimension dimension * @param noise Noise structure to generate noisy measures - * @throws OrekitException - * @throws RuggedException * @return ground measures generator (sensor to ground mapping) + * @throws RuggedException */ public GroundMeasureGenerator generateNoisyPoints(int lineSampling, int pixelSampling, Rugged rugged, String sensorName, int dimension, - Noise noise) throws OrekitException, RuggedException { + Noise noise) throws RuggedException { - GroundMeasureGenerator measures = new GroundMeasureGenerator(rugged, sensorName, dimension); + // Generate ground measures + GroundMeasureGenerator measures = new GroundMeasureGenerator(rugged, sensorName, dimension); - System.out.format("\n**** Generate noisy measures **** %n"); + System.out.format("\n**** Generate noisy measures (sensor to ground mapping) **** %n"); - // Generation noisy measures + // Generate noisy measures measures.createNoisyMeasure(lineSampling, pixelSampling, noise); System.out.format("Number of tie points generated: %d %n", measures.getMeasureCount()); @@ -184,8 +177,7 @@ public class Refining { return measures; } - - /** Generate noisy measurements + /** Generate noisy measurements (sensor to sensor mapping) * @param lineSampling line sampling * @param pixelSampling pixel sampling * @param ruggedA Rugged instance of acquisition A @@ -194,25 +186,27 @@ public class Refining { * @param ruggedB Rugged instance of acquisition B * @param sensorNameB line sensor name B * @param dimensionB dimension for acquisition B - * @param noise Noise structure to generate noisy measures - * @throws OrekitException + * @param noise noise structure to generate noisy measures + * @return inter-measures generator (sensor to sensor mapping) * @throws RuggedException - * @return inter measures generator (sensor to sensor mapping) */ public InterMeasureGenerator generateNoisyPoints(int lineSampling, int pixelSampling, Rugged ruggedA, String sensorNameA, int dimensionA, Rugged ruggedB, String sensorNameB, int dimensionB, - Noise noise) throws OrekitException, RuggedException { + Noise noise) throws RuggedException { - final double outlierValue = 1e+2; // outliers control - final double earthConstraintWeight = 0.1; // earth constraint weight + // Outliers control + final double outlierValue = 1.e+2; + + // Earth constraint weight + final double earthConstraintWeight = 0.1; - /* Generate measures with constraints on Earth distance and outliers control */ + // Generate measures with constraints on Earth distance and outliers control InterMeasureGenerator measures = new InterMeasureGenerator(ruggedA, sensorNameA, dimensionA, ruggedB, sensorNameB, dimensionB, outlierValue, earthConstraintWeight); - System.out.format("\n**** Generate noisy measures **** %n"); + System.out.format("\n**** Generate noisy measures (sensor to sensor mapping) **** %n"); // Generation noisy measures measures.createNoisyMeasure(lineSampling, pixelSampling, noise); @@ -222,34 +216,33 @@ public class Refining { return measures; } - /** Compute metrics to evaluate geometric performances in location, * for fulcrum points study. * @param groundMapping sensor to ground mapping * @param rugged Rugged instance - * @param unit flag to known distance's unit - * @throws OrekitException + * @param unit flag to know if distance is computed in meters (false) or with angular (true) * @throws RuggedException */ public void computeMetrics(SensorToGroundMapping groundMapping, Rugged rugged, boolean unit) throws RuggedException { String stUnit = null; - if(unit) stUnit="degrees"; - else stUnit="meters"; + if(unit) { + stUnit="degrees"; + } else { + stUnit="meters"; + } LocalisationMetrics residues = new LocalisationMetrics(groundMapping, rugged, unit); System.out.format("Max: %3.4e Mean: %3.4e %s%n",residues.getMaxResidual(),residues.getMeanResidual(), stUnit); } - /** Compute metrics to evaluate geometric performances in location, * for liaison points study. * @param interMapping sensor to sensor mapping * @param ruggedA Rugged instance A * @param ruggedB Rugged instance B - * @param unit flag to known distance's unit - * @throws OrekitException + * @param unit flag to know if distance is computed in meters (false) or with angular (true) * @throws RuggedException */ public void computeMetrics(SensorToSensorMapping interMapping, @@ -266,15 +259,13 @@ public class Refining { System.out.format("Earth distance Max: %1.4e Mean: %1.4e %s%n",residues.getEarthMaxDistance(),residues.getEarthMeanDistance(), stUnit); } - /** Reset a model * @param rugged Rugged instance * @param sensorName line sensor name * @param isSelected flag to known if factor parameter is selected or not - * @throws OrekitException * @throws RuggedException */ - public void resetModel(Rugged rugged, String sensorName, boolean isSelected) throws OrekitException, RuggedException { + public void resetModel(Rugged rugged, String sensorName, boolean isSelected) throws RuggedException { final String commonFactorName = "factor"; @@ -291,6 +282,7 @@ public class Refining { throw new OrekitExceptionWrapper(e); } }); + rugged. getLineSensor(sensorName). getParametersDrivers(). @@ -298,29 +290,24 @@ public class Refining { forEach(driver -> { try { driver.setSelected(isSelected); - driver.setValue(1.0); // default value: no Z scale factor applied + + // default value: no Z scale factor applied + driver.setValue(1.0); } catch (OrekitException e) { throw new OrekitExceptionWrapper(e); } }); - } - - - /** Start optimization to adjust parameters (fulcrum points study). * @param maxIterations iterations max * @param convergenceThreshold threshold of convergence * @param measures ground measures * @param rugged Rugged instance - * @throws OrekitException * @throws RuggedException */ public void optimization(int maxIterations, double convergenceThreshold, - Observables measures, - Rugged rugged) throws OrekitException, RuggedException { - + Observables measures, Rugged rugged) throws RuggedException { System.out.format("Iterations max: %d\tconvergence threshold: %3.6e \n", maxIterations, convergenceThreshold); @@ -333,24 +320,20 @@ public class Refining { System.out.format("RMSE: %f \n", optimum.getRMS()); } - /** Start optimization to adjust parameters (liaison points study). * @param maxIterations iterations max * @param convergenceThreshold threshold of convergence - * @param interMapping sensor to sensor mapping - * @param ruggedA Rugged instance A - * @param ruggedB Rugged instance B - * @throws OrekitException + * @param measures measures + * @param ruggeds Rugged instances A and B * @throws RuggedException */ public void optimization(int maxIterations, double convergenceThreshold, Observables measures, - Collection<Rugged> ruggeds) throws OrekitException, RuggedException { - + Collection<Rugged> ruggeds) throws RuggedException { System.out.format("Iterations max: %d\tconvergence threshold: %3.6e \n", maxIterations, convergenceThreshold); - if(ruggeds.size()!= 2 ) - { + + if(ruggeds.size()!= 2 ) { throw new RuggedException(RuggedMessages.UNSUPPORTED_REFINING_CONTEXT,ruggeds.size()); } @@ -361,7 +344,6 @@ public class Refining { ruggedNameList.add(rugged.getName()); } - Optimum optimum = adjustmentContext.estimateFreeParameters(ruggedNameList, maxIterations, convergenceThreshold); // Print statistics @@ -370,21 +352,19 @@ public class Refining { System.out.format("RMSE: %f \n", optimum.getRMS()); } - /** Check adjusted parameters of an acquisition * @param rugged Rugged instance * @param sensorName line sensor name - * @param rollValue rotation on roll value - * @param pitchValue rotation on pitch value - * @param factorValue scale factor - * @throws OrekitException + * @param rollValue rotation on roll value + * @param pitchValue rotation on pitch value + * @param factorValue scale factor * @throws RuggedException */ public void paramsEstimation(Rugged rugged, String sensorName, double rollValue, double pitchValue, double factorValue) - throws OrekitException, RuggedException { + throws RuggedException { - final String commonFactorName = "factor"; + final String commonFactorName = "factor"; // Estimate Roll double estimatedRoll = rugged.getLineSensor(sensorName). @@ -404,7 +384,7 @@ public class Refining { double pitchError = (estimatedPitch - pitchValue); System.out.format("Estimated pitch: %3.5f\tpitch error: %3.6e %n", estimatedPitch, pitchError); - // Estimate factor + // Estimate scale factor double estimatedFactor = rugged.getLineSensor(sensorName). getParametersDrivers(). filter(driver -> driver.getName().equals(commonFactorName)). -- GitLab