Skip to content

Commit 4dc70dc

Browse files
committed
docs: Finalized example tutoriales for cases a-f.
fix: the configuration for plot_forecasts now accept `catalog: True` instead of a dictionary.
1 parent 872bec1 commit 4dc70dc

File tree

20 files changed

+365
-107
lines changed

20 files changed

+365
-107
lines changed

docs/examples/case_a.rst

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
A - Simple Model and Catalog
22
============================
33

4-
.. currentmodule:: floatcsep
4+
The following example shows the definition of a testing experiment of a single **time-independent** forecast against a catalog.
55

6-
.. contents::
7-
:local:
6+
.. currentmodule:: floatcsep
87

98
.. admonition:: **TL; DR**
109

@@ -16,11 +15,15 @@ A - Simple Model and Catalog
1615
1716
After the calculation is complete, the results will be summarized in ``results/report.md``.
1817

18+
.. contents::
19+
:local:
20+
:depth: 2
21+
1922

2023
Experiment Components
2124
---------------------
2225

23-
The following example shows the definition of a testing experiment of a single **time-independent** forecast against a catalog. The example files are found in ``floatcsep/examples/case_a``. The input structure of the experiment is:
26+
The source code can be found in the ``examples/case_a`` folder or in `GitHub <https://github.com/cseptesting/floatcsep/blob/main/examples/case_a>`_. The directory structure of the experiment is:
2427

2528
::
2629

@@ -34,14 +37,17 @@ The following example shows the definition of a testing experiment of a single *
3437
* The testing region ``region.txt`` consists of a grid with two 1ºx1º bins, defined by its bottom-left nodes. The grid spacing is obtained automatically. The nodes are:
3538

3639
.. literalinclude:: ../../examples/case_a/region.txt
40+
:caption: examples/case_a/region.txt
3741

3842
* The testing catalog ``catalog.csep`` contains only one event and is formatted in the :meth:`~pycsep.utils.readers.csep_ascii` style (see :doc:`pycsep:concepts/catalogs`). Catalog formats are detected automatically
3943

4044
.. literalinclude:: ../../examples/case_a/catalog.csep
45+
:caption: examples/case_a/catalog.csep
4146

4247
* The forecast ``best_model.dat`` to be evaluated is written in the ``.dat`` format (see :doc:`pycsep:concepts/forecasts`). Forecast formats are detected automatically (see :mod:`floatcsep.utils.readers.ForecastParsers`)
4348

4449
.. literalinclude:: ../../examples/case_a/best_model.dat
50+
:caption: examples/case_a/best_model.dat
4551

4652

4753
Configuration
@@ -62,6 +68,7 @@ Time
6268
The time configuration is manifested in the ``time_config`` inset. The simplest definition is to set only the start and end dates of the experiment. These are always UTC date-times in isoformat (``%Y-%m-%dT%H:%M:%S.%f`` - ISO861):
6369

6470
.. literalinclude:: ../../examples/case_a/config.yml
71+
:caption: examples/case_a/config.yml
6572
:language: yaml
6673
:lines: 3-5
6774

@@ -77,16 +84,18 @@ Region
7784
The region - a file path or a :mod:`pycsep` function, such as :obj:`~csep.core.regions.italy_csep_region` (check the available regions in :mod:`csep.core.regions`) -, the depth limits and magnitude discretization are defined in the ``region_config`` inset.
7885

7986
.. literalinclude:: ../../examples/case_a/config.yml
87+
:caption: examples/case_a/config.yml
8088
:language: yaml
8189
:lines: 7-13
8290

8391

8492
Catalog
8593
~~~~~~~
8694

87-
It is defined in the ``catalog`` inset. This should only make reference to a catalog file or a catalog query function (e.g. :func:`~csep.query_comcat`). ``floatcsep`` will automatically filter the catalog to the experiment time, spatial and magnitude frames:
95+
It is defined in the ``catalog`` inset. This should only make reference to a catalog **file** or a catalog **query function** (e.g. :func:`~csep.query_comcat`). **floatCSEP** will automatically filter the catalog to the experiment time, spatial and magnitude frames:
8896

8997
.. literalinclude:: ../../examples/case_a/config.yml
98+
:caption: examples/case_a/config.yml
9099
:language: yaml
91100
:lines: 15-15
92101

@@ -95,6 +104,7 @@ Models
95104
The model configuration is set in the ``models`` inset with a list of model names, which specify their file paths (and other attributes). Here, we just set the path as ``best_model.dat``, whose format is automatically detected.
96105

