monkey_wrench.input_output.seviri._common module

The module providing utilities for SEVIRI-CHIMP related filename operations.

monkey_wrench.input_output.seviri._common.input_filename_from_product_id(product_ids: str | list[str] | set[str] | tuple[str, ...], extension: str = '.nc') Path | list[Path] | set[Path] | tuple[Path, ...][source]

Generate (a) CHIMP-compliant input filename(s) based on (a) SEVIRI product ID(s).

Parameters:
  • product_ids – Either a single SEVIRI product ID, or a list/set/tuple of SEVIRI product IDs.

  • extension – The file extension, Defaults to ".nc".

Returns:

Depending on the input, either a single filename, or a list/set/tuple of filenames. The type of the output matches the type of the input in case of a list/set.tuple, e.g. a tuple of strings as input will result in a tuple of paths.

Example

>>> input_filename_from_product_id(
...  "MSG3-SEVI-MSG15-0100-NA-20150731221240.036000000Z-NA"
... )
PosixPath('seviri_20150731_22_12.nc')
>>> input_filename_from_product_id((
...  "MSG3-SEVI-MSG15-0100-NA-20150731221240.036000000Z-NA",
...  "MSG3-SEVI-MSG15-0100-NA-20231231171242.800000000Z-NA"
... ))
(PosixPath('seviri_20150731_22_12.nc'), PosixPath('seviri_20231231_17_12.nc'))
monkey_wrench.input_output.seviri._common.input_filename_from_datetime(datetime_objects: datetime | list[datetime] | set[datetime] | tuple[datetime, ...], extension: str = '.nc') Path | list[Path] | set[Path] | tuple[Path, ...][source]

Generate (a) CHIMP-compliant input filename(s) based on (a) datetime object(s).

Parameters:
  • datetime_objects – Either a single datetime object, or a list/set/tuple of datetime objects.

  • extension – The file extension, Defaults to ".nc".

Returns:

Depending on the input, either a single filename, or a list/set/tuple of filenames. The type of the output matches the type of the input in case of a list/set.tuple, e.g. a tuple of strings as input will result in a tuple of paths.

Example

>>> input_filename_from_datetime(datetime(2020, 1, 1, 0, 12))
PosixPath('seviri_20200101_00_12.nc')
>>> input_filename_from_datetime(
...  [datetime(2020, 1, 1, 0, 12), datetime(2020, 3, 4, 2, 42)]
... )
[PosixPath('seviri_20200101_00_12.nc'), PosixPath('seviri_20200304_02_42.nc')]
monkey_wrench.input_output.seviri._common.output_filename_from_product_id(product_ids: str | list[str] | set[str] | tuple[str, ...], extension: str = '.nc') Path | list[Path][source]

Generate (a) CHIMP-compliant output filename(s) based on (a) SEVIRI product ID(s).

Parameters:
  • product_ids – Either a single SEVIRI product ID , or a list/set/tuple of SEVIRI product IDs.

  • extension – The file extension, Defaults to ".nc".

Returns:

Depending on the input, either a single filename, or a list/set/tuple of filenames. The type of the output matches the type of the input in case of a list/set.tuple, e.g. a tuple of strings as input will result in a tuple of paths.

Example

>>> output_filename_from_product_id(
...  "MSG3-SEVI-MSG15-0100-NA-20150731221240.036000000Z-NA"
... )
PosixPath('chimp_20150731_22_12.nc')
>>> output_filename_from_product_id([
...  "MSG3-SEVI-MSG15-0100-NA-20150731221240.036000000Z-NA",
...  "MSG3-SEVI-MSG15-0100-NA-20231231171242.800000000Z-NA"
... ])
[PosixPath('chimp_20150731_22_12.nc'), PosixPath('chimp_20231231_17_12.nc')]