Commit 4e3ee23c authored by Ole Streicher's avatar Ole Streicher

New upstream version 0.11.0

parent d94dc2ae
Metadata-Version: 2.1
Name: poliastro
Version: 0.11b1
Version: 0.11.0
Summary: Python package for Orbital Mechanics
Home-page: http://blog.poliastro.space/
Home-page: https://blog.poliastro.space/
Author: Juan Luis Cano
Author-email: hello@juanlu.space
License: MIT
......@@ -21,7 +21,7 @@ Description: .. poliastro
:Name: poliastro
:Website: https://poliastro.github.io/
:Author: Juan Luis Cano Rodríguez |orcid|
:Version: 0.11b1
:Version: 0.11.0
.. |circleci| image:: https://img.shields.io/circleci/project/github/poliastro/poliastro/0.11.x.svg?style=flat-square&logo=circleci
:target: https://circleci.com/gh/poliastro/poliastro
......@@ -38,8 +38,8 @@ Description: .. poliastro
.. |codeclimate| image:: https://api.codeclimate.com/v1/badges/fd2aa5bf8c4b7984d11b/maintainability
:target: https://codeclimate.com/github/poliastro/poliastro/maintainability
.. |docs| image:: https://img.shields.io/badge/docs-v0.11b1-brightgreen.svg?style=flat-square
:target: http://docs.poliastro.space/en/v0.11b1/?badge=v0.11b1
.. |docs| image:: https://img.shields.io/badge/docs-v0.11.0-brightgreen.svg?style=flat-square
:target: https://docs.poliastro.space/en/v0.11.0/?badge=v0.11.0
.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
:target: https://github.com/poliastro/poliastro/raw/0.11.x/COPYING
......@@ -85,9 +85,9 @@ Description: .. poliastro
Complete documentation, including a user guide and an API reference, can be read on
the wonderful `Read the Docs`_.
http://docs.poliastro.space/en/v0.11b1/
https://docs.poliastro.space/en/v0.11.0/
.. _`Read the Docs`: http://readthedocs.io/
.. _`Read the Docs`: https://readthedocs.org/
Examples
========
......@@ -140,7 +140,7 @@ Description: .. poliastro
Please check out the `documentation for alternative installation methods`_.
.. _`documentation for alternative installation methods`: http://docs.poliastro.space/en/v0.11b1/getting_started.html#alternative-installation-methods
.. _`documentation for alternative installation methods`: https://docs.poliastro.space/en/v0.11.0/getting_started.html#alternative-installation-methods
Testing
=======
......@@ -231,7 +231,7 @@ Description: .. poliastro
* It leaves out certain features that would be too Earth-specific, such as
TLE reading, SGP4 propagation, groundtrack plotting and others.
.. _`Related software`: http://docs.poliastro.space/en/v0.11b1/about.html#related-software
.. _`Related software`: https://docs.poliastro.space/en/v0.11.0/about.html#related-software
What's the future of the project?
---------------------------------
......
......@@ -12,7 +12,7 @@
:Name: poliastro
:Website: https://poliastro.github.io/
:Author: Juan Luis Cano Rodríguez |orcid|
:Version: 0.11b1
:Version: 0.11.0
.. |circleci| image:: https://img.shields.io/circleci/project/github/poliastro/poliastro/0.11.x.svg?style=flat-square&logo=circleci
:target: https://circleci.com/gh/poliastro/poliastro
......@@ -29,8 +29,8 @@
.. |codeclimate| image:: https://api.codeclimate.com/v1/badges/fd2aa5bf8c4b7984d11b/maintainability
:target: https://codeclimate.com/github/poliastro/poliastro/maintainability
.. |docs| image:: https://img.shields.io/badge/docs-v0.11b1-brightgreen.svg?style=flat-square
:target: http://docs.poliastro.space/en/v0.11b1/?badge=v0.11b1
.. |docs| image:: https://img.shields.io/badge/docs-v0.11.0-brightgreen.svg?style=flat-square
:target: https://docs.poliastro.space/en/v0.11.0/?badge=v0.11.0
.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
:target: https://github.com/poliastro/poliastro/raw/0.11.x/COPYING
......@@ -76,9 +76,9 @@ Documentation
Complete documentation, including a user guide and an API reference, can be read on
the wonderful `Read the Docs`_.
http://docs.poliastro.space/en/v0.11b1/
https://docs.poliastro.space/en/v0.11.0/
.. _`Read the Docs`: http://readthedocs.io/
.. _`Read the Docs`: https://readthedocs.org/
Examples
========
......@@ -131,7 +131,7 @@ install poliastro using `conda <http://conda.io>`_::
Please check out the `documentation for alternative installation methods`_.
.. _`documentation for alternative installation methods`: http://docs.poliastro.space/en/v0.11b1/getting_started.html#alternative-installation-methods
.. _`documentation for alternative installation methods`: https://docs.poliastro.space/en/v0.11.0/getting_started.html#alternative-installation-methods
Testing
=======
......@@ -222,7 +222,7 @@ poliastro is focused on interplanetary applications. This has two consequences:
* It leaves out certain features that would be too Earth-specific, such as
TLE reading, SGP4 propagation, groundtrack plotting and others.
.. _`Related software`: http://docs.poliastro.space/en/v0.11b1/about.html#related-software
.. _`Related software`: https://docs.poliastro.space/en/v0.11.0/about.html#related-software
What's the future of the project?
---------------------------------
......
......@@ -73,8 +73,8 @@ served as inspiration:
.. _astropy: http://www.astropy.org/
.. _Skyfield: http://rhodesmill.org/skyfield/
.. _Plyades: http://plyades.readthedocs.org/en/latest/
.. _orbital: http://pythonhosted.org/OrbitalPy/
.. _Plyades: https://plyades.readthedocs.io/
.. _orbital: https://pythonhosted.org/OrbitalPy/
.. _orekit-python-wrapper: https://www.orekit.org/forge/projects/orekit-python-wrapper/wiki
.. _beyond: https://github.com/galactics/beyond/
.. _SpiceyPy: https://github.com/andrewannex/SpiceyPy
......
What's new
==========
poliastro 0.11 - TBD
--------------------
.. warning::
This version has not been released yet!
poliastro 0.11.0 - 2018-09-21
-----------------------------
This short cycle release brought some new features related to the three body problem,
as well as important changes related to how reference frames are handled in poliastro.
......@@ -20,10 +16,6 @@ Highlights
New features
............
.. todo::
Change name from restricted to lagrange
* **Lagrange points**: The new experimental module :py:mod:`poliastro.threebody.restricted`
contains functions to compute the Lagrange points in the circular restricted three body
problem (CR3BP). It has been validated only approximately, so use it at your own risk.
......@@ -45,8 +37,12 @@ New features
Bugs fixed
..........
We did not fix any of the pending bugs during this release cycle.
Do you want to help? https://github.com/poliastro/poliastro/issues?q=is%3Aopen+is%3Aissue+label%3Abug
* `Issue #450`_: Angles function of safe API have wrong docstrings
.. _`Issue #450`: https://github.com/poliastro/poliastro/issues/450
Do you want to help with the remaining ones? Check the current list here!
https://github.com/poliastro/poliastro/issues?q=is%3Aopen+is%3Aissue+label%3Abug
Backwards incompatible changes
..............................
......
......@@ -59,7 +59,7 @@ master_doc = 'index'
# General information about the project.
project = 'poliastro'
copyright = u'2013-2017, Juan Luis Cano Rodríguez and the poliastro development team'
copyright = u'2013-2018, Juan Luis Cano Rodríguez and the poliastro development team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......@@ -68,7 +68,7 @@ copyright = u'2013-2017, Juan Luis Cano Rodríguez and the poliastro development
# The short X.Y version.
version = '0.11'
# The full version, including alpha/beta/rc tags.
release = '0.11b1'
release = '0.11.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -31,10 +31,19 @@ poliastro.core.perturbations module
.. automodule:: poliastro.core.perturbations
:members:
poliastro.core.thrust module
***********************************
poliastro.core.thrust package
*****************************
.. automodule:: poliastro.core.thrust.change_a_inc
:members:
.. automodule:: poliastro.core.thrust.change_argp
:members:
.. automodule:: poliastro.core.thrust.change_ecc_quasioptimal
:members:
.. automodule:: poliastro.core.thrust
.. automodule:: poliastro.core.thrust.change_inc_ecc
:members:
poliastro.core.propagation module
......
......@@ -795,7 +795,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's define a function to do that quickly for us, using the [`get_frame`](http://docs.poliastro.space/en/latest/safe.html#poliastro.frames.get_frame) function from poliastro.frames:"
"Let's define a function to do that quickly for us, using the [`get_frame`](https://docs.poliastro.space/en/latest/safe.html#poliastro.frames.get_frame) function from poliastro.frames:"
]
},
{
......
......@@ -6,7 +6,7 @@
"source": [
"# Going to Mars with Python using poliastro\n",
"\n",
"<img src=\"http://docs.poliastro.space/en/latest/_images/logo_text.png\" />\n",
"<img src=\"https://docs.poliastro.space/en/latest/_images/logo_text.png\" />\n",
"\n",
"This is an example on how to use [poliastro](https://github.com/poliastro/poliastro), a little library I've been working on to use in my Astrodynamics lessons. It features conversion between **classical orbital elements** and position vectors, propagation of **Keplerian orbits**, initial orbit determination using the solution of the **Lambert's problem** and **orbit plotting**.\n",
"\n",
......
......@@ -334,7 +334,7 @@
"source": [
"While `neows` can only be used to get Orbit objects, `dastcom5` can also provide asteroid and comet complete database.\n",
"Once you have this, you can get specific data about one or more bodies. The complete databases are `ndarrays`, so if you want to know the entire list of available parameters, you can look at the `dtype`, and they are also explained in\n",
"[documentation API Reference](http://docs.poliastro.space/en/latest/dastcom5 parameters.html):"
"[documentation API Reference](https://docs.poliastro.space/en/latest/dastcom5 parameters.html):"
]
},
{
......@@ -399,7 +399,7 @@
"metadata": {},
"source": [
"Talking in orbital terms, `Atiras` have an aphelion distance, `Q < 0.983 au` and a semi-major axis, ` a < 1.0 au`.\n",
"Visiting [documentation API Reference](http://docs.poliastro.space/en/latest/dastcom5 parameters.html), you can see that DASTCOM5 provides semi-major axis, but doesn't provide aphelion distance. You can get aphelion distance easily knowing perihelion distance (q, QR in DASTCOM5) and semi-major axis `Q = 2*a - q`, but there are probably many other ways."
"Visiting [documentation API Reference](https://docs.poliastro.space/en/latest/dastcom5 parameters.html), you can see that DASTCOM5 provides semi-major axis, but doesn't provide aphelion distance. You can get aphelion distance easily knowing perihelion distance (q, QR in DASTCOM5) and semi-major axis `Q = 2*a - q`, but there are probably many other ways."
]
},
{
......
......@@ -72,6 +72,22 @@ you find any, please open an issue in the `issue tracker`_.
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv
.. _`local installations`: http://stackoverflow.com/a/4325047/554319
Using poliastro on JupyterLab
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
After the release of plotly 3.0, plotting orbits using poliastro is easier than ever.
You have to install 2 (two) extensions of JupyterLab to make your experience smooth.
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager
$ jupyter labextension install @jupyterlab/plotly-extension
And as the documentation of JupyterLab Extensions states:
"In order to install JupyterLab extensions, you need to have Node.js version 4 or later installed."
Testing
-------
......
......@@ -8,7 +8,13 @@ poliastro - Astrodynamics in Python
**poliastro** is an open source (MIT) collection of Python functions useful
in Astrodynamics and Orbital Mechanics, focusing on interplanetary applications.
It provides a simple and intuitive API and handles physical quantities with
units. Some of its awesome features are:
units.
View `source code`_ of poliastro!
.. _`source code`: https://github.com/poliastro/poliastro
Some of its awesome features are:
* Analytical and numerical orbit propagation
* Conversion between position and velocity vectors and classical orbital
......@@ -51,6 +57,10 @@ browser using binder, a cloud Jupyter notebook server:
.. _`issue tracker`: https://github.com/poliastro/poliastro/issues
.. _`wiki`: https://github.com/poliastro/poliastro/wiki/
See `benchmarks`_ for the performance analysis of poliastro.
.. _`benchmarks`: https://blog.poliastro.space/poliastro-benchmarks/
poliastro works on recent versions of Python and is released under
the MIT license, hence allowing commercial use of the library.
......
......@@ -49,6 +49,21 @@ poliastro.twobody.rv module
.. automodule:: poliastro.twobody.rv
:members:
poliastro.twobody.thrust package
********************************
.. automodule:: poliastro.twobody.thrust.change_a_inc
:members:
.. automodule:: poliastro.twobody.thrust.change_argp
:members:
.. automodule:: poliastro.twobody.thrust.change_ecc_quasioptimal
:members:
.. automodule:: poliastro.twobody.thrust.change_inc_ecc
:members:
poliastro.iod package
---------------------
......
......@@ -16,7 +16,7 @@ setup(
description="Python package for Orbital Mechanics",
author="Juan Luis Cano",
author_email="hello@juanlu.space",
url="http://blog.poliastro.space/",
url="https://blog.poliastro.space/",
download_url="https://github.com/poliastro/poliastro",
license="MIT",
keywords=[
......@@ -41,7 +41,7 @@ setup(
'dev': [
"coverage",
"pytest",
"pytest-cov",
"pytest-cov<2.6.0",
"pycodestyle",
"sphinx",
"sphinx_rtd_theme",
......
Metadata-Version: 2.1
Name: poliastro
Version: 0.11b1
Version: 0.11.0
Summary: Python package for Orbital Mechanics
Home-page: http://blog.poliastro.space/
Home-page: https://blog.poliastro.space/
Author: Juan Luis Cano
Author-email: hello@juanlu.space
License: MIT
......@@ -21,7 +21,7 @@ Description: .. poliastro
:Name: poliastro
:Website: https://poliastro.github.io/
:Author: Juan Luis Cano Rodríguez |orcid|
:Version: 0.11b1
:Version: 0.11.0
.. |circleci| image:: https://img.shields.io/circleci/project/github/poliastro/poliastro/0.11.x.svg?style=flat-square&logo=circleci
:target: https://circleci.com/gh/poliastro/poliastro
......@@ -38,8 +38,8 @@ Description: .. poliastro
.. |codeclimate| image:: https://api.codeclimate.com/v1/badges/fd2aa5bf8c4b7984d11b/maintainability
:target: https://codeclimate.com/github/poliastro/poliastro/maintainability
.. |docs| image:: https://img.shields.io/badge/docs-v0.11b1-brightgreen.svg?style=flat-square
:target: http://docs.poliastro.space/en/v0.11b1/?badge=v0.11b1
.. |docs| image:: https://img.shields.io/badge/docs-v0.11.0-brightgreen.svg?style=flat-square
:target: https://docs.poliastro.space/en/v0.11.0/?badge=v0.11.0
.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
:target: https://github.com/poliastro/poliastro/raw/0.11.x/COPYING
......@@ -85,9 +85,9 @@ Description: .. poliastro
Complete documentation, including a user guide and an API reference, can be read on
the wonderful `Read the Docs`_.
http://docs.poliastro.space/en/v0.11b1/
https://docs.poliastro.space/en/v0.11.0/
.. _`Read the Docs`: http://readthedocs.io/
.. _`Read the Docs`: https://readthedocs.org/
Examples
========
......@@ -140,7 +140,7 @@ Description: .. poliastro
Please check out the `documentation for alternative installation methods`_.
.. _`documentation for alternative installation methods`: http://docs.poliastro.space/en/v0.11b1/getting_started.html#alternative-installation-methods
.. _`documentation for alternative installation methods`: https://docs.poliastro.space/en/v0.11.0/getting_started.html#alternative-installation-methods
Testing
=======
......@@ -231,7 +231,7 @@ Description: .. poliastro
* It leaves out certain features that would be too Earth-specific, such as
TLE reading, SGP4 propagation, groundtrack plotting and others.
.. _`Related software`: http://docs.poliastro.space/en/v0.11b1/about.html#related-software
.. _`Related software`: https://docs.poliastro.space/en/v0.11.0/about.html#related-software
What's the future of the project?
---------------------------------
......
......@@ -121,6 +121,7 @@ src/poliastro/tests/tests_neos/table.html
src/poliastro/tests/tests_neos/test_dastcom5.py
src/poliastro/tests/tests_neos/test_neos_neows.py
src/poliastro/tests/tests_threebody/test_flybys.py
src/poliastro/tests/tests_threebody/test_restricted.py
src/poliastro/tests/tests_twobody/test_angles.py
src/poliastro/tests/tests_twobody/test_decorators.py
src/poliastro/tests/tests_twobody/test_orbit.py
......
......@@ -15,7 +15,7 @@ numba>=0.39
[dev]
coverage
pytest
pytest-cov
pytest-cov<2.6.0
pycodestyle
sphinx
sphinx_rtd_theme
......
......@@ -7,4 +7,4 @@ Utilities and Python wrappers for Orbital Mechanics
"""
__version__ = '0.11b1'
__version__ = '0.11.0'
......@@ -18,9 +18,9 @@ class Maneuver(object):
>>> man = Maneuver((0 * u.s, [1, 0, 0] * u.km / u.s),
... (10 * u.s, [1, 0, 0] * u.km / u.s))
>>> man[0]
(<Quantity 0 s>, <Quantity [1,0,0] km / s>)
(<Quantity 0. s>, <Quantity [1., 0., 0.] km / s>)
>>> man.impulses[1]
(<Quantity 10 s>, <Quantity [1,0,0] km / s>)
(<Quantity 10. s>, <Quantity [1., 0., 0.] km / s>)
"""
def __init__(self, *impulses):
......
......@@ -43,10 +43,9 @@ def test_planetary_frames_have_proper_string_representations(body, frame):
(Saturn, SaturnICRS),
(Uranus, UranusICRS),
(Neptune, NeptuneICRS),
(Pluto, PlutoICRS),
])
def test_planetary_icrs_frame_is_just_translation(body, frame):
with solar_system_ephemeris.set("de432s"):
with solar_system_ephemeris.set("builtin"):
epoch = J2000
vector = CartesianRepresentation(x=100 * u.km, y=100 * u.km, z=100 * u.km)
vector_result = frame(vector, obstime=epoch).transform_to(ICRS).represent_as(CartesianRepresentation)
......@@ -66,10 +65,9 @@ def test_planetary_icrs_frame_is_just_translation(body, frame):
(Saturn, SaturnICRS),
(Uranus, UranusICRS),
(Neptune, NeptuneICRS),
(Pluto, PlutoICRS),
])
def test_icrs_body_position_to_planetary_frame_yields_zeros(body, frame):
with solar_system_ephemeris.set("de432s"):
with solar_system_ephemeris.set("builtin"):
epoch = J2000
vector = get_body_barycentric(body.name, epoch)
......
......@@ -25,6 +25,7 @@ def _fake_numba_import():
del _jit
del sys.modules['poliastro.core._jit']
if 'numba' in sys.modules:
del sys.modules['numba']
sys.meta_path.insert(0, fail_loader)
......
from math import cos, sin, pi
from astropy.tests.helper import assert_quantity_allclose
from astropy import units as u
from poliastro.bodies import Earth, Moon
from poliastro.threebody.restricted import lagrange_points_vec
def test_lagrange_points_vec():
# Figure 2.36 from Curtis
deg60 = 60 * pi / 180
expected_L1 = 326400 * ([1, 0, 0] * u.km)
expected_L2 = 449100 * ([1, 0, 0] * u.km)
expected_L3 = -381600 * ([1, 0, 0] * u.km)
expected_L4 = 384400 * ([cos(deg60), sin(deg60), 0] * u.km)
expected_L5 = 384400 * ([cos(deg60), -sin(deg60), 0] * u.km)
earth_mass = Earth.mass
moon_mass = Moon.mass
# Values from Curtis
# earth_mass = 5.974e24 * u.kg
# moon_mass = 73.48e21 * u.kg
L1, L2, L3, L4, L5 = lagrange_points_vec(m1=earth_mass,
r1=([0, 0, 0] * u.km),
m2=moon_mass,
r2=384400 * ([1, 0, 0] * u.km),
n=[0, 0, 1] * u.one)
assert_quantity_allclose(L1, expected_L1, rtol=1.e-3)
assert_quantity_allclose(L2, expected_L2, rtol=1.e-3)
assert_quantity_allclose(L3, expected_L3, rtol=1.e-3)
assert_quantity_allclose(L4, expected_L4, rtol=1.e-3)
assert_quantity_allclose(L5, expected_L5, rtol=1.e-3)
......@@ -203,7 +203,7 @@ sun_geo = {'body': Sun, 'tof': 200 * u.day, 'raan': 8.7 * u.deg, 'argp': -5.5 *
def test_3rd_body_Curtis(test_params):
# based on example 12.11 from Howard Curtis
body = test_params['body']
with solar_system_ephemeris.set('de432s'):
with solar_system_ephemeris.set('builtin'):
j_date = 2454283.0 * u.day
tof = (test_params['tof']).to(u.s).value
body_r = build_ephem_interpolant(body, test_params['period'], (j_date, j_date + test_params['tof']), rtol=1e-2)
......@@ -251,7 +251,7 @@ def normalize_to_Curtis(t0, sun_r):
@pytest.mark.slow
def test_solar_pressure():
# based on example 12.9 from Howard Curtis
with solar_system_ephemeris.set('de432s'):
with solar_system_ephemeris.set('builtin'):
j_date = 2438400.5 * u.day
tof = 600 * u.day
sun_r = build_ephem_interpolant(Sun, 365 * u.day, (j_date, j_date + tof), rtol=1e-2)
......
"""Restricted Circular 3-Body Problem (RC3BP)
"""Circular Restricted 3-Body Problem (CR3BP)
Includes the computation of:
* Lagrange points
Includes the computation of Lagrange points
"""
import numpy as np
from astropy import units as u
from scipy.optimize import brentq
from poliastro.util import norm
@u.quantity_input(r12=u.km, m1=u.kg, m2=u.kg)
def lagrange_points(r12, m1, m2):
"""Computes the Lagrangian points of RC3BP given the distance between two
bodies and their masses.
"""Computes the Lagrangian points of CR3BP.
Computes the Lagrangian points of CR3BP given the distance between two
bodies and their masses.
It uses the formulation found in Eq. (2.204) of Curtis, Howard. 'Orbital
mechanics for engineering students'. Elsevier, 3rd Edition.
......@@ -69,10 +72,14 @@ def lagrange_points(r12, m1, m2):
return lp * r12
@u.quantity_input(m1=u.kg, r1=u.km,
m2=u.kg, r2=u.km,
n=u.one)
def lagrange_points_vec(m1, r1, m2, r2, n):
"""Computes the five Lagrange points in the RC3BP. Returns the positions
in the same frame of reference as `r1` and `r2` for the five Lagrangian
points.
"""Computes the five Lagrange points in the CR3BP.
Returns the positions in the same frame of reference as `r1` and `r2`
for the five Lagrangian points.
Parameters
----------
......@@ -86,7 +93,6 @@ def lagrange_points_vec(m1, r1, m2, r2, n):
Position of the secondary body.
n : ~astropy.units.Quantity
Normal vector to the orbital plane.
Returns
-------
list:
......@@ -132,63 +138,3 @@ def lagrange_points_vec(m1, r1, m2, r2, n):
L5 = r1 + ux * x5 + uy * y5
return [L1, L2, L3, L4, L5]
if __name__ == "__main__":
from astropy import units as u
from astropy.constants import G
from poliastro.constants import GM_earth, GM_moon
# ORIGIN = "barycenter"
ORIGIN = "main body"
# Distance Earth - Moon
r12 = 384400
# Earth (1)
m1 = GM_earth / G
# Moon (2)
m2 = GM_moon / G
if ORIGIN == "barycenter":
x1 = - r12 * m2 / (m1 + m2)
x2 = r12 + x1
elif ORIGIN == "main body":
x1 = 0
x2 = r12
# Positions
r1 = np.array([x1, 0, 0]) * u.km
r2 = np.array([x2, 0, 0]) * u.km
# normal vector
n = np.array([0., 0, 1]) * u.one
lp = lagrange_points_vec(m1, r1, m2, r2, n)
for p in lp:
print("{:+8.0f} {:+8.0f} {:+8.0f}".format(p[0], p[1], p[2]))
x = [p[0] for p in lp]
y = [p[1] for p in lp]
# Figure
import matplotlib.pyplot as plt
plt.figure()
plt.scatter(0, 0, marker="+", c="k", label="Origin")
plt.scatter(r1[0], r1[1], s=100, marker="$" + u"\u2641" + "$",
label="Earth", c="k")
plt.scatter(r2[0], r2[1], s=100, marker="$" + u"\u263E" + "$",
label="Moon", c="k")
for i in range(0, 5):
plt.scatter(x[i], y[i], marker="$L" + "{:d}$".format(i + 1),
c="k", s=100)
plt.legend(loc="best")
plt.title("Earth-Moon Lagrangian points")
plt.xlabel("[km]")
plt.ylabel("[km]")
plt.tight_layout()
plt.show()
plt.close('all')
This diff is collapsed.
......@@ -16,6 +16,7 @@ from poliastro.constants import J2000
from poliastro.twobody.angles import nu_to_M, E_to_nu
from poliastro.twobody.propagation import propagate, mean_motion
from poliastro.core.elements import rv2coe
from poliastro.core.angles import nu_to_M as nu_to_M_fast
from poliastro.twobody import rv
from poliastro.twobody import classical
......@@ -290,7 +291,7 @@ class Orbit(object):
Examples
--------
>>> from poliastro.examples import iss
>>> from astropy.coordinates import CartesianRepresentation
>>> from astropy.coordinates import CartesianRepresentation, SphericalRepresentation
>>> iss.represent_as(CartesianRepresentation)
<CartesianRepresentation (x, y, z) in km
(859.07256, -4137.20368, 5295.56871)
......@@ -433,11 +434,16 @@ class Orbit(object):
--------
>>> from astropy import units as u
>>> from poliastro.examples import iss
>>> iss.sample()
>>> iss.sample(10)
>>> iss.sample([0, 180] * u.deg)
>>> iss.sample([0, 10, 20] * u.minute)
>>> iss.sample([iss.epoch + iss.period / 2])
>>> iss.sample() # doctest: +ELLIPSIS
<GCRS Coordinate ...>
>>> iss.sample(10) # doctest: +ELLIPSIS
<GCRS Coordinate ...>
>>> iss.sample([0, 180] * u.deg) # doctest: +ELLIPSIS
<GCRS Coordinate ...>
>>> iss.sample([0, 10, 20] * u.minute) # doctest: +ELLIPSIS
<GCRS Coordinate ...>
>>> iss.sample([iss.epoch + iss.period / 2]) # doctest: +ELLIPSIS
<GCRS Coordinate ...>
"""
if values is None:
......@@ -466,17 +472,24 @@ class Orbit(object):
elif hasattr(values, "unit") and values.unit in ('rad', 'deg'):
values = self._generate_time_values(values)
elif isinstance(values, time.Time):
values = values - self.epoch
elif isinstance(values, list):
# A list of Times is assumed
values = [(value - self.epoch).sec for value in values] * u.s
return self._sample(values, method)
def _sample(self, time_values, method=mean_motion):
positions = method(self, (time_values - self.epoch).to(u.s).value)
positions = method(self, time_values.to(u.s).value)
data = CartesianRepresentation(positions[0] * u.km, xyz_axis=1)
# If the frame supports obstime, set the time values
kwargs = {}
if 'obstime' in self.frame.frame_attributes:
kwargs['obstime'] = time_values
kwargs['obstime'] = self.epoch + time_values
else:
warn("Frame {} does not support 'obstime', time values were not returned".format(self.frame.__class__))
......@@ -488,9 +501,10 @@ class Orbit(object):
def _generate_time_values(self, nu_vals):
# Subtract current anomaly to start from the desired point
M_vals = np.array([nu_to_M(nu_val, self.ecc).value -
nu_to_M(self.nu, self.ecc).value for nu_val in nu_vals]) * u.rad
time_values = self.epoch + (M_vals / self.n).decompose()
ecc = self.ecc.value
nu = self.nu.to(u.rad).value
M_vals = [nu_to_M_fast(nu_val, ecc) - nu_to_M_fast(nu, ecc) for nu_val in nu_vals.to(u.rad).value] * u.rad
time_values = (M_vals / self.n).decompose()
return time_values
def apply_maneuver(self, maneuver, intermediate=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment