diff --git a/java_additions/src/main/java/org/orekit/python/PythonAbstractDetector.java b/java_additions/src/main/java/org/orekit/python/PythonAbstractDetector.java index be8624a6784cdfd74c29fc0d94f5360a7c0a7d19..5073f5f6ba1ba079a3c632a5942bc88d20fc0ef8 100644 --- a/java_additions/src/main/java/org/orekit/python/PythonAbstractDetector.java +++ b/java_additions/src/main/java/org/orekit/python/PythonAbstractDetector.java @@ -64,27 +64,10 @@ public class PythonAbstractDetector<T extends EventDetector> extends AbstractDet int maxIter, EventHandler<T> handler) { super(maxCheck, threshold, maxIter, handler); } - - - /** {@inheritDoc} */ - @Override - public native void init(final SpacecraftState s0, final AbsoluteDate t); - - /** {@inheritDoc} */ - @Override - public native double g(SpacecraftState s) throws OrekitException; - - /** {@inheritDoc} */ - @Override - public native double getMaxCheckInterval(); - - /** {@inheritDoc} */ - @Override - public native int getMaxIterationCount(); /** {@inheritDoc} */ @Override - public native double getThreshold(); + public native double g(SpacecraftState s); /** {@inheritDoc} */ @Override diff --git a/java_additions/src/main/java/org/orekit/python/PythonEventDetector.java b/java_additions/src/main/java/org/orekit/python/PythonEventDetector.java index da1e3b7266924e0015a0204c0408c291af06edfa..ad61c1a4a2694c8a8787f26eb2235bc01b867661 100644 --- a/java_additions/src/main/java/org/orekit/python/PythonEventDetector.java +++ b/java_additions/src/main/java/org/orekit/python/PythonEventDetector.java @@ -79,74 +79,33 @@ public class PythonEventDetector implements EventDetector /** Part of JCC Python interface to object */ public native void pythonDecRef(); - /** Initialize event handler at the start of a propagation. - * <p> - * This method is called once at the start of the propagation. It - * may be used by the event handler to initialize some internal data - * if needed. - * </p> - * @param s0 initial state - * @param t target time for the integration - */ + /** {@inheritDoc} */ @Override public native void init(SpacecraftState s0, AbsoluteDate t); - - - /** Compute the value of the switching function. - * This function must be continuous (at least in its roots neighborhood), - * as the integrator will need to find its roots to locate the events. - * @param s the current state information: date, kinematics, attitude - * @return value of the switching function - * @exception OrekitException if some specific error occurs - */ + + /** {@inheritDoc} */ @Override - public native double g(SpacecraftState s) throws OrekitException; + public native double g(SpacecraftState s); - /** Get the convergence threshold in the event time search. - * @return convergence threshold (s) - */ + /** {@inheritDoc} */ @Override public native double getThreshold(); - /** Get maximal time interval between switching function checks. - * @return maximal time interval (s) between switching function checks - */ + /** {@inheritDoc} */ @Override public native double getMaxCheckInterval(); - /** Get maximal number of iterations in the event time search. - * @return maximal number of iterations in the event time search - */ + /** {@inheritDoc} */ @Override public native int getMaxIterationCount(); - - /** Handle the event. - * @param s SpaceCraft state to be used in the evaluation - * @param increasing with the event occured in an "increasing" or "decreasing" slope direction - * @return the Action that the calling detector should pass back to the evaluation system - * @exception OrekitException if some specific error occurs - * @since 7.0 - */ + /** {@inheritDoc} */ @Override - public native Action eventOccurred(SpacecraftState s, boolean increasing) - throws OrekitException; - - /** Reset the state prior to continue propagation. - * <p>This method is called after the step handler has returned and - * before the next step is started, but only when {@link - * #eventOccurred} has itself returned the {@link Action#RESET_STATE} - * indicator. It allows the user to reset the state for the next step, - * without perturbing the step handler of the finishing step. If the - * {@link #eventOccurred} never returns the {@link Action#RESET_STATE} - * indicator, this function will never be called, and it is safe to simply return null.</p> - * @param oldState old state - * @return new state - * @exception OrekitException if the state cannot be reseted - * @since 7.0 - */ + public native Action eventOccurred(SpacecraftState s, boolean increasing); + + /** {@inheritDoc} */ @Override - public native SpacecraftState resetState(SpacecraftState oldState) throws OrekitException; + public native SpacecraftState resetState(SpacecraftState oldState); } diff --git a/java_additions/src/main/java/org/orekit/python/PythonEventHandler.java b/java_additions/src/main/java/org/orekit/python/PythonEventHandler.java index 2e1c7e238f45a71647fbe52ecf9e7f39fa57b74a..e0ea27ea85db09ec1deb38e27ed60ea4712c306a 100644 --- a/java_additions/src/main/java/org/orekit/python/PythonEventHandler.java +++ b/java_additions/src/main/java/org/orekit/python/PythonEventHandler.java @@ -96,7 +96,7 @@ public class PythonEventHandler<T extends EventDetector> implements EventHandler * * @exception OrekitException if some specific error occurs */ - public native Action eventOccurred(SpacecraftState s, T detector, boolean increasing) throws OrekitException; + public native Action eventOccurred(SpacecraftState s, T detector, boolean increasing); /** Reset the state prior to continue propagation. * <p>This method is called after the step handler has returned and @@ -111,7 +111,7 @@ public class PythonEventHandler<T extends EventDetector> implements EventHandler * @return new state * @exception OrekitException if the state cannot be reseted */ - public native SpacecraftState resetState(T detector, SpacecraftState oldState) throws OrekitException; + public native SpacecraftState resetState(T detector, SpacecraftState oldState); } diff --git a/java_additions/src/main/java/org/orekit/python/PythonOrekitFixedStepHandler.java b/java_additions/src/main/java/org/orekit/python/PythonOrekitFixedStepHandler.java index 9c11265c3a7d2b7efc8e41c0cd71ae945f92ed61..eedd4c85d4a70da154b11d20e3e6307c8d78890e 100644 --- a/java_additions/src/main/java/org/orekit/python/PythonOrekitFixedStepHandler.java +++ b/java_additions/src/main/java/org/orekit/python/PythonOrekitFixedStepHandler.java @@ -15,8 +15,8 @@ * limitations under the License. */ -// this file was created by SCC and is largely a derived work from the -// original file OrekitFixedStepHandler.java created by CS Systèmes d'Information +// this file was created by SSC and is largely a derived work from the +// original java class created by CS Systèmes d'Information package org.orekit.python; import org.orekit.propagation.sampling.OrekitFixedStepHandler; @@ -62,24 +62,12 @@ public class PythonOrekitFixedStepHandler implements OrekitFixedStepHandler { /** Part of JCC Python interface to object */ public native void pythonDecRef(); - /** Initialize step handler at the start of a propagation. - * <p> - * This method is called once at the start of the propagation. It - * may be used by the step handler to initialize some internal data - * if needed. - * </p> - * @param s0 initial state - * @param t target time for the integration - */ - public native void init(SpacecraftState s0, AbsoluteDate t) throws OrekitException; + /** {@inheritDoc} */ + @Override + public native void init(SpacecraftState s0, AbsoluteDate t, double step); - /** Handle the current step. - * @param currentState current state at step time - * @param isLast if true, this is the last integration step - * @exception PropagationException if step cannot be handled - */ - - public native void handleStep(final SpacecraftState currentState, final boolean isLast) - throws OrekitException; + /** {@inheritDoc} */ + @Override + public native void handleStep(final SpacecraftState currentState, final boolean isLast); } diff --git a/java_additions/src/main/java/org/orekit/python/PythonUnivariateFunction.java b/java_additions/src/main/java/org/orekit/python/PythonUnivariateFunction.java index b4a0c8dc2e68b2a986c4fd821f3d961926b2991f..56090025fec1d3f0abe7f09e44cfa3869e226506 100644 --- a/java_additions/src/main/java/org/orekit/python/PythonUnivariateFunction.java +++ b/java_additions/src/main/java/org/orekit/python/PythonUnivariateFunction.java @@ -53,18 +53,7 @@ public class PythonUnivariateFunction implements org.hipparchus.analysis.Univari public native void pythonDecRef(); - /** - * Compute the value of the function. - * - * @param x Point at which the function value should be computed. - * @return the value of the function. - * @throws IllegalArgumentException when the activated method itself can - * ascertain that a precondition, specified in the API expressed at the - * level of the activated method, has been violated. - * When Commons Math throws an {@code IllegalArgumentException}, it is - * usually the consequence of checking the actual parameters passed to - * the method. - */ + /** {@inheritDoc} */ @Override public native double value(double x); diff --git a/java_additions/src/main/java/org/orekit/python/package-info.java b/java_additions/src/main/java/org/orekit/python/package-info.java index a6cf9bf3d94fa9ff3c6cad90622084d19e773503..7b22ee694f40de48f3dcc3379587163957e2ffc3 100644 --- a/java_additions/src/main/java/org/orekit/python/package-info.java +++ b/java_additions/src/main/java/org/orekit/python/package-info.java @@ -24,3 +24,4 @@ * @since 6.1 */ package org.orekit.python; + diff --git a/orekit-conda-recipe/bld.bat b/orekit-conda-recipe/bld.bat index 0a432afb93efb6976ebb77c349f471631de4c010..20a6b315c4007f13820f45d681829074b2bad1ab 100644 --- a/orekit-conda-recipe/bld.bat +++ b/orekit-conda-recipe/bld.bat @@ -1,15 +1,23 @@ +:: adding compile parameters explicitly as relocation for conda does not seem to detect JCC path under windows +@set "JCC_INCLUDES=%JCC_JDK%\include;%JCC_JDK%\include\win32" +@set "JCC_CFLAGS=/EHsc;/D_CRT_SECURE_NO_WARNINGS" +@set "JCC_LFLAGS=/DLL;/LIBPATH:%JCC_JDK%\lib;Ws2_32.lib;jvm.lib" +@set "JCC_DEBUG_CFLAGS=/Od;/DDEBUG" +@set "JCC_JAVAC=%JCC_JDK%\bin\javac.exe" +@set "JCC_JAVADOC=%JCC_JDK%\bin\javadoc.exe" + "%PYTHON%" -m jcc ^ --use_full_names ^ --python orekit ^ --version %PKG_VERSION% ^ ---jar %SRC_DIR%\orekit-9.2.jar ^ ---jar %SRC_DIR%\hipparchus-core-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-filtering-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-fitting-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-geometry-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-ode-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-optim-1.3.jar ^ ---jar %SRC_DIR%\hipparchus-stat-1.3.jar ^ +--jar %SRC_DIR%\orekit-9.3.jar ^ +--jar %SRC_DIR%\hipparchus-core-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-filtering-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-fitting-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-geometry-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-ode-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-optim-1.4.jar ^ +--jar %SRC_DIR%\hipparchus-stat-1.4.jar ^ --package java.io ^ --package java.util ^ --package java.text ^ @@ -48,6 +56,7 @@ java.util.TreeSet ^ --reserved min ^ --reserved max ^ --reserved mean ^ +--files 10 ^ --build ^ --install if errorlevel 1 exit 1 diff --git a/orekit-conda-recipe/build.sh b/orekit-conda-recipe/build.sh index 77af63d68e65971dd93448963aa91455431f01d2..eeb676e4a97e67e4470aadce6587a8ed2a290209 100644 --- a/orekit-conda-recipe/build.sh +++ b/orekit-conda-recipe/build.sh @@ -4,14 +4,14 @@ $PYTHON -m jcc \ --use_full_names \ --python orekit \ --version ${PKG_VERSION} \ ---jar $SRC_DIR/orekit-9.2.jar \ ---jar $SRC_DIR/hipparchus-core-1.3.jar \ ---jar $SRC_DIR/hipparchus-filtering-1.3.jar \ ---jar $SRC_DIR/hipparchus-fitting-1.3.jar \ ---jar $SRC_DIR/hipparchus-geometry-1.3.jar \ ---jar $SRC_DIR/hipparchus-ode-1.3.jar \ ---jar $SRC_DIR/hipparchus-optim-1.3.jar \ ---jar $SRC_DIR/hipparchus-stat-1.3.jar \ +--jar $SRC_DIR/orekit-9.3.jar \ +--jar $SRC_DIR/hipparchus-core-1.4.jar \ +--jar $SRC_DIR/hipparchus-filtering-1.4.jar \ +--jar $SRC_DIR/hipparchus-fitting-1.4.jar \ +--jar $SRC_DIR/hipparchus-geometry-1.4.jar \ +--jar $SRC_DIR/hipparchus-ode-1.4.jar \ +--jar $SRC_DIR/hipparchus-optim-1.4.jar \ +--jar $SRC_DIR/hipparchus-stat-1.4.jar \ --package java.io \ --package java.util \ --package java.text \ @@ -50,6 +50,7 @@ java.util.TreeSet \ --reserved min \ --reserved max \ --reserved mean \ +--files 10 \ --build \ --install diff --git a/orekit-conda-recipe/meta.yaml b/orekit-conda-recipe/meta.yaml index 85fc3590126ded1d628c1d58642019f561873b60..cc075a43ed299f091493c21ebc437279f3c50f6e 100644 --- a/orekit-conda-recipe/meta.yaml +++ b/orekit-conda-recipe/meta.yaml @@ -1,7 +1,7 @@ {% set name = "orekit" %} -{% set version = "9.2" %} -{% set filename = "v9_2" %} -{% set sha256 = "7a25f7f7482751793ea89624e54e68ffff8cd5de619fcfde61aadedc52784671" %} +{% set version = "9.3" %} +{% set filename = "v9_3" %} +{% set sha256 = "5d221350bc9f7fccefeb6405f87dc424d8cd4fcdd3a379d8170d20978a7593c7" %} package: name: {{ name|lower }} @@ -15,7 +15,7 @@ source: build: skip: true # [win32 or linux32] - number: 3 + number: 0 rpaths: - lib/ @@ -29,7 +29,7 @@ requirements: host: - python - setuptools - - jcc 3.3.dev2 + - jcc >=3.3 # Force anaconda openjdk - openjdk 8.0.152 @@ -43,17 +43,9 @@ test: - orekit source_files: - - test/AltitudeDetectorTest.py - - test/BackAndForthDetectorTest.py - - test/EventDetectorTest.py - - test/EventHandlerTest.py - - test/GroundFieldOfViewDetectorTest.py - - test/ImpulseManeuverTest.py - - test/KeplerianConverterTest.py - - test/NodeDetectorTest.py + - test/*.py - test/orekit-data.zip - - test/SmallManeuverAnalyticalModelTest.py - - test/TestAbstractDetector.py + - test/resources.zip about: home: https://www.orekit.org/forge/projects/orekit-python-wrapper diff --git a/orekit-conda-recipe/run_test.bat b/orekit-conda-recipe/run_test.bat index c6fcfd7f8ad262319756b34e249180081778f9ac..ed3e31256be72c142e15ede4bc8ea29040a14dd0 100644 --- a/orekit-conda-recipe/run_test.bat +++ b/orekit-conda-recipe/run_test.bat @@ -1,11 +1,2 @@ cd test -python AltitudeDetectorTest.py -python BackAndForthDetectorTest.py -python EventDetectorTest.py -python EventHandlerTest.py -python GroundFieldOfViewDetectorTest.py -python ImpulseManeuverTest.py -python KeplerianConverterTest.py -python NodeDetectorTest.py -python SmallManeuverAnalyticalModelTest.py -python TestAbstractDetector.py +for %%f in (*.py) do python "%%f" || exit /b 1 diff --git a/orekit-conda-recipe/run_test.sh b/orekit-conda-recipe/run_test.sh index 7b1396c40a044c475b869f536fbc56258d5fab62..84830144e080814fdb0411a4b3b0e9f93fd82a77 100644 --- a/orekit-conda-recipe/run_test.sh +++ b/orekit-conda-recipe/run_test.sh @@ -1,12 +1,4 @@ #!/usr/bin/env bash cd test -python AltitudeDetectorTest.py -python BackAndForthDetectorTest.py -python EventDetectorTest.py -python EventHandlerTest.py -python GroundFieldOfViewDetectorTest.py -python ImpulseManeuverTest.py -python KeplerianConverterTest.py -python NodeDetectorTest.py -python SmallManeuverAnalyticalModelTest.py -python TestAbstractDetector.py +for f in *.py; do python "$f"; done || exit 1 + diff --git a/python_files/test/AltitudeDetectorTest.py b/python_files/test/AltitudeDetectorTest.py index 28177b5a60172fb9b92ca6101d1ff3ccc8570b44..8308159bfdc0faa4544321bd90f3fb25bc1fdd45 100644 --- a/python_files/test/AltitudeDetectorTest.py +++ b/python_files/test/AltitudeDetectorTest.py @@ -28,7 +28,9 @@ import orekit orekit.initVM() from orekit.pyhelpers import setup_orekit_curdir setup_orekit_curdir() # orekit-data.zip shall be in current dir -#from math import abs +import unittest +import sys + from org.hipparchus.util import FastMath from org.orekit.bodies import CelestialBodyFactory @@ -43,35 +45,46 @@ from org.orekit.time import AbsoluteDate from org.orekit.time import TimeScalesFactory from org.orekit.propagation.events import AltitudeDetector -EME2000 = FramesFactory.getEME2000() -initialDate = AbsoluteDate(2009,1,1,TimeScalesFactory.getUTC()) -a = 8000000.0 -e = 0.1 -earthRadius = 6378137.0 -earthF = 1.0 / 298.257223563 -apogee = a*(1+e) -alt = apogee - earthRadius - 500 - -#// initial state is at apogee -initialOrbit = KeplerianOrbit(a,e,0.0,0.0,0.0,FastMath.PI,PositionAngle.MEAN,EME2000, - initialDate,CelestialBodyFactory.getEarth().getGM()) -initialState = SpacecraftState(initialOrbit) -kepPropagator = KeplerianPropagator(initialOrbit) -altDetector = AltitudeDetector(alt, - OneAxisEllipsoid(earthRadius, earthF, EME2000)).withHandler(StopOnEvent().of_(AltitudeDetector)) - -# altitudeDetector should stop propagation upon reaching required altitude -kepPropagator.addEventDetector(altDetector) - -#// propagation to the future -finalState = kepPropagator.propagate(initialDate.shiftedBy(1000.0)) -assert abs(finalState.getPVCoordinates().getPosition().getNorm()-earthRadius -alt)<1e-5 -assert abs(44.079 - finalState.getDate().durationFrom(initialDate))< 1.0e-3 - -#// propagation to the past -kepPropagator.resetInitialState(initialState) -finalState = kepPropagator.propagate(initialDate.shiftedBy(-1000.0)) -assert abs(finalState.getPVCoordinates().getPosition().getNorm()-earthRadius - alt)< 1e-5 -assert abs(-44.079 - finalState.getDate().durationFrom(initialDate))< 1.0e-3 - -print("AltitudeDetectorTest successfully run") + +class AltitudeDetectorTest(unittest.TestCase): + + def testBackAndForth(self): + EME2000 = FramesFactory.getEME2000() + initialDate = AbsoluteDate(2009,1,1,TimeScalesFactory.getUTC()) + a = 8000000.0 + e = 0.1 + earthRadius = 6378137.0 + earthF = 1.0 / 298.257223563 + apogee = a*(1+e) + alt = apogee - earthRadius - 500 + + #// initial state is at apogee + initialOrbit = KeplerianOrbit(a,e,0.0,0.0,0.0,FastMath.PI,PositionAngle.MEAN,EME2000, + initialDate,CelestialBodyFactory.getEarth().getGM()) + initialState = SpacecraftState(initialOrbit) + kepPropagator = KeplerianPropagator(initialOrbit) + altDetector = AltitudeDetector(alt, + OneAxisEllipsoid(earthRadius, earthF, EME2000)).withHandler(StopOnEvent().of_(AltitudeDetector)) + + # altitudeDetector should stop propagation upon reaching required altitude + kepPropagator.addEventDetector(altDetector) + + #// propagation to the future + finalState = kepPropagator.propagate(initialDate.shiftedBy(1000.0)) + assert abs(finalState.getPVCoordinates().getPosition().getNorm()-earthRadius -alt)<1e-5 + assert abs(44.079 - finalState.getDate().durationFrom(initialDate))< 1.0e-3 + + #// propagation to the past + kepPropagator.resetInitialState(initialState) + finalState = kepPropagator.propagate(initialDate.shiftedBy(-1000.0)) + assert abs(finalState.getPVCoordinates().getPosition().getNorm()-earthRadius - alt)< 1e-5 + assert abs(-44.079 - finalState.getDate().durationFrom(initialDate))< 1.0e-3 + + print("AltitudeDetectorTest successfully run") + + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(AltitudeDetectorTest) + ret = not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() + sys.exit(ret) \ No newline at end of file diff --git a/python_files/test/BackAndForthDetectorTest.py b/python_files/test/BackAndForthDetectorTest.py index 108e2a4644a3d645947efcbd8cd8d3863e01d543..ab7b01c789ca62c92c34f0504a926f56e3c8c01c 100644 --- a/python_files/test/BackAndForthDetectorTest.py +++ b/python_files/test/BackAndForthDetectorTest.py @@ -106,7 +106,7 @@ class BackAndForthDetectorTest(unittest.TestCase): propagator.propagate(date1) propagator.propagate(date0) - self.assertEquals(4, visi.getVisiNb()) + self.assertEqual(4, visi.getVisiNb()) if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(BackAndForthDetectorTest) diff --git a/python_files/test/EventDetectorTest.py b/python_files/test/EventDetectorTest.py index fc9e199eaebcd868db12d993caf8195262d051ba..5350ea893bc4d1fa0a87d1eb0f94f7557a4fd6db 100644 --- a/python_files/test/EventDetectorTest.py +++ b/python_files/test/EventDetectorTest.py @@ -23,11 +23,12 @@ """ import orekit + orekit.initVM() -#orekit.initVM(vmargs='-Xcheck:jni,-verbose:jni,-verbose:class,-XX:+UnlockDiagnosticVMOptions') +# orekit.initVM(vmargs='-Xcheck:jni,-verbose:jni,-verbose:class,-XX:+UnlockDiagnosticVMOptions') from org.orekit.frames import FramesFactory, TopocentricFrame -from org.orekit.bodies import OneAxisEllipsoid, GeodeticPoint +from org.orekit.bodies import OneAxisEllipsoid, GeodeticPoint from org.orekit.time import AbsoluteDate, TimeScalesFactory from org.orekit.orbits import KeplerianOrbit from org.orekit.utils import Constants @@ -42,9 +43,11 @@ import math import unittest import sys -from orekit.pyhelpers import setup_orekit_curdir +from orekit.pyhelpers import setup_orekit_curdir + setup_orekit_curdir() + class MyElevationDetector(PythonEventDetector): passes = 0 @@ -66,7 +69,7 @@ class MyElevationDetector(PythonEventDetector): return PythonAbstractDetector.DEFAULT_MAX_ITER def g(self, s): - tmp = self.topo.getElevation(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate())-self.elevation + tmp = self.topo.getElevation(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate()) - self.elevation return tmp def eventOccurred(self, s, increasing): @@ -88,11 +91,10 @@ class MyElevationDetector(PythonEventDetector): class EventDetectorTest(unittest.TestCase): def testOwnElevationDetector(self): - initialDate = AbsoluteDate(2014, 1, 1, 23, 30, 00.000, TimeScalesFactory.getUTC()) - inertialFrame = FramesFactory.getEME2000() # inertial frame for orbit definition - position = Vector3D(-6142438.668, 3492467.560, -25767.25680) - velocity = Vector3D(505.8479685, 942.7809215, 7435.922231) + inertialFrame = FramesFactory.getEME2000() # inertial frame for orbit definition + position = Vector3D(-6142438.668, 3492467.560, -25767.25680) + velocity = Vector3D(505.8479685, 942.7809215, 7435.922231) pvCoordinates = PVCoordinates(position, velocity) initialOrbit = KeplerianOrbit(pvCoordinates, inertialFrame, @@ -108,9 +110,9 @@ class EventDetectorTest(unittest.TestCase): # Station longitude = radians(45.0) - latitude = radians(25.0) - altitude = 0 - station1 = GeodeticPoint(latitude, longitude, float (altitude)) + latitude = radians(25.0) + altitude = 0 + station1 = GeodeticPoint(latitude, longitude, float(altitude)) sta1Frame = TopocentricFrame(earth, station1, "station 1") elevation = math.radians(5.0) @@ -118,10 +120,11 @@ class EventDetectorTest(unittest.TestCase): detector = MyElevationDetector(elevation, sta1Frame) kepler.addEventDetector(detector) - finalState = kepler.propagate(initialDate.shiftedBy(60*60*24.0*15)) + finalState = kepler.propagate(initialDate.shiftedBy(60 * 60 * 24.0 * 15)) print(detector.passes) - self.assertEquals(52, detector.passes) + self.assertEqual(52, detector.passes) + if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(EventDetectorTest) diff --git a/python_files/test/EventHandlerTest.py b/python_files/test/EventHandlerTest.py index 8681a732cec762548782aef6cd732ecd3d3efaa8..79678b0b293b9656da1a1be8c9deb99b96095078 100644 --- a/python_files/test/EventHandlerTest.py +++ b/python_files/test/EventHandlerTest.py @@ -49,7 +49,7 @@ import sys from orekit.pyhelpers import setup_orekit_curdir setup_orekit_curdir() -#%% + class EventHandlerTest(unittest.TestCase): def testOwnContinueOnEvent(self): @@ -80,7 +80,7 @@ class EventHandlerTest(unittest.TestCase): sta1Frame = TopocentricFrame(earth, station1, "station 1") elevation = math.radians(5.0) - #%% + class myContinueOnEvent(PythonEventHandler): def eventOccurred(self, s, T, increasing): @@ -104,12 +104,11 @@ class EventHandlerTest(unittest.TestCase): mylog = logger.getLoggedEvents() for ev in mylog: - #print 'Date: ',ev.getState().getDate(), ' Start pass: ',ev.isIncreasing() if ev.isIncreasing(): taken_passes = taken_passes + 1 - #print 'Taken passes:',taken_passes - self.assertEquals(52, taken_passes) + + self.assertEqual(52, taken_passes) if __name__ == '__main__': diff --git a/python_files/test/GroundFieldOfViewDetectorTest.py b/python_files/test/GroundFieldOfViewDetectorTest.py index c8967bccb169119725b68e1a6232ba9275637249..d909a1b09aa416610b10414735e45838f951c32e 100644 --- a/python_files/test/GroundFieldOfViewDetectorTest.py +++ b/python_files/test/GroundFieldOfViewDetectorTest.py @@ -95,8 +95,8 @@ class GroundFieldOfViewDetectorTest(unittest.TestCase): actual = logger.getLoggedEvents() # verify - self.assertEquals(2, expected.size()) - self.assertEquals(2, actual.size()) + self.assertEqual(2, expected.size()) + self.assertEqual(2, actual.size()) for i in range(0, 1): expectedDate = expected.get(i).getState().getDate() diff --git a/python_files/test/NodeDetectorTest.py b/python_files/test/NodeDetectorTest.py index 7c7b139dc10e261071ee0bb431902b88948135db..043ae291f0ff6df801b87d45ac8851ca4c38bfe1 100644 --- a/python_files/test/NodeDetectorTest.py +++ b/python_files/test/NodeDetectorTest.py @@ -27,6 +27,9 @@ Python version translated from Java by Petrus Hyvönen, SSC 2014 import orekit orekit.initVM() +import sys +import unittest + from orekit.pyhelpers import setup_orekit_curdir setup_orekit_curdir() # orekit-data.zip shall be in current dir @@ -45,59 +48,68 @@ from org.orekit.time import TimeScalesFactory from org.orekit.utils import Constants from orekit import JArray_double -# Floats are needed to be specific in the orekit interface -a = 800000.0 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS -e = 0.0001 -i = FastMath.toRadians(98.0) -w = -90.0 -raan = 0.0 -v = 0.0 - -inertialFrame = FramesFactory.getEME2000() -initialDate = AbsoluteDate(2014, 1, 1, 0, 0, 0.0, TimeScalesFactory.getUTC()) -finalDate = initialDate.shiftedBy(70*24*60*60.0) -initialOrbit = KeplerianOrbit(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU) -initialState = SpacecraftState(initialOrbit, 1000.0) - -tol = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType()) - -# Double array of doubles needs to be retyped to work -integrator = DormandPrince853Integrator(0.001, 1000.0, - JArray_double.cast_(tol[0]), - JArray_double.cast_(tol[1])) - -propagator = NumericalPropagator(integrator) -propagator.setInitialState(initialState) - -# Define 2 instances of NodeDetector: -rawDetector = NodeDetector(1e-6, - initialState.getOrbit(), - initialState.getFrame()).withHandler(ContinueOnEvent().of_(NodeDetector)) - -logger1 = EventsLogger() -node1 = logger1.monitorDetector(rawDetector) -logger2 = EventsLogger() -node2 = logger2.monitorDetector(rawDetector) - -propagator.addEventDetector(node1) -propagator.addEventDetector(node2) - -# First propagation -propagator.setEphemerisMode() -propagator.propagate(finalDate) - -assert 1998==logger1.getLoggedEvents().size() -assert 1998== logger2.getLoggedEvents().size(); -logger1.clearLoggedEvents() -logger2.clearLoggedEvents() - -postpro = propagator.getGeneratedEphemeris() - -# Post-processing -postpro.addEventDetector(node1) -postpro.addEventDetector(node2) -postpro.propagate(finalDate) -assert 1998==logger1.getLoggedEvents().size() -assert 1998==logger2.getLoggedEvents().size() - -print("NodeDetectorTest Successfully run") + +class NodeDetectorTest(unittest.TestCase): + def testIssue138(self): + # Floats are needed to be specific in the orekit interface + a = 800000.0 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS + e = 0.0001 + i = FastMath.toRadians(98.0) + w = -90.0 + raan = 0.0 + v = 0.0 + + inertialFrame = FramesFactory.getEME2000() + initialDate = AbsoluteDate(2014, 1, 1, 0, 0, 0.0, TimeScalesFactory.getUTC()) + finalDate = initialDate.shiftedBy(70*24*60*60.0) + initialOrbit = KeplerianOrbit(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU) + initialState = SpacecraftState(initialOrbit, 1000.0) + + tol = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType()) + + # Double array of doubles needs to be retyped to work + integrator = DormandPrince853Integrator(0.001, 1000.0, + JArray_double.cast_(tol[0]), + JArray_double.cast_(tol[1])) + + propagator = NumericalPropagator(integrator) + propagator.setInitialState(initialState) + + # Define 2 instances of NodeDetector: + rawDetector = NodeDetector(1e-6, + initialState.getOrbit(), + initialState.getFrame()).withHandler(ContinueOnEvent().of_(NodeDetector)) + + logger1 = EventsLogger() + node1 = logger1.monitorDetector(rawDetector) + logger2 = EventsLogger() + node2 = logger2.monitorDetector(rawDetector) + + propagator.addEventDetector(node1) + propagator.addEventDetector(node2) + + # First propagation + propagator.setEphemerisMode() + propagator.propagate(finalDate) + + assert 1998==logger1.getLoggedEvents().size() + assert 1998== logger2.getLoggedEvents().size(); + logger1.clearLoggedEvents() + logger2.clearLoggedEvents() + + postpro = propagator.getGeneratedEphemeris() + + # Post-processing + postpro.addEventDetector(node1) + postpro.addEventDetector(node2) + postpro.propagate(finalDate) + assert 1998==logger1.getLoggedEvents().size() + assert 1998==logger2.getLoggedEvents().size() + + print("NodeDetectorTest Successfully run") + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(NodeDetectorTest) + ret = not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() + sys.exit(ret) diff --git a/python_files/test/SmallManeuverAnalyticalModelTest.py b/python_files/test/SmallManeuverAnalyticalModelTest.py index 2c9713c9ff5521432a46fe5918006c868f3a6818..0fd306d934c72b0a1c7ea05024fbe6f7991d927c 100644 --- a/python_files/test/SmallManeuverAnalyticalModelTest.py +++ b/python_files/test/SmallManeuverAnalyticalModelTest.py @@ -55,8 +55,6 @@ from org.orekit.utils import PVCoordinates from math import radians -# from org.orekit.forces.maneuvers import getEphemeris - import unittest import sys @@ -81,7 +79,7 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): withManeuver = self.getEphemeris(leo, mass, t0, dV, f, isp) model = SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV, isp) - self.assertEquals(t0.toString(), model.getDate().toString()) + self.assertEqual(t0.toString(), model.getDate().toString()) t = withoutManeuver.getMinDate() while t.compareTo(withoutManeuver.getMaxDate()) < 0: @@ -92,8 +90,8 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): modelError = PVCoordinates(pvWith, pvModel).getPosition().getNorm() if t.compareTo(t0) < 0: # before maneuver, all positions should be equal - self.assertEquals(0, nominalDeltaP, 1.0e-10) - self.assertEquals(0, modelError, 1.0e-10) + self.assertEqual(0, nominalDeltaP, 1.0e-10) + self.assertEqual(0, modelError, 1.0e-10) else: # after maneuver, model error should be less than 0.8m, # despite nominal deltaP exceeds 1 kilometer after less than 3 orbits @@ -123,7 +121,7 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): withoutManeuver = self.getEphemeris(leo, mass, t0, Vector3D.ZERO, f, isp) withManeuver = self.getEphemeris(leo, mass, t0, dV, f, isp) model = SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV, isp) - self.assertEquals(t0.toString(), model.getDate().toString()) + self.assertEqual(t0.toString(), model.getDate().toString()) t = withoutManeuver.getMinDate() while t.compareTo(withoutManeuver.getMaxDate()) < 0: @@ -134,8 +132,8 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): modelError = PVCoordinates(pvWith, pvModel).getPosition().getNorm() if t.compareTo(t0) < 0: # before maneuver, all positions should be equal - self.assertEquals(0, nominalDeltaP, 1.0e-10) - self.assertEquals(0, modelError, 1.0e-10) + self.assertEqual(0, nominalDeltaP, 1.0e-10) + self.assertEqual(0, modelError, 1.0e-10) else: # after maneuver, model error should be less than 0.8m, # despite nominal deltaP exceeds 1 kilometer after less than 3 orbits @@ -166,7 +164,7 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): withManeuver = self.getEphemeris(heo, mass, t0, dV, f, isp) model = SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV, isp) - self.assertEquals(t0.toString(), model.getDate().toString()) + self.assertEqual(t0.toString(), model.getDate().toString()) t = withoutManeuver.getMinDate() while t.compareTo(withoutManeuver.getMaxDate()) < 0: @@ -177,8 +175,8 @@ class SmallManeuverAnalyticalModelTest(unittest.TestCase): modelError = PVCoordinates(pvWith, pvModel).getPosition().getNorm() if t.compareTo(t0) < 0: # before maneuver, all positions should be equal - self.assertEquals(0, nominalDeltaP, 1.0e-10) - self.assertEquals(0, modelError, 1.0e-10) + self.assertEqual(0, nominalDeltaP, 1.0e-10) + self.assertEqual(0, modelError, 1.0e-10) else: # after maneuver, model error should be less than 1700m, # despite nominal deltaP exceeds 300 kilometers at perigee, after 3 orbits diff --git a/python_files/test/TLEConverterTest.py b/python_files/test/TLEConverterTest.py index 83ab77b760d745302987717c97649a5806bef75e..8ada328771f8832f8fc451ae9f3606772fdee450 100644 --- a/python_files/test/TLEConverterTest.py +++ b/python_files/test/TLEConverterTest.py @@ -63,8 +63,8 @@ class TLEConverterTest(unittest.TestCase): drivers = builder.getPropagationParametersDrivers().getDrivers() # there should *not *be any drivers for central attraction coefficient (see issue # 313) - self.assertEquals(1, drivers.size()) - self.assertEquals("BSTAR", drivers.get(0).getName()) + self.assertEqual(1, drivers.size()) + self.assertEqual("BSTAR", drivers.get(0).getName()) fitter = FiniteDifferencePropagatorConverter(builder, threshold, 1000) sample = Arrays.asList(sample) @@ -77,27 +77,27 @@ class TLEConverterTest(unittest.TestCase): prop = TLEPropagator.cast_(fitter.getAdaptedPropagator()) fitted = prop.getTLE() - self.assertAlmostEquals(expectedRMS, fitter.getRMS(), delta=0.001 * expectedRMS) + self.assertAlmostEqual(expectedRMS, fitter.getRMS(), delta=0.001 * expectedRMS) - self.assertEquals(tle.getSatelliteNumber(), fitted.getSatelliteNumber()) - self.assertEquals(tle.getClassification(), fitted.getClassification()) - self.assertEquals(tle.getLaunchYear(), fitted.getLaunchYear()) - self.assertEquals(tle.getLaunchNumber(), fitted.getLaunchNumber()) - self.assertEquals(tle.getLaunchPiece(), fitted.getLaunchPiece()) - self.assertEquals(tle.getElementNumber(), fitted.getElementNumber()) - self.assertEquals(tle.getRevolutionNumberAtEpoch(), fitted.getRevolutionNumberAtEpoch()) + self.assertEqual(tle.getSatelliteNumber(), fitted.getSatelliteNumber()) + self.assertEqual(tle.getClassification(), fitted.getClassification()) + self.assertEqual(tle.getLaunchYear(), fitted.getLaunchYear()) + self.assertEqual(tle.getLaunchNumber(), fitted.getLaunchNumber()) + self.assertEqual(tle.getLaunchPiece(), fitted.getLaunchPiece()) + self.assertEqual(tle.getElementNumber(), fitted.getElementNumber()) + self.assertEqual(tle.getRevolutionNumberAtEpoch(), fitted.getRevolutionNumberAtEpoch()) eps = 1.0e-5 - self.assertAlmostEquals(tle.getMeanMotion(), fitted.getMeanMotion(), delta=eps * tle.getMeanMotion()) - self.assertAlmostEquals(tle.getE(), fitted.getE(), delta=eps * tle.getE()) - self.assertAlmostEquals(tle.getI(), fitted.getI(), delta=eps * tle.getI()) - self.assertAlmostEquals(tle.getPerigeeArgument(), fitted.getPerigeeArgument(), + self.assertAlmostEqual(tle.getMeanMotion(), fitted.getMeanMotion(), delta=eps * tle.getMeanMotion()) + self.assertAlmostEqual(tle.getE(), fitted.getE(), delta=eps * tle.getE()) + self.assertAlmostEqual(tle.getI(), fitted.getI(), delta=eps * tle.getI()) + self.assertAlmostEqual(tle.getPerigeeArgument(), fitted.getPerigeeArgument(), delta=eps * tle.getPerigeeArgument()) - self.assertAlmostEquals(tle.getRaan(), fitted.getRaan(), delta=eps * tle.getRaan()) - self.assertAlmostEquals(tle.getMeanAnomaly(), fitted.getMeanAnomaly(), delta=eps * tle.getMeanAnomaly()) + self.assertAlmostEqual(tle.getRaan(), fitted.getRaan(), delta=eps * tle.getRaan()) + self.assertAlmostEqual(tle.getMeanAnomaly(), fitted.getMeanAnomaly(), delta=eps * tle.getMeanAnomaly()) if withBStar: - self.assertAlmostEquals(tle.getBStar(), fitted.getBStar(), delta=eps * tle.getBStar()) + self.assertAlmostEqual(tle.getBStar(), fitted.getBStar(), delta=eps * tle.getBStar()) def testConversionGeoPositionVelocity(self): self.checkFit(self.geoTLE, 86400, 300, 1.0e-3, False, False, 9.350e-8) @@ -121,7 +121,7 @@ class TLEConverterTest(unittest.TestCase): #setup_orekit_curdir() DM = DataProvidersManager.getInstance() - datafile = File('regular-data.zip') + datafile = File('resources.zip') if not datafile.exists(): print('File :', datafile.absolutePath, ' not found') diff --git a/python_files/test/orekit-data.zip b/python_files/test/orekit-data.zip index d77c38d323d9ab92923e795dfdbe58f80407d902..3a1c657e8fdc51d36026cad63df9ae1390890eba 100644 Binary files a/python_files/test/orekit-data.zip and b/python_files/test/orekit-data.zip differ diff --git a/python_files/test/regular-data.zip b/python_files/test/regular-data.zip deleted file mode 100644 index a3a45540349050f055d990871105f7b4367f1f47..0000000000000000000000000000000000000000 Binary files a/python_files/test/regular-data.zip and /dev/null differ