From 1570da783bc8825094be4bc475d9f25434e9123f Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:08:54 +0200 Subject: [PATCH 1/6] Update plot_sunpath_diagrams.py --- .../solar-position/plot_sunpath_diagrams.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index 3f36d643a6..fbad6ff5b0 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -33,7 +33,13 @@ # draw the analemma loops points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear) -ax.figure.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +cbar = ax.figure.colorbar(points) +cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) +cbar.set_ticks(ticks=times_ticks.dayofyear+15, + labels=times_ticks.strftime('%b'), + minor=True) +cbar.ax.tick_params(which='minor', width=0) # draw hour labels for hour in np.unique(solpos.index.hour): @@ -112,7 +118,13 @@ fig, ax = plt.subplots() points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, c=solpos.index.dayofyear, label=None) -fig.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +cbar = fig.colorbar(points) +cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) +cbar.set_ticks(ticks=times_ticks.dayofyear+15, + labels=times_ticks.strftime('%b'), + minor=True) +cbar.ax.tick_params(which='minor', width=0) for hour in np.unique(solpos.index.hour): # choose label position by the largest elevation for each hour From 62c1b7abb9bfd9577c6818192c9f3c4429357125 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:13:44 +0200 Subject: [PATCH 2/6] Update legend location --- docs/examples/solar-position/plot_sunpath_diagrams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index fbad6ff5b0..ca4365f476 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -140,7 +140,7 @@ label = date.strftime('%Y-%m-%d') ax.plot(solpos.azimuth, solpos.apparent_elevation, label=label) -ax.figure.legend(loc='upper left') +ax.figure.legend(loc='upper center', bbox_to_anchor=[0.45, 1], ncols=3) ax.set_xlabel('Solar Azimuth (degrees)') ax.set_ylabel('Solar Elevation (degrees)') From 0a26efb8b65d46f958dec0d3902b56060b5cc926 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:16:48 +0200 Subject: [PATCH 3/6] Update xticks and ylim --- docs/examples/solar-position/plot_sunpath_diagrams.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index ca4365f476..9a8714a076 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -33,8 +33,9 @@ # draw the analemma loops points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear) -times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +# add and format colorbar cbar = ax.figure.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) cbar.set_ticks(ticks=times_ticks.dayofyear+15, labels=times_ticks.strftime('%b'), @@ -118,8 +119,9 @@ fig, ax = plt.subplots() points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, c=solpos.index.dayofyear, label=None) -times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +# add and format colorbar cbar = fig.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) cbar.set_ticks(ticks=times_ticks.dayofyear+15, labels=times_ticks.strftime('%b'), @@ -143,5 +145,7 @@ ax.figure.legend(loc='upper center', bbox_to_anchor=[0.45, 1], ncols=3) ax.set_xlabel('Solar Azimuth (degrees)') ax.set_ylabel('Solar Elevation (degrees)') +ax.set_xticks([0, 90, 180, 270, 360]) +ax.set_ylim(0, None) plt.show() From 4945475b2f15f9a17c5d05a18d30f9731ea8c43a Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:27:00 +0200 Subject: [PATCH 4/6] Update v0.11.0.rst --- docs/sphinx/source/whatsnew/v0.11.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index b306654624..005b750315 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -87,3 +87,4 @@ Contributors * Ioannis Sifnaios (:ghuser:`IoannisSifnaios`) * Mark Campanelli (:ghuser:`markcampanelli`) * Rajiv Daxini (:ghuser:`RDaxini`) +* :ghuser:`PhilBrk8` From 587fb6667cd25d28ad106a9994e271b7aa01764d Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:26:37 +0200 Subject: [PATCH 5/6] Code review by Ioannis --- .../examples/solar-position/plot_sunpath_diagrams.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index 9a8714a076..7b5db509d4 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -32,7 +32,8 @@ ax = plt.subplot(1, 1, 1, projection='polar') # draw the analemma loops points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, - s=2, label=None, c=solpos.index.dayofyear) + s=2, label=None, c=solpos.index.dayofyear, + cbar='twilight_shifted_r') # add and format colorbar cbar = ax.figure.colorbar(points) times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) @@ -55,7 +56,7 @@ times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%Y-%m-%d') + label = date.strftime('%b %d$^{st}$') ax.plot(np.radians(solpos.azimuth), solpos.apparent_zenith, label=label) ax.figure.legend(loc='upper left') @@ -71,7 +72,7 @@ # This is a polar plot of hourly solar zenith and azimuth. The figure-8 # patterns are called `analemmas `_ and # show how the sun's path slowly shifts over the course of the year . The -# colored lines show the single-day sun paths for the winter and summer +# solid colored lines show the single-day sun paths for the winter and summer # solstices as well as the spring equinox. # # The soltice paths mark the boundary of the sky area that the sun traverses @@ -118,7 +119,8 @@ fig, ax = plt.subplots() points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, - c=solpos.index.dayofyear, label=None) + c=solpos.index.dayofyear, label=None, + cbar='twilight_shifted_r') # add and format colorbar cbar = fig.colorbar(points) times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) @@ -139,7 +141,7 @@ times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%Y-%m-%d') + label = date.strftime('%b %d$^{st}$') ax.plot(solpos.azimuth, solpos.apparent_elevation, label=label) ax.figure.legend(loc='upper center', bbox_to_anchor=[0.45, 1], ncols=3) From 9ca3163e11b3647668e816b8ea903eb51ebe32e2 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:18:28 +0200 Subject: [PATCH 6/6] More formatting updates --- .../solar-position/plot_sunpath_diagrams.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index 7b5db509d4..f6f237c706 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -33,7 +33,7 @@ # draw the analemma loops points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear, - cbar='twilight_shifted_r') + cmap='twilight_shifted_r') # add and format colorbar cbar = ax.figure.colorbar(points) times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) @@ -49,14 +49,15 @@ subset = solpos.loc[solpos.index.hour == hour, :] r = subset.apparent_zenith pos = solpos.loc[r.idxmin(), :] - ax.text(np.radians(pos['azimuth']), pos['apparent_zenith'], str(hour)) + ax.text(np.radians(pos['azimuth']), pos['apparent_zenith'], + str(hour).zfill(2), ha='center', va='bottom') # draw individual days for date in pd.to_datetime(['2019-03-21', '2019-06-21', '2019-12-21']): times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%b %d$^{st}$') + label = date.strftime('%b %d') ax.plot(np.radians(solpos.azimuth), solpos.apparent_zenith, label=label) ax.figure.legend(loc='upper left') @@ -120,7 +121,7 @@ fig, ax = plt.subplots() points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, c=solpos.index.dayofyear, label=None, - cbar='twilight_shifted_r') + cmap='twilight_shifted_r') # add and format colorbar cbar = fig.colorbar(points) times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) @@ -135,13 +136,15 @@ subset = solpos.loc[solpos.index.hour == hour, :] height = subset.apparent_elevation pos = solpos.loc[height.idxmax(), :] - ax.text(pos['azimuth'], pos['apparent_elevation'], str(hour)) + azimuth_offset = -10 if pos['azimuth'] < 180 else 10 + ax.text(pos['azimuth']+azimuth_offset, pos['apparent_elevation'], + str(hour).zfill(2), ha='center', va='bottom') for date in pd.to_datetime(['2019-03-21', '2019-06-21', '2019-12-21']): times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%b %d$^{st}$') + label = date.strftime('%d %b') ax.plot(solpos.azimuth, solpos.apparent_elevation, label=label) ax.figure.legend(loc='upper center', bbox_to_anchor=[0.45, 1], ncols=3)