Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Fermi plot_detector_sun_angles #130

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/130.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The function ``plot_detector_sun_angles`` was broken, due to the formatting of the time axis.
15 changes: 9 additions & 6 deletions sunkit_instruments/fermi/fermi.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,26 @@ def plot_detector_sun_angles(angles):
function of time. Obtained from the
`~sunkit_instruments.fermi.get_detector_separation_angles` function.
"""

# make a plot showing the angles vs time
figure = plt.figure(1)
# Reformat the time array so we can plot it
angle_times = []
for t in angles["time"]:
angle_times.append(t.datetime)
# Make a plot showing the angles vs time
figure = plt.figure(1, figsize=(12, 6), layout="constrained")
for n in angles.keys():
if not n == "time":
plt.plot(
angles["time"],
angle_times,
angles[n].value,
label="{lab} ({val})".format(
lab=n, val=str(np.mean(angles[n].value))[0:5]
),
)
plt.ylim(180, 0)
plt.ylabel("angle (degrees)")
plt.xlabel("Start time: " + angles["time"][0].isoformat())
plt.xlabel("Start time: " + angle_times[0].isoformat())
plt.title("Detector pointing angle from Sun")
plt.legend(fontsize=10)
figure.legend(fontsize=10, loc="outside center right")
figure.autofmt_xdate()
plt.show()

Expand Down
Loading