diff --git a/README.txt b/README.txt index f1c5aed583018b9d8783b5d45b39b3807f2244f6..d0fde941aef781d3f2501a63a77affb231ac77ba 100644 --- a/README.txt +++ b/README.txt @@ -9,5 +9,8 @@ The python-wrapper project allows using orekit in a python environment. This repository contains some key files if building the wrapper from scratch. For many applications it is recommended to use pre-built conda packages through -the anaconda python system. See the wiki for more details. +the anaconda python system. See the wiki for more details, + +https://gitlab.orekit.org/orekit-labs/python-wrapper/-/wikis/home + diff --git a/examples/Example_EarthObservation_-_Attitude_Sequence.ipynb b/examples/Example_EarthObservation_-_Attitude_Sequence.ipynb index dcf524676dac4cb860c2d2e870b9f69e45b8b571..6b1f0249c0aea0227c98931c012d2765be42a869 100644 --- a/examples/Example_EarthObservation_-_Attitude_Sequence.ipynb +++ b/examples/Example_EarthObservation_-_Attitude_Sequence.ipynb @@ -659,7 +659,7 @@ "anaconda-cloud": {}, "hide_input": false, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -673,7 +673,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.7.1" }, "toc": { "base_numbering": 1, @@ -690,5 +690,5 @@ } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 2 } diff --git a/examples/Example_numerical_prop.ipynb b/examples/Example_numerical_prop.ipynb index 0e4f1c9289364275cd5deb608d0690d3a5419ff9..b909785017c05a9d57cc99bf8449e56eacd31401 100644 --- a/examples/Example_numerical_prop.ipynb +++ b/examples/Example_numerical_prop.ipynb @@ -32,7 +32,7 @@ { "data": { "text/plain": [ - "<jcc.JCCEnv at 0x8a6ecc0>" + "<jcc.JCCEnv at 0x906bd20>" ] }, "execution_count": 2, @@ -272,7 +272,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -286,9 +286,51 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.7.1" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 2 } diff --git a/examples/orekit_map.ipynb b/examples/orekit_map.ipynb index d6564cf30a9bf479930b1f2b2b5f11df829087b1..022ebb648c30b7f26ac3687b3d6cf84cdb312553 100644 --- a/examples/orekit_map.ipynb +++ b/examples/orekit_map.ipynb @@ -50,28 +50,17 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "<jcc.JCCEnv at 0x8a68cf0>" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import orekit\n", - "orekit.initVM()" + "vm = orekit.initVM()" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -88,7 +77,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -107,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -116,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -134,11 +123,11 @@ "source": [ "## Osculating orbit\n", "#Initial orbit parameters\n", - "ra = 800 * 1000 # Apogee!\n", - "rp = 700 * 1000 # Perigee!\n", - "i = radians(98.55) # inclination\n", - "omega = radians(90.0) # perigee argument\n", - "raan = radians(5.1917) # right ascension of ascending node\n", + "ra = 800 * 1000 # Apogee\n", + "rp = 700 * 1000 # Perigee\n", + "i = radians(98.55) # Inclination\n", + "omega = radians(90.0) # Perigee argument\n", + "raan = radians(5.1917) # Right ascension of ascending node\n", "lv = radians(359.93) # True anomaly\n", "\n", "epochDate = AbsoluteDate(2012, 1, 26, 16, 0, 00.000, utc)\n", @@ -358,7 +347,7 @@ "metadata": { "hide_input": false, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -372,7 +361,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.7.6" }, "toc": { "navigate_menu": false, @@ -389,5 +378,5 @@ } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/python_files/test/AbstractDetectorTest.py b/python_files/test/AbstractDetectorTest.py index 2bd3ddb35d88f7cfd41438f9775fc34274c2a032..5e0621a94fc62895991a9069c0660751c5abc5b7 100644 --- a/python_files/test/AbstractDetectorTest.py +++ b/python_files/test/AbstractDetectorTest.py @@ -10,28 +10,33 @@ from org.orekit.orbits import KeplerianOrbit from org.orekit.utils import Constants from org.orekit.propagation.analytical import KeplerianPropagator from org.orekit.utils import PVCoordinates, IERSConventions -from org.orekit.propagation.events.handlers import EventHandler +from org.orekit.propagation.events.handlers import PythonEventHandler from org.hipparchus.geometry.euclidean.threed import Vector3D -from org.orekit.python import PythonEventHandler, PythonAbstractDetector -from org.orekit.propagation.events.handlers import ContinueOnEvent, StopOnEvent +from org.orekit.propagation.events import PythonAbstractDetector +from org.orekit.propagation.events.handlers import StopOnEvent +from org.hipparchus.ode.events import Action + from math import radians import math import unittest import sys -from orekit.pyhelpers import setup_orekit_curdir +from orekit.pyhelpers import setup_orekit_curdir setup_orekit_curdir() class PassCounter(PythonEventHandler): """Eventhandler that counts positive events""" passes = 0 + def init(self, initialstate, target): + pass + def eventOccurred(self, s, T, increasing): if increasing: self.passes = self.passes + 1 - return EventHandler.Action.CONTINUE + return Action.CONTINUE def resetState(self, detector, oldState): return oldState diff --git a/python_files/test/AdditionalEquationsTest.py b/python_files/test/AdditionalEquationsTest.py index b6d6cf851e90ad910cba4bf02496f145b460aa72..12f4437f8300a711b5a036969b0d89816798bbb0 100644 --- a/python_files/test/AdditionalEquationsTest.py +++ b/python_files/test/AdditionalEquationsTest.py @@ -32,7 +32,7 @@ orekit.initVM() from orekit import JArray_double from org.orekit.data import DataProvidersManager, ZipJarCrawler -from org.orekit.python import PythonAdditionalEquations +from org.orekit.propagation.integration import PythonAdditionalEquations from org.orekit.propagation.integration import AdditionalEquations from org.orekit.forces.gravity.potential import GravityFieldFactory from org.orekit.forces.gravity.potential import SHMFormatReader diff --git a/python_files/test/BackAndForthDetectorTest.py b/python_files/test/BackAndForthDetectorTest.py index ab7b01c789ca62c92c34f0504a926f56e3c8c01c..afe000bee2ea31a724eb3b0fb1eb78b2261d7663 100644 --- a/python_files/test/BackAndForthDetectorTest.py +++ b/python_files/test/BackAndForthDetectorTest.py @@ -35,13 +35,14 @@ from org.orekit.orbits import KeplerianOrbit from org.orekit.frames import FramesFactory from org.orekit.orbits import PositionAngle from org.orekit.propagation.analytical import KeplerianPropagator -from org.orekit.propagation.events.handlers import EventHandler -from org.orekit.python import PythonEventHandler +from org.orekit.propagation.events.handlers import EventHandler, PythonEventHandler from org.orekit.time import AbsoluteDate from org.orekit.time import TimeScalesFactory from org.orekit.utils import Constants from org.orekit.utils import IERSConventions from org.orekit.propagation.events import ElevationDetector +from org.hipparchus.ode.events import Action + import unittest import sys import math @@ -52,13 +53,16 @@ class Visibility(PythonEventHandler): # implements EventHandler<ElevationDetecto def __init__(self): self._visiNb = 0 super(Visibility, self).__init__() + + def init(self, initialstate, target): + pass def getVisiNb(self): return self._visiNb def eventOccurred(self, s, ed, increasing): self._visiNb += 1 - return EventHandler.Action.CONTINUE + return Action.CONTINUE # def resetState(self, detector, oldState): return oldState diff --git a/python_files/test/EventDetectorTest.py b/python_files/test/EventDetectorTest.py index 5350ea893bc4d1fa0a87d1eb0f94f7557a4fd6db..5d2914f775fc6b1bbd3917a15984be996d14a6d0 100644 --- a/python_files/test/EventDetectorTest.py +++ b/python_files/test/EventDetectorTest.py @@ -36,7 +36,10 @@ from org.orekit.propagation.analytical import KeplerianPropagator from org.orekit.utils import PVCoordinates, IERSConventions from org.orekit.propagation.events.handlers import EventHandler from org.hipparchus.geometry.euclidean.threed import Vector3D -from org.orekit.python import PythonEventHandler, PythonAbstractDetector, PythonEventDetector +from org.orekit.propagation.events.handlers import PythonEventHandler +from org.orekit.propagation.events import PythonAbstractDetector, PythonEventDetector +from org.hipparchus.ode.events import Action + from math import radians import math @@ -76,7 +79,7 @@ class MyElevationDetector(PythonEventDetector): if increasing: self.passes = self.passes + 1 - return EventHandler.Action.CONTINUE + return Action.CONTINUE def resetState(self, oldState): return oldState diff --git a/python_files/test/EventHandlerTest.py b/python_files/test/EventHandlerTest.py index 79678b0b293b9656da1a1be8c9deb99b96095078..4589183ccf05545a0e67a94af23fce2cfb692c5c 100644 --- a/python_files/test/EventHandlerTest.py +++ b/python_files/test/EventHandlerTest.py @@ -34,11 +34,10 @@ from org.orekit.utils import Constants from org.orekit.propagation.analytical import KeplerianPropagator from org.orekit.utils import PVCoordinates, IERSConventions from org.orekit.propagation.events import ElevationDetector -from org.orekit.propagation.events.handlers import EventHandler +from org.orekit.propagation.events.handlers import EventHandler, PythonEventHandler from org.hipparchus.geometry.euclidean.threed import Vector3D -from org.orekit.python import PythonEventHandler from org.orekit.propagation.events import EventsLogger - +from org.hipparchus.ode.events import Action from math import radians import math @@ -46,7 +45,7 @@ import unittest import sys #%% Setup Orekit -from orekit.pyhelpers import setup_orekit_curdir +from orekit.pyhelpers import setup_orekit_curdir setup_orekit_curdir() @@ -83,8 +82,11 @@ class EventHandlerTest(unittest.TestCase): class myContinueOnEvent(PythonEventHandler): + def init(self, initialstate, target): + pass + def eventOccurred(self, s, T, increasing): - return EventHandler.Action.CONTINUE + return Action.CONTINUE def resetState(self, detector, oldState): return oldState diff --git a/python_files/test/FieldAdditionalEquationsTest.py b/python_files/test/FieldAdditionalEquationsTest.py index 17660c4c8243cc892d8326ad95a5f3af30cef999..afa7f373f46425ee2a3510f8c09ca34b7edf3d5e 100644 --- a/python_files/test/FieldAdditionalEquationsTest.py +++ b/python_files/test/FieldAdditionalEquationsTest.py @@ -33,7 +33,7 @@ orekit.initVM() from orekit import JArray_double from org.orekit.data import DataProvidersManager, ZipJarCrawler -from org.orekit.python import PythonFieldAdditionalEquations +from org.orekit.propagation.integration import PythonFieldAdditionalEquations from org.orekit.forces.gravity.potential import GravityFieldFactory from org.orekit.forces.gravity.potential import SHMFormatReader from java.io import File diff --git a/python_files/test/FieldStopOnDecreasingTest.py b/python_files/test/FieldStopOnDecreasingTest.py index aa8701b8d723ac1f58cc769b6badfffb42fd2daa..e28f040b619519f3db705d0f180f0113acbdd106 100644 --- a/python_files/test/FieldStopOnDecreasingTest.py +++ b/python_files/test/FieldStopOnDecreasingTest.py @@ -40,6 +40,7 @@ from org.orekit.orbits import PositionAngle from org.orekit.utils import Constants from org.orekit.propagation.events.handlers import FieldStopOnDecreasing from org.orekit.propagation.events.handlers import FieldEventHandler +from org.hipparchus.ode.events import Action class FieldStopOnDecreasingTest(unittest.TestCase): @@ -65,7 +66,7 @@ class FieldStopOnDecreasingTest(unittest.TestCase): PositionAngle.MEAN, FramesFactory.getEME2000(), date, - Constants.EIGEN5C_EARTH_MU)) + zero.add(Constants.EIGEN5C_EARTH_MU))) handler = FieldStopOnDecreasing() handler_casted = FieldEventHandler.cast_(handler) @@ -85,13 +86,13 @@ class FieldStopOnDecreasingTest(unittest.TestCase): PositionAngle.MEAN, FramesFactory.getEME2000(), date, - Constants.EIGEN5C_EARTH_MU)) + zero.add(Constants.EIGEN5C_EARTH_MU))) handler = FieldStopOnDecreasing() handler_casted = FieldEventHandler.cast_(handler) event = handler_casted.eventOccurred(s, None, True) - self.assertEqual(FieldEventHandler.Action.CONTINUE, event) + self.assertEqual(Action.CONTINUE, event) diff --git a/python_files/test/InterSatDirectViewDetectorTest.py b/python_files/test/InterSatDirectViewDetectorTest.py index e28a8106e99dcab97838973a24124bf9a1a0bfe9..b4d9aa60ccf4fd792c929ce3afa1c57177357ad2 100644 --- a/python_files/test/InterSatDirectViewDetectorTest.py +++ b/python_files/test/InterSatDirectViewDetectorTest.py @@ -39,7 +39,7 @@ from org.orekit.orbits import PositionAngle from org.orekit.time import AbsoluteDate from org.orekit.time import TimeScalesFactory from org.orekit.utils import Constants -from org.orekit.python import PythonOrekitFixedStepHandler +from org.orekit.propagation.sampling import PythonOrekitFixedStepHandler from org.orekit.propagation.events import InterSatDirectViewDetector from org.hipparchus.geometry.euclidean.threed import Line from org.hipparchus.geometry.euclidean.threed import Vector3D @@ -47,13 +47,17 @@ from org.orekit.bodies import OneAxisEllipsoid from org.orekit.frames import TopocentricFrame from org.orekit.orbits import CircularOrbit from org.orekit.propagation.analytical import KeplerianPropagator -from org.orekit.propagation.events.handlers import EventHandler +from org.orekit.propagation.events.handlers import EventHandler, PythonEventHandler from org.orekit.utils import IERSConventions -from org.orekit.python import PythonEventHandler + +from org.hipparchus.ode.events import Action class GrazingHandler(PythonEventHandler): + def init(self, initialstate, target): + pass + def eventOccurred(self, s, detector, increasing): # just before increasing events and just after decreasing events, # the master/slave line intersects Earth limb @@ -78,7 +82,7 @@ class GrazingHandler(PythonEventHandler): topo.getAzimuth(pMaster, frame, grazingDate))) assert -6.0e-14 < testvalue - 180.0 < 6.0e-14 - return EventHandler.Action.CONTINUE + return Action.CONTINUE # The full interface is required for java to accept it as a class of that type def resetState(self, detector, oldState): diff --git a/python_files/test/OrekitStepHandlerTest.py b/python_files/test/OrekitStepHandlerTest.py index a9ffeb12c2d5090ec9cb735f0611ca3be6982785..7e6fd6c3a132540420c53933249581f6fee45098 100644 --- a/python_files/test/OrekitStepHandlerTest.py +++ b/python_files/test/OrekitStepHandlerTest.py @@ -58,12 +58,10 @@ from org.orekit.propagation.analytical import KeplerianPropagator from org.orekit.propagation.events import DateDetector from org.orekit.propagation.events.handlers import ContinueOnEvent from org.orekit.propagation.numerical import NumericalPropagator +from org.orekit.propagation.sampling import PythonOrekitStepHandler, PythonOrekitFixedStepHandler from org.orekit.time import AbsoluteDate from org.orekit.time import TimeScalesFactory from org.orekit.utils import Constants -from org.orekit.python import PythonOrekitStepHandler -from org.orekit.python import PythonOrekitFixedStepHandler - class OrekitStepHandlerTest(unittest.TestCase): diff --git a/python_files/test/TLEConverterTest.py b/python_files/test/TLEConverterTest.py index 8ada328771f8832f8fc451ae9f3606772fdee450..06e5baaeda079581d9a28cc98085c164dcd110d2 100644 --- a/python_files/test/TLEConverterTest.py +++ b/python_files/test/TLEConverterTest.py @@ -77,7 +77,9 @@ class TLEConverterTest(unittest.TestCase): prop = TLEPropagator.cast_(fitter.getAdaptedPropagator()) fitted = prop.getTLE() - self.assertAlmostEqual(expectedRMS, fitter.getRMS(), delta=0.001 * expectedRMS) + tolerance = max(threshold, 0.001 * expectedRMS) + + self.assertAlmostEqual(expectedRMS, fitter.getRMS(), delta=tolerance) self.assertEqual(tle.getSatelliteNumber(), fitted.getSatelliteNumber()) self.assertEqual(tle.getClassification(), fitted.getClassification()) diff --git a/python_files/test/TestAbstractDetector.py b/python_files/test/TestAbstractDetector.py deleted file mode 100644 index cf99943c4348c3c23af3e5d4174ade2c247d3e20..0000000000000000000000000000000000000000 --- a/python_files/test/TestAbstractDetector.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- - -import orekit -orekit.initVM() - -from org.orekit.frames import FramesFactory, TopocentricFrame -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 -from org.orekit.propagation.analytical import KeplerianPropagator -from org.orekit.utils import PVCoordinates, IERSConventions -from org.orekit.propagation.events.handlers import EventHandler -from org.hipparchus.geometry.euclidean.threed import Vector3D -from org.orekit.python import PythonEventHandler, PythonAbstractDetector -from org.orekit.propagation.events.handlers import ContinueOnEvent, StopOnEvent - -from math import radians -import math -import unittest -import sys - -from orekit.pyhelpers import setup_orekit_curdir -setup_orekit_curdir() - -class PassCounter(PythonEventHandler): - """Eventhandler that counts positive events""" - passes = 0 - - def eventOccurred(self, s, T, increasing): - if increasing: - self.passes = self.passes + 1 - - return EventHandler.Action.CONTINUE - - def resetState(self, detector, oldState): - return oldState - - -class MyElevationDetector(PythonAbstractDetector): - - def __init__(self, elevation, topo, handler=None): - self.elevation = elevation - self.topo = topo - - dmax = float(PythonAbstractDetector.DEFAULT_MAXCHECK) - dthresh = float(PythonAbstractDetector.DEFAULT_THRESHOLD) - dmaxiter = PythonAbstractDetector.DEFAULT_MAX_ITER - if handler is None: - handler = StopOnEvent().of_(MyElevationDetector) - - super(MyElevationDetector, self).__init__(dmax, dthresh, dmaxiter, handler) #super(maxCheck, threshold, maxIter, handler); - - def init(self, *args, **kw): - pass - - def getElevation(self): - return self.elevation - - def getTopocentricFrame(self): - return self.topo - - def g(self, s): - tmp = self.topo.getElevation(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate())-self.elevation - return tmp - - def create(self, newMaxCheck, newThreshHold, newMaxIter, newHandler): - return MyElevationDetector(self.elevation, self.topo, handler=newHandler) - -class AbstractDetectorTest(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) - pvCoordinates = PVCoordinates(position, velocity) - initialOrbit = KeplerianOrbit(pvCoordinates, - inertialFrame, - initialDate, - Constants.WGS84_EARTH_MU) - - kepler = KeplerianPropagator(initialOrbit) - - ITRF = FramesFactory.getITRF(IERSConventions.IERS_2010, True) - earth = OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, - Constants.WGS84_EARTH_FLATTENING, - ITRF) - - # Station - longitude = radians(45.0) - latitude = radians(25.0) - altitude = 0 - station1 = GeodeticPoint(latitude, longitude, float (altitude)) - sta1Frame = TopocentricFrame(earth, station1, "station 1") - - elevation = math.radians(5.0) - - detector = MyElevationDetector(elevation, sta1Frame) - - mycounter = PassCounter().of_(MyElevationDetector) - detector = detector.withHandler(mycounter) - - kepler.addEventDetector(detector) - - finalState = kepler.propagate(initialDate.shiftedBy(60*60*24.0*15)) - - print(mycounter.passes) - self.assertEquals(52, mycounter.passes) - -if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(AbstractDetectorTest) - ret = not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() - sys.exit(ret) diff --git a/python_files/test/orekit-data.zip b/python_files/test/orekit-data.zip index 3a1c657e8fdc51d36026cad63df9ae1390890eba..564a2ad7eb4d223c5a532737d1960e5a5a2bee97 100644 Binary files a/python_files/test/orekit-data.zip and b/python_files/test/orekit-data.zip differ