Skip to content

Commit dd34480

Browse files
committed
docs: added references to plotting API. added references in each docstring to where the function is used in the tutorials. Added and fixed multiple docs references. Added changelogs in docstrings with versionchanged/versionadded directives to outline major changes. Added optional label to multiple args in docstrings
ft: re-added xlabel_rotation for comparison_plots fix: typos in docstrings build-sphinx: rewrite "make clean" directive, to effectively delete generated sphinx-gallery and sphinx-autodocs material.
1 parent aebad73 commit dd34480

15 files changed

+398
-173
lines changed

csep/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def query_gns(start_time, end_time, min_magnitude=2.950,
333333
verbose (bool): print catalog summary statistics
334334
335335
Returns:
336-
:class:`csep.core.catalogs.CSEPCatalog
336+
:class:`csep.core.catalogs.CSEPCatalog`
337337
"""
338338

339339
# Timezone should be in UTC

csep/utils/plots.py

+311-152
Large diffs are not rendered by default.

docs/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ livehtml:
1717

1818
clean:
1919
rm -rf $(BUILDDIR)/*
20-
rm -rf auto_examples/
20+
rm -rf tutorials/*
21+
rm -rf reference/generated
2122

2223
.PHONY: help Makefile
2324

docs/concepts/evaluations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ statistics from these catalogs and compare them against one another.
9191

9292
We provide four statistics that probe fundamental aspects of the earthquake forecasts. Please see
9393
:ref:`Savran et al., 2020<savran-2020>` for a complete description of the individual tests. For the implementation
94-
details please follow the links below and see the :ref:`example<catalog-forecast-evaluation>` for catalog-based
94+
details please follow the links below and see the :ref:`Example <tutorial-catalog-forecast-evaluation>` for catalog-based
9595
forecast evaluation for an end-to-end walk through.
9696

9797
.. automodule:: csep.core.catalog_evaluations

docs/concepts/forecasts.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Working with catalog-based forecasts
129129

130130
.. autosummary:: csep.core.forecasts.CatalogForecast
131131

132-
Please see visit :ref:`this<catalog-forecast-evaluation>` example for an end-to-end tutorial on how to evaluate a catalog-based
132+
Please see visit :ref:`this Example <tutorial-catalog-forecast-evaluation>` for an end-to-end tutorial on how to evaluate a catalog-based
133133
earthquake forecast. An example of a catalog-based forecast stored in the default pyCSEP format can be found
134134
`here <https://github.com/SCECcode/pycsep/blob/dev/csep/artifacts/ExampleForecasts/CatalogForecasts/ucerf3-landers_1992-06-28T11-57-34-14.csv>`__.
135135

docs/concepts/regions.rst

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Regions
66

77
.. automodule:: csep.core.regions
88
:no-index:
9-
.. automodule:: csep.utils.basic_types
10-
:no-index:
119

1210
PyCSEP includes commonly used CSEP testing regions and classes that facilitate working with gridded data sets. This
1311
module is early in development and will be a focus of future development.

docs/getting_started/theory.rst

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ examples use the Helmstetter et al (2007) smoothed seismicity forecast
104104
Found 24 events in the ComCat catalog.
105105
106106
107+
.. _theory-consistency-tests:
108+
107109
Consistency tests
108110
~~~~~~~~~~~~~~~~~
109111

@@ -655,6 +657,8 @@ case, the model with aftershocks performs statistically worse than the
655657
benchmark model. We note that this comparison is used for demonstation
656658
purposes only.
657659

660+
.. _theory-catalog-forecasts:
661+
658662
Catalog-based forecast tests
659663
----------------------------
660664

docs/reference/api_reference.rst

+17-7
Original file line numberDiff line numberDiff line change
@@ -234,28 +234,30 @@ Region utilities:
234234
.. currentmodule:: csep.utils.plots
235235
.. automodule:: csep.utils.plots
236236

237+
.. _api-plot-functions:
238+
237239
Plotting
238240
--------
239241

240-
General plotting:
242+
PyCSEP offers multiple plot functionalities to visually explore forecasts, catalogs and results.
243+
244+
Exploratory plotting:
241245

242246
.. autosummary::
243247
:toctree: generated
244248

245249
plot_magnitude_versus_time
246250
plot_cumulative_events_versus_time
247251
plot_magnitude_histogram
248-
plot_basemap
249-
plot_catalog
250-
plot_gridded_dataset
251252

252-
Plotting catalog-based evaluations:
253+
Spatial plotting:
253254

254255
.. autosummary::
255256
:toctree: generated
256257

257-
plot_test_distribution
258-
plot_calibration_test
258+
plot_basemap
259+
plot_catalog
260+
plot_gridded_dataset
259261

260262
Plotting grid-based evaluations:
261263

@@ -265,6 +267,14 @@ Plotting grid-based evaluations:
265267
plot_comparison_test
266268
plot_consistency_test
267269

270+
Plotting catalog-based evaluations:
271+
272+
.. autosummary::
273+
:toctree: generated
274+
275+
plot_test_distribution
276+
plot_calibration_test
277+
268278
Plotting alarm-based evaluations:
269279

270280
.. autosummary::

examples/tutorials/catalog_filtering.py

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100

101101

102102
####################################################################################################################################
103+
#
104+
# .. _tutorial-catalog-filtering-plot:
105+
#
103106
# Plot catalog
104107
# -------------
105108
#

examples/tutorials/catalog_forecast_evaluation.py

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
comcat_catalog.plot(show=True)
103103

104104
####################################################################################################################################
105+
#
106+
# .. _catalog-forecast-evaluation-exploratory:
107+
#
105108
# Exploratory visualizations
106109
# --------------------------
107110
#
@@ -126,6 +129,9 @@
126129
number_test_result = catalog_evaluations.number_test(forecast, comcat_catalog)
127130

128131
####################################################################################################################################
132+
#
133+
# .. _catalog-forecast-evaluation-plot:
134+
#
129135
# Plot number test result
130136
# -----------------------
131137
#

examples/tutorials/gridded_forecast_evaluation.py

+12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
csep.write_json(spatial_test_result, 'example_spatial_test.json')
9494

9595
####################################################################################################################################
96+
#
97+
# .. _grid-forecast-evaluation-plot:
98+
#
9699
# Plot spatial test results
97100
# -------------------------
98101
#
@@ -105,6 +108,9 @@
105108

106109

107110
####################################################################################################################################
111+
#
112+
# .. _grid-forecast-evaluation-plot-comparison:
113+
#
108114
# Performing a comparative test
109115
# -----------------------------
110116
#
@@ -126,6 +132,9 @@
126132

127133

128134
####################################################################################################################################
135+
#
136+
# .. _grid-forecast-evaluation-concentration-roc:
137+
#
129138
# Plot ROC Curves
130139
# ---------------
131140
#
@@ -149,6 +158,9 @@
149158

150159

151160
####################################################################################################################################
161+
#
162+
# .. _grid-forecast-evaluation-roc-and-molchan:
163+
#
152164
# Plot ROC and Molchan curves using the alarm-based approach
153165
# ----------------------------------------------------------
154166

examples/tutorials/plot_customizations.py

+30-7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
5. Creating composite plots
1616
6. Plot multiple Evaluation Results
1717
18+
19+
Please refer to the :ref:`Plotting API Reference <api-plot-functions>` for a description of all
20+
PyCSEP plotting functionality.
1821
"""
1922

2023
################################################################################################################
21-
# Example 1: Spatial dataset plot arguments
22-
# -----------------------------------------
24+
#
25+
# .. _tutorial-plot-customizations-ex1:
26+
#
27+
# Example 1: Customizing Gridded Dataset Plot
28+
# -------------------------------------------
2329

2430
####################################################################################################################################
2531
# **Load required libraries**
@@ -49,10 +55,10 @@
4955
# * Assign a title
5056
# * Set labels to the geographic axes
5157
# * Draw country borders
52-
# * Set a linewidth of 0.5 to country border
53-
# * Assign ``'rainbow'`` as the colormap. Possible values from ``matplotlib.cm`` library
58+
# * Set a linewidth of 1.5 to country border
59+
# * Assign ``'rainbow'`` as the colormap. Possible values from :mod:`matplotlib.cm` library
5460
# * Defines 0.8 for an exponential transparency function (default is 0 for constant alpha, whereas 1 for linear).
55-
# * An object cartopy.crs.Projection() is passed as Projection to the map
61+
# * An object :class:`cartopy.crs.Projection` (in this case :class:`cartopy.crs.Mercator`) is passed to the map
5662
#
5763
# The complete description of plot arguments can be found in :func:`csep.utils.plots.plot_gridded_dataset`
5864
#
@@ -70,6 +76,9 @@
7076
show=True)
7177

7278
####################################################################################################################################
79+
#
80+
# .. _tutorial-plot-customizations-ex2:
81+
#
7382
# Example 2: Plot a global forecast and a selected magnitude bin range
7483
# --------------------------------------------------------------------
7584
#
@@ -105,7 +114,7 @@
105114
####################################################################################################################################
106115
# **Plotting the dataset**
107116
#
108-
# To plot a global forecast, we must assign the option ``set_global=True``, which is required by :ref:`cartopy` to handle
117+
# To plot a global forecast, we must assign the option ``set_global=True``, which is required by :mod:`cartopy` to handle
109118
# internally the extent of the plot. We can further customize the plot using the required arguments from :func:`~csep.utils.plots.plot_gridded_dataset`
110119
#
111120

@@ -131,6 +140,9 @@
131140

132141

133142
####################################################################################################################################
143+
#
144+
# .. _tutorial-plot-customizations-ex3:
145+
#
134146
# Example 3: Plot a catalog with a custom basemap
135147
# -----------------------------------------------
136148

@@ -178,8 +190,15 @@
178190

179191
ax = catalog.plot(show=True, **plot_args)
180192

193+
####################################################################################################################################
194+
# Alternatively, it can be plotted using the :func:`csep.utils.plots.plot_catalog` function
195+
196+
plots.plot_catalog(catalog=catalog, show=True, **plot_args)
181197

182198
####################################################################################################################################
199+
#
200+
# .. _tutorial-plot-customizations-ex4:
201+
#
183202
# Example 4: Plot composition
184203
# -----------------------------------------------
185204
#
@@ -205,6 +224,7 @@
205224
# Plot the basemap alone by using :func:`csep.utils.plots.plot_basemap`. Do not set ``show=True`` and store the returned ``ax`` object to
206225
# start the composite plot
207226

227+
# Start the base plot
208228
ax = plots.plot_basemap(figsize=(8, 8),
209229
projection=cartopy.crs.AlbersEqualArea(central_longitude=-120.),
210230
extent=forecast.region.get_bbox(),
@@ -217,9 +237,12 @@
217237
ax = forecast.plot(colormap='PuBu_r', alpha_exp=0.5, ax=ax)
218238

219239
# Use show=True to finalize the composite.
220-
catalog.plot(markercolor='darkred', ax=ax, show=True)
240+
plots.plot_catalog(catalog=catalog, markercolor='darkred', ax=ax, show=True)
221241

222242
####################################################################################################################################
243+
#
244+
# .. _tutorial-plot-customizations-ex5:
245+
#
223246
# Example 5: Plot multiple evaluation results
224247
# -------------------------------------------
225248

examples/tutorials/plot_gridded_forecast.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
3-
.. tutorial-handling-grid-forecast:
3+
.. _tutorial-handling-grid-forecast:
44
55
Handling Grid-based Forecasts
66
=============================
@@ -42,6 +42,9 @@
4242
name='helmstetter_mainshock')
4343

4444
####################################################################################################################################
45+
#
46+
# .. _tutorial-handling-grid-forecast-plot:
47+
#
4548
# Plot forecast
4649
# -------------
4750
#

examples/tutorials/quadtree_gridded_forecast_evaluation.py

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@
186186

187187

188188
####################################################################################################################################
189+
#
190+
# .. _quadtree_gridded-forecast-evaluation-plot:
191+
#
189192
# Plot spatial test results
190193
# -------------------------
191194
#

examples/tutorials/working_with_catalog_forecasts.py

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868

6969

7070
####################################################################################################################################
71+
#
72+
# .. _tutorial-working-catalog-forecasts-plot:
73+
#
7174
# Plot expected event counts
7275
# --------------------------
7376
#

0 commit comments

Comments
 (0)