Skip to content

Commit

Permalink
Update to fix EU-12 and EU-15 region name for GCAM XML
Browse files Browse the repository at this point in the history
  • Loading branch information
mengqi-z committed Jul 20, 2023
1 parent f829219 commit 9d8368d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion R/pkg_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ find_mapping_grid <- function(data = NULL, spatial = NULL) {
}

mapping_data <- data %>%
dplyr::left_join(mapping, by = c('lat', 'lon')) %>%
dplyr::left_join(mapping, by = c('lat', 'lon')) %>%
# correct the EU region name for XML
dplyr::mutate(region = dplyr::case_when(region == 'EU_12' ~ 'EU-12',
region == 'EU_15' ~ 'EU-15',
TRUE ~ region),
subRegion = dplyr::case_when(subRegion == 'EU_12' ~ 'EU-12',
subRegion == 'EU_15' ~ 'EU-15',
TRUE ~ subRegion)) %>%
dplyr::filter(!is.na(ID))

return(mapping_data)
Expand Down
7 changes: 4 additions & 3 deletions R/save_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ save_xml <- function(hdcd_gcam = tibble::tibble(),
# Format to match GCAM output file L2441.HDDCDD_Fixed_rcp4p5_gcamusa.csv
if (nrow(hdcd_gcam) > 0) {
hdcd_comb_xml <- hdcd_gcam %>%
dplyr::mutate(value = abs(value)) %>%
dplyr::mutate(value = abs(value),
value = round(value, 2)) %>%
dplyr::select(
region = subRegion,
gcam.consumer,
nodeInput,
building.node.input,
thermal.building.service.input,
year,
degree.days = value
)
degree.days = value) %>%
tibble::as_tibble()

# Save csv corresponding to xml
filename_i_xml_csv <- file.path(
Expand Down

0 comments on commit 9d8368d

Please sign in to comment.