Getting Started
Entrypoint
All you need to in order to make your model compatible is to define an entry point, a simple function, for your model. With a predefined format for input and output from this entrypoint, hermes is then able to execute your model and store the results in the database using that funcion.
def entrypoint(input: dict) -> list:
# Call and execute your model here.
return output
Usage
The description of the formats used for the input and output of the entrypoint can be found in the input and output format sections. If you want, you can stop there, without installation of this package, as hermes doesn't need anything else. If you would like to have some kind of validation of the input and output of your entrypoint, you can install this package and read the validation section.
Input and Output Formats
The validate_entrypoint decorator will validate the input and output of the entrypoint, and raise an error if the input or output is not valid. The induced parameter is optional, and defaults to False. If set to True the input fields injection_observation and injection_plan will be validated as well.
Input Format
The input dictionary has the following fields:
model_input = {
'forecast_start': 'datetime'
'forecast_end': 'datetime',
'injection_observation': 'list[hydjson]',
'injection_plan': 'hydjson',
'bounding_polygon': 'wkt(str)',
'depth_min': 'float',
'depth_max': 'float'
'seismicity_observation': 'quakeml',
'model_parameters': 'dict'
}
Following a complete description of the input fields:
forecast_start: datetime.datetime
Date and time from when on the forecast should be made.
forecast_end: datetime.datetime
Date and time until when the forecast should be made.
injection_observation: list[dict] # HYDJSON format
A list of dictionaries in the HYDJSON format, containing the history of injections into the well.
injection_plan: str | dict # HYDJSON format
A dictionary in the HYDJSON format, containing the planned injections.
seismicity_observation: str # QUAKEML format
An XML string in the QUAKEML format, containing the seismic events catalog.
model_parameters: dict
A dictionary containing the parameters for the model. The keys are the names of the parameters, and the values are the values of the parameters.
bounding_polygon: str # WKT format
depth_min: float
depth_max: float
The geometry of the area of interest. The bounding_polygon is a string in the WKT format. It is the model's responsibility to discretize the area of interest and to calculate the forecast for each discretized volume.
Output Format
The output of the entrypoint should be a list of forecasts, where each entry in the list represents the forecast for one timestep. The forecasts can be one of two types, either Catalogs of events, including their magnitude, location and time, or a a parametric description of the seismicity, including at least a, b and mc values.
Each forecast should be returned either as a pd.DataFrame() object, or, if using the SeismoStats package, as a (Forecast)Catalog object or a (Forecast)GRRateGrid object.
In any case, they each need two attributes, starttime and endtime, which are datetime.datetime objects defining the timestep for which the forecast is made.
def entrypoint(input: dict) -> list:
catalog = pd.DataFrame(#your data here)
catalog.starttime = datetime.datetime(2020, 11, 24, 14, 47, 9)
catalog.endtime = datetime.datetime(2020, 11, 24, 15, 47, 9)
return [catalog]
Catalog
If returning a Catalog of events, the returned object should have at least the following columns:
time longitude latitude depth magnitude
0 2020-11-24 14:47:09.823149 8.474492 46.509983 1294.102992 -2.82
1 2020-11-24 15:28:54.648949 8.474545 46.510010 1268.102992 -2.94
2 2020-11-24 15:31:42.411869 8.474323 46.509967 1265.102992 -3.03
3 2020-11-24 15:35:01.114360 8.474359 46.509832 1260.102992 -2.95
4 2020-11-24 15:35:07.995789 8.474372 46.509814 1261.102992 -2.94
It is possible to return multiple realizations of catalogs for one timestep. In this case a catalog_id column is required, to distinguish between the different realizations:
time longitude latitude depth magnitude catalog_id
0 2020-11-24 14:47:09.823149 8.474492 46.509983 1294.102992 -2.82 0
1 2020-11-24 15:28:54.648949 8.474545 46.510010 1268.102992 -2.94 0
2 2020-11-24 15:31:42.411869 8.474323 46.509967 1265.102992 -3.03 0
3 2020-11-24 15:35:01.114360 8.474359 46.509832 1260.102992 -2.95 1
4 2020-11-24 15:35:07.995789 8.474372 46.509814 1261.102992 -2.94 1
GRRateGrid
If using a grid of Gutenberg-Richter rates, the returned object should have at least the following columns:
longitude_min longitude_max latitude_min latitude_max depth_min depth_max a b mc
0 8.472518 8.476478 46.508451 46.511185 1121.433 1421.434 -26.1 2.1 -2.91
Additional columns are allowed. Currently number_events, alpha are also stored if available.
Similar to the catalog, grid_id can be used to return probabilistic forecast, returning multiple possible realizations of a grid per timestep:
longitude_min longitude_max latitude_min latitude_max depth_min depth_max a alpha b mc grid_id
0 8.472518 8.476478 46.508451 46.511185 1121.434 1421.434 -26.1 -5.3 2.1 -2.91 0
1 8.472518 8.476478 46.508451 46.511185 1121.434 1421.434 -26.1 -5.3 2.1 -2.91 1
2 8.472518 8.476478 46.508451 46.511185 1121.434 1421.434 -26.1 -5.3 2.1 -2.91 2
3 8.472518 8.476478 46.508451 46.511185 1121.434 1421.434 -26.1 -5.3 2.0 -2.91 3
Validation
If you would like to have some kind of validation of the input and output of your entrypoint, you can install this package following these instructions.
The changes to the entrypoint are minimal:
from hermes import validate_entrypoint, ModelInput
@validate_entrypoint(induced=True)
def entrypoint(model_input: ModelInput):
# Call and execute your model here.
return output
Note, that you now don't have a dict anymore inside the function, but an object, with the fields of the input format as attributes. The validate_entrypoint decorator will validate the input and output of the entrypoint, and raise an error if the input or output is not valid.
The induced parameter is optional, and defaults to False. If set to True the input fields injection_observation and injection_plan will be validated as well. Note, that if you're using the validation for induced seismicity, you need to install the package with the extra 'hydws' dependency:
Installation
If you want to use the validation features, you can install the package by running the following command:
# basic installation
pip install git+https://gitlab.seismo.ethz.ch/indu/hermes-model.git
# installation with hydws dependency
pip install 'hermes-model[hydws] @ git+https://gitlab.seismo.ethz.ch/indu/hermes-model.git'
You can reference the dependency in your requirements.txt or setup.cfg file as well:
# basic dependency
hermes-model @ git+https://gitlab.seismo.ethz.ch/indu/hermes-model.git
# dependency with hydws
hermes-model[hydws] @ git+https://gitlab.seismo.ethz.ch/indu/hermes-model.git
Dependencies
The data formats we rely on are HYDJSON for the models forecasting induced seismicity, and QUAKEML for the events data. To work with those formats, we use the two packages hydws-client and SeismoStats respectively. It is not required to use them as well, but this package uses them to validate the input and output data, and they are very handy to work with quakeml and hydjson. hydws-client will only be installed, if you install the package with the extra 'hydws' dependency.
Release files for hermes-model 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hermes_model-1.0.0.tar.gz | 49.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hermes_model-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:81.6 kB
Release files / hermes_model-1.0.0.tar.gz
| Download URL | hermes_model-1.0.0.tar.gz |
|---|---|
| Size | 49.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d54c8a4a2c9bdaa6f36b5aea6cc6a2e07495d6d73ba10b6f7c170fcd0f5f511e
|
|
BLAKE2b-256 checksum How to use checksums |
c3cdf34c553cc1208279828151c99b462b8f52f7336a8f95aae69d5fe0d7b26c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 28, 2025.
Transparency logRelease files / hermes_model-1.0.0-py3-none-any.whl
| Download URL | hermes_model-1.0.0-py3-none-any.whl |
|---|---|
| Size | 32.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47d1d4485f78e5cbc237f5d43326f002cb1740f8d03fae46cd903c8bf80feb32
|
|
BLAKE2b-256 checksum How to use checksums |
6de0741600f0ff229c8054b1057703c6e8568e352dbb68899e8917652818d7b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 28, 2025.
Transparency log