forked from DOI-USGS/vizstorm-GIF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_visualize.yml
254 lines (215 loc) · 9.06 KB
/
6_visualize.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
target_default: 6_visualize
include:
packages:
- dplyr
- tidyr
- showtext
file_extensions:
- feather
- ind
sources:
- 6_visualize/src/create_gif_tasks.R
- 6_visualize/src/create_gif_makefile.R
- 6_visualize/src/prep_watermark_fun.R
- 6_visualize/src/prep_basemap_fun.R
- 6_visualize/src/prep_view_fun.R
- 6_visualize/src/prep_storm_line_fun.R
- 6_visualize/src/prep_gage_sites_fun.R
- 6_visualize/src/prep_rivers_fun.R
- 6_visualize/src/prep_legend_fun.R
- 6_visualize/src/prep_major_cities_fun.R
- 6_visualize/src/prep_ocean_name_fun.R
- 6_visualize/src/visualize_utils.R
- 6_visualize/src/combine_animation_frames.R
targets:
6_visualize:
depends:
- 6_visualize/out/animation_a.gif
# here we'll generate the components for basemap, focus_geoms, secondary_geoms,
# adn storm_line. each of these components doesn't change over time. each
# component is a closure, i.e., a function that contains all the data it needs
# to run. the closure should accept 0 arguments. the closure should be saved
# into an RDS file with a corresponding .rds.ind indicator file.
# tmp=temporary folder for holding files to only be created on 1 computer.
# log=folder for the few indicator files that don't correspond to a data file.
visualize_folders:
command: list(
tmp=I('6_visualize/tmp'),
log=I('6_visualize/log'))
dates_config:
command: viz_config[[I('dates')]]
date_display_tz:
command: viz_config[[I('date_display_tz')]]
gage_color_config:
command: viz_config[I(c('gage_flood_col','gage_norm_col','gage_out_col','gage_line_col','gage_ltn_col','gage_stn_col'))]
intro_config:
command: viz_config[[I(c('intro'))]]
legend_text_cfg:
command: viz_config[[I("legend_text")]]
timeline_cfg:
command: viz_config[[I("timeline_style")]]
# ---- location of images on figure ---- #
component_placement:
command: viz_config[[I('component_placement')]]
datetime_placement:
command: component_placement[[I('datetime')]]
watermark_x_pos:
command: component_placement[[I('watermark_x_pos')]]
watermark_y_pos:
command: component_placement[[I('watermark_y_pos')]]
legend_x_pos:
command: component_placement[[I('legend_x_pos')]]
legend_y_pos:
command: component_placement[[I('legend_y_pos')]]
sparkline_placement:
command: component_placement[[I('sparks')]]
outro_placement:
command: component_placement[[I('outro')]]
# ---- location of labels on figure ---- #
ocean_name_placement:
command: viz_config[[I('ocean_name_placement')]]
# ---- static image calls ----- #
view_cfg:
command: viz_config[I('ocean_col')]
view_fun:
command: prep_view_fun(view_polygon, view_cfg)
bbox_fun:
command: prep_bbox_fun(view_config)
basemap_fun:
command: prep_basemap_fun('1_fetch/out/focus_geoms.rds.ind', '1_fetch/out/secondary_geoms.rds.ind')
storm_line_cfg:
command: viz_config[[I("storm_line")]]
storm_points_sf:
command: fetch_read('2_process/out/storm_points_interp.rds.ind')
gage_sites_initial:
command: prep_gage_sites_fun(stage_data, gage_color_config, storm_start_date)
stage_data:
command: fetch_read('2_process/out/cleaned_streamdata.rds.ind')
storm_date_limits:
command: get_date_limits(timestep_ind = '2_process/out/timesteps.rds.ind')
storm_date_limits_local:
command: convert_to_local_tz(storm_date_limits, date_display_tz)
storm_start_date:
command: storm_date_limits[1]
site_data:
command: fetch_read('2_process/out/gage_sites.rds.ind')
precip_rasters:
command: fetch_read('2_process/out/precip_rasters.rds.ind')
rivers_cfg:
command: viz_config[I(c('major_river_col','gage_river_col','lake_col','marsh_col'))]
rivers_fun:
command: prep_rivers_fun('2_process/out/river_geoms.rds.ind', rivers_cfg)
watermark_fun:
command: prep_watermark_fun('6_visualize/in/usgs_logo_black.png', x_pos = watermark_x_pos, y_pos = watermark_y_pos)
ocean_name_fun:
command: prep_ocean_name_fun(ocean_name_placement)
cities_fun:
command: prep_major_cities_fun('1_fetch/out/major_cities.rds.ind')
# Use timesteps but change to match the frames desires
timesteps:
command: timesteps_to_build('2_process/out/timesteps.rds.ind', storm_frame_step)
#### intro frames - animating the link between gages and sparklines ####
intro_frame_config:
command: viz_config[I(c('width','height'))]
intro_gif_tasks:
command: create_intro_gif_tasks(
intro_config = intro_config,
folders = visualize_folders,
storm_track_cfg = storm_track_cfg,
storm_start_date = storm_start_date)
6_intro_gif_tasks.yml:
command: create_intro_gif_makefile(
makefile = target_name,
task_plan = intro_gif_tasks,
remake_file = I('remake.yml'))
# Build the timestep-specific functions and png files.
# When we like how this is looking, we can set task_names=NULL to build all frames.
# In the meantime, you may want to edit the command for trial_intro_frames (rebuild with force=TRUE)
# and set task_names=trial_intro_frames to specify a subset of frames to build.
# If you're trying to iterate on just a few png frames, delete 6_visualize/log/6_intro_gif_tasks.ind,
# then you can call scmake('6_visualize/log/6_intro_gif_tasks.ind') repeatedly.
# Once the .ind file exists, you'll need to call scmake('6_visualize/log/6_intro_gif_tasks.ind', force=TRUE)
# to iterate on all frames at once.
trial_intro_frames:
command: sprintf(I('a_01_%03d'), I(c(1:5,7,9,11,13,15:20)))
6_visualize/log/6_intro_gif_tasks.ind:
command: loop_tasks(
task_plan=intro_gif_tasks, task_makefile='6_intro_gif_tasks.yml',
task_names=NULL,
num_tries=I(1), sleep_on_error=I(0))
#### storm frames - animating the progression of the storm, precip, and stage over time ####
storm_frame_config:
command: viz_config[I(c('width','height'))]
storm_frame_step:
command: viz_config[[I('frame_step')]]
storm_gif_tasks:
command: create_storm_gif_tasks(
timesteps,
storm_track_cfg = storm_track_cfg,
folders = visualize_folders)
6_storm_gif_tasks.yml:
command: create_storm_gif_makefile(
makefile = target_name,
task_plan = storm_gif_tasks,
remake_file = I('remake.yml'))
# Build the timestep-specific functions and png files.
# When we like how this is looking, we can set task_names=NULL to build all frames.
# In the meantime, you may want to edit the command for trial_storm_frames (rebuild with force=TRUE)
# and set task_names=trial_storm_frames to specify a subset of frames to build.
# If you're trying to iterate on just a few png frames, delete 6_visualize/log/6_storm_gif_tasks.ind,
# then you can call scmake('6_visualize/log/6_storm_gif_tasks.ind') repeatedly.
# Once the .ind file exists, you'll need to call scmake('6_visualize/log/6_storm_gif_tasks.ind', force=TRUE)
# to iterate on all frames at once.
trial_storm_frames_01:
command: sprintf(I('a_201708%02d_01'), I(25:31))
trial_storm_frames_07:
command: sprintf(I('a_201708%02d_07'), I(25:31))
trial_storm_frames_13:
command: sprintf(I('a_201708%02d_13'), I(25:31))
trial_storm_frames_19:
command: sprintf(I('a_201708%02d_19'), I(25:31))
trial_storm_frames:
command: c(trial_storm_frames_01, trial_storm_frames_07, trial_storm_frames_13, trial_storm_frames_19)
6_visualize/log/6_storm_gif_tasks.ind:
command: loop_tasks(
task_plan=storm_gif_tasks, task_makefile='6_storm_gif_tasks.yml',
task_names=NULL,
num_tries=I(1), sleep_on_error=I(0))
6_outro_gif_tasks.yml:
command: create_outro_gif_makefile(
target_name = target_name,
template_fn = '6_visualize/in/6_outro_gif_tasks_template.mustache',
timesteps)
6_visualize/log/6_outro_gif_tasks.ind:
command: scmake(I('6_outro_gif_tasks'), '6_outro_gif_tasks.yml')
# Combine the png files into a gif.
#
# For now, call scmake('6_visualize/out/animation_a.gif', force=TRUE)
# if any of the pngs have changed. You also need force=TRUE for
# the final_intro_frames and final_storm_frames
#
# When we're close to done, we can add
# depends:
# - 6_visualize/log/6_intro_gif_tasks.ind
# - 6_visualize/log/6_storm_gif_tasks.ind
# and set task_names=NULL to build all the frames.
trial_frames:
command: c(trial_intro_frames, trial_storm_frames)
final_intro_frames:
command: existing_png_tasks(pattern=I('a_01_[[:digit:]]{3}'))
final_storm_frames:
command: existing_png_tasks(pattern=I('a_[[:digit:]]{8}_[[:digit:]]{2}'))
final_frames:
command: c(I('a_20170825_01'), final_intro_frames, final_storm_frames)
animation_cfg:
command: viz_config[I('frame_delay_cs')]
6_visualize/out/animation_a.gif:
command: combine_animation_frames(
gif_file=target_name,
animation_cfg=animation_cfg,
frame_ind_intro = "6_visualize/log/6_intro_gif_tasks.ind",
frame_ind_storm = "6_visualize/log/6_storm_gif_tasks.ind",
frame_ind_outro = "6_visualize/log/6_outro_gif_tasks.ind",
intro_config = intro_config)
6_visualize/out/animation_a.gif.ind:
command: gd_put(target_name, '6_visualize/out/animation_a.gif')