forked from rich-iannone/splitr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils-disp.R
94 lines (86 loc) · 2.77 KB
/
utils-disp.R
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
#' @noRd
write_disp_control_file <- function(start_day,
start_year_GMT,
start_month_GMT,
start_day_GMT,
start_hour,
lat,
lon,
height,
direction,
duration,
vert_motion,
model_height,
met_files,
species,
output_filename,
system_type,
met_dir,
exec_dir) {
start_block <-
paste0(
start_year_GMT, " ", start_month_GMT, " ",
start_day_GMT, " ", start_hour, "\n",
"1\n",
lat, " ", lon, " ", height, "\n",
duration, "\n",
vert_motion, "\n",
model_height, "\n",
length(met_files), "\n",
paste0(met_dir, "/\n", met_files, collapse = "\n"), "\n"
)
i <- 1
release_duration <- as.numeric(species$release_end - species$release_start)
emission_block <-
paste0(
"1\n",
substr(species$name, 1, 4), "\n",
species$rate, "\n",
release_duration, "\n",
species$release_start %>% substr(3, 10) %>% tidy_gsub("-", " "), " ",
formatC(lubridate::hour(species$release_start), width = 2, flag = "0"), " ", "00", "\n"
)
end_year_GMT <- to_short_year(species$release_end)
end_month_GMT <- to_short_month(species$release_end)
end_day_GMT <- to_short_day(species$release_end)
grid_block <-
paste0(
"1", "\n",
"0.0 0.0", "\n",
"0.01 0.01", "\n",
"180 360", "\n",
"./", "\n",
"output.bin", "\n",
"1", "\n",
"0.0", "\n",
start_year_GMT, " ", start_month_GMT, " ",
start_day_GMT, " ", start_hour, " 00", "\n",
end_year_GMT, " ", end_month_GMT, " ",
end_day_GMT, " ", "23 00", " \n",
"00 01 00", "\n"
)
species_block <-
paste0(
"1", "\n",
species$pdiam, " ",
species$density, " ",
species$shape_factor, "\n",
species$ddep_vel, " ",
species$ddep_mw, " ",
species$ddep_a_ratio, " ",
species$ddep_d_ratio, " ",
species$ddep_hl_coeff, "\n",
species$wdep_hl_coeff, " ",
species$wdep_in_cloud, " ",
species$wdep_below_cloud, "\n",
species$rad_decay, "\n",
species$resuspension, "\n"
)
paste0(
start_block,
emission_block,
grid_block,
species_block
) %>%
cat(file = file.path(exec_dir, "CONTROL"), sep = "", append = FALSE)
}