Skip to content

Commit

Permalink
Merge branch 'main' of github.com:swiss-seismological-service/SeismoS…
Browse files Browse the repository at this point in the history
…tats into tests/catalog-methods
  • Loading branch information
martahan committed Aug 20, 2024
2 parents cba338d + 1f85761 commit d353071
Show file tree
Hide file tree
Showing 22 changed files with 626 additions and 248 deletions.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

server:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) --watch "../seismostats"
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) --watch "../seismostats" --re-ignore "api/.*"

clean:
rm -rf $(BUILDDIR)/
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@
html_context = {
"default_mode": "light",
}
suppress_warnings = ['autosectionlabel.*']
81 changes: 74 additions & 7 deletions docs/source/reference/catalog.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Catalog
# Catalog Formats
Basic formats to store earthquake event data. All Structures are subclassing `pandas.DataFrame`, with additional methods to estimate parameters and convert to other formats.


```{eval-rst}
.. currentmodule:: seismostats
```

## Constructor
## Catalog
Simple representation of an earthquake catalog, storing each single event as a row.

(constructor-cat)=
### Constructor

```{eval-rst}
.. autosummary::
:toctree: api/
Catalog
Catalog.from_quakeml
Catalog.from_dict
```

## Modify Catalog
### Modify Catalog

```{eval-rst}
.. autosummary::
Expand All @@ -25,7 +33,7 @@
Catalog.drop_uncertainties
```

## Estimate from Catalog
### Estimate from Catalog

```{eval-rst}
.. autosummary::
Expand All @@ -35,13 +43,72 @@
Catalog.estimate_mc
```

## Transform from or to other format
(convert-cat)=
### Convert to other format

```{eval-rst}
.. autosummary::
:toctree: api/
Catalog.to_quakeml
Catalog.from_quakeml
Catalog.from_dict
```

## ForecastCatalog
Subclass of {ref}`/reference/catalog.md#catalog`, storing events from `n_catalogs` number of forecasted catalogs, distinguished by the `catalog_id` column. Holds additional methods to work with this data structure.

(constructor-fc)=
### Constructor

```{eval-rst}
.. autosummary::
:toctree: api/
ForecastCatalog
```

(convert-fc)=
### Convert to Other Format

```{eval-rst}
.. autosummary::
:toctree: api/
ForecastCatalog.to_quakeml
```

## GRRateGrid
Subclass of `pandas.DataFrame`, storing the Gutenberg-Richter rate values for a spatial grid. Holds additional methods to work with this data structure.

(constructor-grrg)=
### Constructor

```{eval-rst}
.. autosummary::
:toctree: api/
GRRateGrid
```

### Modify GRRateGrid

```{eval-rst}
.. autosummary::
:toctree: api/
GRRateGrid.strip
GRRateGrid.add_time_index
GRRateGrid.reindex_cell_id
```

## ForecastGRRateGrid
Subclass of {ref}`/reference/catalog.md#grrategrid`, storing the Gutenberg-Richter rate values for a `n_grids` number of forecasted grids, distinguished by the `grid_id` column. Holds additional methods to work with this data structure.

(constructor-fgrrg)=
### Constructor

```{eval-rst}
.. autosummary::
:toctree: api/
ForecastGRRateGrid
```
17 changes: 12 additions & 5 deletions docs/source/reference/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@

## Coordinates

### Spatial Transformations
```{eval-rst}
.. autosummary::
:toctree: api/
utils.CoordinateTransformer
[//]: <> utils.CoordinateTransformer.to_local_coords
[//]: <> utils.CoordinateTransformer.from_local_coords
[//]: <> utils.CoordinateTransformer.polygon_from_local_coords
[//]: <> utils.CoordinateTransformer.polygon_to_local_coords
utils.bounding_box_to_polygon
utils.polygon_to_bounding_box
```
### Coordinate Transformer
```{eval-rst}
.. autosummary::
:toctree: api/
utils.CoordinateTransformer
utils.CoordinateTransformer.to_local_coords
utils.CoordinateTransformer.from_local_coords
utils.CoordinateTransformer.polygon_from_local_coords
utils.CoordinateTransformer.polygon_to_local_coords
```

