efts_io
¶
efts-io package.
Ensemble forecast time series
Modules:
-
attributes–Management of netCDF attributes.
-
cli–Module that contains the command line application.
-
conventions–Naming conventions for the EFTS netCDF file format.
-
debug–Debugging utilities.
-
dimensions–Functions to create and manipulate dimensions for netCDF files.
-
helpers–Helper functions for netcdf file.
-
variables–Handling of EFTS netCDF variables definitions.
-
wrapper–A thin wrapper around xarray for reading and writing Ensemble Forecast Time Series (EFTS) data sets.
Classes:
-
DataOriginType–Type of data origin according to STF 2.0 conventions.
-
EftsDataSet–Convenience class for access to a Ensemble Forecast Time Series in netCDF file.
-
LocationType–Type of measurement location according to STF 2.0 conventions.
-
StfVariable–Hydrological variable type in the STF convention.
-
TimeSeriesType–Type of time series aggregation according to STF 2.0 conventions.
Functions:
-
create_global_attributes–Creates STF global attributes.
-
create_mandatory_global_attributes–Create a dictionary of mandatory global attributes for an EFTS dataset.
-
create_quality_variable_attributes–Create attributes for a quality code variable (e.g., rain_obs_qual).
-
create_state_variable_attributes–Create attributes for a state variable (e.g., sv1, sv2).
-
create_var_attribute_definition–Create variable attribute definition (legacy function).
-
create_variable_attributes–Create variable attributes for STF 2.0 compliant netCDF files.
-
get_parser–Return the CLI argument parser.
-
main–Run the main program.
-
open_efts–Open an EFTS NetCDF file.
-
template_variable_attributes–Create a template dictionary for variable attributes.
-
validate_global_attributes–Validate a dictionary of global attributes against STF 2.0 conventions.
-
validate_quality_variable_attributes–Validate a dictionary of quality variable attributes against STF 2.0 conventions.
-
validate_state_variable_attributes–Validate a dictionary of state variable attributes against STF 2.0 conventions.
-
validate_variable_attributes–Validate a dictionary of data variable attributes against STF 2.0 conventions.
-
xr_efts–Create an xarray Dataset for EFTS data.
DataOriginType
¶
DataOriginType(code: str, description: str)
Bases: Enum
Type of data origin according to STF 2.0 conventions.
This enumeration defines how the data was obtained or generated, following the STF (Standard Time Format) 2.0 conventions.
Attributes:
-
OBSERVED–Data observed directly from instruments (e.g., gauged rainfall)
-
DERIVED–Data derived from observations through processing (e.g., AWAP rainfall)
-
SIMULATED–Data simulated from historical observations (e.g., flow from GR4H with obs forcing)
-
FORECAST–Data forecast/simulated from predictions (e.g., flow from GR4H with NWP forcing)
Examples:
>>> from efts_io.attributes import DataOriginType
>>> origin = DataOriginType.OBSERVED
>>> origin.code
'obs'
>>> origin.description
'observed directly'
Parameters:
-
(code¶str) –String code defined by STF 2.0 conventions
-
(description¶str) –Human-readable description of the data origin
Source code in src/efts_io/conventions.py
1119 1120 1121 1122 1123 1124 1125 1126 1127 | |
EftsDataSet
¶
Convenience class for access to a Ensemble Forecast Time Series in netCDF file.
Methods:
-
append_history–Append a new entry to the
historyattribute with a timestamp. -
create_data_variables–Create data variables in the data set.
-
get_all_series–Return a multivariate time series, where each column is the series for one of the identifiers.
-
get_dim_names–Gets the name of all dimensions in the data set.
-
get_ensemble_for_stations–Not yet implemented.
-
get_ensemble_forecasts–Not yet implemented. Gets an ensemble forecast for a variable.
-
get_ensemble_size–Return the length of the ensemble size dimension.
-
get_lead_time_count–Length of the lead time dimension.
-
get_lead_time_values–Return the values of the lead time dimension.
-
get_single_series–Return a single point time series for a station identifier.
-
get_station_count–Return the number of stations in the data set.
-
get_stations_varname–Return the name of the variable that has the station identifiers.
-
get_time_dim–Return the time dimension variable as a vector of date-time stamps.
-
new_variable–Create a new variable in the data set.
-
put_lead_time_values–Set the values of the lead time dimension.
-
save_to_stf2–Save to file.
-
set_mandatory_global_attributes–Sets mandatory global attributes for an EFTS dataset.
-
to_netcdf–Write the data set to a netCDF file.
-
writeable_to_stf2–Check if the dataset can be written to a netCDF file compliant with STF 2.0 specification.
Attributes:
-
catchment(str) –Get or set the catchment attribute of the dataset.
-
comment(str) –Get or set the comment attribute of the dataset.
-
history(str) –Gets/sets the history attribute of the dataset.
-
institution(str) –Get or set the institution attribute of the dataset.
-
source(str) –Get or set the source attribute of the dataset.
-
stf2_int_datatype(str) –The type of integer to save to in the STF 2.x netcdf convention: 'i4' or 'i8'.
-
stf_convention_version(float) –Get or set the STF_convention_version attribute of the dataset.
-
stf_nc_spec(str) –Get or set the STF_nc_spec attribute of the dataset.
-
title(str) –Get or set the title attribute of the dataset.
Source code in src/efts_io/wrapper.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
institution
property
writable
¶
institution: str
Get or set the institution attribute of the dataset.
stf2_int_datatype
property
writable
¶
stf2_int_datatype: str
The type of integer to save to in the STF 2.x netcdf convention: 'i4' or 'i8'.
stf_convention_version
property
writable
¶
stf_convention_version: float
Get or set the STF_convention_version attribute of the dataset.
stf_nc_spec
property
writable
¶
stf_nc_spec: str
Get or set the STF_nc_spec attribute of the dataset.
append_history
¶
Append a new entry to the history attribute with a timestamp.
message: The message to append. timestamp: If not provided, the current UTC time is used.
Source code in src/efts_io/wrapper.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
create_data_variables
¶
Create data variables in the data set.
var_defs_dict["variable_1"].keys() dict_keys(['name', 'longname', 'units', 'dim_type', 'missval', 'precision', 'attributes'])
Source code in src/efts_io/wrapper.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
get_all_series
¶
Return a multivariate time series, where each column is the series for one of the identifiers.
Source code in src/efts_io/wrapper.py
496 497 498 499 500 501 502 503 | |
get_dim_names
¶
Gets the name of all dimensions in the data set.
Source code in src/efts_io/wrapper.py
524 525 526 | |
get_ensemble_for_stations
¶
get_ensemble_for_stations(
variable_name: str = "rain_sim",
identifier: Optional[str] = None,
dimension_id: str = ENS_MEMBER_DIMNAME,
start_time: Timestamp = None,
lead_time_count: Optional[int] = None,
) -> DataArray
Not yet implemented.
Source code in src/efts_io/wrapper.py
530 531 532 533 534 535 536 537 538 539 540 | |
get_ensemble_forecasts
¶
get_ensemble_forecasts(
variable_name: str = "rain_sim",
identifier: Optional[str] = None,
dimension_id: Optional[str] = None,
start_time: Optional[Timestamp] = None,
lead_time_count: Optional[int] = None,
) -> DataArray
Not yet implemented. Gets an ensemble forecast for a variable.
Source code in src/efts_io/wrapper.py
542 543 544 545 546 547 548 549 550 551 552 553 554 | |
get_ensemble_size
¶
get_ensemble_size() -> int
Return the length of the ensemble size dimension.
Source code in src/efts_io/wrapper.py
582 583 584 | |
get_lead_time_count
¶
get_lead_time_count() -> int
Length of the lead time dimension.
Source code in src/efts_io/wrapper.py
586 587 588 | |
get_lead_time_values
¶
get_lead_time_values() -> ndarray
Return the values of the lead time dimension.
Source code in src/efts_io/wrapper.py
590 591 592 | |
get_single_series
¶
get_single_series(
variable_name: str = "rain_obs",
identifier: Optional[str] = None,
dimension_id: Optional[str] = None,
) -> DataArray
Return a single point time series for a station identifier.
Source code in src/efts_io/wrapper.py
598 599 600 601 602 603 604 605 606 607 608 | |
get_station_count
¶
get_station_count() -> int
Return the number of stations in the data set.
Source code in src/efts_io/wrapper.py
610 611 612 | |
get_stations_varname
¶
get_stations_varname() -> str
Return the name of the variable that has the station identifiers.
Source code in src/efts_io/wrapper.py
614 615 616 617 618 | |
get_time_dim
¶
get_time_dim() -> ndarray
Return the time dimension variable as a vector of date-time stamps.
Source code in src/efts_io/wrapper.py
620 621 622 623 | |
new_variable
¶
new_variable(
varname: str,
dim_names: Iterable[str],
var_attributes: dict[str, Any],
data: Optional[ndarray] = None,
) -> DataArray
Create a new variable in the data set.
Parameters:
-
(varname¶str) –Name of the new variable.
-
(dim_names¶Iterable[str]) –Names of the dimensions for the new variable.
-
(var_attributes¶dict[str, Any]) –Attributes for the new variable. Must include 'units' key. See
template_variable_attributes -
(data¶Optional[ndarray], default:None) –Data for the new variable. If None, the variable is initialized with NaNs. Defaults to None.
Returns:
-
DataArray–xr.DataArray: The newly created variable as an xarray DataArray.
Source code in src/efts_io/wrapper.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
put_lead_time_values
¶
Set the values of the lead time dimension.
Source code in src/efts_io/wrapper.py
594 595 596 | |
save_to_stf2
¶
save_to_stf2(
path: str,
variable_name: Optional[str] = None,
var_type: StfVariable = STREAMFLOW,
data_type: DataOriginType = OBSERVED,
ens: bool = False,
timestep: str = "days",
data_qual: Optional[DataArray] = None,
) -> None
Save to file.
Source code in src/efts_io/wrapper.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
set_mandatory_global_attributes
¶
set_mandatory_global_attributes(
title: str = "not provided",
institution: str = "not provided",
catchment: str = "not provided",
source: str = "not provided",
comment: str = "not provided",
history: str = "not provided",
append_history: bool = False,
) -> None
Sets mandatory global attributes for an EFTS dataset.
Source code in src/efts_io/wrapper.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
to_netcdf
¶
Write the data set to a netCDF file.
Source code in src/efts_io/wrapper.py
301 302 303 304 305 306 307 308 | |
writeable_to_stf2
¶
writeable_to_stf2() -> bool
Check if the dataset can be written to a netCDF file compliant with STF 2.0 specification.
This method checks if the underlying xarray dataset or dataarray has the required dimensions and global attributes as specified by the STF 2.0 convention.
Returns:
-
bool(bool) –True if the dataset can be written to a STF 2.0 compliant netCDF file, False otherwise.
Source code in src/efts_io/wrapper.py
333 334 335 336 337 338 339 340 341 342 343 | |
LocationType
¶
Bases: Enum
Type of measurement location according to STF 2.0 conventions.
This enumeration defines whether the measurement represents a point or an area-averaged value.
Attributes:
-
POINT–Point measurement (e.g., rain gauge, stream gauge)
-
AREA–Area-averaged measurement (e.g., subcatchment area)
Examples:
>>> from efts_io.attributes import LocationType
>>> loc = LocationType.POINT
>>> loc.value
'Point'
TimeSeriesType
¶
TimeSeriesType(code: int, description: str)
Bases: Enum
Type of time series aggregation according to STF 2.0 conventions.
This enumeration defines how time series data is aggregated or sampled, following the STF (Standard Time Format) 2.0 conventions for water forecasting netCDF files.
Attributes:
-
INSTANTANEOUS–Data recorded at a specific instant (e.g., stage height)
-
ACCUMULATED–Data accumulated over the preceding time interval (e.g., rainfall)
-
AVERAGED–Data averaged over the preceding time interval (e.g., flow, average temp)
-
ACCUMULATED_FORECAST–Data accumulated since start of forecast (e.g., cumulative flow)
-
POINT_IN_INTERVAL–Point value recorded in the preceding interval (e.g., max/min temperature)
-
CLIMATOLOGY_INSTANTANEOUS–Climatology of instantaneous data
-
CLIMATOLOGY_ACCUMULATED–Climatology of accumulated data
-
CLIMATOLOGY_AVERAGED–Climatology of averaged data
-
CLIMATOLOGY_ACCUMULATED_FORECAST–Climatology of forecast-accumulated data
-
CLIMATOLOGY_POINT–Climatology of point-in-interval data
Examples:
>>> from efts_io.attributes import TimeSeriesType
>>> ts_type = TimeSeriesType.ACCUMULATED
>>> ts_type.code
2
>>> ts_type.description
'accumulated over the preceding interval'
Parameters:
-
(code¶int) –Numeric code defined by STF 2.0 conventions
-
(description¶str) –Human-readable description of the aggregation type
Source code in src/efts_io/conventions.py
1082 1083 1084 1085 1086 1087 1088 1089 1090 | |
create_global_attributes
¶
create_global_attributes(
title: str,
institution: str,
source: str,
catchment: str,
comment: str,
stf_convention_version: float = 2.0,
stf_nc_spec: str = STF_2_0_URL,
history: str = "",
) -> dict[str, Any]
Creates STF global attributes.
Parameters:
-
(title¶str) –title
-
(institution¶str) –institution
-
(source¶str) –source
-
(catchment¶str) –catchment
-
(comment¶str) –comment
-
(stf_convention_version¶float, default:2.0) –STF convention version (default: 2.0)
-
(stf_nc_spec¶str, default:STF_2_0_URL) –URL to the STF specification document (default: STF 2.0 URL)
-
(history¶str, default:'') –audit trail for modifications to the original data (default: "")
Raises:
-
ValueError–Unexpected or insufficient information
Returns:
Source code in src/efts_io/attributes.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
create_mandatory_global_attributes
¶
create_mandatory_global_attributes(
title: str,
institution: str,
catchment: str,
source: str,
comment: str,
history: Optional[str] = None,
) -> Dict[str, str]
Create a dictionary of mandatory global attributes for an EFTS dataset.
Parameters:
-
(title¶str) –Title of the dataset.
-
(institution¶str) –Institution responsible for the dataset.
-
(catchment¶str) –Catchment area description.
-
(source¶str) –Source of the data.
-
(comment¶str) –Additional comments about the dataset.
-
(history¶Optional[str], default:None) –History of the dataset. If None, a default history message is created. Defaults to None.
Returns:
Source code in src/efts_io/wrapper.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | |
create_quality_variable_attributes
¶
create_quality_variable_attributes(
long_name: str,
quality_code_standard: str,
fill_value: int = -1,
) -> dict[str, Any]
Create attributes for a quality code variable (e.g., rain_obs_qual).
Quality code variables have a distinct set of attributes from data variables.
Per the STF 2.0 conventions, they require long_name, units (the quality
code standard), and _FillValue (an integer, default -1).
Parameters:
-
(long_name¶str) –Human-readable name (e.g., "Quality of observed rainfall")
-
(quality_code_standard¶str) –Quality code standard used (e.g., "ABC Quality coding")
-
(fill_value¶int, default:-1) –Integer fill value for missing data (default: -1)
Returns:
-
dict[str, Any]–Dictionary of attributes ready to use with xarray DataArray or EftsDataSet.new_variable()
Examples:
>>> attrs = create_quality_variable_attributes(
... long_name="Quality of observed rainfall",
... quality_code_standard="ABC Quality coding",
... )
>>> attrs['_FillValue']
-1
Source code in src/efts_io/attributes.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
create_state_variable_attributes
¶
create_state_variable_attributes(
long_name: str,
model_name: str,
sv_name: str,
sv_description: str,
fill_value: float = -9999.0,
) -> dict[str, Any]
Create attributes for a state variable (e.g., sv1, sv2).
State variables store internal model states. Per the STF 2.0 conventions,
they require long_name, model_name, sv_name, sv_description,
and _FillValue.
Parameters:
-
(long_name¶str) –Human-readable name (e.g., "state var 1")
-
(model_name¶str) –Name of the model (e.g., "GR4H_RR")
-
(sv_name¶str) –Name of the state variable in the model (e.g., "UH_Inflow")
-
(sv_description¶str) –Description of the state variable (e.g., "Total inflow to Unit Hydrographs in GR4H")
-
(fill_value¶float, default:-9999.0) –Fill value for missing data (default: -9999.0)
Returns:
-
dict[str, Any]–Dictionary of attributes ready to use with xarray DataArray or EftsDataSet.new_variable()
Examples:
>>> attrs = create_state_variable_attributes(
... long_name="state var 1",
... model_name="GR4H_RR",
... sv_name="UH_Inflow",
... sv_description="Total inflow to Unit Hydrographs in GR4H",
... )
>>> attrs['model_name']
'GR4H_RR'
Source code in src/efts_io/attributes.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
create_var_attribute_definition
¶
create_var_attribute_definition(
data_type_code: int = 2,
type_description: str = "accumulated over the preceding interval",
dat_type: str = "der",
dat_type_description: str = "AWAP data interpolated from observations",
location_type: str = "Point",
) -> dict[str, str]
Create variable attribute definition (legacy function).
.. deprecated::
This function is maintained for backward compatibility.
For new code, use :func:create_variable_attributes with the type-safe enumerations
(:class:TimeSeriesType, :class:DataOriginType, :class:LocationType) instead.
Parameters:
-
(data_type_code¶int, default:2) –Numeric code for time series type (1-5, 11-15)
-
(type_description¶str, default:'accumulated over the preceding interval') –Description of the aggregation type
-
(dat_type¶str, default:'der') –String code for data origin ("obs", "der", "sim", "fct")
-
(dat_type_description¶str, default:'AWAP data interpolated from observations') –Description of the data
-
(location_type¶str, default:'Point') –"Point" or "Area"
Returns:
Examples:
>>> # Old way (still works but not recommended)
>>> attrs = create_var_attribute_definition(
... data_type_code=2,
... type_description='accumulated over the preceding interval',
... dat_type='obs'
... )
>>>
>>> # New recommended way
>>> from efts_io.attributes import create_variable_attributes, TimeSeriesType, DataOriginType
>>> attrs = create_variable_attributes(
... long_name="observed rainfall",
... units="mm",
... time_series_type=TimeSeriesType.ACCUMULATED,
... data_origin=DataOriginType.OBSERVED,
... data_description="gauge measurements"
... )
Source code in src/efts_io/attributes.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
create_variable_attributes
¶
create_variable_attributes(
long_name: str,
units: str,
time_series_type: TimeSeriesType,
data_origin: DataOriginType,
data_description: str,
location_type: LocationType = POINT,
fill_value: float = -9999.0,
) -> dict[str, Any]
Create variable attributes for STF 2.0 compliant netCDF files.
This is the recommended function for creating metadata attributes for data variables. It uses type-safe enumerations to ensure attributes conform to STF 2.0 conventions without requiring users to remember numeric codes or string identifiers.
Parameters:
-
(long_name¶str) –Human-readable name for the variable (e.g., "observed rainfall")
-
(units¶str) –Units of measurement (e.g., "mm", "m3/s", "°C")
-
(time_series_type¶TimeSeriesType) –How the data is aggregated/sampled (use TimeSeriesType enum)
-
(data_origin¶DataOriginType) –How the data was obtained (use DataOriginType enum)
-
(data_description¶str) –Detailed description of the data (e.g., "AWAP data interpolated from observations")
-
(location_type¶LocationType, default:POINT) –Whether data is point or area measurement (default: POINT)
-
(fill_value¶float, default:-9999.0) –Value used for missing data (default: -9999.0)
Returns:
-
dict[str, Any]–Dictionary of attributes ready to use with xarray DataArray or EftsDataSet.new_variable()
Examples:
>>> from efts_io.attributes import (
... create_variable_attributes,
... TimeSeriesType,
... DataOriginType,
... LocationType
... )
>>> attrs = create_variable_attributes(
... long_name="observed rainfall",
... units="mm",
... time_series_type=TimeSeriesType.ACCUMULATED,
... data_origin=DataOriginType.OBSERVED,
... data_description="gauge measurements from station network",
... location_type=LocationType.POINT
... )
>>> attrs['type']
2
>>> attrs['type_description']
'accumulated over the preceding interval'
>>> attrs['dat_type']
'obs'
See Also
- TimeSeriesType: Enumeration of valid time series aggregation types
- DataOriginType: Enumeration of valid data origin types
- LocationType: Enumeration of valid location types
- template_variable_attributes: For getting an empty template dictionary
Source code in src/efts_io/attributes.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
get_parser
¶
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser–An argparse parser.
Source code in src/efts_io/_internal/cli.py
30 31 32 33 34 35 36 37 38 39 | |
main
¶
Run the main program.
This function is executed when you type efts or python -m efts_io.
Parameters:
Returns:
-
int–An exit code.
Source code in src/efts_io/_internal/cli.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
open_efts
¶
open_efts(ncfile: Any) -> EftsDataSet
Open an EFTS NetCDF file.
Source code in src/efts_io/wrapper.py
764 765 766 767 768 769 770 771 772 | |
template_variable_attributes
¶
template_variable_attributes(
time_series_type: Optional[TimeSeriesType] = None,
data_origin: Optional[DataOriginType] = None,
location_type: Optional[LocationType] = None,
fill_value: float = -9999.0,
) -> dict[str, Any]
Create a template dictionary for variable attributes.
This function provides a starting point for creating variable attributes that comply with STF 2.0 conventions. For the recommended type-safe approach, use the enumerations from efts_io.attributes.
Parameters:
-
(time_series_type¶Optional[TimeSeriesType], default:None) –TimeSeriesType enum or None (pre-fills type info if provided)
-
(data_origin¶Optional[DataOriginType], default:None) –DataOriginType enum or None (pre-fills data origin if provided)
-
(location_type¶Optional[LocationType], default:None) –LocationType enum or None (defaults to POINT)
-
(fill_value¶float, default:-9999.0) –Value for missing data (default: -9999.0)
Returns:
Examples:
>>> from efts_io import EftsDataSet
>>> from efts_io.attributes import TimeSeriesType, DataOriginType
>>>
>>> # Using type-safe enums (recommended)
>>> attrs = template_variable_attributes(
... time_series_type=TimeSeriesType.ACCUMULATED,
... data_origin=DataOriginType.OBSERVED
... )
>>> attrs['long_name'] = "observed rainfall"
>>> attrs['units'] = "mm"
>>>
>>> # Or get a blank template
>>> attrs = template_variable_attributes()
Note
For complete attribute creation in one call, use:
from efts_io.attributes import create_variable_attributes
See Also
- efts_io.attributes.create_variable_attributes: Type-safe attribute creation
- efts_io.attributes.TimeSeriesType: Valid time series aggregation types
- efts_io.attributes.DataOriginType: Valid data origin types
- efts_io.attributes.LocationType: Valid location types
Source code in src/efts_io/attributes.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
validate_global_attributes
¶
Validate a dictionary of global attributes against STF 2.0 conventions.
Parameters:
Returns:
Examples:
>>> from efts_io.attributes import create_global_attributes
>>> attrs = create_global_attributes("Title", "Inst", "Src", "Catch", "Comment")
>>> validate_global_attributes(attrs)
[]
Source code in src/efts_io/attributes.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
validate_quality_variable_attributes
¶
Validate a dictionary of quality variable attributes against STF 2.0 conventions.
Parameters:
Returns:
Examples:
>>> from efts_io.attributes import create_quality_variable_attributes
>>> attrs = create_quality_variable_attributes("Quality of observed rainfall", "ABC Quality coding")
>>> validate_quality_variable_attributes(attrs)
[]
Source code in src/efts_io/attributes.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | |
validate_state_variable_attributes
¶
Validate a dictionary of state variable attributes against STF 2.0 conventions.
Parameters:
Returns:
Examples:
>>> from efts_io.attributes import create_state_variable_attributes
>>> attrs = create_state_variable_attributes("sv1", "GR4H_RR", "UH_Inflow", "desc")
>>> validate_state_variable_attributes(attrs)
[]
Source code in src/efts_io/attributes.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |
validate_variable_attributes
¶
Validate a dictionary of data variable attributes against STF 2.0 conventions.
Checks that all required keys are present and that coded values are valid.
Parameters:
Returns:
Examples:
>>> errors = validate_variable_attributes({})
>>> len(errors) > 0
True
Source code in src/efts_io/attributes.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
xr_efts
¶
xr_efts(
issue_times: Iterable[ConvertibleToTimestamp],
station_ids: Iterable[str],
lead_times: Optional[Iterable[int]] = None,
lead_time_tstep: str = "hours",
ensemble_size: int = 1,
station_names: Optional[Iterable[str]] = None,
latitudes: Optional[Iterable[float]] = None,
longitudes: Optional[Iterable[float]] = None,
areas: Optional[Iterable[float]] = None,
nc_attributes: Optional[Dict[str, str]] = None,
) -> Dataset
Create an xarray Dataset for EFTS data.
Source code in src/efts_io/wrapper.py
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |