Skip to content

Add GloFAS river discharge as an alternative inflow source - #34

Draft
Asdominet34 wants to merge 5 commits into
modelblocks-org:mainfrom
Asdominet34:feature/glofas-discharge
Draft

Asdominet34 wants to merge 5 commits into
modelblocks-org:mainfrom
Asdominet34:feature/glofas-discharge

Conversation

@Asdominet34

Copy link
Copy Markdown

Part of #25

Summary of changes in this pull request

  • New config option inflow.source: era5 | glofas (default era5, so existing configurations are unchanged).
  • glofas: daily river discharge from the GloFAS v4.0 historical reanalysis (Copernicus EWDS, downloaded with cdsapi), taken at one GloFAS cell per powerplant instead of ERA5 runoff aggregated over HydroBASINS.
    • The cell is the one with the largest upstream area within ±inflow.glofas.search_window_cells (default 1, i.e. 3 × 3 cells) of the powerplant. This is a simple placeholder for proper river snapping (River snapping #26). The chosen cells are saved to glofas_cells.parquet.
    • Daily values are shifted to the day of flow and interpolated linearly to hourly values. No extra smoothing is applied.
    • Everything after the inflow step is unchanged (EIA/user normalisation, capping, per-unit profiles).
  • New rules: download_glofas_discharge (one request per year, cropped to the shapes) and download_glofas_uparea (GloFAS v4.0 upstream area).
  • Explicit dependencies: cdsapi, xarray, netcdf4; lock file and conda environments re-exported. atlite stays at 0.4.0.
  • Integration tests: a second module instance using glofas. README updated (usage, Copernicus account note, citations).

Results (Montenegro, 2015)

Comparison with real HydroBASINS (not the synthetic test basins), after normalisation:

monthly_cf_by_plant inflow_mw_by_plant
  • Same annual energy (fixed by the normalisation), but a different seasonal shape: GloFAS shows the spring snowmelt peak (April–May), ERA5 peaks in winter.
  • With ERA5, Glava Zete and Perućica get the same inflow shape because they share a level-06 basin; with GloFAS each plant has its own river cell.
  • For reservoirs the values are inflow / capacity (energy entering the reservoir), so they can exceed 1.

Notes for reviewers

  • CI: the GloFAS test needs a Copernicus key with the GloFAS licence accepted on EWDS (https://ewds.climate.copernicus.eu). cdsapi uses the EWDS URL explicitly, so the same key works for CDS (ERA5) and EWDS.
  • Upstream area file: downloaded from an ECMWF Confluence attachment. A stable copy (e.g. on Zenodo) would be safer; happy to follow your preference.
  • ERA5 path: outputs are bit-identical to main on the Montenegro test case.
  • Tested locally on Windows (12/12 integration tests). pre-commit hooks could not be installed locally, so I ran ruff, snakefmt, codespell and the YAML checks by hand.

Reviewer checklist

  • There are no pip dependencies in the module's environment files (workflow/envs/).
  • All rules use pathvars (e.g., <results>) in their inputs and outputs.
  • The integration test-suite is successful, including:
    • pre-commit.ci tests pass.
    • tests pass for all relevant OS configurations (linux, osx, windows).
  • Module documentation is up-to-date, including:
    • INTERFACE.yaml mentions all relevant pathvars and wildcards.
    • README.md describes how to use the module and has the necessary citations.

Developed with the help of Claude Code; all changes reviewed and tested by me.

New option inflow.source (era5 | glofas, default era5). With glofas:
- download_glofas_discharge: daily GloFAS v4.0 discharge from the EWDS via cdsapi
  (url set explicitly, so ~/.cdsapirc can keep pointing to the CDS for ERA5)
- download_glofas_uparea: static GloFAS v4.0 upstream area map
- powerplants_get_inflow_m3 (glofas): each plant takes the discharge of the cell with the
  largest upstream area within +-search_window_cells (default 1, i.e. 3x3); no smoothing
The rest of the pipeline (normalisation, aggregation) is unchanged.

cdsapi, xarray and netcdf4 are now explicit module dependencies. ERA5 outputs of the
integration test are unchanged; the integration test runs a second, GloFAS instance.
Daily means are placed at noon and hours are linearly interpolated between them,
instead of constant steps within each day. Annual volumes are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant