Package: pyorb
PyOrbPyOrb is a lightweight package designed to convert back and forth between cartesian and kepler coordinates seamlessly and in a physically consistent manner, following defined rules. It provides a convenience class for handling orbits and is tested for special cases such as planar and circular orbits.See full documentationhere.Feature listCurrent features:Clear definition of an orbit, consistent throughout the code, including planar and circular orbitsKepler to Cartesian conversionCartesian to Kepler conversionCan handle hyperbolic orbitsAll function handles all special cases (e.g. planar, circular and parabolic orbits)ConvenientOrbitclass or storing orbits and seamlessly convert between Kepler and Cartesian elementsAccess to all types of orbit anomaliesVectorized function for increased performanceAccess to alternative parameterizations such as Equinoctial elementsOn the upcoming feature list:C-implementation of conversion function for performanceConverting of orbits to a byte-streamSaving orbits to file (binary or HDFS 5)To installpipinstallpyorbor to do the "nightly" build:gitclonehttps://github.com/danielk333/pyorbcdpyorb
gitcheckoutdevelop
pipinstall.Alternatively, if you are following updates closely you can install usingpip install -e .so that in the future agit pullwill update the library.Exampleimportpyorborb=pyorb.Orbit(M0=pyorb.M_sol,degrees=True)orb.update(a=1*pyorb.AU,e=0,i=0,omega=0,Omega=0,anom=0)# Convert and get cartesian elementsprint(orb.cartesian)# Make eccentric and place at aphelionorb.e=0.2orb.anom=180# print cartesian position in AU at aphelion after the above changesprint(orb.r/pyorb.AU)To developFirst clone and branch off developgitclonehttps://github.com/danielk333/pyorbcdpyorb
gitcheckoutdevelop
gitcheckout-bmy-name/my-featurethen editable install with development extras and install the pre-commit hookspipinstall-e.[develop]pre-commitinstalland get to hacking!Internal developmentPlease refer to the style and contribution guidelines documented in theIRF Software Contribution Guide.External code-contributionsGenerally external code-contributions are made trough a "Fork-and-pull"
workflow towards thedevelopbranch.Ellipse and angle definitionsVariables:a: Semi-major axise: Eccentricityi: Inclinationomega: Argument of perihelionOmega: Longitude of the ascending nodenu: True anomalyE: Elliptic, parabolic or hyperbolic eccentric anomalyM: Mean anomalyOrientation of the ellipse in the coordinate system and angle definitions:For zero inclination: the ellipse is located in the x-y plane.The direction of motion as True anomaly increases for a zero inclination orbit is anti-coockwise, i.e. from +x towards +y.If the eccentricity is increased for an unrotated orbit, the periapsis will lie in +x direction.If the inclination is increased, the ellipse will rotate around the x-axis, so that +y is rotated toward +z.An increase in Longitude of the ascending node corresponds to a rotation around the z-axis so that +x is rotated toward +y.Changing argument of perihelion will not change the plane of the orbit, it will rotate the orbit in the plane.Changing argument of perihelion will rotate the periapsis in the direction of motion.True anomaly measures from the +x axis, i.enu = 0is located at periapsis andnu = piat apoapsis.All anomalies and orientation angles reach between0and2piIf the inclination is0orpithe longitude of the ascending node is always zero (the rotation is described by only argument of perihelion).If the eccentricity is zero, the argument of perihelion is always zero (the rotation is described by only the longitude of the ascending node).If bothe=0andi=0ori=pi: the position on the circle is only described by the anomaly.The eccentric anomaly is used for elliptic, parabolic and hyperbolic cases but the kepler equation changes accordingly.For parabolic and hyperbolic orbits the true and eccentric anomaly wraps atpito the same trajectory, not the mirror version.Shape definitions:The Semi-major axis is always positive.In the case of a parabolic orbit, as the Semi-major axis is undefined it is used as the periapsis distance instead.NotesDisabling direct conversionThere are two toggle flags in thepyorb.Orbitclass for changing the conversion behavior:direct_updateandauto_updatethat areTrueby default.Disablingdirect_updatewill stop automatic conversion between elements if any element is changed. This would allow for e.g.orb.a=1orb.omega=0without any conversion to be done. However, as the kepler elements changed, the class has internally tracked this change and ifauto_update=Trueonce an access to a cartesian property is performed, e.g.print(orb.x), the conversion is performed so that the pair of cartesian-kepler elements are never contradictory.If alsoauto_updateis disabled, the update between kepler and cartesian needs to be manually by callingorb.calculate_cartesian()ororb.calculate_kepler()Using conversion functions directlyThepyorb.cart_to_keporpyorb.kep_to_cartuses True anomaly and takes only numpy arrays ordered as per the function documentation.FramesRemember that an Keplerian orbit only makes sense in an inertial frame if gravitation dominated physics is your concern.Array orbitsProperties act on ALL orbits in the classOnly way to update individual orbits of a set is to useself.updatewith theindskeywordIterations are passive, the objects are copies from the array so the array itself is NOT modifiedMIT LicenseCopyright (c) [2023] [Daniel Kastinen]Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.