dpyverification.datasources.netcdf#

Read and write NetCDF files in a fews compatible format.

Classes

NetCDF(config)

A datasource for reading NetCDF files compatible with the internal datamodel.

NetCDFConfig(*, directory, filename_glob, ...)

A NetCDF config element.

class dpyverification.datasources.netcdf.NetCDF(config)[source]#

A datasource for reading NetCDF files compatible with the internal datamodel.

You can validate that the NetCDF file satisfies the internal datamodel using the following example:

import xarray as xr
from dpyverification.datasources import validate_input_data

data_array = xr.open_dataarray("path/to/netcdf/file/example.nc")
validated_data = validate_input_data(data_array)

Note

The NetCDF file must contain exactly one data variable. The data variable must also have a data_type attribute that matches one of the supported data types.

Parameters:

config (NetCDFConfig)

kind: str = 'netcdf'#
config_class#

alias of NetCDFConfig

supported_data_types: ClassVar[set[DataType]] = {DataType.observed_historical, DataType.simulated_forecast_ensemble, DataType.simulated_forecast_probabilistic, DataType.simulated_forecast_single, DataType.threshold}#
fetch_data()[source]#

Retrieve NetCDF file content as an xarray DataArray.

Return type:

Self

class dpyverification.datasources.netcdf.NetCDFConfig(*, directory, filename_glob, import_adapter, source, data_type, general, id_mapping=None, **extra_data)[source]#

A NetCDF config element.

Parameters:
  • directory (str)

  • filename_glob (str)

  • import_adapter (Literal[DataSourceKind.NETCDF])

  • 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_]*$), MinLen(min_length=1)])

  • data_type (DataType)

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

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

  • extra_data (Any)

import_adapter: Literal[DataSourceKind.NETCDF]#