|
6 | 6 | [](https://hermes-client.readthedocs.io/en/latest/?badge=latest) |
7 | 7 |
|
8 | 8 | # 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. |
0 commit comments