Skip to content

Commit e6dd7e5

Browse files
authored
Merge pull request #24 from quantifyearth/mwd-snakemake
Simplify and fix land cover demendacy in snakemake
2 parents dd1c8b2 + f2e186f commit e6dd7e5

2 files changed

Lines changed: 1 addition & 30 deletions

File tree

workflow/rules/aoh.smk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def aoh_species_inputs(wildcards):
5858
"habitat_sentinel": ancient(
5959
DATADIR / "habitat_layers" / SCENARIO / ".habitat_complete"
6060
),
61+
"lcc_0": DATADIR / "habitat_layers" / SCENARIO / "lcc_0.tif",
6162
"crosswalk": DATADIR / "crosswalk.csv",
6263
"mask": ancient(DATADIR / "masks" / "CGLS100Inland_withGADMIslands.tif"),
6364
"elevation_max": ancient(DATADIR / config["inputs"]["zenodo_elevation_max"]),

workflow/rules/prepare.smk

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,3 @@ rule copy_islands_layer:
135135
"""
136136
cp {input.islands} {output.lcc_0} 2>&1 | tee {log}
137137
"""
138-
139-
140-
# =============================================================================
141-
# Helper rule to get specific habitat layer
142-
# =============================================================================
143-
144-
145-
def get_habitat_layer(wildcards):
146-
"""
147-
Returns the path to a specific habitat layer.
148-
lcc_0 is special (islands layer), others come from habitat processing.
149-
"""
150-
n = int(wildcards.n)
151-
if n == 0:
152-
return DATADIR / "habitat_layers" / SCENARIO / "lcc_0.tif"
153-
else:
154-
return DATADIR / "habitat_layers" / SCENARIO / f"lcc_{n}.tif"
155-
156-
157-
rule habitat_layer:
158-
"""
159-
Pseudo-rule to request a specific habitat layer.
160-
This triggers either the habitat processing or islands copy as needed.
161-
"""
162-
input:
163-
layer=get_habitat_layer,
164-
output:
165-
# This is a bit of a trick - we declare the output but let the
166-
# upstream rules actually create it
167-
touch(DATADIR / "habitat_layers" / SCENARIO / ".lcc_{n}_exists"),

0 commit comments

Comments
 (0)