veriflow.datasources.fewsnetcdf#

Read and write NetCDF files in a fews compatible format.

Classes

FewsNetCDF(config)

For reading data from a NetCDF file produced by Delft-FEWS.

FewsNetCDFConfig(*, directory, ...[, ...])

A FEWS NetCDF config element.

class veriflow.datasources.fewsnetcdf.FewsNetCDF(config)[source]#

For reading data from a NetCDF file produced by Delft-FEWS.

Parameters:

config (FewsNetCDFConfig)

kind: str = 'fewsnetcdf'#
config_class#

alias of FewsNetCDFConfig

supported_data_types: ClassVar[set[DataType]] = {DataType.observed_historical, DataType.simulated_forecast_ensemble}#
config: FewsNetCDFConfig#
property configured_stations: set[str] | None#

Return the internal station identifiers configured for this datasource.

This is needed for standardization of station identifiers across sources.

property configured_variables: set[str] | None#

Return the internal variable identifiers configured for this datasource.

This is needed for standardization of variable identifiers across sources.

property cache: ZarrCache | None#

Return the cache instance if caching is enabled, otherwise None.

property configured_variables_internal: set[str] | None#

Return the standardized internal variable identifiers configured for this datasource.

This standardized format is needed for caching across different datasources. If your datasource implementation does not have any configurable variables, return None.

create_cache_request(cached_dataset)#

Get the cache request based on the cached dataset and the config.

Parameters:

cached_dataset (Dataset)

Return type:

CacheRequest

property data_type: DataType#

Whether the instance represents sim or obs data.

fetch_validate_filter_cache(*, clear_cache=False)#

High-level wrapper to fetch, validate, filter and apply id mapping to the dataset.

Parameters:

clear_cache (bool)

Return type:

Self

filter_dataset(dataset)#

Filter the dataset on lead times and times outside the verification period.

Parameters:

dataset (Dataset)

Return type:

Dataset

classmethod from_config(raw_config)#

Initialize class from config dict.

Parameters:

raw_config (dict[str, Any])

Return type:

Self

static get_cached_data(cached_dataset, datasource)#

Get the dataset from the cache based on the datasource configuration.

Parameters:
Return type:

Dataset

get_data()#

Get data and make use of cache if configured.

Return type:

Self

standardize_dataset(dataset, data_type)[source]#

Standardize a fetched dataset to the internal datamodel.

Ensures the station dim is indexed by the station id, sets standard dim ordering on each data variable, and ensures each data variable carries a units attribute (filling in "unknown" when missing).

Parameters:
Return type:

Dataset

validate_fetched_data()#

Validate that the dataset is consistent with the config.

Return type:

None

dataset: Dataset#
fetch_data()[source]#

Retrieve fewsnetcdf content as an xarray Dataset.

Return type:

Self

class veriflow.datasources.fewsnetcdf.FewsNetCDFConfig(*, directory, filename_glob, import_adapter, source, data_type, general, id_mapping=None, netcdf_kind, station_ids=None, parameter_ids=None, **extra_data)[source]#

A FEWS NetCDF config element.

Parameters:
  • directory (str)

  • filename_glob (str)

  • import_adapter (Literal[DataSourceKind.FEWSNETCDF])

  • source (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)])

  • data_type (DataType)

  • general (Annotated[GeneralInfoConfig, SkipJsonSchema()])

  • id_mapping (Annotated[IdMappingConfig, SkipJsonSchema()] | None)

  • netcdf_kind (FewsNetCDFKind)

  • station_ids (Annotated[list[str], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] | None)

  • parameter_ids (Annotated[list[str], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] | None)

  • extra_data (Any)

import_adapter: Literal[DataSourceKind.FEWSNETCDF]#
netcdf_kind: FewsNetCDFKind#
station_ids: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] | None#
parameter_ids: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] | None#
property lead_times: LeadTimes | None#
property paths: Iterator[Path]#

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

property verification_period: TimePeriod#
property verification_period_on_frt: TimePeriod#
property verification_period_on_time: TimePeriod#
source#
data_type#
general#
id_mapping#
directory#
filename_glob#