From f062c01e6d6fa96651b2a8a69a0cd2c9503f77ca Mon Sep 17 00:00:00 2001 From: "F. R. Herpich" Date: Wed, 21 May 2025 15:06:44 -0300 Subject: [PATCH 1/3] Modify plot_sky function to add labels of the hours to the object track --- astroplan/plots/sky.py | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/astroplan/plots/sky.py b/astroplan/plots/sky.py index 8c0d3fa3..249a0671 100644 --- a/astroplan/plots/sky.py +++ b/astroplan/plots/sky.py @@ -13,7 +13,7 @@ @u.quantity_input(az_label_offset=u.deg) def plot_sky(target, observer, time, ax=None, style_kwargs=None, north_to_east_ccw=True, grid=True, az_label_offset=0.0*u.deg, - warn_below_horizon=False, style_sheet=None): + warn_below_horizon=False, style_sheet=None, hours_value=np.array([])): """ Plots target positions in the sky with respect to the observer's location. @@ -81,6 +81,11 @@ def plot_sky(target, observer, time, ax=None, style_kwargs=None, astroplan, print *astroplan.plots.available_style_sheets*. Defaults to the light theme. + hours_value : `numpy.ndarray` + Array with the labels of the hours to be plotted. The length of + this array must be equal to the length of the time array. If + passed, the hours will be plotted on the sky map. + Returns ------- An `~matplotlib.axes.Axes` object (ax) with a map of the sky. @@ -171,8 +176,35 @@ def plot_sky(target, observer, time, ax=None, style_kwargs=None, if north_to_east_ccw is False: ax.set_theta_direction(-1) - # Plot target coordinates. - ax.scatter(az_plot, alt_plot, **style_kwargs) + # Hours added to map by F. Herpich 2025-05-19 + if isinstance(hours_value, (list, tuple)): + hours_value = np.array(hours_value) + if not isinstance(hours_value, np.ndarray): + raise TypeError("hours_value must be a numpy array, list or tuple") + + if len(hours_value) != len(time): + raise ValueError("hours_value must have the same length as the time array") + + if hours_value.size > 0: + hoursvalue = hours_value[altitude <= 91.0] + if len(hoursvalue) > 1: + hoursname = ["%.1f" % i for i in hoursvalue] + for i, txt in enumerate(hoursname): + ax.annotate(txt, (az_plot[i].value, alt_plot[i].value), + fontsize=8) + elif len(hoursvalue) == 1: + hoursname = ["%.1f" % hoursvalue[0]] + ax.annotate(hoursname[0], (az_plot[0].value, alt_plot[0].value), + fontsize=8) + else: + pass + + # Plot target coordinates. Modified by F. Herpich 2025-05-19 + if 'c' in style_kwargs.keys(): + colorformap = style_kwargs.pop('c')[altitude <= 91.0] + ax.scatter(az_plot, alt_plot, c=colorformap, **style_kwargs) + else: + ax.scatter(az_plot, alt_plot, **style_kwargs) # Set radial limits. ax.set_rlim(1, 91) From 2cc058fc2a3f2a36ffcb2e27b578586e2599bd89 Mon Sep 17 00:00:00 2001 From: "F. R. Herpich" Date: Wed, 21 May 2025 15:07:35 -0300 Subject: [PATCH 2/3] Update gitignore to not commit python eggs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4982cbf3..f19ae459 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.o *.so __pycache__ +.eggs # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. From f646d2ad3b03467299abda8e32d09137ecc9475a Mon Sep 17 00:00:00 2001 From: "F. R. Herpich" Date: Mon, 26 May 2025 15:07:41 -0300 Subject: [PATCH 3/3] Fix bug to prevent raising error when units are not defined --- astroplan/plots/sky.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astroplan/plots/sky.py b/astroplan/plots/sky.py index 249a0671..e647a4bf 100644 --- a/astroplan/plots/sky.py +++ b/astroplan/plots/sky.py @@ -190,11 +190,11 @@ def plot_sky(target, observer, time, ax=None, style_kwargs=None, if len(hoursvalue) > 1: hoursname = ["%.1f" % i for i in hoursvalue] for i, txt in enumerate(hoursname): - ax.annotate(txt, (az_plot[i].value, alt_plot[i].value), + ax.annotate(txt, (az_plot[i], alt_plot[i]), fontsize=8) elif len(hoursvalue) == 1: hoursname = ["%.1f" % hoursvalue[0]] - ax.annotate(hoursname[0], (az_plot[0].value, alt_plot[0].value), + ax.annotate(hoursname[0], (az_plot[0], alt_plot[0]), fontsize=8) else: pass