Skip to content

Commit

Permalink
update tutorial documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlend committed Jul 18, 2024
1 parent 05d257d commit bd8a061
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/code_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,4 @@ NEOSpy Python
~~~~~~~~~~~~~
The remaining part of the code which is strictly Python is mostly quality of life
functions, plotting, and web query code. There is little to no mathematics or physics
contained within the Python. The exception being the population related code, which
manages the fair sampling of the known asteroids to generation synthetic populations.
contained within the Python.
Binary file added docs/data/background_frames.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs/tutorials/background.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ definitions, and the object from which they are relative to must also be kept tr
Additionally, all coordinate frames within NEOSpy are treated as inertial, meaning there
is no funny business regarding accelerating frames such as a rocket.

.. image:: ../data/background_frames.png
:alt: Conversions between reference frames.

There are several common definitions of coordinate frames in astronomy, here are some
listed in order of general popularity:
popular choices:

- **Equatorial** - The X-Y plane is defined by the celestial equator (Earth's
Equator). The x-axis is defined pointing to the Vernal Equinox (IE: where the
Expand Down
73 changes: 73 additions & 0 deletions docs/tutorials/background_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np
import matplotlib.pyplot as plt
import neospy

lon_steps = np.linspace(0, 360, 1000)
equatorial = [neospy.Vector.from_ra_dec(step, 0) for step in lon_steps]
ecliptic = [neospy.Vector.from_lat_lon(0, step) for step in lon_steps]
galactic = [
neospy.Vector.from_el_az(0, step, 1, frame=neospy.Frames.Galactic)
for step in lon_steps
]

vectors_frames = [equatorial, ecliptic, galactic]

fig = plt.figure(figsize=(6, 8))
plt.subplot(3, 1, 1, projection="mollweide")
plt.title("Equatorial Frame")
for vectors in vectors_frames:
frame = str(vectors[0].frame).split(".")[1]
vecs = [v.as_equatorial for v in vectors]
pos = np.array([[v.az, v.el] for v in vecs])

# roll the indices so that it plots pretty
# this is just to make the visualization nice
pos[:, 0] = (pos[:, 0] + 180) % 360 - 180
idx = np.argmax(abs(np.diff(pos[:, 0])))
pos = np.roll(pos, -idx - 1, axis=0)
pos = np.radians(pos)

# plot the results
plt.plot(*pos.T, label=frame)
plt.grid()


plt.subplot(3, 1, 2, projection="mollweide")
plt.title("Ecliptic Frame")
for vectors in vectors_frames:
frame = str(vectors[0].frame).split(".")[1]
vecs = [v.as_ecliptic for v in vectors]
pos = np.array([[v.az, v.el] for v in vecs])

# roll the indices so that it plots pretty
# this is just to make the visualization nice
pos[:, 0] = (pos[:, 0] + 180) % 360 - 180
idx = np.argmax(abs(np.diff(pos[:, 0])))
pos = np.roll(pos, -idx - 1, axis=0)
pos = np.radians(pos)

# plot the results
plt.plot(*pos.T, label=frame)
plt.grid()


plt.subplot(3, 1, 3, projection="mollweide")
plt.title("Galactic Frame")
for vectors in vectors_frames:
frame = str(vectors[0].frame).split(".")[1]
vecs = [v.as_galactic for v in vectors]
pos = np.array([[v.az, v.el] for v in vecs])

# roll the indices so that it plots pretty
# this is just to make the visualization nice
pos[:, 0] = (pos[:, 0] + 180) % 360 - 180
idx = np.argmax(abs(np.diff(pos[:, 0])))
pos = np.roll(pos, -idx - 1, axis=0)
pos = np.radians(pos)

# plot the results
plt.plot(*pos.T, label=frame)
plt.grid()
plt.tight_layout()
plt.legend(bbox_to_anchor=(1.05, 1.29), framealpha=1)
plt.savefig("data/background_frames.png")

0 comments on commit bd8a061

Please sign in to comment.