From f2e186fc00ccbb93bb6477f5621d4049e5aba405 Mon Sep 17 00:00:00 2001 From: Michael Dales Date: Mon, 2 Feb 2026 14:41:00 +0000 Subject: [PATCH] Simplify and fix land cover demendacy in snakemake --- workflow/rules/aoh.smk | 1 + workflow/rules/prepare.smk | 30 ------------------------------ 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/workflow/rules/aoh.smk b/workflow/rules/aoh.smk index e29294a..160a70a 100644 --- a/workflow/rules/aoh.smk +++ b/workflow/rules/aoh.smk @@ -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"]), diff --git a/workflow/rules/prepare.smk b/workflow/rules/prepare.smk index 00bafe9..ba068a1 100644 --- a/workflow/rules/prepare.smk +++ b/workflow/rules/prepare.smk @@ -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"),