Reader¶
The reader module is the core component of hydrodatasource for accessing and reading various hydrological datasets. It provides a unified, URI-only interface for handling different data sources, with a special focus on custom, user-prepared datasets.
Two Ways to Open a Dataset¶
1. The open_dataset() factory (registered datasets)¶
If a dataset is registered in the resolution registry (either in HDS_DATASETS or one of hydrodataset's datasets), you can resolve and open it in one line:
1 2 3 4 5 6 7 | |
A custom ResolverContext can override the storage root and registry without touching ~/hydro_setting.yml:
1 2 3 4 | |
2. Direct URI-only construction (custom datasets)¶
For a dataset that is not registered, construct the reader class directly by passing the dataset directory as uri:
1 2 3 | |
Note. Legacy
data_path=/dataset_name=constructor arguments were removed and now raiseValueError. Pass the absolute path (ors3://URI) of the dataset directory asuri.
Directory Structure¶
To use SelfMadeHydroDataset, your data should be organized in the following structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
attributes/attributes.csv: A CSV file containing static attributes for each basin (e.g., area, slope, land cover). It must contain abasin_idcolumn.shapes/basins.shp: A shapefile containing the geographic boundaries of each basin.timeseries/: Time series data, with subdirectories for each time resolution (1h,3h,1D,8D,1M).- Each subdirectory contains CSV files, one for each basin, named with the
basin_id. - Each subdirectory also contains a
*_units_info.jsonfile that specifies the units for the variables in the CSV files.
- Each subdirectory contains CSV files, one for each basin, named with the
Extended readers may expect extra directories:
intermediate/— interval-basin data with topology (TgHydroDatasource).stations/— gauging-station data and adjacency matrices (StationHydroDataset).forecasts/— forecast time series (SelfMadeForecastDataset).
Example Usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Reader Aliases¶
All hydrodatasource readers are registered in READER_ALIASES:
| Alias | Class | Directory convention |
|---|---|---|
selfmade |
SelfMadeHydroDataset |
standard dataset |
longterm |
LongTermDataset |
self-made dataset with long-term support |
forecast |
SelfMadeForecastDataset |
standard + forecasts/ |
station |
StationHydroDataset |
standard + stations/ |
tghydro |
TgHydroDatasource |
standard + intermediate/ + LSTM predictions |
floodevent |
FloodEventDatasource |
flood-event data with per-basin event markers |
gages |
Gages |
GAGES-II public dataset |
grdc |
Grdc |
GRDC public dataset |
rainfall |
RainfallReader |
cleaned station rainfall |
crd |
Crd |
China reservoir database |
rsvrinflow |
RsvrInflowReader |
reservoir inflow data |
hydrodataset's public datasets (e.g. camels_us) are also resolvable through the same
open_dataset() / resolve_data_path() interface.
Other Readers¶
SelfMadeForecastDataset: ExtendsSelfMadeHydroDatasetto support forecast data, expected in aforecastsdirectory.StationHydroDataset: ExtendsSelfMadeHydroDatasetto include data from gauging stations, expected in astationsdirectory.TgHydroDatasource: ExtendsSelfMadeHydroDatasetwith LSTM prediction and graph-network structure support, using anintermediate/directory for interval-basin topology.