Skip to content

Commit 3a25969

Browse files
authored
Fix simplification of lat-to-lon aspect ratio (#125)
1 parent 5638e89 commit 3a25969

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

csep/utils/plots.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434

3535
def plot_cumulative_events_versus_time_dev(xdata, ydata, obs_data, plot_args, show=False):
3636
"""
37-
38-
37+
38+
3939
Args:
4040
xdata (ndarray): time bins for plotting shape (N,)
4141
ydata (ndarray or list like): ydata for plotting; shape (N,5) in order 2.5%Per, 25%Per, 50%Per, 75%Per, 97.5%Per
4242
obs_data (ndarry): same shape as xdata
43-
plot_args:
44-
show:
43+
plot_args:
44+
show:
4545
4646
Returns:
4747
@@ -581,9 +581,10 @@ def plot_basemap(basemap, extent, ax=None, coastline=True, borders=False, linec
581581
projection = ccrs.PlateCarree()
582582
fig = pyplot.figure()
583583
ax = fig.add_subplot(111, projection=projection)
584-
# Re-aspect plot (only for plain matplotlib plots, or when using PlateCarree)
585-
LATKM = 110.574
586-
ax.set_aspect(111.320 * numpy.cos(numpy.deg2rad(central_latitude)) / LATKM)
584+
# Set plot aspect according to local longitude-latitude ratio in metric units
585+
# (only compatible with plain PlateCarree "projection")
586+
LATKM = 110.574 # length of a ° of latitude [km]; constant --> ignores Earth's flattening
587+
ax.set_aspect(111.320 / LATKM / numpy.cos(numpy.deg2rad(central_latitude)))
587588
else:
588589
fig = pyplot.figure()
589590
ax = fig.add_subplot(111, projection=projection)

0 commit comments

Comments
 (0)