-
Notifications
You must be signed in to change notification settings - Fork 11
/
6_visualize.yml
236 lines (206 loc) · 7.85 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
target_default: 6_visualize
include:
- 2_process.yml
packages:
- dplyr
- tidyr
- showtext
- sysfonts
- png
- grid
file_extensions:
- feather
- ind
sources:
- 6_visualize/src/create_gif_tasks.R
- 6_visualize/src/create_gif_makefile.R
- 6_visualize/src/prep_view_fun.R
- 6_visualize/src/prep_basemap_fun.R
- 6_visualize/src/prep_title_fun.R
- 6_visualize/src/prep_footnote_fun.R
- 6_visualize/src/prep_legend_fun.R
- 6_visualize/src/prep_vertical_legend_fun.R
- 6_visualize/src/prep_watermark_fun.R
- 6_visualize/src/prep_gage_sites_fun.R
- 6_visualize/src/prep_callouts_fun.R
- 6_visualize/src/combine_animation_frames.R
targets:
6_visualize:
depends:
- font_abel
- font_oswald
- 6_timestep_gif_tasks.yml
- 6_visualize/log/6_timestep_gif_tasks.ind
- 6_visualize/log/6_intro_gif_tasks.ind
- 6_visualize/log/6_final_gif_tasks.ind
- 6_visualize/out/year_in_review.mp4
#### fonts. not sure how to add these better, but this might do ####
font_abel:
command: font_add_google(I('Abel'), I('abel'))
font_oswald:
command: font_add_google(I('Oswald'), I('Oswald'))
#### non-positional configuration information ####
dates_config:
command: viz_config[[I('dates')]]
wheel_dates_config:
command: viz_config[[I('wheelDates')]]
date_display_tz:
command: viz_config[[I('date_display_tz')]]
intro_config:
command: viz_config[[I(c('intro'))]]
legend_cfg:
command: viz_config[[I("legend_cfg")]]
datewheel_cfg:
command: viz_config[[I("datewheel_cfg")]]
#### location of images on figure ####
component_placement:
command: viz_config[[I('component_placement')]]
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')]]
outro_placement:
command: component_placement[[I('outro')]]
#### static plot-component functions ####
# each plot-component function 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
# to save on remake hashing time
view_cfg:
command: viz_config[I('background_col')]
view_fun:
command: prep_view_fun(view_polygon, view_cfg)
# basemap fun will need different args to match the new state boundary data
basemap_cfg:
command: viz_config[[I(c('basemap'))]]
basemap_fun:
command: prep_basemap_fun(states_shifted, basemap_cfg)
title_cfg:
command: viz_config[[I(c('title_cfg'))]]
title_fun:
command: prep_title_fun(title_cfg)
footnote_cfg:
command: viz_config[[I(c('footnote_cfg'))]]
footnote_fun:
command: prep_footnote_fun(footnote_cfg)
legend_fun:
command: prep_vertical_legend_fun(
x_pos = legend_x_pos,
y_pos = legend_y_pos,
legend_cfg = legend_cfg,
gage_style = gage_style_config,
display_percentiles = display_percentiles)
watermark_fun:
command: prep_watermark_fun('6_visualize/in/usgs_logo_black.png', x_pos = watermark_x_pos, y_pos = watermark_y_pos)
watermark_intro_fun:
command: prep_watermark_for_intro_fun('6_visualize/in/usgs_logo_black.png', x_pos = watermark_x_pos, y_pos = watermark_y_pos)
#### animation frames ####
timestep_frame_config:
command: viz_config[I(c('width','height'))]
timestep_frame_step:
command: viz_config[[I('frame_step')]]
callouts_cfg:
command: yaml.load_file("callouts_cfg.yml") # viz_config[[I('callouts')]]
intro_frame:
command: viz_config[[I('intro_frame')]]
intro_frame_cfg:
command: intro_frame[[I('cfg')]]
final_frame:
command: viz_config[[I('final_frame')]]
final_frame_cfg:
command: final_frame[[I('cfg')]]
final_frame_text:
command: final_frame[[I('paragraphs')]]
timestep_gif_tasks:
command: create_timestep_gif_tasks(
timestep_ind = '2_process/out/timesteps.rds.ind',
folders = I(list(tmp=I('6_visualize/tmp'), log=I('6_visualize/log'))))
# 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.
6_timestep_gif_tasks.yml:
command: create_timestep_gif_makefile(
makefile = target_name,
task_plan = timestep_gif_tasks,
remake_file = I('6_visualize.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.
# While iterating on the individual-png level, you may want to
# edit the list in trial_timestep_frames,
# task_names=trial_timestep_frames in the loop_tasks command, and
# rebuild with force=TRUE
#
# If you're trying to iterate on just a few png frames, delete 6_visualize/log/6_timestep_gif_tasks.ind,
# then you can call scmake('6_visualize/log/6_timestep_gif_tasks.ind') repeatedly.
# Once the .ind file exists, you'll need to call scmake('6_visualize/log/6_timestep_gif_tasks.ind', force=TRUE)
# to iterate on all frames at once.
#
# The following loop_tasks recipe can be used to build just a few tasks each time, but
# it's much slower than the scmake() version (below) if you're building all the frames
#
#trial_timestep_frames: I(c(''))
#6_visualize/log/6_timestep_gif_tasks.ind:
# command: loop_tasks(
# task_plan=timestep_gif_tasks, task_makefile='6_timestep_gif_tasks.yml',
# task_names=NULL,
# num_tries=I(1), sleep_on_error=I(0))
6_visualize/log/6_timestep_gif_tasks.ind:
command: scmake(I('6_timestep_gif_tasks'), '6_timestep_gif_tasks.yml')
# Create frames for pausing the last step before the final frame
pause_gif_tasks:
command: create_pause_gif_tasks(
date_cfg = vizDates,
frame_cfg = final_frame_cfg,
folders = I(list(tmp=I('6_visualize/tmp'), log=I('6_visualize/log'))))
6_pause_gif_tasks.yml:
command: create_pause_gif_makefile(
makefile = target_name,
task_plan = pause_gif_tasks,
remake_file = I('6_visualize.yml'))
6_visualize/log/6_pause_gif_tasks.ind:
command: scmake(I('6_pause_gif_tasks'), '6_pause_gif_tasks.yml')
# Create the final frames
final_gif_tasks:
command: create_final_gif_tasks(
frame_cfg = final_frame_cfg,
folders = I(list(tmp=I('6_visualize/tmp'), log=I('6_visualize/log'))))
6_final_gif_tasks.yml:
command: create_final_gif_makefile(
makefile = target_name,
task_plan = final_gif_tasks,
remake_file = I('6_visualize.yml'))
6_visualize/log/6_final_gif_tasks.ind:
command: scmake(I('6_final_gif_tasks'), '6_final_gif_tasks.yml')
# Create the intro frames
intro_gif_tasks:
command: create_intro_gif_tasks(
frame_cfg = intro_frame_cfg,
folders = I(list(tmp=I('6_visualize/tmp'), log=I('6_visualize/log'))))
6_intro_gif_tasks.yml:
command: create_intro_gif_makefile(
makefile = target_name,
task_plan = intro_gif_tasks,
remake_file = I('6_visualize.yml'))
6_visualize/log/6_intro_gif_tasks.ind:
command: scmake(I('6_intro_gif_tasks'), '6_intro_gif_tasks.yml')
# Combine the png files into a gif.
#
# While task_names != NULL or 6_visualize/log/6_timestep_gif_tasks.ind is
# not a declared dependency, always call
# scmake('6_visualize/out/year_in_review.gif', force=TRUE)
#
# When we're close to done, we can add
# depends:
# - 6_visualize/log/6_timestep_gif_tasks.ind
# and set task_names=NULL to build all the frames.
animation_cfg:
command: viz_config[[I('animation')]]
6_visualize/out/year_in_review.mp4:
command: combine_animation_frames_video(
out_file=target_name,
animation_cfg=animation_cfg)
6_visualize/out/year_in_review.mp4.ind:
command: gd_put(target_name, '6_visualize/out/year_in_review.mp4')