Skip to content

Commit a3ce827

Browse files
committed
docs: extend readme with short example
1 parent bf9b059 commit a3ce827

File tree

3 files changed

+96
-11
lines changed

3 files changed

+96
-11
lines changed

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,95 @@
66
[![Documentation Status](https://readthedocs.org/projects/hermes-client/badge/?version=latest)](https://hermes-client.readthedocs.io/en/latest/?badge=latest)
77

88
# HERMES Python Client
9+
10+
This Python client provides a simple interface to the HERMES API, allowing users to easily access and interact with the HERMES data.
11+
12+
## Installation
13+
You can install the client using pip:
14+
15+
```bash
16+
pip install hermes-client
17+
```
18+
19+
Generally, the client is compatible with the respective `vMajor.minor` version of the HERMES webservice. For example, the `hermes-client` version `0.1.x` is compatible with the HERMES webservice version `0.1.x`.
20+
21+
## Usage
22+
You will mainly interact with two client classes. The [HermesClient](https://hermes-client.readthedocs.io/stable/reference/hermes_client.html) as well as the [ForecastSeriesClient](https://hermes-client.readthedocs.io/stable/reference/forecastseries_client.html).
23+
The former should mainly be used to explore the available Projects and Forecastseries, while the latter can be used to access the data linked to specific ForecastSeries, Forecasts and ModelRuns.
24+
25+
### Find the correct ForecastSeries
26+
To find the correct ForecastSeries, you can use the `HermesClient` to search for ForecastSeries by name or other attributes. For example:
27+
28+
```python
29+
from hermes_client import HermesClient
30+
client = HermesClient(url="https://example.com/api/")
31+
32+
projects = client.list_projects()
33+
projects
34+
```
35+
36+
This will return a list of available projects.
37+
38+
```
39+
[{'oid': 'c9d163c4-02ea-4d4d-9ef5-26e82c025c92',
40+
'name': 'project_induced',
41+
'starttime': '2022-04-21T00:00:00',
42+
'endtime': '2022-04-21T23:59:59',
43+
'description': 'This is a test project',
44+
'creationinfo': {'creationtime': '2025-05-22T16:51:41'}},
45+
...
46+
```
47+
48+
Likewise, you can list all ForecastSeries within a project:
49+
50+
```python
51+
forecastseries = client.list_forecastseries(project="project_induced")
52+
```
53+
54+
Which will again return a list of ForecastSeries
55+
```python
56+
[{'oid': 'c9d163c4-02ea-4d4d-9ef5-26e82c025c92',
57+
'name': 'forecastseries_induced',
58+
...
59+
},
60+
...
61+
]
62+
```
63+
64+
### Access ForecastSeries data
65+
Once you have identified the correct ForecastSeries, you can use the `ForecastSeriesClient` to access the data. For example:
66+
67+
```python
68+
from hermes_client import ForecastSeriesClient
69+
client = ForecastSeriesClient(
70+
url="https://example.com/api/",
71+
forecastseries="c9d163c4-02ea-4d4d-9ef5-26e82c025c92"
72+
)
73+
client.forecasts
74+
```
75+
76+
Which will return a list of [ForecastClient](https://hermes-client.readthedocs.io/stable/reference/forecast_client.html) objects, each allowing you to access the data for a specific forecast:
77+
78+
```
79+
[Forecast(COMPLETED, 2022-04-21 15:00:00, 2022-04-21 18:00:00),
80+
Forecast(COMPLETED, 2022-04-21 16:00:00, 2022-04-21 18:00:00),
81+
Forecast(COMPLETED, 2022-04-21 17:00:00, 2022-04-21 18:00:00)]
82+
```
83+
84+
You can then access the data for a specific forecast by using the `ForecastClient`:
85+
86+
```python
87+
forecast = client.forecasts[0]
88+
89+
injectionplan_name = forecast.metadata.injectionplans[0]
90+
model_name = forecast.metadata.modelconfigs[0]
91+
92+
results = forecast.get_results(injectionplan_name, model_name)
93+
```
94+
95+
This will return a [ForecastGRRateGrid](https://seismostats.readthedocs.io/latest/reference/formats/forecastgrrategrid.html) object (or [ForecastCatalog](https://seismostats.readthedocs.io/latest/reference/formats/forecastcatalog.html), depending on the model result types).
96+
97+
## Further Information
98+
For more information on the available methods and attributes, please refer to the [API reference](https://hermes-client.readthedocs.io/stable/reference/index.html).
99+
100+
The documentation will be extended in the future to include more examples and use cases - The API Reference should however give a good overview of the available methods and attributes.

docs/source/index.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ API reference <reference/index>
55
Changelog <changelog>
66
```
77

8-
# hermes-client
8+
```{include} ../../README.md
9+
:relative-docs: docs/
10+
:relative-images: docs/
911
10-
Easily access data from the RT-HERMES API using Python.
11-
12-
Check {doc}`reference/index` section for a technical reference.
13-
14-
<!-- ## Indices and tables
15-
16-
- {ref}`genindex`
17-
- {ref}`modindex`
18-
- {ref}`search` -->

docs/source/reference/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# API Documentation
22

33
```{toctree}
4-
:maxdepth: 2
4+
:maxdepth: 1
55
66
hermes_client
77
forecastseries_client

0 commit comments

Comments
 (0)