veriflow.configuration.utils#

A module for frequently used config elements in the context of verification.

Classes

LeadTimes(*, unit, values)

A lead times config element.

LocalFile(*, directory, filename)

Configuration pointing to a local file.

LocalFiles(*, directory, filename_glob)

Config for multiple local files using pathlib.Path.glob.

Range(*, start, end, step)

A range.

TimePeriod(*, start, end)

A time period config element.

VerificationPair(*, id, obs, sim, variable)

Configuration for a verification pair.

VerificationPeriod(*, start, end[, dimension])

Definition of the verification period.

class veriflow.configuration.utils.LeadTimes(*, unit, values)[source]#

A lead times config element.

Parameters:
unit: TimeUnits#
values: <lambda>, json_schema_input_type=PydanticUndefined)]#
classmethod convert_range_to_list(v)[source]#

Convert range to list.

Parameters:

v (Range | list[int])

Return type:

list[int]

property timedelta64: list[timedelta64]#

As numpy timedelta64.

property stdlib_timedelta: list[timedelta]#

As datetime timedelta.

property max: timedelta#

Get the maximum lead time.

property min: timedelta#

Get the minimum lead time.

class veriflow.configuration.utils.LocalFile(*, directory, filename)[source]#

Configuration pointing to a local file.

Parameters:
directory: Path#
filename: str#
class veriflow.configuration.utils.LocalFiles(*, directory, filename_glob)[source]#

Config for multiple local files using pathlib.Path.glob.

Parameters:
  • directory (str)

  • filename_glob (str)

directory: str#
filename_glob: Annotated[str, FieldInfo(annotation=NoneType, required=True, description="A valid filename glob, like '*.nc' for all netcdf files.")]#
property paths: Iterator[Path]#

Return all filepaths as Path objects in a deterministic sorted order.

class veriflow.configuration.utils.Range(*, start, end, step)[source]#

A range.

Parameters:
start: int#
end: int#
step: int#
to_list()[source]#

Convert to list.

Return type:

list[int]

class veriflow.configuration.utils.TimePeriod(*, start, end)[source]#

A time period config element.

Parameters:
start: Annotated[datetime, FieldInfo(annotation=NoneType, required=True, description='YYYY-MM-DD[T]HH:MM[:SS[.ffffff]][Z or [±]HH[:]MM], see: https://docs.pydantic.dev/2.0/usage/types/datetime/#validation-of-datetime-types')]#
end: Annotated[datetime, FieldInfo(annotation=NoneType, required=True, description='YYYY-MM-DD[T]HH:MM[:SS[.ffffff]][Z or [±]HH[:]MM], see: https://docs.pydantic.dev/2.0/usage/types/datetime/#validation-of-datetime-types')]#
classmethod to_utc_naive_numpy_datetime(v)[source]#

Convert timezone aware datetimes to naive UTC; leave naive untouched (assumed UTC).

Parameters:

v (datetime)

Return type:

datetime

property start_datetime64: datetime64#

Get start as numpy format.

property end_datetime64: datetime64#

Get start as numpy format.

class veriflow.configuration.utils.VerificationPair(*, id, obs, sim, variable)[source]#

Configuration for a verification pair.

Should consist of an id and reference to a source for observations and simulations. The id can be any arbitrary string, and the obs and sim fields should contain an exact reference to a configured source in the datasource configuration. The variable field selects which physical variable from each source’s dataset to verify; after id mapping the same internal variable name must exist as a data variable on both the observation and simulation source.

Parameters:
  • id (str)

  • obs (Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=^[A-Za-z][A-Za-z0-9_]*$, ascii_only=None), MinLen(min_length=1)])

  • sim (Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=^[A-Za-z][A-Za-z0-9_]*$, ascii_only=None), MinLen(min_length=1)])

  • variable (Annotated[str, MinLen(min_length=1)])

id: str#
obs: ", metadata=[MinLen(min_length=1)])]#
sim: ", metadata=[MinLen(min_length=1)])]#
variable: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='The variable name references a physical variable to be verified. Must match the variable definition in the datasource. IdMapping can be set in the general config, to map external variables to an internal definition. This is needed when you want to verify data from different sources, where the variable definition is not equal.', metadata=[MinLen(min_length=1)])]#
class veriflow.configuration.utils.VerificationPeriod(*, start, end, dimension='forecast_reference_time')[source]#

Definition of the verification period.

Parameters:
dimension: Annotated[Literal['forecast_reference_time', 'time'], FieldInfo(annotation=NoneType, required=True, description="The dimension along which the verification period is defined. Using 'forecast_reference_time' allows for a forecast-centric verification run, whereas 'time' allows for an observation-centric verification run.")]#