monkey_wrench.query._types module

class monkey_wrench.query._types.CollectionMeta(*, query_string: str, snapshot_minutes: list[Annotated[int, Ge(ge=0), FieldInfo(annotation=NoneType, required=True, metadata=[Lt(lt=60)])]] | None = None)[source]

Bases: Model

Named tuple to gather the collection metadata.

query_string: str

A colon (:) delimited string which represents the query string for the collection on the EUMETSAT API.

Example

For SEVIRI we have: "EO:EUM:DAT:MSG:HRSEVIRI".

snapshot_minutes: list[Annotated[int, Ge(ge=0), FieldInfo(annotation=NoneType, required=True, metadata=[Lt(lt=60)])]] | None

The minutes for which we have data in an hour.

Warning

For collections that this does not apply, set the default value, i.e. None.

Example

For SEVIRI we have one snapshot per 15 minutes, starting from the 12th minute. As a result, we have [12, 27, 42, 57] for SEVIRI snapshots in an hour.

class monkey_wrench.query._types.EumetsatCollection(*values)[source]

Bases: Enum

Enum class that defines the collections for the EUMETSAT datastore.

amsu = CollectionMeta(query_string='EO:EUM:DAT:METOP:AMSUL1', snapshot_minutes=None)
avhrr = CollectionMeta(query_string='EO:EUM:DAT:METOP:AVHRRL1', snapshot_minutes=None)
mhs = CollectionMeta(query_string='EO:EUM:DAT:METOP:MHSL1', snapshot_minutes=None)
seviri = CollectionMeta(query_string='EO:EUM:DAT:MSG:HRSEVIRI', snapshot_minutes=[12, 27, 42, 57])
class monkey_wrench.query._types.EumetsatAPI[source]

Bases: object

Static class for EUMETSAT API functionalities.

api_base_url = HttpUrl('https://api.eumetsat.int/')

The root URL of the EUMETSAT API.

download_path_template = '{base}/data/download/1.0.0/collections/{collection}/products'

The template URL for the downloading collections.

credentials_env_vars: ClassVar[dict[str, str]] = {'login': 'EUMETSAT_API_LOGIN', 'password': 'EUMETSAT_API_PASSWORD'}

The keys of environment variables used to authenticate the EUMETSAT API calls.

Example

On Linux, you can use the export command to set the credentials in a terminal,

export EUMETSAT_API_LOGIN=<login>;
export EUMETSAT_API_PASSWORD=<password>;
static make_collection_url(collection: EumetsatCollection) HttpUrl[source]

Make a complete collection URL from the API base URL and the given collection (query string).

Parameters:

collection – A collection of type EumetsatCollection, e.g. for the SEVIRI we have EumetsatCollection.seviri.

Returns:

The full collection URL using which the files can be fetched.

Example

>>> EumetsatAPI.make_collection_url(EumetsatCollection.seviri)
HttpUrl('https://api.eumetsat.int/data/download/1.0.0/collections/EO%3AEUM%3ADAT%3AMSG%3AHRSEVIRI/products')
static seviri_collection_url() HttpUrl[source]

Return the complete URL for the SEVIRI collection.

classmethod get_token() AccessToken[source]

Get a token using the credentials_env_vars.

This method returns the same token if it is still valid and issues a new one otherwise.

Returns:

A token using which the datastore can be accessed.

Note

See API key management on the eumdac website for more information.

monkey_wrench.query._types.Batches

Type alias for search results in batches.

For each batch there exists a 2-tuple, in which the first element is the returned items and the second element is the number of returned items in the same batch.

alias of Generator[tuple[T, int], None, None]