Skip to content

Commit 55fcd79

Browse files
authored
Add region_isos definitions for new scenarios (#247)
New regional definitions for scenarios coming from: WEO 2020, ISF 2020, NZE 2021
1 parent 5375f42 commit 55fcd79

File tree

9 files changed

+1999
-13
lines changed

9 files changed

+1999
-13
lines changed

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# r2dii.data (development version)
22

3+
* `region_isos` gains data for new scenario `source`s: `weo_2020`, `isf_2020`
4+
and `nze_2021` (#241, @georgeharris2deg).
5+
36
# r2dii.data 0.2.0
47

58
* `ald_demo` and `scenario_demo_2020` gain rows of dummy data for the `hdv`
@@ -15,7 +18,7 @@ of type "character".
1518
# r2dii.data 0.1.9
1619

1720
* In `sector_classifications` and `psic_classification`, all values of `sector`
18-
are now lowercase (#222 daisy-pacheco).
21+
are now lowercase (#222 @daisy-pacheco).
1922

2023
# r2dii.data 0.1.8
2124

data-raw/region_isos.R

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,23 @@ exclude_values <- function(data, values, .region) {
9191
mutate(region = .region)
9292
}
9393

94+
process_countries <- function(data, ald_isos, source_year) {
95+
96+
region_data %>%
97+
pick_type("country_name") %>%
98+
warn_if_is_missing_country_isos() %>%
99+
rbind(global_data(., source_year)) %>%
100+
prepare_isos() %>%
101+
bind_rows(mutate(ald_isos, source = source_year)) %>%
102+
unique()
103+
}
104+
94105
# Some isos are missing from the global regions definition. Here we read in the
95106
# actual isos from a real ALD file, and buffer the potentially missing isos.
96107
ald_isos <- read_regions(
97108
file.path("data-raw", paste0("ald_all_isos", ".csv"))
98109
)
99110

100-
ald_isos_weo_2019 <- mutate(ald_isos, source = "weo_2019")
101-
102-
ald_isos_etp_2017 <- mutate(ald_isos, source = "etp_2017")
103-
104111
# Process raw_regions_weo_2019.csv ----------------------------------------
105112

106113
# Source: raw_regions_weo_2019.csv was transcribed from page 780 of the 2019
@@ -166,7 +173,7 @@ region_isos_weo_2019 <- bound1 %>%
166173
non_opec
167174
) %>%
168175
prepare_isos() %>%
169-
bind_rows(ald_isos_weo_2019) %>%
176+
bind_rows(mutate(ald_isos, source = source_year)) %>%
170177
unique()
171178

172179
# Process raw_regions_etp_2017.csv ----------------------------------------
@@ -185,14 +192,55 @@ region_isos_etp_2017 <- region_data %>%
185192
warn_if_is_missing_country_isos() %>%
186193
rbind(global_data(., source_year)) %>%
187194
prepare_isos() %>%
188-
bind_rows(ald_isos_etp_2017) %>%
195+
bind_rows(mutate(ald_isos, source = source_year)) %>%
189196
unique()
190197

198+
# Process raw_regions_weo_2020.csv ----------------------------------------
199+
200+
# Source: raw_regions_weo_2020.csv was transcribed from the 2020 World Energy
201+
# Outlook
202+
source_year <- "weo_2020"
203+
region_data <- read_regions(regions_path(source_year))
204+
205+
region_isos_weo_2020 <- process_countries(
206+
region_data,
207+
ald_isos,
208+
source_year
209+
)
210+
211+
# Process raw_regions_isf_2020.csv ----------------------------------------
212+
213+
# Source: raw_regions_etp_2017.csv was transcribed from page 780 of the 2017
214+
# Energy Technology Perspectives
215+
source_year <- "isf_2020"
216+
region_data <- read_regions(regions_path(source_year))
217+
218+
region_isos_isf_2020 <- process_countries(
219+
region_data,
220+
ald_isos,
221+
source_year
222+
)
223+
224+
# Process raw_regions_nze_2021.csv ----------------------------------------
225+
226+
# Source: https://oneearth.uts.edu.au/regions#regional-narratives
227+
source_year <- "nze_2021"
228+
region_data <- read_regions(regions_path(source_year))
229+
230+
region_isos_nze_2021 <- process_countries(
231+
region_data,
232+
ald_isos,
233+
source_year
234+
)
235+
191236
# Combine -----------------------------------------------------------------
192237

193238
region_isos <- rbind(
194239
region_isos_weo_2019,
195-
region_isos_etp_2017
240+
region_isos_etp_2017,
241+
region_isos_weo_2020,
242+
region_isos_isf_2020,
243+
region_isos_nze_2021
196244
) %>%
197245
group_by(region, source) %>%
198246
distinct(isos) %>%

0 commit comments

Comments
 (0)