Skip to content

Commit

Permalink
build(etl): add hotspot layers to snakemake
Browse files Browse the repository at this point in the history
Add `hotspot_layers.csv` to the ETL pipeline. Update the `Snakefile` and `config.yml` to include the new file.
  • Loading branch information
eatyourgreens committed Mar 11, 2025
1 parent b470ce3 commit 5c3410b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions etl/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ configfile: "config.yml"

# Read further configuration data from CSV
hazard_layers = pandas.read_csv(config["hazard_layers"])
hotspot_layers = pandas.read_csv(config["hotspot_layers"])
network_layers = pandas.read_csv(config["network_layers"])
storm_layers = pandas.read_csv(config["storm_layers"])
network_tilelayers = pandas.read_csv(config["network_tilelayers"])
Expand All @@ -33,6 +34,7 @@ rule all:
),
expand("../tileserver/raster/data/{layer}.tif", layer=hazard_layers.key),
expand('../tileserver/raster/data/{layer}.tif', layer=storm_layers.key),
expand("../tileserver/raster/data/{layer}.tif", layer=hotspot_layers.key),


# Prerequisite, not fully traced by file dependency
Expand Down Expand Up @@ -323,10 +325,13 @@ def get_hazard_layer(layer_name, hazard_layers):
try:
hazard_layer = hazard_layers[hazard_layers.key == layer_name]
storm_layer = storm_layers[storm_layers.key == layer_name]
hotspot_layer = hotspot_layers[hotspot_layers.key == layer_name]
if not hazard_layer.empty:
return hazard_layer.iloc[0]
elif not storm_layer.empty:
return storm_layer.iloc[0]
elif not hotspot_layer.empty:
return hotspot_layer.iloc[0]
else:
raise IndexError
except IndexError as e:
Expand Down
1 change: 1 addition & 0 deletions etl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ network_layers: "network_layers.csv"
network_tilelayers: "network_tilelayers.csv"
hazard_layers: "hazard_layers.csv"
storm_layers: "storm_layers.csv"
hotspot_layers: "hotspot_layers.csv"
damage_rp_files: "damage_rp_files.csv"
damage_exp_files: "damage_exp_files.csv"
damage_npv_files: "damage_npv_files.csv"
Expand Down
5 changes: 5 additions & 0 deletions etl/hotspot_layers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hazard,path,rp,rcp,epoch,confidence,variable,unit,key
hotspots,hotspots/power/demand_affected.tiff,100,baseline,2010,None,demand affected,MWh,demandAffected__rp_100__rcp_baseline__epoch_2010__conf_None
hotspots,hotspots/power/exposure_value.tiff,100,baseline,2010,None,exposure value,$,exposureValue__rp_100__rcp_baseline__epoch_2010__conf_None
hotspots,hotspots/power/loss_gdp.tiff,100,baseline,2010,None,loss GDP,$,lossGdp__rp_100__rcp_baseline__epoch_2010__conf_None
hotspots,hotspots/power/population_affected.tiff,100,baseline,2010,None,population affected,,populationAffected__rp_100__rcp_baseline__epoch_2010__conf_None

0 comments on commit 5c3410b

Please sign in to comment.