From 90df3feb08a333659f41cca7a1aa80df2659c3b6 Mon Sep 17 00:00:00 2001 From: aringlis Date: Wed, 14 Aug 2024 16:23:50 -0400 Subject: [PATCH 1/2] reformat time data to datetime in plot_detector_sun_angles. Tidy up legend location as well. --- sunkit_instruments/fermi/fermi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sunkit_instruments/fermi/fermi.py b/sunkit_instruments/fermi/fermi.py index 8b63d061..a087cd99 100644 --- a/sunkit_instruments/fermi/fermi.py +++ b/sunkit_instruments/fermi/fermi.py @@ -226,12 +226,17 @@ def plot_detector_sun_angles(angles): `~sunkit_instruments.fermi.get_detector_separation_angles` function. """ + #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) + 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] @@ -239,9 +244,9 @@ def plot_detector_sun_angles(angles): ) 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() From ec8112244b589646f140ccab037106a4c0adf56a Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Thu, 22 Aug 2024 10:17:19 -0700 Subject: [PATCH 2/2] changelog --- changelog/130.bugfix.rst | 1 + sunkit_instruments/fermi/fermi.py | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 changelog/130.bugfix.rst diff --git a/changelog/130.bugfix.rst b/changelog/130.bugfix.rst new file mode 100644 index 00000000..337b63c8 --- /dev/null +++ b/changelog/130.bugfix.rst @@ -0,0 +1 @@ +The function ``plot_detector_sun_angles`` was broken, due to the formatting of the time axis. diff --git a/sunkit_instruments/fermi/fermi.py b/sunkit_instruments/fermi/fermi.py index a087cd99..e8f7076e 100644 --- a/sunkit_instruments/fermi/fermi.py +++ b/sunkit_instruments/fermi/fermi.py @@ -225,14 +225,12 @@ def plot_detector_sun_angles(angles): function of time. Obtained from the `~sunkit_instruments.fermi.get_detector_separation_angles` function. """ - - #reformat the time array so we can plot it + # Reformat the time array so we can plot it angle_times = [] - for t in angles['time']: + 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') + # 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( @@ -246,7 +244,7 @@ def plot_detector_sun_angles(angles): plt.ylabel("angle (degrees)") plt.xlabel("Start time: " + angle_times[0].isoformat()) plt.title("Detector pointing angle from Sun") - figure.legend(fontsize=10, loc ='outside center right') + figure.legend(fontsize=10, loc="outside center right") figure.autofmt_xdate() plt.show()