@@ -3,12 +3,20 @@ import yaml
33conda : "requirements.yaml"
44configfile : "conf/config.yaml"
55
6- tag = config ["shapefile_tag" ]
7- polygon_name = config ["shapefile_polygon_name" ]
6+ # == Load configuration ==
7+
8+ # dynamic config files
9+ defaults_dict = {key : value for d in config ['defaults' ] if isinstance (d , dict ) for key , value in d .items ()}
10+ shapefiles_cfg = yaml .safe_load (open (f"conf/shapefiles/{ defaults_dict ['shapefiles' ]} .yaml" , 'r' ))
11+ # == Define variables ==
12+ shapefile_list = shapefiles_cfg .keys ()
13+ print (shapefile_list )
814
915rule all :
1016 input :
11- f"data/output/climate_types_raster2polygon/climate_types_{ polygon_name } _{ tag } .parquet"
17+ expand (f"data/output/climate_types_raster2polygon/climate_types_{{shapefile_name}}.parquet" ,
18+ shapefile_name = shapefile_list
19+ )
1220
1321rule download_climate_types :
1422 output :
@@ -19,17 +27,17 @@ rule download_climate_types:
1927# temporarily removing download step in snakemake
2028# rule download_shapefiles:
2129# output:
22- # f"data/input/shapefiles/shapefile_{polygon_name}_{tag}/shapefile .shp" #ext = ["shp", "shx", "dbf", "prj", "cpg", "xml"]
30+ # f"data/input/shapefiles/{{shapefile_name}}/{{shapefile_name}} .shp" #ext = ["shp", "shx", "dbf", "prj", "cpg", "xml"]
2331# shell:
24- # f"python src/download_shapefile .py shapefile_tag={tag} shapefile_polygon_name={polygon_name} "
32+ # f"python src/download_us_shapefile .py"
2533
2634rule aggregate_climate_types :
2735 input :
2836 f"data/input/climate_types/{ config ['climate_types_file' ]} " ,
29- f"data/input/shapefiles/shapefile_ { polygon_name } _ { tag } /shapefile .shp"
37+ f"data/input/shapefiles/{{shapefile_name}}/{{shapefile_name}} .shp"
3038 output :
31- f"data/output/climate_types_raster2polygon/climate_types_{ polygon_name } _ { tag } .parquet" ,
32- f"data/intermediate/climate_pcts/climate_pcts_{ polygon_name } _ { tag } .json" ,
33- f"data/intermediate/climate_pcts/climate_types_{ polygon_name } _ { tag } .csv"
39+ f"data/output/climate_types_raster2polygon/climate_types_{{shapefile_name} }.parquet" ,
40+ f"data/intermediate/climate_pcts/climate_pcts_{{shapefile_name} }.json" ,
41+ f"data/intermediate/climate_pcts/climate_types_{{shapefile_name} }.csv"
3442 shell :
35- f"python src/aggregate_climate_types.py shapefile_tag= { tag } shapefile_polygon_name= { polygon_name } "
43+ f"python src/aggregate_climate_types.py"
0 commit comments