## Spatial Filtering

Expand Down
55 changes: 51 additions & 4 deletions docs/source/user/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ How to reference a section in the documentation.

**Code**
```
Using a custom name: {ref}`Reference <reference/catalog:transformation>`
Using the title of the section: {ref}`/reference/catalog.md#transformation`
Using a custom name: {ref}`Reference <reference/catalog:modify catalog>`
Using the title of the section: {ref}`/reference/catalog.md#modify-catalog`
```

**Output**
Using a custom name: {ref}`Reference <reference/catalog:transformation>`
Using the title of the section: {ref}`/reference/catalog.md#transformation`
Using a custom name: {ref}`Reference <reference/catalog:modify catalog>`
Using the title of the section: {ref}`/reference/catalog.md#modify-catalog`

#### Function / Class
How to reference a function or class in the documentation.
Expand Down Expand Up @@ -113,7 +113,54 @@ def _example():
**Output**
```{eval-rst}
.. module:: seismostats.utils.docs
:noindex:
```
```{eval-rst}
.. autofunction:: _example
```

### Add Mathematical Equations
Mathematical expressions can be added to the documentation using LaTeX.
The expressions can be added in text or in docstrings.


#### In Text

**Code**
```
$$
\frac{\partial u}{\partial t}=-u \frac{\partial u}{\partial x}- \\
v \frac{\partial u}{\partial y}-w \frac{\partial u}{\partial z}
$$
```

**Output**
$$
\frac{\partial u}{\partial t}=-u \frac{\partial u}{\partial x}- \\
v \frac{\partial u}{\partial y}-w \frac{\partial u}{\partial z}
$$


#### In Docstrings

**Code**
```python
def _math():
"""
This function is purely used as an example for the documentation.
Formulas inside docstrings can be used like this
:math:`\\frac{\\partial u}{\\partial t} = 1`. Note that backslashes
need to be escaped by doubling them up.
"""
pass
```

**Output**
```{eval-rst}
.. module:: seismostats.utils.docs
:noindex:
```
```{eval-rst}
.. autofunction:: _math
```
22 changes: 8 additions & 14 deletions seismostats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@

# flake8: noqa

from seismostats.analysis.estimate_a import estimate_a
# analysis
from seismostats.analysis.estimate_beta import estimate_b, shi_bolt_confidence
from seismostats.analysis.estimate_a import estimate_a

# seismicity
from seismostats.catalogs.catalog import Catalog, ForecastCatalog
from seismostats.catalogs.rategrid import ForecastGRRateGrid, GRRateGrid
# plots
from seismostats.plots.basics import (
plot_cum_count,
plot_cum_fmd,
plot_fmd,
plot_mags_in_time,
)
from seismostats.plots.basics import (plot_cum_count, plot_cum_fmd, plot_fmd,
plot_mags_in_time)
from seismostats.plots.seismicity import plot_in_space
from seismostats.plots.statistical import plot_mc_vs_b

# seismicity
from seismostats.seismicity.catalog import Catalog, ForecastCatalog
from seismostats.seismicity.rategrid import ForecastGRRateGrid, GRRateGrid
from seismostats.utils._config import get_option, set_option

# utils
from seismostats.utils.binning import bin_to_precision
from seismostats.utils.filtering import cat_intersect_polygon
from seismostats.utils.simulate_distributions import simulate_magnitudes, simulate_magnitudes_binned
from seismostats.utils.simulate_distributions import (
simulate_magnitudes, simulate_magnitudes_binned)
1 change: 1 addition & 0 deletions seismostats/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
b_value_to_beta
)
from seismostats.analysis.estimate_mc import mc_ks, mc_max_curvature
from seismostats.analysis.estimate_a import estimate_a_positive, estimate_a_classic
Loading

0 comments on commit d353071

Please sign in to comment.