97106
.. literalinclude:: ../../examples/case_a/config.yml
107+
:caption: examples/case_a/config.yml
98108
:language: yaml
99109
:lines: 17-19
100110

@@ -107,6 +117,7 @@ Evaluations
107117
The experiment's evaluations are defined in the ``tests`` inset. It should be a list of test names, making reference to their function and plotting function. These can be either defined in ``pycsep`` (see :doc:`pycsep:concepts/evaluations`) or manually. In this example, we employ the consistency N-test: its function is :func:`csep.core.poisson_evaluations.number_test`, whereas its plotting function correspond to :func:`csep.utils.plots.plot_poisson_consistency_test`
108118

109119
.. literalinclude:: ../../examples/case_a/config.yml
120+
:caption: examples/case_a/config.yml
110121
:language: yaml
111122
:lines: 21-24
112123

@@ -127,26 +138,8 @@ Run command
127138

128139
.. note::
129140

130-
The command ``floatcsep run <config>`` can be called from any working directory, as long as the specified file paths (e.g. region, models) are relative to the ``config.yml`` file.
131-
132-
133-
Plot command
134-
~~~~~~~~~~~~
135-
136-
If only the result plots are desired, when the calculation was already completed, you can type:
137-
138-
.. code-block:: console
139-
140-
$ floatcsep plot config.yml
141-
142-
This can be used, for example, when an additional plot is desired. Try adding to ``config.yml`` the following lines
143-
144-
.. code-block:: yaml
145-
146-
postproc_config:
147-
plot_forecasts: True
141+
The command ``floatcsep run {config_file}`` can be called from any working directory, as long as the specified file paths (e.g. region, models) are relative to the ``config.yml`` file.
148142

149-
and re-run with the ``plot`` command. A forecast figure will appear in ``results/{window}/forecasts``
150143

151144
Results
152145
~~~~~~~
@@ -155,13 +148,13 @@ Results
155148

156149
* The testing catalog of the window is stored in ``results/{window}/catalog`` in ``json`` format. This is a subset of the global testing catalog.
157150
* Human-readable results are found in ``results/{window}/evaluations``
158-
* Catalog and evaluation results figures in ``results/{window}/figures``.
151+
* Catalog, forecasts and evaluation results figures in ``results/{window}/figures``.
159152
* The complete results are summarized in ``results/report.md``
160153

161154

162155
Advanced
163-
--------
156+
~~~~~~~~
164157

165-
The experiment run logic can be seen in the file ``case_a.py``, which executes the same example but in python source code. The run logic of the terminal commands ``run``, ``plot`` and ``reproduce`` can be found in :mod:`floatcsep.commands.main`
158+
The experiment run logic can be seen in the file ``case_a.py``, which executes the same example but in python source code. The run logic of the terminal commands ``run``, ``plot`` and ``reproduce`` can be found in :mod:`floatcsep.commands.main`, and can be customized by creating a script similar to ``case_a.py``.
166159

167160

docs/examples/case_b.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
B - Multiple Models and Tests
22
=============================
33

4-
.. currentmodule:: floatcsep
4+
The following example is an experiment including **multiple** time-independent forecasts and **multiple** evaluations.
55

6-
.. contents::
7-
:local:
6+
.. currentmodule:: floatcsep
87

98
.. admonition:: **TL; DR**
109

@@ -16,11 +15,15 @@ B - Multiple Models and Tests
1615
1716
After the calculation is complete, the results will be summarized in ``results/report.md``.
1817

18+
.. contents::
19+
:local:
20+
:depth: 2
21+
1922

2023
Experiment Components
2124
---------------------
2225

23-
The following example is an experiment including **multiple** time-independent forecasts and evaluations. The input structure of the experiment is:
26+
The source code can be found in the ``examples/case_b`` folder or in `GitHub <https://github.com/cseptesting/floatcsep/blob/main/examples/case_b>`_. The input structure of the experiment is:
2427

2528
::
2629

@@ -36,11 +39,11 @@ The following example is an experiment including **multiple** time-independent f
3639
├── tests.yml
3740
└── region.txt
3841

39-
40-
The testing catalog is now defined in ``json`` format, which is the default catalog used by ``floatcsep``, as it allows the storage of metadata.
42+
.. important::
43+
Although not necessary, the testing catalog is here defined in the ``.json`` format, which is the default catalog used by ``floatcsep``, as it allows the storage of metadata.
4144

4245
.. note::
43-
An user-defined catalog can be saved as ``json`` with :meth:`CSEPCatalog.write_json() <csep.core.catalogs.CSEPCatalog.write_json>` using ``pycsep``
46+
A catalog can be stored as ``.json`` with :meth:`CSEPCatalog.write_json() <csep.core.catalogs.CSEPCatalog.write_json>` using ``pycsep``
4447

4548

4649
Configuration
@@ -49,10 +52,11 @@ Configuration
4952
In this example, the time, region and catalog specifications are written in the ``config.yml`` file.
5053

5154
.. literalinclude:: ../../examples/case_b/config.yml
55+
:caption: examples/case_b/config.yml
5256
:language: yaml
5357
:lines: 3-15
5458

55-
whereas the models' and tests' configurations are referred to external files for readability
59+
whereas the models' and tests' configurations are referred to external files for better readability
5660

5761
.. literalinclude:: ../../examples/case_b/config.yml
5862
:language: yaml
@@ -64,6 +68,7 @@ Models
6468
The model configuration is now set in the ``models.yml`` file, where a list of model names specify their file paths.
6569

6670
.. literalinclude:: ../../examples/case_b/models.yml
71+
:caption: examples/case_b/models.yml
6772
:language: yaml
6873

6974
Evaluations
@@ -72,11 +77,12 @@ Evaluations
7277

7378
.. literalinclude:: ../../examples/case_b/tests.yml
7479
:language: yaml
80+
:caption: examples/case_b/tests.yml
7581

7682
.. note::
7783
Plotting keyword arguments can be set in the ``plot_kwargs`` option - see :func:`~csep.utils.plots.plot_poisson_consistency_test` and :func:`~csep.utils.plots.plot_comparison_test` -.
7884

79-
.. note::
85+
.. important::
8086
Comparison tests (such as the ``paired_t_test``) requires a reference model, whose name should be set in ``ref_model`` at the given test configuration.
8187

8288
Running the experiment
@@ -87,7 +93,7 @@ The experiment can be run by simply navigating to the ``examples/case_b`` folder
8793

8894
.. code-block:: console
8995
90-
floatcsep run config.yml
96+
$ floatcsep run config.yml
9197
9298
This will automatically set all the file paths of the calculation (testing catalogs, evaluation results, figures) and will display a summarized report in ``results/report.md``.
9399

docs/examples/case_c.rst

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
C - Multiple Time Windows
22
=========================
33

4-
.. currentmodule:: floatcsep
4+
The following example shows an experiment with **multiple time windows**.
55

6-
.. contents::
7-
:local:
6+
.. currentmodule:: floatcsep
87

98
.. admonition:: **TL; DR**
109

@@ -16,11 +15,15 @@ C - Multiple Time Windows
1615
1716
After the calculation is complete, the results will be summarized in ``results/report.md``.
1817

18+
.. contents::
19+
:local:
20+
21+
1922

2023
Experiment Components
2124
---------------------
2225

23-
The following example shows an experiment with multiple time windows. The input structure of the experiment is:
26+
The source code can be found in the ``examples/case_c`` folder or in `GitHub <https://github.com/cseptesting/floatcsep/blob/main/examples/case_c>`_. The input structure of the experiment is:
2427

2528
::
2629

@@ -42,11 +45,12 @@ Configuration
4245
Time
4346
~~~~
4447

45-
The time configuration now set the time intervals between the start and end dates.
48+
The time configuration now sets a sequence of time intervals between the start and end dates.
4649

4750
.. literalinclude:: ../../examples/case_c/config.yml
48-
:language: yaml
49-
:lines: 3-7
51+
:caption: examples/case_c/config.yml
52+
:language: yaml
53+
:lines: 3-7
5054

5155
.. note::
5256

@@ -58,25 +62,32 @@ Time
5862

5963
Evaluations
6064
~~~~~~~~~~~
61-
The experiment's evaluations are defined in ``tests.yml``, which can now include temporal evaluations (see :func:`~floatcsep.extras.sequential_likelihood`, :func:`~floatcsep.extras.sequential_information_gain`, :func:`~floatcsep.utils.plot_sequential_likelihood`).
65+
The experiment's evaluations are defined in ``tests.yml``, which can now include temporal evaluations (see :func:`~floatcsep.utils.helpers.sequential_likelihood`, :func:`~floatcsep.utils.helpers.sequential_information_gain`, :func:`~floatcsep.utils.helpers.plot_sequential_likelihood`).
6266

6367
.. literalinclude:: ../../examples/case_c/tests.yml
64-
:language: yaml
68+
:language: yaml
69+
:caption: examples/case_c/tests.yml
6570

6671
.. note::
6772

68-
Plot arguments (title, labels, font sizes, axes limits, etc.) can be passed as a dictionary in ``plot_args`` (see details in :func:`~csep.utils.plots.plot_poisson_consistency_test`)
73+
Plot arguments (title, labels, font sizes, axes limits, etc.) can be passed as a dictionary in ``plot_args`` (see the arguments details in :func:`~csep.utils.plots.plot_poisson_consistency_test`)
6974

7075
Results
7176
-------
7277

73-
The :obj:`~floatcsep.cmd.main.run` command creates the result path tree for all time windows.
78+
The :obj:`~floatcsep.cmd.main.run` command
79+
80+
.. code-block:: console
81+
82+
$ floatcsep run config.yml
83+
84+
now creates the result path tree for all time windows.
7485

75-
* The testing catalog of the window is stored in ``results/{window}/catalog`` in ``json`` format. This is a subset of the global testing catalog.
76-
* Human-readable results are found in ``results/{window}/evaluations``
77-
* Catalog and evaluation results figures in ``results/{window}/figures``.
86+
* The testing catalog of the window is stored in ``results/{time_window}/catalog`` in ``json`` format. This is a subset of the global testing catalog.
87+
* Human-readable results are found in ``results/{time_window}/evaluations``
88+
* Catalog and evaluation results figures in ``results/{time_window}/figures``.
7889
* The complete results are summarized in ``results/report.md``
7990

80-
The report now shows the temporal evaluations for all time-windows, whereas the discrete evaluations are shown only for the last time window.
91+
The report shows the temporal evaluations for all time-windows, whereas the discrete evaluations are shown only for the last time window.
8192

8293

docs/examples/case_d.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
D - Catalog Queries and Model Repositories
22
==========================================
33

4-
.. currentmodule:: floatcsep
4+
The following example shows an experiment whose forecasts are **retrieved from a repository** (Zenodo - https://zenodo.org) and the testing **catalog** from an authoritative source **web service** (namely the gCMT catalog from the International Seismological Centre - http://www.isc.ac.uk).
5+
56

6-
.. contents::
7-
:local:
7+
8+
.. currentmodule:: floatcsep
89

910
.. admonition:: **TL; DR**
1011

@@ -16,11 +17,14 @@ D - Catalog Queries and Model Repositories
1617
1718
After the calculation is complete, the results will be summarized in ``results/report.md``.
1819

20+
.. contents::
21+
:local:
22+
1923

2024
Experiment Components
2125
---------------------
2226

23-
The following example shows an experiment whose forecasts are retrieved from a repository (Zenodo - https://zenodo.org) and the testing catalog from an authoritative source web service (namely the gCMT catalog from the ISC - http://www.isc.ac.uk). The initial structure is:
27+
The source code can be found in the ``examples/case_d`` folder or in `GitHub <https://github.com/cseptesting/floatcsep/blob/main/examples/case_d>`_. The **initial** input structure of the experiment is:
2428

2529
::
2630

@@ -60,8 +64,9 @@ Catalog
6064
The ``catalog`` inset from ``config.yml`` now makes reference to a catalog query function, in this case :func:`~pycsep.query_gcmt`.
6165

6266
.. literalinclude:: ../../examples/case_d/config.yml
63-
:language: yaml
64-
:lines: 14-14
67+
:caption: examples/case_d/config.yml
68+
:language: yaml
69+
:lines: 14-14
6570

6671
``floatcsep`` will automatically filter the catalog to the experiment time, spatial and magnitude windows of the experiment.
6772

@@ -74,14 +79,15 @@ Models
7479
The model configuration is set in ``models.yml``.
7580

7681
.. literalinclude:: ../../examples/case_d/models.yml
77-
:language: yaml
82+
:caption: examples/case_d/models.yml
83+
:language: yaml
7884

7985
* The option ``zenodo_id`` makes reference to the zenodo **record id**. The model ``team`` is found in https://zenodo.org/record/6289795, whereas the model ``wheel`` in https://zenodo.org/record/6255575.
8086

81-
* The option ``flavours`` allows multiple model sub-classes to be quickly instantiated.
82-
8387
* The ``zenodo`` (or ``git``) repositories could contain multiple files, each of which can be assigned to a flavour.
8488

89+
* The option ``flavours`` allows multiple model sub-classes to be quickly instantiated.
90+
8591
* When multiple flavours are passed, ``path`` refers to the folder where the models would be downloaded.
8692

8793
* If a single file of the repository is needed (without specifying model flavours), ``path`` can reference to the file itself. For example, you can try replacing the whole WHEEL inset in ``models.yml`` to:

0 commit comments

Comments
 (0)