-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_targets.R
65 lines (52 loc) · 1.21 KB
/
_targets.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
# Load required libraries
library(targets)
library(tarchetypes)
library(dplyr)
source("functions.R")
# Define the directory where your files are located
data_dir <- "data/"
# Define vertical extent of interest
min_alt <- 4
max_alt <- 26
#Define x and y resolution in image
x_res <- 1 # in units of days
y_res <- 0.1 # in units of km
# --- BEGIN PIPELINE
t1 <- tar_files(
name = input_files,
command = list.files(data_dir, pattern = "\\.l100", full.names = TRUE)
)
t2 <- tar_target(
name = processed_data,
command = process_files(input_files,
min_alt = min_alt,
max_alt = max_alt),
pattern = map(input_files)
)
t3 <- tar_target(
years,
unique(str_extract(input_files, "(?<=_)\\d{4}"))
)
t4 <- tar_target(
grid,
generate_grid(x_res, y_res, min_alt, max_alt, years)
)
t5 <- tar_target(
fitted_model,
fit_model(processed_data)
)
t6 <- tar_target(
results,
do_predictions(fitted_model, grid)
)
t7 <- tar_target(
ozone_scale,
define_ozone_scale()
)
t8 <- tar_target(
year_plot,
create_year_plot(results, ozone_scale, year = years),
pattern = map(years),
iteration = "list"
)
list(t1, t2, t3, t4, t5, t6, t7, t8)