.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/plot_gridded_forecast.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorials_plot_gridded_forecast.py: .. _tutorial-handling-grid-forecast: Handling Grid-based Forecasts ============================= This example show you how to load a gridded forecast stored in the default ASCII format. .. GENERATED FROM PYTHON SOURCE LINES 12-17 Load required libraries ----------------------- Most of the core functionality can be imported from the top-level :mod:`csep` package. Utilities are available from the :mod:`csep.utils` subpackage. .. GENERATED FROM PYTHON SOURCE LINES 17-21 .. code-block:: Python import csep from csep.utils import datasets, time_utils .. GENERATED FROM PYTHON SOURCE LINES 22-28 Define forecast properties -------------------------- We choose a :ref:`time-independent-forecast` to show how to evaluate a grid-based earthquake forecast using PyCSEP. Note, the start and end date should be chosen based on the creation of the forecast. This is important for time-independent forecasts because they can be rescaled to any arbitrary time period. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python start_date = time_utils.strptime_to_utc_datetime('2006-11-12 00:00:00.0') end_date = time_utils.strptime_to_utc_datetime('2011-11-12 00:00:00.0') .. GENERATED FROM PYTHON SOURCE LINES 33-38 Load forecast ------------- For this example, we provide the example forecast data set along with the main repository. The filepath is relative to the root directory of the package. You can specify any file location for your forecasts. .. GENERATED FROM PYTHON SOURCE LINES 38-44 .. code-block:: Python forecast = csep.load_gridded_forecast(datasets.helmstetter_mainshock_fname, start_date=start_date, end_date=end_date, name='helmstetter_mainshock') .. GENERATED FROM PYTHON SOURCE LINES 45-52 .. _tutorial-handling-grid-forecast-plot: Plot forecast ------------- The forecast object provides a :meth:`~csep.core.forecasts.GriddedForecast.plot` method to plot its data spatially. This function returns a matplotlib axes, so more specific attributes can be set on the figure (See :ref:`tutorial-plot-customizations` and :func:`~csep.plots.plot_gridded_dataset` for more information). .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: Python ax = forecast.plot(show=True) .. image-sg:: /tutorials/images/sphx_glr_plot_gridded_forecast_001.png :alt: helmstetter_mainshock :srcset: /tutorials/images/sphx_glr_plot_gridded_forecast_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Cleaning existing basemap cache .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.478 seconds) .. _sphx_glr_download_tutorials_plot_gridded_forecast.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_gridded_forecast.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gridded_forecast.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_gridded_forecast.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_