Skip to content

Commit 5658925

Browse files
authored
Merge pull request #5 from calliope-project/feature-dynamic-inputs
Feature dynamic inputs
2 parents 539a292 + 6da4aa5 commit 5658925

7 files changed

Lines changed: 41 additions & 36 deletions

File tree

config/config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ imputation:
2222
# Applies per reservoir polygon within the CO2Stop database
2323
co2stop:
2424
# minimums/bounds based on van den Broek et al 2010 (Table 2)
25-
# Seal thickness and permeability have been set to 0 due to missing data.
25+
# Seal thickness, porosity, and permeability have been set to 0 due to missing data.
2626
# https://doi.org/10.1016/j.envsoft.2010.06.015
2727
aquifer:
2828
bounds_mtco2:
2929
lower: 2
3030
upper: 300000
3131
minimums:
32-
porosity_ratio: 0.1
32+
porosity_ratio: 0
3333
depth_m: 800
3434
reservoir_thickness_m: 10
3535
seal_thickness_m: 0
3636
permeability_md: 0
37-
remove_w_remarks:
37+
remove_remarks:
3838
surface_issues: False
3939
subsurface_issues: False
4040
artificial_polygons: True
@@ -48,7 +48,7 @@ imputation:
4848
reservoir_thickness_m: 10
4949
seal_thickness_m: 0
5050
permeability_md: 0
51-
remove_w_remarks:
51+
remove_remarks:
5252
surface_issues: False
5353
subsurface_issues: False
5454
artificial_polygons: True
@@ -62,7 +62,7 @@ imputation:
6262
reservoir_thickness_m: 10
6363
seal_thickness_m: 0
6464
permeability_md: 0
65-
remove_w_remarks:
65+
remove_remarks:
6666
surface_issues: False
6767
subsurface_issues: False
6868
artificial_polygons: True

docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ These shapes should follow the schema provided by the [geo-boundaries module](ht
3030
>[!WARNING]
3131
>Estimates from the CO2Stop dataset are biased by disclosure (or lack thereof), and the filtering settings used.
3232
>Some countries are affected more than others, with Germany having particularly poor disclosure.
33-
>We provide automated figures and logging so users can evaluate how their settings affect polygon selection.
3433
>
34+
>Similarly, CO2Stop suffers from poor data handling practices that make unavailable data and 'true' zero values indistinguishable from each other, amplifying the uneven assignation of sequestration. For example: setting `porosity_ratio: 0.1` will completely remove France in most cases.
35+
>
36+
>We provide automated figures and logging (in `logs/storage_units/` and `logs/traps/`) so users can evaluate how their settings affect polygon selection.
3537
>Below is an example for storage unit aquifers where only undisclosed and artificial polygons have been removed. This can be seen as a _MINIMUM_ amount of removals.
3638
>![filters](./aquifer_kept.png)
3739

workflow/internal/config.schema.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $defs:
4141
description: "Settings for each CDR group in the CO2Stop dataset."
4242
type: object
4343
additionalProperties: false
44-
required: [bounds_mtco2, minimums, remove_w_remarks]
44+
required: [bounds_mtco2, minimums, remove_remarks]
4545
properties:
4646
bounds_mtco2:
4747
description: "These bounds will be applied to each row in the CO2Stop dataset."
@@ -73,9 +73,9 @@ $defs:
7373
permeability_md:
7474
description: Permeability in millidarcy (md)
7575
$ref: "#/$defs/nonNegativeNumber"
76-
remove_w_remarks:
76+
remove_remarks:
7777
description: |
78-
Remove CO2Stop polygons in certain cases.
78+
Remove CO2Stop polygons based on remarks by the dataset authors.
7979
Note that CO2Stop settings and comments are the only thing used for these filters.
8080
Quality may vary due to the inconsistent nature of the dataset.
8181
type: object

workflow/rules/aggregate.smk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ rule aggregate_co2stop:
1111
proj_crs=config["crs"]["projected"],
1212
input:
1313
shapes="resources/user/{shapes}/shapes.parquet",
14-
storage_units="resources/automatic/co2stop/storage_units/aquifer.parquet",
15-
traps="resources/automatic/co2stop/traps/{cdr_group}.parquet",
14+
storage_units=rules.prepare_co2stop_storage_units.output.mtco2,
15+
traps=rules.prepare_co2stop_traps.output.mtco2,
1616
output:
1717
aggregated="results/{shapes}/{scenario}/{cdr_group}.parquet",
1818
plot=report(
@@ -39,8 +39,11 @@ rule aggregate_totals:
3939
proj_crs=config["crs"]["projected"],
4040
input:
4141
shapes="resources/user/{shapes}/shapes.parquet",
42-
aggregates=expand(
43-
"results/{{shapes}}/{{scenario}}/{cdr_group}.parquet", cdr_group=CDR_GROUP
42+
aggregates=lambda wc: expand(
43+
rules.aggregate_co2stop.output.aggregated,
44+
shapes=wc.shapes,
45+
scenario=wc.scenario,
46+
cdr_group=CDR_GROUP,
4447
),
4548
output:
4649
totals="results/{shapes}/{scenario}/totals.parquet",

workflow/rules/automatic.smk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ rule unzip_co2stop:
2828
input:
2929
zipfile=rules.download_co2stop.output.zipfile,
3030
output:
31-
storage_data="resources/automatic/co2stop/storage_table.csv",
31+
storage_data="resources/automatic/co2stop/storage_data.csv",
3232
storage_map="resources/automatic/co2stop/storage_map.kml",
33-
traps_data="resources/automatic/co2stop/traps_table1.csv",
33+
traps_data="resources/automatic/co2stop/traps_data.csv",
3434
traps_map="resources/automatic/co2stop/traps_map.kml",
3535
country_map="resources/automatic/co2stop/countries.kml",
3636
log:

workflow/rules/prepare.smk

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,32 @@ CDR_GROUP = ["aquifer", "gas", "oil"]
55

66
rule prepare_co2stop_storage_units:
77
message:
8-
"Harmonising CO2Stop {wildcards.dataset}:{wildcards.cdr_group}."
8+
"Harmonising CO2Stop storage units: aquifer."
99
params:
10-
cdr_group_config=lambda wc: config["imputation"]["co2stop"][wc.cdr_group],
10+
cdr_group="aquifer",
11+
cdr_group_config=lambda wc: config["imputation"]["co2stop"]["aquifer"],
12+
dataset="storage_units",
1113
geo_crs=config["crs"]["geographic"],
1214
input:
13-
table="resources/automatic/co2stop/storage_table.csv",
14-
polygons="resources/automatic/co2stop/storage_map.kml",
15-
countries="resources/automatic/co2stop/countries.kml",
15+
table=rules.unzip_co2stop.output.storage_data,
16+
polygons=rules.unzip_co2stop.output.storage_map,
17+
countries=rules.unzip_co2stop.output.country_map,
1618
output:
17-
mtco2="resources/automatic/co2stop/{dataset}/{cdr_group}.parquet",
19+
mtco2="resources/automatic/co2stop/storage_units/aquifer.parquet",
1820
plot_kept=report(
19-
"resources/automatic/co2stop/{dataset}/{cdr_group}_kept.png",
21+
"resources/automatic/co2stop/storage_units/aquifer_kept.png",
2022
caption="../report/prepare_co2stop_kept.rst",
2123
category="CO2Stop module",
2224
subcategory="kept polygons",
2325
),
2426
plot_scenarios=report(
25-
"resources/automatic/co2stop/{dataset}/{cdr_group}_scenarios.png",
27+
"resources/automatic/co2stop/storage_units/aquifer_scenarios.png",
2628
caption="../report/prepare_co2stop_scenarios.rst",
2729
category="CO2Stop module",
2830
subcategory="scenarios",
2931
),
3032
log:
31-
"logs/{dataset}/{cdr_group}/prepare_co2stop.log",
32-
wildcard_constraints:
33-
dataset="storage_units",
34-
cdr_group="aquifer",
33+
"logs/storage_units/aquifer/prepare_co2stop.log",
3534
conda:
3635
"../envs/co2stop.yaml"
3736
script:
@@ -40,32 +39,33 @@ rule prepare_co2stop_storage_units:
4039

4140
rule prepare_co2stop_traps:
4241
message:
43-
"Harmonising CO2Stop {wildcards.dataset}:{wildcards.cdr_group}."
42+
"Harmonising CO2Stop traps: {wildcards.cdr_group}."
4443
params:
44+
cdr_group=lambda wc: wc.cdr_group,
4545
cdr_group_config=lambda wc: config["imputation"]["co2stop"][wc.cdr_group],
46+
dataset="traps",
4647
geo_crs=config["crs"]["geographic"],
4748
input:
4849
table=rules.unzip_co2stop.output.traps_data,
4950
polygons=rules.unzip_co2stop.output.traps_map,
5051
countries=rules.unzip_co2stop.output.country_map,
5152
output:
52-
mtco2="resources/automatic/co2stop/{dataset}/{cdr_group}.parquet",
53+
mtco2="resources/automatic/co2stop/traps/{cdr_group}.parquet",
5354
plot_kept=report(
54-
"resources/automatic/co2stop/{dataset}/{cdr_group}_kept.png",
55+
"resources/automatic/co2stop/traps/{cdr_group}_kept.png",
5556
caption="../report/prepare_co2stop_kept.rst",
5657
category="CO2Stop module",
5758
subcategory="kept polygons",
5859
),
5960
plot_scenarios=report(
60-
"resources/automatic/co2stop/{dataset}/{cdr_group}_scenarios.png",
61+
"resources/automatic/co2stop/traps/{cdr_group}_scenarios.png",
6162
caption="../report/prepare_co2stop_scenarios.rst",
6263
category="CO2Stop module",
6364
subcategory="scenarios",
6465
),
6566
log:
66-
"logs/{dataset}/{cdr_group}/prepare_co2stop.log",
67+
"logs/traps/{cdr_group}/prepare_co2stop.log",
6768
wildcard_constraints:
68-
dataset="traps",
6969
cdr_group="|".join(CDR_GROUP),
7070
conda:
7171
"../envs/co2stop.yaml"

workflow/scripts/prepare_co2stop.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ def main() -> None:
306306
if not CRS.from_user_input(geo_crs).is_geographic:
307307
raise ValueError(f"Expected geographic CRS, got {geo_crs!r}.")
308308

309-
dataset_name = snakemake.wildcards.dataset
310-
cdr_group = snakemake.wildcards.cdr_group
309+
dataset_name = snakemake.params.dataset
310+
cdr_group = snakemake.params.cdr_group
311311
config = snakemake.params.cdr_group_config
312312

313313
match dataset_name:
@@ -330,7 +330,7 @@ def main() -> None:
330330

331331
# Identify and remove 'bad apples', depending on the configuration.
332332
mask_issues = identify_removals(
333-
dataset, config["remove_w_remarks"], config["minimums"], data_id
333+
dataset, config["remove_remarks"], config["minimums"], data_id
334334
)
335335
dataset = dataset[~mask_issues]
336336

0 commit comments

Comments
 (0)