diff --git a/src/main/java/org/orekit/rugged/adjustment/AdjustmentContext.java b/src/main/java/org/orekit/rugged/adjustment/AdjustmentContext.java index aae53d50b0204172dcf53007ae4b68af3a4db4e2..5a3af203c783011f25235bdb56e7d2e66f844ea7 100644 --- a/src/main/java/org/orekit/rugged/adjustment/AdjustmentContext.java +++ b/src/main/java/org/orekit/rugged/adjustment/AdjustmentContext.java @@ -127,6 +127,7 @@ public class AdjustmentContext { public Optimum estimateFreeParameters(final Collection<String> ruggedNameList, final int maxEvaluations, final double parametersConvergenceThreshold) throws RuggedException { + try { final List<Rugged> ruggedList = new ArrayList<Rugged>(); diff --git a/src/main/java/org/orekit/rugged/adjustment/GroundOptimizationProblemBuilder.java b/src/main/java/org/orekit/rugged/adjustment/GroundOptimizationProblemBuilder.java index 30689765054506d3a476ea5a0cd12cda0ccb6402..5ea75f877e6f5f7c61149e40c25e972d0ef44765 100644 --- a/src/main/java/org/orekit/rugged/adjustment/GroundOptimizationProblemBuilder.java +++ b/src/main/java/org/orekit/rugged/adjustment/GroundOptimizationProblemBuilder.java @@ -209,11 +209,9 @@ public class GroundOptimizationProblemBuilder extends OptimizationProblemBuilder } l += 2; - } } - // inverse loc result with Jacobian for all reference points return new Pair<RealVector, RealMatrix>(value, jacobian); diff --git a/src/main/java/org/orekit/rugged/adjustment/LeastSquareAdjuster.java b/src/main/java/org/orekit/rugged/adjustment/LeastSquareAdjuster.java index e8accef0e7ae70bbf7a518a367e6107065dc7e60..edc5dc5ba9bf9250c294d4957fb178149b8b095f 100644 --- a/src/main/java/org/orekit/rugged/adjustment/LeastSquareAdjuster.java +++ b/src/main/java/org/orekit/rugged/adjustment/LeastSquareAdjuster.java @@ -41,6 +41,7 @@ public class LeastSquareAdjuster { */ // TODO GP public protected ??? LeastSquareAdjuster(final OptimizerId optimizerID) { + this.optimizerID = optimizerID; this.adjuster = this.selectOptimizer(); } @@ -48,6 +49,7 @@ public class LeastSquareAdjuster { /** Default constructor with Gauss Newton with QR decomposition algorithm.*/ // TODO GP public protected ??? LeastSquareAdjuster() { + this.optimizerID = OptimizerId.GAUSS_NEWTON_QR; this.adjuster = this.selectOptimizer(); } diff --git a/src/main/java/org/orekit/rugged/refining/measures/Noise.java b/src/main/java/org/orekit/rugged/refining/measures/Noise.java index 748ddb9dfa04084f40692af528c095cbd6304d09..1c578385ffc5f7f85b0e0659e80c2504726f6196 100644 --- a/src/main/java/org/orekit/rugged/refining/measures/Noise.java +++ b/src/main/java/org/orekit/rugged/refining/measures/Noise.java @@ -44,6 +44,7 @@ public class Noise { * @param dimension noise dimension */ public Noise(final int distribution, final int dimension) { + this.mean = new double[dimension]; this.standardDeviation = new double[dimension]; Noise.dimension = dimension; diff --git a/src/main/java/org/orekit/rugged/refining/measures/Observables.java b/src/main/java/org/orekit/rugged/refining/measures/Observables.java index 75099999f657a42c3f85010e1766b6f2bd8865be..cab15368ca81de4c5b6f0750a167158e07f0acdc 100644 --- a/src/main/java/org/orekit/rugged/refining/measures/Observables.java +++ b/src/main/java/org/orekit/rugged/refining/measures/Observables.java @@ -49,6 +49,7 @@ public class Observables { * @param nbModels number of viewing models to map */ public Observables(final int nbModels) { + this.groundMappings = new LinkedHashMap<String, SensorToGroundMapping>(); this.interMappings = new LinkedHashMap<String, SensorToSensorMapping>(); this.nbModels = nbModels; @@ -58,6 +59,7 @@ public class Observables { * @param interMapping sensor to sensor mapping */ public void addInterMapping(final SensorToSensorMapping interMapping) { + interMappings.put(this.createKey(interMapping), interMapping); } @@ -66,6 +68,7 @@ public class Observables { * @param groundMapping sensor to ground mapping */ public void addGroundMapping(final SensorToGroundMapping groundMapping) { + groundMappings.put(this.createKey(groundMapping), groundMapping); } @@ -83,6 +86,7 @@ public class Observables { * @return selected ground mapping or null if sensor is not found */ public SensorToGroundMapping getGroundMapping(final String ruggedName, final String sensorName) { + final SensorToGroundMapping mapping = this.groundMappings.get(ruggedName + RUGGED_SENSOR_SEPARATOR + sensorName); return mapping; } diff --git a/src/main/java/org/orekit/rugged/refining/measures/SensorMapping.java b/src/main/java/org/orekit/rugged/refining/measures/SensorMapping.java index 1ec4f131c40ceaf259c7b7bb7b41d71de2519bd2..8434e3fa281ab673dd1810d15e7cca03312db44d 100644 --- a/src/main/java/org/orekit/rugged/refining/measures/SensorMapping.java +++ b/src/main/java/org/orekit/rugged/refining/measures/SensorMapping.java @@ -55,6 +55,7 @@ public class SensorMapping<T> { * @param ruggedName name of the Rugged to which mapping applies */ public SensorMapping(final String sensorName, final String ruggedName) { + this.sensorName = sensorName; this.ruggedName = ruggedName; this.mapping = new LinkedHashMap<SensorPixel, T>(); diff --git a/src/main/java/org/orekit/rugged/refining/measures/SensorToGroundMapping.java b/src/main/java/org/orekit/rugged/refining/measures/SensorToGroundMapping.java index 321c9003828652cce0678c41b3c5db951e73f37e..d8e63b715c50d90b279a19f8697e677f69c719d0 100644 --- a/src/main/java/org/orekit/rugged/refining/measures/SensorToGroundMapping.java +++ b/src/main/java/org/orekit/rugged/refining/measures/SensorToGroundMapping.java @@ -54,6 +54,7 @@ public class SensorToGroundMapping { * @param sensorName name of the sensor to which mapping applies */ public SensorToGroundMapping(final String ruggedName, final String sensorName) { + this.sensorName = sensorName; this.groundMapping = new SensorMapping<GeodeticPoint>(sensorName, ruggedName); } diff --git a/src/tutorials/java/RefiningPleiades/GroundRefining.java b/src/tutorials/java/RefiningPleiades/GroundRefining.java index 0ee1e3a407c0285529314ca43918c853444a51d8..21eb12bf4682abb2d0e6d5b8f2909c6d030dcbfb 100644 --- a/src/tutorials/java/RefiningPleiades/GroundRefining.java +++ b/src/tutorials/java/RefiningPleiades/GroundRefining.java @@ -251,6 +251,9 @@ public class GroundRefining extends Refining { */ private double[] computeGSD(final LineSensor lineSensor) throws RuggedException { + // Get number of line + int dimension = pleiadesViewingModel.getDimension(); + // 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. @@ -258,26 +261,26 @@ public class GroundRefining extends Refining { 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); + los = lineSensor.getLOS(firstLineDate,dimension-1); // Get center geodetic point - AbsoluteDate lineDate = lineSensor.getDate(pleiadesViewingModel.dimension/2); - los = lineSensor.getLOS(lineDate,pleiadesViewingModel.dimension/2); + AbsoluteDate lineDate = lineSensor.getDate(dimension/2); + los = lineSensor.getLOS(lineDate,dimension/2); // Get upper right geodetic point - int pixelPosition = pleiadesViewingModel.dimension-1; + int pixelPosition = 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); + AbsoluteDate lineDate_y = lineSensor.getDate(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; + upperRight.getLongitude() , upperRight.getLatitude())/dimension; double gsdY = DistanceTools.computeDistanceInMeter(upLeftPoint.getLongitude(), upLeftPoint.getLatitude(), - lowerLeft.getLongitude() , lowerLeft.getLatitude())/pleiadesViewingModel.dimension; + lowerLeft.getLongitude() , lowerLeft.getLatitude())/dimension; double [] gsd = {gsdX, gsdY}; return gsd; @@ -295,7 +298,7 @@ public class GroundRefining extends Refining { * Set the Pleiades viewing model * @param pleiadesViewingModel Pleiades viewing model to set */ - public void setPleiadesViewingModel(PleiadesViewingModel pleiadesViewingModel) { + public void setPleiadesViewingModel(final PleiadesViewingModel pleiadesViewingModel) { this.pleiadesViewingModel = pleiadesViewingModel; } @@ -311,7 +314,7 @@ public class GroundRefining extends Refining { * Set the orbit model * @param orbitmodel the orbit model to set */ - public void setOrbitmodel(OrbitModel orbitmodel) { + public void setOrbitmodel(final OrbitModel orbitmodel) { this.orbitmodel = orbitmodel; } @@ -335,7 +338,7 @@ public class GroundRefining extends Refining { * Set the Rugged instance * @param rugged the Rugged instance to set */ - public void setRugged(Rugged rugged) { + public void setRugged(final Rugged rugged) { this.rugged = rugged; } @@ -343,7 +346,7 @@ public class GroundRefining extends Refining { * Set the measures * @param measures the measures to set */ - public void setMeasures(GroundMeasureGenerator measures) { + public void setMeasures(final GroundMeasureGenerator measures) { this.measures = measures; } } diff --git a/src/tutorials/java/RefiningPleiades/InterRefining.java b/src/tutorials/java/RefiningPleiades/InterRefining.java index 75f9fa8ef3c7f837abe9a4b1644bbf21510416ce..fa07097be45712321780ce575041c673ef2d5c6e 100644 --- a/src/tutorials/java/RefiningPleiades/InterRefining.java +++ b/src/tutorials/java/RefiningPleiades/InterRefining.java @@ -354,12 +354,18 @@ public class InterRefining extends Refining { */ private double computeDistance(final LineSensor lineSensorA, final LineSensor lineSensorB) throws RuggedException { + + // Get number of line of sensors + int dimensionA = pleiadesViewingModelA.getDimension(); + int dimensionB = pleiadesViewingModelB.getDimension(); + + 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); + AbsoluteDate lineDateA = lineSensorA.getDate(dimensionA/2); + Vector3D losA = lineSensorA.getLOS(lineDateA,dimensionA/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()), @@ -369,8 +375,8 @@ public class InterRefining extends Refining { 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); + AbsoluteDate lineDateB = lineSensorB.getDate(dimensionB/2); + Vector3D losB = lineSensorB.getLOS(lineDateB,dimensionB/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()), @@ -384,8 +390,8 @@ public class InterRefining extends Refining { FastMath.toDegrees(firstPointB.getLatitude()), FastMath.toDegrees(firstPointB.getLongitude()),firstPointB.getAltitude()); - lineDateB = lineSensorB.getDate(pleiadesViewingModelB.dimension-1); - losB = lineSensorB.getLOS(lineDateB,pleiadesViewingModelB.dimension-1); + lineDateB = lineSensorB.getDate(dimensionB-1); + losB = lineSensorB.getLOS(lineDateB,dimensionB-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()), @@ -407,8 +413,7 @@ public class InterRefining extends Refining { /** * @param pleiadesViewingModelA the pleiadesViewingModelA to set */ - public void - setPleiadesViewingModelA(PleiadesViewingModel pleiadesViewingModelA) { + public void setPleiadesViewingModelA(final PleiadesViewingModel pleiadesViewingModelA) { this.pleiadesViewingModelA = pleiadesViewingModelA; } @@ -422,8 +427,7 @@ public class InterRefining extends Refining { /** * @param pleiadesViewingModelB the pleiadesViewingModelB to set */ - public void - setPleiadesViewingModelB(PleiadesViewingModel pleiadesViewingModelB) { + public void setPleiadesViewingModelB(final PleiadesViewingModel pleiadesViewingModelB) { this.pleiadesViewingModelB = pleiadesViewingModelB; } @@ -437,7 +441,7 @@ public class InterRefining extends Refining { /** * @param orbitmodelA the orbitmodelA to set */ - public void setOrbitmodelA(OrbitModel orbitmodelA) { + public void setOrbitmodelA(final OrbitModel orbitmodelA) { this.orbitmodelA = orbitmodelA; } @@ -451,7 +455,7 @@ public class InterRefining extends Refining { /** * @param orbitmodelB the orbitmodelB to set */ - public void setOrbitmodelB(OrbitModel orbitmodelB) { + public void setOrbitmodelB(final OrbitModel orbitmodelB) { this.orbitmodelB = orbitmodelB; } @@ -479,7 +483,7 @@ public class InterRefining extends Refining { /** * @param ruggedA the ruggedA to set */ - public void setRuggedA(Rugged ruggedA) { + public void setRuggedA(final Rugged ruggedA) { this.ruggedA = ruggedA; } @@ -501,14 +505,14 @@ public class InterRefining extends Refining { /** * @param ruggedB the ruggedB to set */ - public void setRuggedB(Rugged ruggedB) { + public void setRuggedB(final Rugged ruggedB) { this.ruggedB = ruggedB; } /** * @param measures the measures to set */ - public void setMeasures(InterMeasureGenerator measures) { + public void setMeasures(final InterMeasureGenerator measures) { this.measures = measures; } } diff --git a/src/tutorials/java/RefiningPleiades/Refining.java b/src/tutorials/java/RefiningPleiades/Refining.java index 6b0cacbccc96db7691f0a146ab53c176addb2d51..dbd5d8b11a71b1c5e28e662dca5639c866ba7b72 100644 --- a/src/tutorials/java/RefiningPleiades/Refining.java +++ b/src/tutorials/java/RefiningPleiades/Refining.java @@ -64,8 +64,8 @@ public class Refining { * @param factorValue scale factor * @throws RuggedException */ - public void applyDisruptions(Rugged rugged, String sensorName, - double rollValue, double pitchValue, double factorValue) + public void applyDisruptions(final Rugged rugged, final String sensorName, + final double rollValue, final double pitchValue, final double factorValue) throws OrekitException, RuggedException { final String commonFactorName = "factor"; @@ -98,9 +98,9 @@ public class Refining { * @return ground measures generator (sensor to ground mapping) * @throws RuggedException */ - public GroundMeasureGenerator generatePoints(int lineSampling, int pixelSampling, - Rugged rugged, String sensorName, - int dimension) throws RuggedException { + public GroundMeasureGenerator generatePoints(final int lineSampling, final int pixelSampling, + final Rugged rugged, final String sensorName, + final int dimension) throws RuggedException { GroundMeasureGenerator measures = new GroundMeasureGenerator(rugged, sensorName, dimension); @@ -126,9 +126,10 @@ public class Refining { * @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 RuggedException { + public InterMeasureGenerator generatePoints(final int lineSampling, final int pixelSampling, + final Rugged ruggedA, final String sensorNameA, final int dimensionA, + final Rugged ruggedB, final String sensorNameB, final int dimensionB) + throws RuggedException { // Outliers control final double outlierValue = 1e+2; @@ -161,9 +162,9 @@ public class Refining { * @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 RuggedException { + public GroundMeasureGenerator generateNoisyPoints(final int lineSampling, final int pixelSampling, + final Rugged rugged, final String sensorName, final int dimension, + final Noise noise) throws RuggedException { // Generate ground measures GroundMeasureGenerator measures = new GroundMeasureGenerator(rugged, sensorName, dimension); @@ -191,10 +192,10 @@ public class Refining { * @return inter-measures generator (sensor to sensor mapping) * @throws RuggedException */ - public InterMeasureGenerator generateNoisyPoints(int lineSampling, int pixelSampling, - Rugged ruggedA, String sensorNameA, int dimensionA, - Rugged ruggedB, String sensorNameB, int dimensionB, - Noise noise) throws RuggedException { + public InterMeasureGenerator generateNoisyPoints(final int lineSampling, final int pixelSampling, + final Rugged ruggedA, final String sensorNameA, final int dimensionA, + final Rugged ruggedB, final String sensorNameB, final int dimensionB, + final Noise noise) throws RuggedException { // Outliers control final double outlierValue = 1.e+2; @@ -224,8 +225,8 @@ public class Refining { * @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 { + public void computeMetrics(final SensorToGroundMapping groundMapping, + final Rugged rugged, final boolean unit) throws RuggedException { String stUnit = null; if(unit) { @@ -246,9 +247,9 @@ public class Refining { * @param unit flag to know if distance is computed in meters (false) or with angular (true) * @throws RuggedException */ - public void computeMetrics(SensorToSensorMapping interMapping, - Rugged ruggedA, Rugged ruggedB, - boolean unit) throws RuggedException { + public void computeMetrics(final SensorToSensorMapping interMapping, + final Rugged ruggedA, final Rugged ruggedB, + final boolean unit) throws RuggedException { String stUnit = null; if(unit) stUnit="degrees"; @@ -266,7 +267,7 @@ public class Refining { * @param isSelected flag to known if factor parameter is selected or not * @throws RuggedException */ - public void resetModel(Rugged rugged, String sensorName, boolean isSelected) throws RuggedException { + public void resetModel(final Rugged rugged, final String sensorName, final boolean isSelected) throws RuggedException { final String commonFactorName = "factor"; @@ -307,8 +308,8 @@ public class Refining { * @param rugged Rugged instance * @throws RuggedException */ - public void optimization(int maxIterations, double convergenceThreshold, - Observables measures, Rugged rugged) throws RuggedException { + public void optimization(final int maxIterations, final double convergenceThreshold, + final Observables measures, final Rugged rugged) throws RuggedException { System.out.format("Iterations max: %d\tconvergence threshold: %3.6e \n", maxIterations, convergenceThreshold); @@ -328,9 +329,9 @@ public class Refining { * @param ruggeds Rugged instances A and B * @throws RuggedException */ - public void optimization(int maxIterations, double convergenceThreshold, - Observables measures, - Collection<Rugged> ruggeds) throws RuggedException { + public void optimization(final int maxIterations, final double convergenceThreshold, + final Observables measures, + final Collection<Rugged> ruggeds) throws RuggedException { System.out.format("Iterations max: %d\tconvergence threshold: %3.6e \n", maxIterations, convergenceThreshold); @@ -361,8 +362,8 @@ public class Refining { * @param factorValue scale factor * @throws RuggedException */ - public void paramsEstimation(Rugged rugged, String sensorName, - double rollValue, double pitchValue, double factorValue) + public void paramsEstimation(final Rugged rugged, final String sensorName, + final double rollValue, final double pitchValue, final double factorValue) throws RuggedException { final String commonFactorName = "factor"; diff --git a/src/tutorials/java/RefiningPleiades/models/PleiadesViewingModel.java b/src/tutorials/java/RefiningPleiades/models/PleiadesViewingModel.java index 83541a8b61943e53c3a14ad7c7771e3b2ea899df..8e5f3d4f6297b81343bce52e85bac34f092ecdfe 100644 --- a/src/tutorials/java/RefiningPleiades/models/PleiadesViewingModel.java +++ b/src/tutorials/java/RefiningPleiades/models/PleiadesViewingModel.java @@ -50,13 +50,14 @@ import org.orekit.errors.OrekitException; public class PleiadesViewingModel { /** intrinsic Pleiades parameters. */ - public double fov = 1.65; // 20km - alt 694km + private double fov = 1.65; // 20km - alt 694km + // Number of line of the sensor - public int dimension = 40000; + private int dimension = 40000; - public double angle; - public LineSensor lineSensor; - public String date; + private double angle; + private LineSensor lineSensor; + private String date; private String sensorName; @@ -156,9 +157,10 @@ public class PleiadesViewingModel { return sensorName; } - /** TODO GP add comments + /** Get the number of lines of the sensor + * @return the number of lines of the sensor */ - public int getDimension() { +public int getDimension() { return dimension; }