Created
May 17, 2023 14:46
-
-
Save hayesla/98b0b7f2a375858d3e4b5ddd54f2edbb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import matplotlib.pyplot as plt | |
import numpy as np | |
from sunpy.coordinates import get_horizons_coord | |
from sunpy.time import parse_time | |
from astropy import units as u | |
import astropy.constants as const | |
def plot_positions_hgs(obstime): | |
""" | |
Function to plot the positions of SoLO and Earth with respect to the Sun. | |
obstime : `str` | |
""" | |
obstime = parse_time(obstime) | |
solo_pos = get_horizons_coord("SOLO", obstime) | |
earth_pos = get_horizons_coord("399", obstime) | |
sun_pos = get_horizons_coord("10", obstime) | |
fig = plt.figure(figsize=(6, 6)) | |
ax = fig.add_subplot(projection="polar") | |
ax.plot(solo_pos.lon.to(u.rad), solo_pos.radius.to(u.AU), marker='o', label="SoLO", color='tab:blue', ms=10) | |
ax.plot(earth_pos.lon.to(u.rad), earth_pos.radius.to(u.AU), marker='o', color='g', label="Earth", ms=10) | |
ax.plot([solo_pos.lon.to_value(u.rad), sun_pos.lon.to_value(u.rad)], | |
[solo_pos.radius.to_value(u.AU), sun_pos.radius.to_value(u.AU)], color='tab:blue', ls="dashed") | |
ax.plot([earth_pos.lon.to_value(u.rad), sun_pos.lon.to_value(u.rad)], | |
[earth_pos.radius.to_value(u.AU), sun_pos.radius.to_value(u.AU)], color='green', ls="dashed") | |
ax.plot(sun_pos.lon.to(u.rad), sun_pos.radius.to(u.AU), marker='o', color='y', label="Sun", ms=14) | |
ax.set_theta_zero_location("S") | |
_ = ax.set_yticklabels([]) | |
ax.legend(bbox_to_anchor=(1.3, 0.9)) | |
ax.set_rlim(0, 1.3) | |
ax.set_title("Positions in Heliographic StonyHurst") | |
ax.text(np.deg2rad(160), 1.4, "{:s}".format(obstime.strftime("%Y-%m-%d %H:%M"))) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment