Skip to content

Commit 8133006

Browse files
committed
docs: Finished the evaluation config docs. Added .js to custom behavior of external links (now open in a new tab). Added sphinx-design for expandable tables.
1 parent 1a4d0d3 commit 8133006

File tree

5 files changed

+161
-54
lines changed

5 files changed

+161
-54
lines changed

docs/_static/custom.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* custom.js
3+
*
4+
* This script contains custom JavaScript modifications for the Sphinx documentation.
5+
* It can be expanded to include additional customizations related to behavior,
6+
* style, and functionality of the generated documentation.
7+
*
8+
*
9+
* Usage:
10+
* - Place this script in the _static directory of your Sphinx project.
11+
* - Include it in the html_js_files configuration in conf.py to load it automatically.
12+
* - Expand this file with other JavaScript customizations as needed.
13+
*
14+
* Author: Pablo Iturrieta
15+
* Date: 28.09.2024
16+
*/
17+
18+
document.addEventListener("DOMContentLoaded", function () {
19+
// - Ensures that all external links open in a new tab by adding the target="_blank"
20+
// attribute to all links with the 'external' class (automatically applied by Sphinx).
21+
// - Adds rel="noopener noreferrer" for security purposes, ensuring the new page
22+
// does not have access to the originating window context (prevents security risks).
23+
// Select all external links in the documentation
24+
const links = document.querySelectorAll('a.external');
25+
26+
// Loop through all the links and set them to open in a new tab
27+
links.forEach(function (link) {
28+
link.setAttribute('target', '_blank');
29+
link.setAttribute('rel', 'noopener noreferrer');
30+
});
31+
});

docs/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"sphinx.ext.napoleon",
3131
"sphinx.ext.intersphinx",
3232
"sphinx_copybutton",
33+
"sphinx_design",
3334
]
3435

3536
# language = 'en'
@@ -66,6 +67,10 @@
6667
"logo_only": True,
6768
}
6869
html_logo = "_static/floatcsep_logo.svg"
70+
html_js_files = [
71+
"custom.js",
72+
]
73+
6974
todo_include_todos = False
7075

7176
copybutton_prompt_text = "$ " # Text to ignore when copying (for shell commands)

docs/guide/evaluation_config.rst

Lines changed: 122 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
Evaluations Definition
44
======================
55

6-
**floatCSEP** evaluate forecasts using the testing procedures from **pyCSEP** (See `Testing Theory <https://docs.cseptesting.org/getting_started/theory.html>`_). Depending on the forecast type (e.g., **GriddedForecasts** or **CatalogForecasts**), different evaluation functions can be used. T
6+
**floatCSEP** evaluate forecasts using the routines defined in **pyCSEP** (See `Testing Theory <https://docs.cseptesting.org/getting_started/theory.html>`_). Depending on the forecast types (e.g., **GriddedForecasts** or **CatalogForecasts**), different evaluation functions can be used.
77

8-
Each evaluation specifies a `func` parameter, representing the evaluation function to be applied, and a `plot_func` parameter for visualizing the results.
8+
Each evaluation specifies a ``func`` parameter, representing the evaluation function to be applied, a configuration of the function with ``func_kwargs`` (e.g., number of simulations, confidence intervals) and a ``plot_func`` parameter for visualizing the results. Evaluations for **GriddedForecasts** typically use functions from :mod:`csep.core.poisson_evaluations` or :mod:`csep.core.binomial_evaluations`, while evaluations for **CatalogForecasts** use functions from :mod:`csep.core.catalog_evaluations`.
99

10-
Evaluations for **GriddedForecasts** typically use functions from :mod:`csep.core.poisson_evaluations` or :mod:`csep.core.binomial_evaluations`, while evaluations for **CatalogForecasts** use functions from :mod:`csep.core.catalog_evaluations`.
10+
.. important::
11+
12+
An evaluation in ``test_config`` points to a **pyCSEP** `evaluation function <https://docs.cseptesting.org/concepts/evaluations.html>`_, valid for the forecast class.
1113

12-
The structure of the evaluation configuration file is similar to the model configuration, with multiple tests, each pointing to a specific evaluation function and plotting method.
1314

1415
**Example Configuration**:
1516

1617
.. code-block:: yaml
18+
:caption: test_config.yml
1719
18-
- N-test:
19-
func: poisson_evaluations.number_test
20-
plot_func: plot_poisson_consistency_test
2120
- S-test:
2221
func: poisson_evaluations.spatial_test
2322
plot_func: plot_poisson_consistency_test
@@ -32,66 +31,136 @@ The structure of the evaluation configuration file is similar to the model confi
3231
Evaluation Parameters:
3332
----------------------
3433

34+
Each evaluation listed in ``test_config`` accepts the following parameters:
35+
3536
.. list-table::
36-
:widths: 20 80
37+
:widths: 30 80
3738
:header-rows: 1
3839

3940
* - **Parameter**
4041
- **Description**
4142
* - **func** (required)
42-
- The evaluation function, specifying which test to run. Must be an available function from the pyCSEP evaluation suite (e.g., `poisson_evaluations.number_test`).
43+
- Specify which evaluation/test function to run. Must be a **pyCSEP** ``{module}.{function}`` suite \
44+
(e.g., :func:`poisson_evaluations.number_test <csep.core.poisson_evaluations.number_test>`) or
45+
**floatCSEP** function.
46+
* - **func_kwargs**
47+
- Any keyword argument to control the specific **func**. For example, :func:`poisson_evaluations.spatial_test <csep.core.poisson_evaluations.spatial_test>` may be configured with ``num_simulations: 2000``.
4348
* - **plot_func** (required)
44-
- The function to plot the evaluation results, specified from the available plotting functions (e.g., `plot_poisson_consistency_test`).
49+
- The function to plot the evaluation results, from either the :mod:`csep.utils.plots` module (e.g., :func:`plot_poisson_consistency_test <csep.utils.plots.plot_poisson_consistency_test>`) or **floatCSEP** :mod:`~floatcsep.utils.helpers` module.
4550
* - **plot_args**
46-
- Arguments passed to customize plot titles, labels, or font size.
51+
- Arguments passed to customize the plot function. Can be titles, labels, colors, font size, etc. Review the documentation of the respective function.
4752
* - **plot_kwargs**
48-
- Keyword arguments passed to the plotting function for fine-tuning plot appearance (e.g., `one_sided_lower: True`).
53+
- Keyword arguments to customize the plot function. Review the documentation of the respective function.
4954
* - **ref_model**
5055
- A reference model against which the current model is compared in comparative tests (e.g., `Model A`).
5156
* - **markdown**
5257
- A description of the test to be used as caption when reporting results
5358

5459

55-
Evaluations Functions:
56-
----------------------
57-
58-
Depending on the type of forecast being evaluated, different evaluation functions are used:
59-
60-
1. **GriddedForecasts**:
61-
62-
.. list-table::
63-
:widths: 20 80
64-
:header-rows: 1
65-
66-
* - **Function**
67-
- **Description**
68-
* - **poisson_evaluations.number_test**
69-
- Evaluates the forecast by comparing the total number of forecasted events with the observed events using a Poisson distribution.
70-
* - **poisson_evaluations.spatial_test**
71-
- Compares the spatial distribution of forecasted events to the observed events.
72-
* - **poisson_evaluations.magnitude_test**
73-
- Evaluates the forecast by comparing the magnitude distribution of forecasted events with observed events.
74-
* - **poisson_evaluations.conditional_likelihood_test**
75-
- Tests the likelihood of observed events given the forecasted rates, conditioned on the total earthquake occurrences.
76-
* - **poisson_evaluations.paired_t_test**
77-
- Calculate the information gain between one forecast to a reference (``ref_model``), and test a significant difference by using a paired T-test.
78-
* - **binomial_evaluations.binary_spatial_test**
79-
- Binary spatial test to compare forecasted and observed event distributions.
80-
* - **binomial_evaluations.binary_likelihood_test**
81-
- Likelihood test likelihood of observed events given the forecasted rates, assuming a Binary distribution
82-
* - **binomial_evaluations.negative_binomial_number_test**
83-
- Evaluates the number of events using a negative binomial distribution, comparing observed and forecasted event counts.
84-
* - **brier_score**
85-
- Uses a quadratic metric rather than logarithmic. Does not penalize false-negatives as much as log-likelihood metrics
86-
* - **vector_poisson_t_w_test**
87-
- Carries out the paired_t_test and w_test for a single forecast compared to multiple.
88-
* - **sequential_likelihood**
89-
- Obtain the distribution of log-likelihoods in time.
90-
* - **sequential_information_gain**
91-
- Obtain the distribution of information gain in time, compared to a ``ref_model``.
92-
93-
94-
2. **CatalogForecasts**:
95-
60+
Evaluations Functions
61+
---------------------
62+
63+
**floatCSEP** supports the following evaluations:
64+
65+
66+
.. dropdown:: **Evaluations for GriddedForecasts**
67+
:animate: fade-in-slide-down
68+
:icon: list-unordered
69+
70+
.. list-table::
71+
:widths: 20 80
72+
:header-rows: 1
73+
74+
* - **Function**
75+
- **Evaluates:**
76+
* - :func:`poisson_evaluations.number_test <csep.core.poisson_evaluations.number_test>`
77+
- the total number of forecasted events compared to the observed events using a Poisson distribution.
78+
* - :func:`poisson_evaluations.spatial_test <csep.core.poisson_evaluations.spatial_test>`
79+
- the forecasted spatial distribution relative to the observed events using a Poisson distribution.
80+
* - :func:`poisson_evaluations.magnitude_test <csep.core.poisson_evaluations.magnitude_test>`
81+
- the forecasted magnitude distribution relative to the observed events using a Poisson distribution.
82+
* - :func:`poisson_evaluations.conditional_likelihood_test <csep.core.poisson_evaluations.conditional_likelihood_test>`
83+
- the likelihood of the observed events given the forecasted rates, conditioned on the total earthquake occurrences, assuming a Poisson distribution.
84+
* - :func:`poisson_evaluations.paired_t_test <csep.core.poisson_evaluations.paired_t_test>`
85+
- the information gain between one forecast to a reference (``ref_model``), and test for a significant difference by using a paired T-test.
86+
* - :func:`binomial_evaluations.binary_spatial_test <csep.core.binomial_evaluations.binary_spatial_test>`
87+
- the forecasted spatial distribution relative to the observed events, assuming a Binary/Bernoulli process.
88+
* - :func:`binomial_evaluations.binary_likelihood_test <csep.core.binomial_evaluations.binary_likelihood_test>`
89+
- the likelihood of the observed events given the forecasted rates, assuming a Binary distribution.
90+
* - :func:`binomial_evaluations.negative_binomial_number_test <csep.core.binomial_evaluations.negative_binomial_number_test>`
91+
- the total number of forecasted events compared to the observed events using a Negative Binomial distribution.
92+
* - :func:`brier_score <floatcsep.utils.helpers.brier_score>`
93+
- the forecast skill using a quadratic metric rather than logarithmic. Does not penalize false-negatives as much as log-likelihood metrics.
94+
* - :func:`vector_poisson_t_w_test <floatcsep.utils.helpers.vector_poisson_t_w_test>`
95+
- a forecast skill compared to multiple forecasts, by carrying out the paired_t_test and w_test jointly.
96+
* - :func:`sequential_likelihood <floatcsep.utils.helpers.sequential_likelihood>`
97+
- the temporal evolution of log-likelihoods scores.
98+
* - :func:`sequential_information_gain <floatcsep.utils.helpers.sequential_information_gain>`
99+
- the temporal evolution of the information gain in time, compared to a ``ref_model``.
100+
101+
102+
103+
.. dropdown:: **Evaluations for CatalogForecasts**
104+
:animate: fade-in-slide-down
105+
:icon: list-unordered
106+
107+
.. list-table::
108+
:widths: 20 80
109+
:header-rows: 1
110+
111+
* - **Function**
112+
- **Evaluates:**
113+
* - :func:`catalog_evaluations.number_test <csep.core.catalog_evaluations.number_test>`
114+
- the total number of forecasted events compared to observed events in an earthquake catalog.
115+
* - :func:`catalog_evaluations.spatial_test <csep.core.catalog_evaluations.spatial_test>`
116+
- the spatial distribution of forecasted vs. observed earthquake events in an earthquake catalog.
117+
* - :func:`catalog_evaluations.magnitude_test <csep.core.catalog_evaluations.magnitude_test>`
118+
- the magnitude distribution of forecasted events to those observed in the earthquake catalog.
119+
* - :func:`catalog_evaluations.pseudolikelihood_test <csep.core.catalog_evaluations.pseudolikelihood_test>`
120+
- the pseudolikelihood of the observed events, given the forecasted synthetic catalogs
121+
* - :func:`catalog_evaluations.calibration_test <csep.core.catalog_evaluations.calibration_test>`
122+
- the consistency of multiple test-quantiles in time with the expected uniform distribution using a Kolmogorov-Smirnov test.
123+
124+
.. note::
125+
126+
Check each function's `docstring` to see which ``func_kwargs`` are compatible with it.
127+
128+
Plotting Functions
129+
------------------
130+
131+
**floatCSEP** supports the following:
132+
133+
.. dropdown:: Plotting functions
134+
:animate: fade-in-slide-down
135+
:icon: list-unordered
136+
137+
.. list-table::
138+
:widths: 20 80
139+
:header-rows: 1
140+
141+
* - **Plotting function**
142+
- **Compatible with:**
143+
* - :func:`plot_poisson_consistency_test <csep.utils.plots.plot_poisson_consistency_test>`
144+
- :func:`poisson_evaluations.number_test <csep.core.poisson_evaluations.number_test>`, :func:`poisson_evaluations.spatial_test <csep.core.poisson_evaluations.spatial_test>`, :func:`poisson_evaluations.magnitude_test <csep.core.poisson_evaluations.magnitude_test>`, :func:`poisson_evaluations.conditional_likelihood_test <csep.core.poisson_evaluations.conditional_likelihood_test>`, :func:`binomial_evaluations.negative_binomial_number_test <csep.core.binomial_evaluations.negative_binomial_number_test>`, :func:`binomial_evaluations.binary_likelihood_test <csep.core.binomial_evaluations.binary_likelihood_test>`, :func:`binomial_evaluations.binary_spatial_test <csep.core.binomial_evaluations.binary_spatial_test>`, :func:`brier_score <floatcsep.utils.helpers.brier_score>`.
145+
* - :func:`plot_comparison_test <csep.utils.plots.plot_comparison_test>`
146+
- :func:`poisson_evaluations.paired_t_test <csep.core.poisson_evaluations.paired_t_test>`
147+
* - :func:`plot_number_test <csep.utils.plots.plot_number_test>`
148+
- :func:`catalog_evaluations.number_test <csep.core.catalog_evaluations.number_test>`
149+
* - :func:`plot_magnitude_test <csep.utils.plots.plot_magnitude_test>`
150+
- :func:`catalog_evaluations.magnitude_test <csep.core.catalog_evaluations.magnitude_test>`
151+
* - :func:`plot_spatial_test <csep.utils.plots.plot_spatial_test>`
152+
- :func:`catalog_evaluations.spatial_test <csep.core.catalog_evaluations.spatial_test>`
153+
* - :func:`plot_likelihood_test <csep.utils.plots.plot_likelihood_test>`
154+
- :func:`catalog_evaluations.pseudolikelihood_test <csep.core.catalog_evaluations.pseudolikelihood_test>`
155+
* - :func:`plot_calibration_test <csep.utils.plots.plot_calibration_test>`
156+
- :func:`catalog_evaluations.calibration_test <csep.core.catalog_evaluations.calibration_test>`
157+
* - :func:`plot_sequential_likelihood <~floatcsep.utils.helpers.plot_sequential_likelihood>` :func:``
158+
- :func:`sequential_likelihood <floatcsep.utils.helpers.sequential_likelihood>`, :func:`sequential_information_gain <floatcsep.utils.helpers.sequential_information_gain>`
159+
* - :func:`plot_matrix_comparative_test <floatcsep.utils.helpers.plot_matrix_comparative_test>`
160+
- :func:`vector_poisson_t_w_test <floatcsep.utils.helpers.vector_poisson_t_w_test>`
161+
162+
.. note::
163+
164+
Check each plot functions's `docstring` to see which ``plot_args`` and ``plot_kwargs`` are compatible with it.
96165

97166

docs/guide/experiment_config.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ Configuration files are written in ``YAML`` format and are divided into differen
2323
`YAML` (Yet Another Markup Language) is a human-readable format used for configuration files. It uses **key: value** pairs to define settings, and indentation to represent nested structures. Lists are denoted by hyphens (`-`).
2424

2525

26-
**Example Basic Configuration** (``config.yml``):
26+
**Example Basic Configuration**:
2727

2828
.. code-block:: yaml
29+
:caption: config.yml
2930
3031
name: CSEP Experiment
3132
time_config:

docs/guide/model_config.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ In the experiment ``config.yml`` file (See :ref:`experiment_config`), the parame
1111
**Example**:
1212

1313
.. code-block:: yaml
14+
:caption: model_config.yml
1415
1516
- MODEL_1 NAME:
1617
parameter_1: value

0 commit comments

Comments
 (0)