Skip to content

Commit 4fe7f6b

Browse files
Merge pull request #32 from NSAPH-Data-Processing/audiracmichelle/issue28
Audiracmichelle/issue28
2 parents 2c6623b + e605096 commit 4fe7f6b

File tree

8 files changed

+664
-37
lines changed

8 files changed

+664
-37
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN python utils/create_dir_paths.py datapaths=datapaths.yaml
2020

2121
# snakemake --configfile conf/config.yaml --cores 4 -C shapefile_polygon_name=zcta
2222
ENTRYPOINT ["snakemake"]
23-
CMD ["--cores", "1", "-C", "shapefile_year=2015", "shapefile_polygon_name=county"]
23+
CMD ["--cores", "1", "-C", "shapefile_tag=2015", "shapefile_polygon_name=county"]

Snakefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,33 @@ import yaml
33
conda: "requirements.yaml"
44
configfile: "conf/config.yaml"
55

6-
year=config["shapefile_year"]
6+
tag=config["shapefile_tag"]
77
polygon_name=config["shapefile_polygon_name"]
88

99
rule all:
1010
input:
11-
f"data/output/climate_types_raster2polygon/climate_types_{polygon_name}_{year}.parquet"
11+
f"data/output/climate_types_raster2polygon/climate_types_{polygon_name}_{tag}.parquet"
1212

1313
rule download_climate_types:
1414
output:
1515
f"data/input/climate_types/{config['climate_types_file']}"
1616
shell:
1717
"python src/download_climate_types.py"
1818

19-
rule download_shapefiles:
20-
output:
21-
f"data/input/shapefiles/shapefile_{polygon_name}_{year}/shapefile.shp" #ext = ["shp", "shx", "dbf", "prj", "cpg", "xml"]
22-
shell:
23-
f"python src/download_shapefile.py shapefile_year={year} shapefile_polygon_name={polygon_name}"
19+
# temporarily removing download step in snakemake
20+
# rule download_shapefiles:
21+
# output:
22+
# f"data/input/shapefiles/shapefile_{polygon_name}_{tag}/shapefile.shp" #ext = ["shp", "shx", "dbf", "prj", "cpg", "xml"]
23+
# shell:
24+
# f"python src/download_shapefile.py shapefile_tag={tag} shapefile_polygon_name={polygon_name}"
2425

2526
rule aggregate_climate_types:
2627
input:
2728
f"data/input/climate_types/{config['climate_types_file']}",
28-
f"data/input/shapefiles/shapefile_{polygon_name}_{year}/shapefile.shp"
29+
f"data/input/shapefiles/shapefile_{polygon_name}_{tag}/shapefile.shp"
2930
output:
30-
f"data/output/climate_types_raster2polygon/climate_types_{polygon_name}_{year}.parquet",
31-
f"data/intermediate/climate_pcts/climate_pcts_{polygon_name}_{year}.json",
32-
f"data/intermediate/climate_pcts/climate_types_{polygon_name}_{year}.csv"
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"
3334
shell:
34-
f"python src/aggregate_climate_types.py shapefile_year={year} shapefile_polygon_name={polygon_name}"
35+
f"python src/aggregate_climate_types.py shapefile_tag={tag} shapefile_polygon_name={polygon_name}"

conf/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defaults:
22
- _self_
33
- datapaths: datapaths
4-
- shapefiles: shapefiles
4+
- shapefiles: global_shapefiles
55
- climate_keys: climate_keys
66

77
# Climate types raw raster information
@@ -14,8 +14,8 @@ climate_types_file: Beck_KG_V1_present_0p0083.tif # it's the one at highest res
1414
# - Beck_KG_V1_present_conf_0p5.tif
1515

1616
# Shapefiles information
17-
shapefile_year: 2015 #to be matched with cfg.shapefiles
18-
shapefile_polygon_name: county #to be matched with cfg.shapefiles, column name of id in output file
17+
shapefile_tag: ADM2all #to be matched with cfg.shapefiles
18+
shapefile_polygon_name: MEX #to be matched with cfg.shapefiles, column name of id in output file
1919

2020
hydra:
2121
run:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Catalog of shapefiles
2+
# cfg.shapefile_tag and cfg.shapefile_polygon_name are used to match the shapefile to use
3+
4+
CAN:
5+
ADM3all:
6+
url: null
7+
idvar: shapeID_3
8+
MEX:
9+
ADM2all:
10+
url: null
11+
idvar: shapeID_2
12+
USA:
13+
ADM2all:
14+
url: null
15+
idvar: shapeID_2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Catalog of shapefiles
2-
# cfg.shapefile_year and cfg.shapefile_polygon_name are used to match the shapefile to use
2+
# cfg.shapefile_tag and cfg.shapefile_polygon_name are used to match the shapefile to use
33

44
county: #County shapefiles (cartographic boudaries) https://www.census.gov/programs-surveys/geography/guidance/tiger-data-products-guide.html
55
2015:

0 commit comments

Comments
 (0)