-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from darioizzo/mit
Mit
- Loading branch information
Showing
17 changed files
with
951 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. _utils: | ||
|
||
Utils | ||
############################################################################### | ||
|
||
.. currentmodule:: pykep.utils | ||
|
||
Spice Utils | ||
############################################################################### | ||
|
||
.. autofunction:: spice_version | ||
|
||
.. autofunction:: load_spice_kernels | ||
|
||
.. autofunction:: unload_spice_kernels | ||
|
||
.. autofunction:: inspect_spice_kernel | ||
|
||
.. autofunction:: name2naifid | ||
|
||
.. autofunction:: framename2naifid | ||
|
||
.. autofunction:: rotation_matrix | ||
|
||
.. Autofunction:: naifid2name | ||
|
||
.. currentmodule:: pykep | ||
|
||
Encoding Utils | ||
############################################################################### | ||
|
||
.. autofunction:: alpha2direct | ||
|
||
.. autofunction:: direct2alpha | ||
|
||
.. autofunction:: eta2direct | ||
|
||
.. autofunction:: direct2eta | ||
|
||
.. currentmodule:: pykep.utils | ||
|
||
.. autofunction:: uvV2cartesian | ||
|
||
.. autofunction:: cartesian2uvV | ||
|
||
Miscellanea | ||
############################################################################### | ||
|
||
.. autofunction:: planet_to_keplerian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
set(PYKEP_PLOT_PYTHON_FILES __init__.py _planet.py _lambert.py _ballistic.py _sf_leg.py) | ||
set(PYKEP_PLOT_PYTHON_FILES | ||
__init__.py | ||
_planet.py | ||
_lambert.py | ||
_ballistic.py | ||
_sf_leg.py | ||
_mit.py) | ||
|
||
install(FILES ${PYKEP_PLOT_PYTHON_FILES} DESTINATION ${_PYKEP_INSTALL_DIR}/plot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import pykep as _pk | ||
import numpy as _np | ||
|
||
def add_mit(ax, | ||
mit, | ||
mu, | ||
units=_pk.AU, | ||
N=60, | ||
c_segments=["royalblue", "indianred"], | ||
figsize=(5, 5), | ||
**kwargs | ||
): | ||
""" | ||
Plot a Multiple Impulse Trajectory (mit) stored in the mit format: | ||
mit = [ [[r,v], DV, DT], ... ] | ||
Args: | ||
*mit* (:class:`list`): The decision vector in the correct tof encoding. | ||
*mu* (:class:`float`): The gravitational parameter | ||
*ax* (:class:`mpl_toolkits.mplot3d.axes3d.Axes3D`, optional): The 3D axis to plot on. Defaults to None. | ||
*units* (:class:`float`, optional): The unit scale for the plot. Defaults to pk.AU. | ||
*N* (:class:`int`, optional): The number of points to use when plotting the trajectory. Defaults to 60. | ||
*c_segments* (:class:`list`, optional): The colors to alternate the various trajectory segments (inbetween DSMs). Defaults to ["royalblue", "indianred"]. | ||
*figsize* (:class:`tuple`): The figure size (only used if *ax* is None and axis have to be created.), Defaults to (5, 5). | ||
*\\*\\*kwargs*: Additional keyword arguments to pass to the trajectory plot (common to Lambert arcs and ballistic arcs) | ||
Returns: | ||
:class:`mpl_toolkits.mplot3d.axes3d.Axes3D`: The 3D axis where the trajectory was plotted. | ||
""" | ||
if ax is None: | ||
ax = _pk.plot.make_3Daxis(figsize=figsize) | ||
|
||
DVs = [_np.linalg.norm(node[1]) for node in mit] | ||
maxDV = max(DVs) | ||
DVs = [s / maxDV * 30 for s in DVs] | ||
|
||
# 3 - We loop across grid nodes | ||
for i, node in enumerate(mit): | ||
ax.scatter( | ||
node[0][0][0] / units, | ||
node[0][0][1] / units, | ||
node[0][0][2] / units, | ||
color="k", | ||
s=DVs[i], | ||
) | ||
|
||
r_after_dsm = node[0][0] | ||
v_after_dsm = [a + b for a, b in zip(node[0][1], node[1])] | ||
_pk.plot.add_ballistic_arc( | ||
ax, | ||
[r_after_dsm, v_after_dsm], | ||
node[2], | ||
mu, | ||
N=N, | ||
units=units, | ||
c=c_segments[i % len(c_segments)], | ||
**kwargs | ||
) | ||
return ax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.