-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_scenario_isf_2021.R
67 lines (50 loc) · 1.67 KB
/
process_scenario_isf_2021.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
logger::log_info("ISF 2021: Setting ISF 2021 config.")
isf_2021_raw_path <- config[["isf_2021_raw_path"]]
isf_2021_power_raw_filename <- config[["isf_2021_power_raw_filename"]]
isf_2021_not_power_raw_filename <- config[["isf_2021_not_power_raw_filename"]]
logger::log_info("ISF 2021: Setting ISF 2021 paths.")
isf_2021_raw_full_path <-
file.path(
scenario_preparation_inputs_path,
isf_2021_raw_path
)
isf_2021_power_raw_full_filepath <-
file.path(
isf_2021_raw_full_path,
isf_2021_power_raw_filename
)
isf_2021_not_power_raw_full_filepath <-
file.path(
isf_2021_raw_full_path,
isf_2021_not_power_raw_filename
)
logger::log_info("ISF 2021: Checking that ISF 2021 filepaths exist.")
stopifnot(fs::file_exists(isf_2021_power_raw_full_filepath))
stopifnot(fs::file_exists(isf_2021_not_power_raw_full_filepath))
logger::log_info("ISF 2021: Loading ISF 2021 raw data.")
isf_2021_power_raw <-
tidyxl::xlsx_cells(
path = isf_2021_power_raw_full_filepath
)
isf_2021_not_power_raw <-
tidyxl::xlsx_cells(
path = isf_2021_not_power_raw_full_filepath
)
logger::log_info("ISF 2021: Processing ISF 2021 data.")
isf_2021 <-
pacta.scenario.data.preparation::prepare_isf_2021_scenario(
isf_2021_power_raw,
isf_2021_not_power_raw
)
if (pacta.data.validation::validate_intermediate_scenario_output(isf_2021)) {
logger::log_info("ISF 2021: ISF 2021 data is valid.")
output_path <- fs::path(scenario_preparation_outputs_path, "isf_2021.csv")
readr::write_csv(
x = isf_2021,
file = output_path
)
logger::log_info("ISF 2021: ISF 2021 data saved to {output_path}.")
} else {
logger::log_error("ISF 2021 data is not valid.")
stop()
}