model.runtime.loaders.gauge_data_loader

Gauge discharge target loader for routing calibration.

Reads observed daily river discharge for a set of gauges from a merged GRDC NetCDF (runoff_mean(time, id) in m3 s-1, time as days-since-1700) and aligns it to a daily model window. Also returns the per-gauge observed standard deviation used as the weight in the basin-averaged NSE loss.

Module Contents

Functions

load_gauge_allocation

Load a canonical gauge-allocation CSV.

select_gauges

Select clean gauges for routing calibration.

load_gauge_discharge

Load observed daily discharge aligned to [start, end] for gauge_ids.

API

model.runtime.loaders.gauge_data_loader.load_gauge_allocation(allocation_path)

Load a canonical gauge-allocation CSV.

Expected columns are written by preprocessing/convert_cama_gauge_alloc.py: gauge_station_id, gauge_catchment_id, gauge_reported_area_km2, gauge_allocated_area_km2.

model.runtime.loaders.gauge_data_loader.select_gauges(parameters_nc, merged_nc, bbox=None, start='2001-01-01', end='2020-12-31', area_tol=0.2, min_area_km2=1000.0, min_days=1095, min_obs_runoff=0.05, allocation_path=None)

Select clean gauges for routing calibration.

Keeps gauges that (a) have an area-matched cell in the parameter file, (b) lie in bbox (lon_min, lon_max, lat_min, lat_max), (c) have a large enough drainage area, (d) have at least min_days observed days in the window, and (e) have a plausible mean runoff (drops dry / broken records).

Return type:

np.ndarray of gauge ids (int64).

model.runtime.loaders.gauge_data_loader.load_gauge_discharge(merged_nc, gauge_ids, start, end, device='cpu', dtype=torch.float32)

Load observed daily discharge aligned to [start, end] for gauge_ids.

Parameters:
  • merged_nc (str) – Merged GRDC file with id, time (days since 1700) and runoff_mean(time, id) [m3 s-1].

  • gauge_ids (sequence[int]) – Gauge ids to load (in this order; ids absent from the file are dropped).

  • start (str) – Inclusive YYYY-MM-DD window; defines the daily time axis.

  • end (str) – Inclusive YYYY-MM-DD window; defines the daily time axis.

Returns:

  • gauge_ids : [n_g] ids that were found.

  • order : [n_g] index into the input gauge_ids of each kept id.

  • discharge : [n_g, T] tensor, NaN where missing.

  • std : [n_g] per-gauge std over finite days (NSE loss weight).

  • n_days : [n_g] finite-day count per gauge.

Return type:

dict with