Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions workflow/rules/aoh.smk
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def aoh_species_inputs(wildcards):
"habitat_sentinel": ancient(
DATADIR / "habitat_layers" / SCENARIO / ".habitat_complete"
),
"lcc_0": DATADIR / "habitat_layers" / SCENARIO / "lcc_0.tif",
"crosswalk": DATADIR / "crosswalk.csv",
"mask": ancient(DATADIR / "masks" / "CGLS100Inland_withGADMIslands.tif"),
"elevation_max": ancient(DATADIR / config["inputs"]["zenodo_elevation_max"]),
Expand Down
30 changes: 0 additions & 30 deletions workflow/rules/prepare.smk
Original file line number Diff line number Diff line change
Expand Up @@ -135,33 +135,3 @@ rule copy_islands_layer:
"""
cp {input.islands} {output.lcc_0} 2>&1 | tee {log}
"""


# =============================================================================
# Helper rule to get specific habitat layer
# =============================================================================


def get_habitat_layer(wildcards):
"""
Returns the path to a specific habitat layer.
lcc_0 is special (islands layer), others come from habitat processing.
"""
n = int(wildcards.n)
if n == 0:
return DATADIR / "habitat_layers" / SCENARIO / "lcc_0.tif"
else:
return DATADIR / "habitat_layers" / SCENARIO / f"lcc_{n}.tif"


rule habitat_layer:
"""
Pseudo-rule to request a specific habitat layer.
This triggers either the habitat processing or islands copy as needed.
"""
input:
layer=get_habitat_layer,
output:
# This is a bit of a trick - we declare the output but let the
# upstream rules actually create it
touch(DATADIR / "habitat_layers" / SCENARIO / ".lcc_{n}_exists"),