forked from USGS-R/delaware-model-prep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_predictions.yml
169 lines (140 loc) · 6.06 KB
/
3_predictions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
target_default: 3_predictions
packages:
- RcppCNPy
- tidyverse
- sf
- feather
- yaml
sources:
- 3_predictions/src/munge_predictions.R
- 3_predictions/src/get_prms_sntemp_model.R
- 3_predictions/src/set_sntemp_output.R
- 3_predictions/src/update_sntemp.R
- 3_predictions/src/run_sntemp.R
- 3_predictions/src/get_sntemp_values.R
- 3_predictions/src/gather_sntemp_output.R
- 3_predictions/src/get_subbasins.R
- 3_predictions/src/get_upstream_downstream_segs.R
- 3_predictions/src/download_files.R
- 3_predictions/src/dwallin_functions.R
targets:
3_predictions:
depends:
- 3_predictions/out/compare_predictions_obs.feather.ind
- 3_predictions/out/model_evaluation.csv
# getting some settings for running PRMS-SNTemp uncalibrated
uncal_settings:
command: read_yaml('3_predictions/cfg/uncal_settings.yml')
orig_model_loc:
command: uncal_settings[[I('orig_model_loc')]]
uncal_model_run_loc:
command: uncal_settings[[I('uncal_model_run_loc')]]
uncal_start:
command: uncal_settings[[I('start')]]
uncal_stop:
command: uncal_settings[[I('stop')]]
sntemp_output_vars:
command: uncal_settings[[I('sntemp_output')]]
# need to make sure that 20191002_Delaware_streamtemp folder is in project on
# local machine; this is on GD if not on local machine
# within this function, moving model to temporary run location so that we can change parameters, etc.. while keeping
# original model preserved
3_predictions/tmp/control/delaware.control.ind:
command: get_prms_sntemp_model(
out_ind = target_name,
gd_zip_ind_file = '3_predictions/in/prms_sntemp/20191002_Delaware_streamtemp.zip.ind',
unzip_loc = I('prms_sntemp'),
orig_model_loc = orig_model_loc,
model_run_loc = uncal_model_run_loc)
set_sntemp_output_vars:
command: set_sntemp_output(
output_names = sntemp_output_vars,
model_run_loc = uncal_model_run_loc)
depends: '3_predictions/tmp/control/delaware.control.ind'
3_predictions/tmp/output/stream_temp.out.nsegment.ind:
command: run_sntemp(
out_ind = target_name,
start = uncal_start,
stop = uncal_stop,
spinup = I('F'),
restart = I('F'),
model_run_loc = uncal_model_run_loc)
depends: set_sntemp_output_vars
# includes output in 3_predictions/cfg/uncal_settings.yml
3_predictions/out/uncal_sntemp_input_output.feather.ind:
command: gather_sntemp_output(
ind_file = target_name,
model_run_loc = uncal_model_run_loc,
model_output_file = I('output/stream_temp.out.nsegment'),
model_fabric_file = I('GIS/Segments_subset.shp'),
sntemp_vars = sntemp_output_vars)
depends: '3_predictions/tmp/output/stream_temp.out.nsegment.ind'
# subbasins in the DRB
3_predictions/out/drb_subbasins.rds.ind:
command: get_subbasins(
ind_file = target_name,
subbasin_outlet_file = '3_predictions/cfg/subbasin_outlets.yml',
model_run_loc = uncal_model_run_loc)
3_predictions/out/uncal_sntemp_input_output_subbasin_4182.feather.ind:
command: gather_sntemp_output_subbasin(
ind_file = target_name,
subbasin_ind_file = '3_predictions/out/drb_subbasins.rds.ind',
full_data_ind_file = '3_predictions/out/uncal_sntemp_input_output.feather.ind',
subbasin_outlet_id = I('4182')) # outlet seg_id_nat of subbasin that Xiaowei uses
3_predictions/out/uncal_sntemp_preds.csv.ind:
command: pull_sntemp_preds(
sntemp_ind = '3_predictions/out/uncal_sntemp_input_output.feather.ind',
out_ind = target_name)
3_predictions/out/rgcn_v1_preds.feather.ind:
command: munge_rgcn_output(in_ind = '3_predictions/in/rgcn_v1_preds_raw.npy.ind', out_ind = target_name)
# put it all together!
3_predictions/out/compare_predictions_obs.feather.ind:
command: combine_preds_obs(
obs_ind = '2_observations/out/obs_temp_drb.rds.ind',
sntemp_ind = '3_predictions/out/uncal_sntemp_preds.csv.ind',
rgcn_v1_ind = '3_predictions/out/rgcn_v1_preds.feather.ind',
rgcn_v2_ind = '3_predictions/in/rgcn_v2_preds.feather.ind',
rgcn_v2_full_ind = '3_predictions/in/rgcn_v2_preds_full.feather.ind',
out_ind = target_name)
# write some model comparisons/stats and git commit for each comparison
3_predictions/out/model_evaluation.csv:
command: calc_metrics(
compare_ind = '3_predictions/out/compare_predictions_obs.feather.ind',
out_file = target_name)
# get GLM reservoir predictions
3_predictions/in/reservoir_downstream_preds.csv.ind:
command: get_sb_item(out_ind = target_name,
sb_id = I('5f6a28a782ce38aaa2449137'),
sb_names = I('reservoir_downstream_preds.csv'))
# calculate decay rates to be used to weight GLM vs PRMS-SNTemp preds
# for Cannonsville
test_period:
command: c(I(c(seq(as.Date('1979-10-01'), as.Date('1984-09-30'), 1),
seq(as.Date('2010-10-01'), as.Date('2015-09-30'), 1),
seq(as.Date('2020-10-01'), as.Date('2021-09-30'), 1))))
cannonsville_decay_estimate:
command: calc_decay(
segs_downstream = I(c('1566', '1563', '1565' , '1571', '1572')),
reservoir_nhdid = I('nhdhr_120022743'),
glm_preds_file = '3_predictions/in/reservoir_downstream_preds.csv.ind',
reservoir_subseg = I('128_1'),
test_period = test_period)
pepacton_decay_estimate:
command: calc_decay(
segs_downstream = I(c('1444', '1450', '1459', '1461', '1462', '1463')),
reservoir_nhdid = I('nhdhr_151957878'),
glm_preds_file = '3_predictions/in/reservoir_downstream_preds.csv.ind',
reservoir_subseg = I('15_1'),
test_period = test_period)
# object that retains observations and sntemp predictions for comparison purposes
dwallin_preds:
command: combine_dwallin_models(
west = cannonsville_decay_estimate,
east = pepacton_decay_estimate,
distance_ind = '1_network/out/subseg_distance_matrix.rds.ind',
confluence_subseg = I('140_1'),
west_subseg = I('128_1'),
east_subseg = I('15_1'))
# pare down columns and write to file for data release
3_predictions/out/dwallin_stream_preds.csv.ind:
command: simplify_and_write(dwallin_preds, target_name)