Skip to content

Commit 303ca7a

Browse files
committed
ci: added plots.py to coverage
ft: added helper to issue deprecation warning when plot_args is passed. Added typehinting overload to legacy wrappers, so IDEs can detect signature/docstrings. fix: avoid drawing basemap when an ax is passed to plot_catalog and plot_gridded_dataset. modified .plot methods to be consistent with new plot functionality docs: remove plots.rst
1 parent 3b9bd3d commit 303ca7a

File tree

6 files changed

+197
-171
lines changed

6 files changed

+197
-171
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ omit =
55
tests/*
66
docs/*
77
examples/*
8-
csep/utils/plots.py
98
csep/utils/constants.py
109
csep/utils/datasets.py
1110
csep/utils/documents.py

csep/core/catalogs.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -841,40 +841,41 @@ def b_positive(self):
841841
pass
842842

843843
def plot(self, ax=None, show=False, extent=None, set_global=False, **kwargs):
844-
""" Plot catalog according to plate-carree projection. See
845-
https://docs.cseptesting.org/reference/generated/csep.utils.plots.plot_catalog.html for
846-
a description of keyword arguments.
844+
""" Plots the catalog epicenters.
845+
846+
See :func:`csep.utils.plots.plot_catalog` for a description of keyword arguments.
847847
848848
Args:
849-
ax (`matplotlib.pyplot.axes`): Previous axes onto which catalog can be drawn
850-
show (bool): if true, show the figure. this call is blocking.
849+
ax (matplotlib.pyplot.axes): Previous axes onto which catalog can be drawn
850+
show (bool): If True, shows the figure.
851851
extent (list): Force an extent [lon_min, lon_max, lat_min, lat_max]
852852
set_global (bool): Whether to plot using a global projection
853+
**kwargs (dict): Keyword arguments passed to
854+
:func:`csep.utils.plots.plot_catalog`
853855
854856
Returns:
855857
axes: matplotlib.Axes.axes
856858
"""
857859

858860
# no mutable function arguments
859-
plot_args_default = {
861+
plot_args = {
860862
'basemap': kwargs.pop('basemap', 'ESRI_terrain') if ax is None else None
861863
}
862864

863865
# Plot the region border (if it exists) by default
864866
try:
865867
# This will throw error if catalog does not have region
866868
_ = self.region.num_nodes
867-
plot_args_default['region_border'] = True
869+
plot_args['region_border'] = True
868870
except AttributeError:
869871
pass
870872

871-
plot_args = kwargs.get('plot_args', {})
872-
plot_args_default.update(plot_args)
873-
plot_args_default.update(kwargs)
873+
plot_args.update(kwargs.get('plot_args', {}))
874+
plot_args.update(kwargs)
874875

875876
# this call requires internet connection and basemap
876877
ax = plot_catalog(self, ax=ax, show=show, extent=extent,
877-
set_global=set_global, **plot_args_default)
878+
set_global=set_global, **plot_args)
878879
return ax
879880

880881
def plot_magnitude_versus_time(self, ax=None, show=False, **kwargs):

csep/core/forecasts.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,25 @@ def load_ascii(cls, ascii_fname, start_date=None, end_date=None, name=None, swap
434434

435435
def plot(self, ax=None, show=False, log=True, extent=None, set_global=False, plot_args=None,
436436
**kwargs):
437-
""" Plot gridded forecast according to plate-carree projection
437+
""" Plot the spatial rate of the forecast
438+
439+
See :func:`csep.utils.plots.plot_gridded_dataset` for a detailed description of the
440+
keyword arguments.
438441
439442
Args:
440-
show (bool): if true, show the figure. this call is blocking.
441-
plot_args (optional/dict): dictionary containing plotting arguments for making figures
443+
ax (`matplotlib.pyplot.axes`): Previous axes onto which catalog can be drawn
444+
show (bool): If True, shows the figure.
445+
log (bool): If True, plots the base-10 logarithm of the spatial rates
446+
extent (list): Force an extent [lon_min, lon_max, lat_min, lat_max]
447+
set_global (bool): Whether to plot using a global projection
448+
**kwargs (dict): Keyword arguments passed to
449+
:func:`csep.utils.plots.plot_gridded_dataset`
442450
443451
Returns:
444452
axes: matplotlib.Axes.axes
445453
"""
446-
# no mutable function arguments
454+
455+
447456
if self.start_time is None or self.end_time is None:
448457
time = 'forecast period'
449458
else:

0 commit comments

Comments
 (0)