Commit bc0cd059 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed findbugs errors.

parent 16a79ea2
......@@ -34,9 +34,14 @@
<Match>
<Or>
<Class name="~.*\.DSSTPropagator\$MeanPlusShortPeriodicMapper$" />
<Class name="~.*\.AbstractGaussianContribution\$GaussianShortPeriodicCoefficients$" />
<Class name="~.*\.DSSTThirdBody\$ThirdBodyShortPeriodicCoefficients$" />
<Class name="~.*\.TesseralContributionContribution\$TesseralShortPeriodicCoefficients$" />
<Class name="~.*\.ZonalContribution\$ZonalShortPeriodicCoefficients$" />
<Class name="~.*\.FieldOfView$" />
<Class name="~.*\.FootprintOverlapDetector$" />
<Class name="~.*\.GeographicZoneDetector$" />
<Class name="~.*\.SaastamoinenModel$" />
</Or>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
......
......@@ -82,13 +82,13 @@ public class SaastamoinenModel implements TroposphericDelayModel {
};
/** Interpolation function for the B correction term. */
private final UnivariateFunction bFunction;
private final transient UnivariateFunction bFunction;
/** Polynomial function for the e term. */
private final PolynomialFunction eFunction;
private final transient PolynomialFunction eFunction;
/** Interpolation function for the delta R correction term. */
private final BilinearInterpolatingFunction deltaRFunction;
private final transient BilinearInterpolatingFunction deltaRFunction;
/** The temperature at the station [K]. */
private double t0;
......
......@@ -16,11 +16,14 @@
*/
package org.orekit.propagation.semianalytical.dsst.forces;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import org.apache.commons.math3.analysis.UnivariateVectorFunction;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
......@@ -191,7 +194,8 @@ public abstract class AbstractGaussianContribution implements DSSTForceModel {
final List<ShortPeriodTerms> list = new ArrayList<ShortPeriodTerms>();
gaussianSPCoefs = new GaussianShortPeriodicCoefficients(coefficientsKeyPrefix,
JMAX, INTERPOLATION_POINTS);
JMAX, INTERPOLATION_POINTS,
new TimeSpanMap<Slot>(new Slot(JMAX, INTERPOLATION_POINTS)));
list.add(gaussianSPCoefs);
return list;
......@@ -1355,20 +1359,22 @@ public abstract class AbstractGaussianContribution implements DSSTForceModel {
private final String coefficientsKeyPrefix;
/** All coefficients slots. */
private final TimeSpanMap<Slot> slots;
private final transient TimeSpanMap<Slot> slots;
/** Constructor.
* @param coefficientsKeyPrefix prefix for coefficients keys
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param slots all coefficients slots
*/
GaussianShortPeriodicCoefficients(final String coefficientsKeyPrefix,
final int jMax, final int interpolationPoints) {
final int jMax, final int interpolationPoints,
final TimeSpanMap<Slot> slots) {
//Initialize fields
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.coefficientsKeyPrefix = coefficientsKeyPrefix;
this.slots = new TimeSpanMap<Slot>(new Slot(jMax, interpolationPoints));
this.slots = slots;
}
/** Get the slot valid for some date.
......@@ -1588,6 +1594,90 @@ public abstract class AbstractGaussianContribution implements DSSTForceModel {
}
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if an additional state provider is not serializable
*/
private Object writeReplace() throws NotSerializableException {
// slots transitions
final SortedSet<TimeSpanMap.Transition<Slot>> transitions = slots.getTransitions();
final AbsoluteDate[] transitionDates = new AbsoluteDate[transitions.size()];
final Slot[] allSlots = new Slot[transitions.size() + 1];
int i = 0;
for (final TimeSpanMap.Transition<Slot> transition : transitions) {
if (i == 0) {
// slot before the first transition
allSlots[i] = transition.getBefore();
}
if (i < transitionDates.length) {
transitionDates[i] = transition.getDate();
allSlots[++i] = transition.getAfter();
}
}
return new DataTransferObject(jMax, interpolationPoints, coefficientsKeyPrefix,
transitionDates, allSlots);
}
/** Internal class used only for serialization. */
private static class DataTransferObject implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** Maximum value for j index. */
private final int jMax;
/** Number of points used in the interpolation process. */
private final int interpolationPoints;
/** Prefix for coefficients keys. */
private final String coefficientsKeyPrefix;
/** Transitions dates. */
private final AbsoluteDate[] transitionDates;
/** All slots. */
private final Slot[] allSlots;
/** Simple constructor.
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param coefficientsKeyPrefix prefix for coefficients keys
* @param transitionDates transitions dates
* @param allSlots all slots
*/
DataTransferObject(final int jMax, final int interpolationPoints,
final String coefficientsKeyPrefix,
final AbsoluteDate[] transitionDates, final Slot[] allSlots) {
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.coefficientsKeyPrefix = coefficientsKeyPrefix;
this.transitionDates = transitionDates;
this.allSlots = allSlots;
}
/** Replace the deserialized data transfer object with a {@link GaussianShortPeriodicCoefficients}.
* @return replacement {@link GaussianShortPeriodicCoefficients}
*/
private Object readResolve() {
final TimeSpanMap<Slot> slots = new TimeSpanMap<Slot>(allSlots[0]);
if (transitionDates != null) {
for (int i = 0; i < transitionDates.length; ++i) {
slots.addValidAfter(allSlots[i + 1], transitionDates[i]);
}
}
return new GaussianShortPeriodicCoefficients(coefficientsKeyPrefix, jMax, interpolationPoints, slots);
}
}
}
/** The U<sub>i</sub><sup>j</sup> and V<sub>i</sub><sup>j</sup> coefficients described by
......@@ -1873,7 +1963,10 @@ public abstract class AbstractGaussianContribution implements DSSTForceModel {
}
/** Coefficients valid for one time slot. */
private static class Slot {
private static class Slot implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/**The coefficients D<sub>i</sub><sup>j</sup>.
* <p>
......
......@@ -16,11 +16,14 @@
*/
package org.orekit.propagation.semianalytical.dsst.forces;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
......@@ -310,8 +313,10 @@ public class DSSTThirdBody implements DSSTForceModel {
maxEccPowShort = MAX_ECCPOWER_SP;
Qns = CoefficientsFactory.computeQns(gamma, maxAR3Pow, FastMath.max(maxEccPow, maxEccPowShort));
shortPeriods = new ThirdBodyShortPeriodicCoefficients(maxAR3Pow + 1, INTERPOLATION_POINTS,
maxFreqF, body.getName());
final int jMax = maxAR3Pow + 1;
shortPeriods = new ThirdBodyShortPeriodicCoefficients(jMax, INTERPOLATION_POINTS,
maxFreqF, body.getName(),
new TimeSpanMap<Slot>(new Slot(jMax, INTERPOLATION_POINTS)));
final List<ShortPeriodTerms> list = new ArrayList<ShortPeriodTerms>();
list.add(shortPeriods);
......@@ -1856,7 +1861,7 @@ public class DSSTThirdBody implements DSSTForceModel {
private final String prefix;
/** All coefficients slots. */
private final TimeSpanMap<Slot> slots;
private final transient TimeSpanMap<Slot> slots;
/**
* Standard constructor.
......@@ -1864,14 +1869,16 @@ public class DSSTThirdBody implements DSSTForceModel {
* @param jMax maximal value for j
* @param maxFreqF Max frequency of F
* @param bodyName third body name
* @param slots all coefficients slots
*/
ThirdBodyShortPeriodicCoefficients(final int jMax, final int interpolationPoints,
final int maxFreqF, final String bodyName) {
final int maxFreqF, final String bodyName,
final TimeSpanMap<Slot> slots) {
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.maxFreqF = maxFreqF;
this.prefix = "DSST-3rd-body-" + bodyName + "-";
this.slots = new TimeSpanMap<Slot>(new Slot(jMax, interpolationPoints));
this.slots = slots;
}
/** Get the slot valid for some date.
......@@ -1972,10 +1979,102 @@ public class DSSTThirdBody implements DSSTForceModel {
}
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if an additional state provider is not serializable
*/
private Object writeReplace() throws NotSerializableException {
// slots transitions
final SortedSet<TimeSpanMap.Transition<Slot>> transitions = slots.getTransitions();
final AbsoluteDate[] transitionDates = new AbsoluteDate[transitions.size()];
final Slot[] allSlots = new Slot[transitions.size() + 1];
int i = 0;
for (final TimeSpanMap.Transition<Slot> transition : transitions) {
if (i == 0) {
// slot before the first transition
allSlots[i] = transition.getBefore();
}
if (i < transitionDates.length) {
transitionDates[i] = transition.getDate();
allSlots[++i] = transition.getAfter();
}
}
return new DataTransferObject(jMax, interpolationPoints, maxFreqF, prefix,
transitionDates, allSlots);
}
/** Internal class used only for serialization. */
private static class DataTransferObject implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** Maximum value for j index. */
private final int jMax;
/** Number of points used in the interpolation process. */
private final int interpolationPoints;
/** Max frequency of F. */
private final int maxFreqF;
/** Coefficients prefix. */
private final String prefix;
/** Transitions dates. */
private final AbsoluteDate[] transitionDates;
/** All slots. */
private final Slot[] allSlots;
/** Simple constructor.
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param maxFreqF max frequency of F
* @param prefix prefix for coefficients keys
* @param transitionDates transitions dates
* @param allSlots all slots
*/
DataTransferObject(final int jMax, final int interpolationPoints,
final int maxFreqF, final String prefix,
final AbsoluteDate[] transitionDates, final Slot[] allSlots) {
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.maxFreqF = maxFreqF;
this.prefix = prefix;
this.transitionDates = transitionDates;
this.allSlots = allSlots;
}
/** Replace the deserialized data transfer object with a {@link GaussianShortPeriodicCoefficients}.
* @return replacement {@link GaussianShortPeriodicCoefficients}
*/
private Object readResolve() {
final TimeSpanMap<Slot> slots = new TimeSpanMap<Slot>(allSlots[0]);
if (transitionDates != null) {
for (int i = 0; i < transitionDates.length; ++i) {
slots.addValidAfter(allSlots[i + 1], transitionDates[i]);
}
}
return new ThirdBodyShortPeriodicCoefficients(jMax, interpolationPoints, maxFreqF, prefix, slots);
}
}
}
/** Coefficients valid for one time slot. */
private static class Slot {
private static class Slot implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** The coefficients C<sub>i</sub><sup>j</sup>.
* <p>
......
......@@ -16,6 +16,8 @@
*/
package org.orekit.propagation.semianalytical.dsst.forces;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
......@@ -23,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
......@@ -338,7 +341,9 @@ class TesseralContribution implements DSSTForceModel {
shortPeriodTerms = new TesseralShortPeriodicCoefficients(bodyFrame, maxOrderMdailyTesseralSP,
maxDegreeTesseralSP < 0, nonResOrders,
mMax, jMax, INTERPOLATION_POINTS);
mMax, jMax, INTERPOLATION_POINTS,
new TimeSpanMap<Slot>(new Slot(mMax, jMax,
INTERPOLATION_POINTS)));
final List<ShortPeriodTerms> list = new ArrayList<ShortPeriodTerms>();
list.add(shortPeriodTerms);
......@@ -1221,20 +1226,22 @@ class TesseralContribution implements DSSTForceModel {
private final int interpolationPoints;
/** All coefficients slots. */
private final TimeSpanMap<Slot> slots;
private final transient TimeSpanMap<Slot> slots;
/** Constructor.
* @param bodyFrame central body rotating frame
* @param maxOrderMdailyTesseralSP maximal order to consider for short periodics m-daily tesseral harmonics potential
* @param mDailiesOnly flag to take into account only M-dailies harmonic tesserals for short periodic perturbations
* @param nonResOrders lst of non resonant orders with j != 0
* @param mMax maximum value for m index
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param mMax maximum value for m index
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param slots all coefficients slots
*/
TesseralShortPeriodicCoefficients(final Frame bodyFrame, final int maxOrderMdailyTesseralSP,
final boolean mDailiesOnly, final SortedMap<Integer, List<Integer> > nonResOrders,
final int mMax, final int jMax, final int interpolationPoints) {
final int mMax, final int jMax, final int interpolationPoints,
final TimeSpanMap<Slot> slots) {
this.bodyFrame = bodyFrame;
this.maxOrderMdailyTesseralSP = maxOrderMdailyTesseralSP;
this.mDailiesOnly = mDailiesOnly;
......@@ -1242,7 +1249,7 @@ class TesseralContribution implements DSSTForceModel {
this.mMax = mMax;
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.slots = new TimeSpanMap<Slot>(new Slot(mMax, jMax, interpolationPoints));
this.slots = slots;
}
/** Get the slot valid for some date.
......@@ -1402,10 +1409,122 @@ class TesseralContribution implements DSSTForceModel {
}
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if an additional state provider is not serializable
*/
private Object writeReplace() throws NotSerializableException {
// slots transitions
final SortedSet<TimeSpanMap.Transition<Slot>> transitions = slots.getTransitions();
final AbsoluteDate[] transitionDates = new AbsoluteDate[transitions.size()];
final Slot[] allSlots = new Slot[transitions.size() + 1];
int i = 0;
for (final TimeSpanMap.Transition<Slot> transition : transitions) {
if (i == 0) {
// slot before the first transition
allSlots[i] = transition.getBefore();
}
if (i < transitionDates.length) {
transitionDates[i] = transition.getDate();
allSlots[++i] = transition.getAfter();
}
}
return new DataTransferObject(bodyFrame, maxOrderMdailyTesseralSP,
mDailiesOnly, nonResOrders,
mMax, jMax, interpolationPoints,
transitionDates, allSlots);
}
/** Internal class used only for serialization. */
private static class DataTransferObject implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** Central body rotating frame. */
private final Frame bodyFrame;
/** Maximal order to consider for short periodics m-daily tesseral harmonics potential. */
private final int maxOrderMdailyTesseralSP;
/** Flag to take into account only M-dailies harmonic tesserals for short periodic perturbations. */
private final boolean mDailiesOnly;
/** List of non resonant orders with j != 0. */
private final SortedMap<Integer, List<Integer> > nonResOrders;
/** Maximum value for m index. */
private final int mMax;
/** Maximum value for j index. */
private final int jMax;
/** Number of points used in the interpolation process. */
private final int interpolationPoints;
/** Transitions dates. */
private final AbsoluteDate[] transitionDates;
/** All slots. */
private final Slot[] allSlots;
/** Simple constructor.
* @param bodyFrame central body rotating frame
* @param maxOrderMdailyTesseralSP maximal order to consider for short periodics m-daily tesseral harmonics potential
* @param mDailiesOnly flag to take into account only M-dailies harmonic tesserals for short periodic perturbations
* @param nonResOrders lst of non resonant orders with j != 0
* @param mMax maximum value for m index
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param transitionDates transitions dates
* @param allSlots all slots
*/
DataTransferObject(final Frame bodyFrame, final int maxOrderMdailyTesseralSP,
final boolean mDailiesOnly, final SortedMap<Integer, List<Integer> > nonResOrders,
final int mMax, final int jMax, final int interpolationPoints,
final AbsoluteDate[] transitionDates, final Slot[] allSlots) {
this.bodyFrame = bodyFrame;
this.maxOrderMdailyTesseralSP = maxOrderMdailyTesseralSP;
this.mDailiesOnly = mDailiesOnly;
this.nonResOrders = nonResOrders;
this.mMax = mMax;
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.transitionDates = transitionDates;
this.allSlots = allSlots;
}
/** Replace the deserialized data transfer object with a {@link GaussianShortPeriodicCoefficients}.
* @return replacement {@link GaussianShortPeriodicCoefficients}
*/
private Object readResolve() {
final TimeSpanMap<Slot> slots = new TimeSpanMap<Slot>(allSlots[0]);
if (transitionDates != null) {
for (int i = 0; i < transitionDates.length; ++i) {
slots.addValidAfter(allSlots[i + 1], transitionDates[i]);
}
}
return new TesseralShortPeriodicCoefficients(bodyFrame, maxOrderMdailyTesseralSP, mDailiesOnly,
nonResOrders, mMax, jMax, interpolationPoints,
slots);
}
}
}
/** Coefficients valid for one time slot. */
private static class Slot {
private static class Slot implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** The coefficients C<sub>i</sub><sup>j</sup><sup>m</sup>.
* <p>
......
......@@ -16,11 +16,14 @@
*/
package org.orekit.propagation.semianalytical.dsst.forces;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.commons.math3.util.FastMath;
......@@ -257,7 +260,8 @@ class ZonalContribution implements DSSTForceModel {
final int jMax = 2 * maxDegreeShortPeriodics + 1;
final List<ShortPeriodTerms> list = new ArrayList<ShortPeriodTerms>();
zonalSPCoefs = new ZonalShortPeriodicCoefficients(maxDegreeShortPeriodics, jMax, INTERPOLATION_POINTS);
zonalSPCoefs = new ZonalShortPeriodicCoefficients(maxDegreeShortPeriodics, jMax, INTERPOLATION_POINTS,
new TimeSpanMap<Slot>(new Slot(jMax, INTERPOLATION_POINTS)));
list.add(zonalSPCoefs);
return list;
......@@ -959,21 +963,23 @@ class ZonalContribution implements DSSTForceModel {
private final int interpolationPoints;
/** All coefficients slots. */
private final TimeSpanMap<Slot> slots;
private final transient TimeSpanMap<Slot> slots;
/** Constructor.
* @param maxDegreeShortPeriodics maximal degree to consider for harmonics potential
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param slots all coefficients slots
*/
ZonalShortPeriodicCoefficients(final int maxDegreeShortPeriodics,
final int jMax, final int interpolationPoints) {
final int jMax, final int interpolationPoints,
final TimeSpanMap<Slot> slots) {
// Save parameters
this.maxDegreeShortPeriodics = maxDegreeShortPeriodics;
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.slots = new TimeSpanMap<Slot>(new Slot(jMax, interpolationPoints));
this.slots = slots;
}
......@@ -1086,6 +1092,91 @@ class ZonalContribution implements DSSTForceModel {
}
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if an additional state provider is not serializable
*/
private Object writeReplace() throws NotSerializableException {
// slots transitions
final SortedSet<TimeSpanMap.Transition<Slot>> transitions = slots.getTransitions();
final AbsoluteDate[] transitionDates = new AbsoluteDate[transitions.size()];
final Slot[] allSlots = new Slot[transitions.size() + 1];
int i = 0;
for (final TimeSpanMap.Transition<Slot> transition : transitions) {
if (i == 0) {
// slot before the first transition
allSlots[i] = transition.getBefore();
}
if (i < transitionDates.length) {
transitionDates[i] = transition.getDate();
allSlots[++i] = transition.getAfter();
}
}
return new DataTransferObject(maxDegreeShortPeriodics,
jMax, interpolationPoints,
transitionDates, allSlots);
}
/** Internal class used only for serialization. */
private static class DataTransferObject implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20160319L;
/** Maximal degree to consider for harmonics potential. */
private final int maxDegreeShortPeriodics;
/** Maximum value for j index. */
private final int jMax;
/** Number of points used in the interpolation process. */
private final int interpolationPoints;
/** Transitions dates. */
private final AbsoluteDate[] transitionDates;
/** All slots. */
private final Slot[] allSlots;
/** Simple constructor.
* @param maxDegreeShortPeriodics maximal degree to consider for harmonics potential
* @param jMax maximum value for j index
* @param interpolationPoints number of points used in the interpolation process
* @param transitionDates transitions dates
* @param allSlots all slots
*/
DataTransferObject(final int maxDegreeShortPeriodics,
final int jMax, final int interpolationPoints,
final AbsoluteDate[] transitionDates, final Slot[] allSlots) {
this.maxDegreeShortPeriodics = maxDegreeShortPeriodics;
this.jMax = jMax;
this.interpolationPoints = interpolationPoints;
this.transitionDates = transitionDates;
this.allSlots = allSlots;
}
/** Replace the deserialized data transfer object with a {@link GaussianShortPeriodicCoefficients}.
* @return replacement {@link GaussianShortPeriodicCoefficients}
*/
private Object readResolve() {
final TimeSpanMap<Slot> slots = new TimeSpanMap<Slot>(allSlots[0]);
if (transitionDates != null) {
for (int i = 0; i < transitionDates.length; ++i) {
slots.addValidAfter(allSlots[i + 1], transitionDates[i]);
}
}