Skip to content

Commit e4cb7d4

Browse files
Feature: standardisation with powerplants (#14)
* produce the CDS api key within the integration test * Use CDS envvar in integration tests * Standardise with future powerplants module --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 0ecc66c commit e4cb7d4

44 files changed

Lines changed: 3813 additions & 10390 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr-ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ on:
66

77
jobs:
88
ci-tests:
9-
uses: calliope-project/data-module-template/.github/workflows/template-pr-ci.yml@latest
9+
uses: calliope-project/data-module-template/.github/workflows/template-pr-ci.yml@feature-ci-cdsapi
10+
secrets:
11+
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
__pycache__
1212
*.pyc
1313

14+
### Environments
15+
.pixi/
16+
1417
### Snakemake
1518
.snakemake/
1619
gurobi.log
@@ -24,5 +27,3 @@ gurobi.log
2427
**/results/*
2528
**/temp/*
2629
**/tmp/*
27-
!tests/integration/resources/automatic/
28-
!tests/integration/resources/user

INTERFACE.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Module Input-Output structure for automated doc. generation
22
resources:
33
user:
4-
national_generation.parquet: Annual hydropower generation statistics per country.
5-
powerplants.parquet: Powerplant statistics.
6-
shapes.parquet: Resolution shapes, used for capacity aggregation.
4+
"{shapes}/powerplants.parquet": Powerplant statistics.
5+
"{shapes}/shapes.parquet": Resolution shapes, used for capacity aggregation.
76
results:
8-
adjusted_powerplants.parquet: >
9-
Powerplants statistics after geo-location correction, plus assigned shape_id and country_id.
10-
Can be used to identify which powerplants were assigned to a given polygon.
11-
by_shape_id/hydro_dam_cf.parquet: Capacity Factors for hydro dams, per shape.
12-
by_shape_id/hydro_run_of_rover_cf.parquet: Capacity Factors for run of river plants, per shape.
7+
"{shapes}/statistics/generation.parquet": >
8+
National hydropower generation statistics for the requested shapes.
9+
"{shapes}/disaggregated/inflow_mwh.parquet": >
10+
Inflow time series for each powerplant in MWh.
11+
Only includes powerplants that fall within the provided shapes after buffering.
12+
"{shapes}/aggregated/reservoir_cf.parquet": >
13+
Capacity Factors of hydropower reservoirs aggregated to shapes.
14+
"{shapes}/aggregated/run_of_river_cf.parquet": >
15+
Capacity Factors of run of river plants aggregated to shapes.
16+
wildcards:
17+
shapes: name of the provided shapes case.

README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,8 @@
22

33
A module to calculate hydropower inflow timeseries for facilities around the globe. Based on Euro-Calliope methods.
44

5-
![Hydropower CFs assorted europe](./docs/hydro_dam_cf.png)
6-
75
A modular `snakemake` workflow built for [`clio`](https://clio.readthedocs.io/) data modules.
86

9-
## Steps
10-
11-
1. [HydroBasins](https://www.hydrosheds.org/) data is downloaded and combined into a global dataset.
12-
2. Powerplant positions are geo-corrected to the nearest basin, and then assigned to the nearest shape.
13-
3. Inflow in cubic meters is obtained for each powerplant location using ERA5 data through the [`atlite`](https://github.com/PyPSA/atlite) library.
14-
4. Inflow in MWh is obtained for each plant using the given historical national annual hydropower generation and its share of total installed national capacity.
15-
16-
> [!IMPORTANT]
17-
> The module assumes that provided sample of powerplants sums up to the total national capacity in the given year.
18-
> Providing incomplete data might lead to distortions in the calculated time series!
19-
207
## Using this module
218

229
This module can be imported directly into any `snakemake` workflow.
@@ -36,7 +23,7 @@ pixi install --all
3623
For testing, simply run:
3724

3825
```shell
39-
pixi run test
26+
pixi run test-integration
4027
```
4128

4229
To view the documentation locally, use:
@@ -50,5 +37,5 @@ To test a minimal example of a workflow using this module:
5037
```shell
5138
pixi shell # activate this project's environment
5239
cd tests/integration/ # navigate to the integration example
53-
snakemake --use-conda # run the workflow!
40+
snakemake --use-conda --cores 2 # run the workflow!
5441
```

config/config.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# A minimal example of how to configure this module
22
pfafstetter_level: "06"
3-
years:
4-
start: 2000
5-
end: 2000
3+
years: # Include 2011, 2012 data
4+
start: 2011
5+
end: 2013
66
powerplants:
7+
technology_mapping:
8+
run_of_river: "run of river"
9+
reservoir: "reservoir"
710
basin_adjustment:
811
buffer_radius: 1000 # epsg:3857 is in meters
912
max_outside: 50

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[mypy]
22
disable_error_code = import-untyped
3+
exclude = (^|/)\.(snakemake|pixi)(/|$)

pixi.lock

Lines changed: 3246 additions & 9947 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
11
[project]
22
name = "module_hydropower"
33
authors = ["See AUTHORS file"]
4-
description = "A module to calculate hydropower generation timeseries for facilities around the globe."
4+
description = "A module to calculate hydropower inflow timeseries for facilities around the globe. Based on Euro-Calliope methods."
55
license = "Apache-2.0"
66
readme = "README.md"
77
channels = ["conda-forge", "bioconda"]
88
platforms = ["win-64", "linux-64", "osx-arm64"]
99
homepage = "https://clio.readthedocs.io/"
1010

1111
[dependencies]
12-
python = ">=3.12"
13-
mkdocs-material = ">=9.6.7"
12+
clio-tools = ">=2025.03.03"
13+
conda = ">=25.0.0"
14+
ipdb = ">=0.13.13"
15+
ipykernel = ">=6.29.5"
16+
jsonschema = ">=4.0.0"
1417
mypy = ">=1.15.0"
1518
pytest = ">=8.3.5"
19+
python = ">=3.12"
1620
ruff = ">=0.9.9"
1721
snakefmt = ">=0.10.2"
18-
conda = ">=25.0.0"
1922
snakemake-minimal = ">=8.29.0"
20-
clio-tools = ">=2025.03.03"
21-
geopandas = ">=1.0.1,<2"
22-
ipykernel = ">=6.29.5,<7"
23-
pyarrow = ">=19.0.1,<20"
24-
pycountry = ">=24.6.1,<25"
25-
numpy = ">=2.2.4,<3"
26-
pandera-geopandas = ">=0.24.0,<0.25"
27-
contextily = ">=1.6.2,<2"
28-
ipdb = ">=0.13.13"
29-
atlite = ">=0.4.0,<0.5"
30-
geofileops = ">=0.9.2,<0.10"
31-
xarray = ">=2025.3.0,<2026"
32-
scipy = ">=1.15.2,<2"
33-
pandera-io = ">=0.24.0,<0.25"
34-
35-
[pypi-dependencies]
36-
mkdocs-mermaid2-plugin = ">=1.2.1"
3723

3824
[tasks]
39-
test = {cmd = "pytest tests/"}
40-
serve-docs = {cmd = "mkdocs serve"}
41-
build-docs = {cmd = "mkdocs build"}
25+
test-integration = {cmd = "pytest tests/clio_test.py"}

results/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)