diff --git a/NAMESPACE b/NAMESPACE index 29505d27..467849a3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -58,7 +58,6 @@ export(reportClimate) export(reportCosts) export(reportCrossVariables) export(reportDIETER) -export(reportEDGETransport) export(reportEmi) export(reportEmiAirPol) export(reportEmployment) @@ -86,16 +85,10 @@ importFrom(abind,abind) importFrom(assertr,assert) importFrom(assertr,not_na) importFrom(data.table,":=") -importFrom(data.table,CJ) -importFrom(data.table,as.data.table) -importFrom(data.table,copy) -importFrom(data.table,data.table) importFrom(data.table,fread) importFrom(data.table,frollmean) importFrom(data.table,fwrite) -importFrom(data.table,rbindlist) importFrom(data.table,setDT) -importFrom(data.table,setnames) importFrom(dplyr,"%>%") importFrom(dplyr,across) importFrom(dplyr,arrange) @@ -125,7 +118,6 @@ importFrom(dplyr,tibble) importFrom(dplyr,tribble) importFrom(dplyr,ungroup) importFrom(gdx,readGDX) -importFrom(gdxdt,readgdx) importFrom(gdxrrw,gdxInfo) importFrom(ggplot2,aes) importFrom(ggplot2,aes_) @@ -244,9 +236,6 @@ importFrom(rlang,is_empty) importFrom(rlang,sym) importFrom(rlang,syms) importFrom(rmarkdown,render) -importFrom(rmndt,approx_dt) -importFrom(rmndt,readMIF) -importFrom(rmndt,writeMIF) importFrom(tibble,as_tibble) importFrom(tibble,tibble) importFrom(tibble,tribble) diff --git a/R/reportCapitalStock.R b/R/reportCapitalStock.R index abcb99dc..cedb79ce 100644 --- a/R/reportCapitalStock.R +++ b/R/reportCapitalStock.R @@ -81,17 +81,6 @@ reportCapitalStock <- function(gdx,regionSubsetList=NULL,t=c(seq(2005,2060,5),se tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,"apCarH2T"] * pm_conv_cap_2_MioLDV,dim=c(3.1,3.2)),"Est H2 LDV Sales (million vehicles)")) tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,"apCarPeT"] * pm_conv_cap_2_MioLDV,dim=c(3.1,3.2)),"Est ICE LDV Sales (million vehicles)")) - tmp <- mbind(tmp,setNames(dimSums(vm_cap[,,c("apCarDiT","apcarDiEffT","apcarDiEffH2T")],dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Stock|uedit (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_cap[,,"apCarDiT"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Stock|apCarDiT (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_cap[,,"apcarDiEffT"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Stock|apcarDiEffT (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_cap[,,"apcarDiEffH2T"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Stock|apcarDiEffH2T (arbitrary unit)")) - - tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,c("apCarDiT","apcarDiEffT","apcarDiEffH2T")],dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Sales|uedit (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,"apCarDiT"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Sales|apCarDiT (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,"apcarDiEffT"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Sales|apcarDiEffT (arbitrary unit)")) - tmp <- mbind(tmp,setNames(dimSums(vm_deltaCap[,,"apcarDiEffH2T"] ,dim=c(3.1,3.2)), "Services and Products|Transport|non-LDV|Sales|apcarDiEffH2T (arbitrary unit)")) - - ## add global values tmp <- mbind(tmp,dimSums(tmp,dim=1)) } diff --git a/R/reportCrossVariables.R b/R/reportCrossVariables.R index 08e28326..4428bfc0 100644 --- a/R/reportCrossVariables.R +++ b/R/reportCrossVariables.R @@ -25,6 +25,7 @@ #' @importFrom tibble as_tibble #' @importFrom tidyselect everything #' @importFrom madrat toolAggregate +#' @importFrom data.table := #' reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL, diff --git a/R/reportEDGETransport.R b/R/reportEDGETransport.R deleted file mode 100644 index 5b86dde4..00000000 --- a/R/reportEDGETransport.R +++ /dev/null @@ -1,680 +0,0 @@ -#' Reporting for the coupled EDGE-T Transport Sector Model (REMIND Module edge_esm) -#' -#' Data is loaded from the EDGE-T subfolder in the output folder. -#' The input files can be (re-) generated calling -#' `Rscript EDGETransport.R --reporting` -#' from the output folder. -#' -#' *Warning* The function modifies the "REMIND_generic_.mif" file by appending the -#' additional reporting variables and replaces the "_withoutPlus" version. -#' -#' Region subsets are obtained from fulldata.gdx -#' -#' @param output_folder path to the output folder, default is current folder. -#' @param remind_root path to the REMIND root directory, defaults to two levels up from output_folder. -#' @param append try to find the REMIND output file in the output folder and append to it. If FALSE, the function returns a quitte object with the reporting variables. -#' @author Alois Dirnaichner Marianna Rottoli -#' -#' @importFrom rmndt approx_dt readMIF writeMIF -#' @importFrom gdxdt readgdx -#' @importFrom data.table fread fwrite rbindlist copy CJ setnames := data.table as.data.table -#' @importFrom dplyr %>% -#' @importFrom quitte as.quitte -#' @importFrom utils capture.output -#' @export - -reportEDGETransport <- function(output_folder=".", - remind_root=NULL, - append=TRUE) { - - if(is.null(remind_root)){ - remind_root <- file.path(output_folder, "../..") - } - gdx <- file.path(output_folder, "fulldata.gdx") - - ## check the regional aggregation - regionSubsetList <- toolRegionSubsets(gdx) - - # ADD EU-27 region aggregation if possible - if("EUR" %in% names(regionSubsetList)){ - regionSubsetList <- c(regionSubsetList,list( - "EU27"=c("ENC","EWN","ECS","ESC","ECE","FRA","DEU","ESW") - )) - } - - sub_folder = "EDGE-T/" - - ## NULL Definitons for codeCheck compliance - RegionCode <- CountryCode <- cfg <- `.` <- sector <- subsector_L3 <- region <- year <- NULL - subsector_L2 <- subsector_L1 <- aggr_mode <- vehicle_type <- det_veh <- aggr_nonmot <- NULL - demand_F <- demand_EJ <- remind_rep <- V25 <- aggr_veh <- technology <- NULL - ttot <- se_share <- fe_demand <- variable <- value <- demand_VKM <- loadFactor <- NULL - all_enty <- ef <- variable_agg <- model <- scenario <- period <- NULL - Region <- Variable <- co2 <- co2val <- elh2 <- fe <- NULL - int <- se <- sec <- sharesec <- te <- tech <- val <- share <- NULL - eff <- sharebio <- sharesyn <- totseliq <- type <- ven <- NULL - unit <- NULL - - load(file.path(output_folder, "config.Rdata")) - - datapath <- function(fname){ - file.path(output_folder, sub_folder, fname) - } - - ## load input data from last EDGE run - demand_km <- readRDS(datapath(fname = "demandF_plot_pkm.RDS"))[ - , demand_F := demand_F * 1e-3] ## million -> billion pkm - load_factor <- readRDS(datapath(fname = "loadFactor.RDS")) - annual_mileage <- readRDS(datapath(fname = "annual_mileage.RDS")) - demand_vkm <- merge(demand_km, load_factor, by=c("year", "region", "vehicle_type")) - demand_vkm[, demand_VKM := demand_F/loadFactor] ## billion vkm - - demand_ej <- readRDS(datapath(fname = "demandF_plot_EJ.RDS")) ## detailed final energy demand, EJ - - ## ES and FE Demand - - reportingESandFE <- function(datatable, mode){ - - datatable[, sector := ifelse(sector %in% c("trn_pass", "trn_aviation_intl"), "Pass", "Freight")] - - ## attribute aggregated mode and vehicle names for plotting purposes, and aggregate - ## Large Categories (as used by REMIND) - datatable[subsector_L2 == "trn_pass_road_LDV", - aggr_mode := "Pass|Road|LDV"] - datatable[subsector_L2 != "trn_pass_road_LDV" & sector == "Pass", - aggr_mode := "Pass|non-LDV"] - - ## A little more detail: Vehicle Aggregates - datatable[grepl("^Truck", vehicle_type), aggr_veh := "Freight|Road"] - datatable["Freight Rail_tmp_vehicletype" == vehicle_type, aggr_veh := "Freight|Rail"] - ## there seem to be no passenger ships in EDGE-T! - datatable[subsector_L3 == "International Ship", aggr_veh := "Freight|International Shipping"] - datatable[subsector_L3 == "Domestic Ship", aggr_veh := "Freight|Navigation"] - - datatable[grepl("Bus", vehicle_type), aggr_veh := "Pass|Road|Bus"] - - - if(mode == "ES") - datatable[grepl("Cycle|Walk", subsector_L3), aggr_nonmot := "Pass|Road|Non-Motorized"] - - ## Rail & Aviation - datatable[grepl("Passenger Rail|HSR", vehicle_type), aggr_veh := "Pass|Rail"] - datatable[subsector_L3 == "Domestic Aviation", aggr_veh := "Pass|Aviation|Domestic"] - datatable[subsector_L3 == "International Aviation", aggr_veh := "Pass|Aviation|International"] - - ## Freight - datatable[grepl("^Truck", vehicle_type), det_veh := sprintf("Freight|Road|%s", vehicle_type)] - - ## High Detail: Ecoinvent-Compatible Output - datatable[grepl("Subcompact", vehicle_type), - det_veh := "Pass|Road|LDV|Small"] - datatable[grepl("Mini", vehicle_type), - det_veh := "Pass|Road|LDV|Mini"] - datatable[vehicle_type == "Compact Car", det_veh := "Pass|Road|LDV|Medium"] - datatable[grepl("Large Car|Midsize Car", vehicle_type), det_veh := "Pass|Road|LDV|Large"] - datatable[grepl("SUV", vehicle_type), - det_veh := "Pass|Road|LDV|SUV"] - datatable[grepl("Van|Multipurpose", vehicle_type), - det_veh := "Pass|Road|LDV|Van"] - - datatable[grepl("Motorcycle|Scooter|Moped", vehicle_type), - det_veh := "Pass|Road|LDV|Two-Wheelers"] - - prepare4MIF <- function(dt, remind_unit, valcol, varcol){ - ## REMIND years, loading from MIF File would take too long - yrs <- c(seq(2005, 2060, 5), seq(2070, 2110, 10), 2130, 2150) - remind_scenario <- cfg$title - - prefix <- switch(mode, - "FE" = "FE|Transport|", - "ES" = "ES|Transport|", - "VKM" = "ES|Transport|VKM|") - - ## we only care for non-NA variables (NA is basically *all others*) - toadd = dt[!is.na(get(varcol)), .(model=cfg$model_name, scenario=remind_scenario, region, - variable=paste0(prefix, get(varcol)), - unit=remind_unit, period=year, - value=get(valcol))] - - toadd <- approx_dt(toadd, yrs, xcol="period", ycol = "value", - idxcols=colnames(toadd)[1:5], - extrapolate=T) - return(toadd) - } - - if(mode == "ES"){ - report <- rbindlist(list( - prepare4MIF( - datatable[sector == "Pass", sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_mode")], - "bn pkm/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[sector == "Freight" & !is.na(aggr_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_veh")], - "bn tkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[sector == "Pass" & !is.na(aggr_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_veh")], - "bn pkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[!is.na(aggr_nonmot), sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_nonmot")], - "bn pkm/yr", "V1", "aggr_nonmot"), - prepare4MIF( - datatable[!is.na(det_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "det_veh")], "bn pkm/yr", "V1", "det_veh"))) - }else if(mode == "VKM"){ - report <- rbindlist(list( - prepare4MIF( - datatable[sector == "Pass", sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_mode")], - "bn vkm/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[sector == "Freight" & !is.na(aggr_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_veh")], - "bn vkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[sector == "Pass" & !is.na(aggr_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_veh")], - "bn vkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[!is.na(det_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "det_veh")], "bn vkm/yr", "V1", "det_veh"))) - }else{ - report <- rbindlist(list( - prepare4MIF( - datatable[!is.na(aggr_mode), sum(demand_EJ, na.rm=T), - by = c("region", "year", "aggr_mode")], - "EJ/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[!is.na(aggr_veh), sum(demand_EJ, na.rm=T), - by = c("region", "year", "aggr_veh")], - "EJ/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[!is.na(det_veh), sum(demand_EJ, na.rm=T), - by = c("region", "year", "det_veh")], - "EJ/yr", "V1", "det_veh"))) - } - - ## with energy carrier - - ## remove cycling and walking placeholder techs for ESs - techmap <- data.table(technology=unique(datatable$technology), - key="technology")[!c("Cycle_tmp_technology", "Walk_tmp_technology")] - - if(mode == "ES"){ - ## for energy services, it is better to refer to the actual technologies - ## and not the fuel types (-> LCA) - techmap[, remind_rep := technology] - techmap["NG", remind_rep := "Gases"] - - datatable <- datatable[techmap, on="technology"] - - report_tech <- rbindlist(list( - prepare4MIF( - datatable[sector == "Pass", sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_mode", "remind_rep") - ][, aggr_mode := paste0(aggr_mode, "|", remind_rep)], - "bn pkm/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[sector == "Freight" & !is.na(aggr_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, aggr_veh := paste0(aggr_veh, "|", remind_rep)], - "bn tkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[sector == "Pass" & !is.na(aggr_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, aggr_veh := paste0(aggr_veh, "|", remind_rep)], - "bn pkm/yr", "V1", "aggr_veh"), - prepare4MIF(datatable[!is.na(det_veh), sum(demand_F, na.rm=T), - by = c("region", "year", "det_veh", "remind_rep") - ][, det_veh := paste0(det_veh, "|", remind_rep)], - "bn pkm/yr", "V1", "det_veh"))) - }else if(mode == "VKM"){ - ## for energy services, it is better to refer to the actual technologies - ## and not the fuel types (-> LCA) - techmap[, remind_rep := technology] - techmap["LA-BEV", remind_rep := "BEV"] - techmap["NG", remind_rep := "Gases"] - - datatable <- datatable[techmap, on="technology"] - - report_tech <- rbindlist(list( - prepare4MIF( - datatable[sector == "Pass", sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_mode", "remind_rep") - ][, aggr_mode := paste0(aggr_mode, "|", remind_rep)], - "bn vkm/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[sector == "Freight" & !is.na(aggr_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, aggr_veh := paste0(aggr_veh, "|", remind_rep)], - "bn vkm/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[sector == "Pass" & !is.na(aggr_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, aggr_veh := paste0(aggr_veh, "|", remind_rep)], - "bn vkm/yr", "V1", "aggr_veh"), - prepare4MIF(datatable[!is.na(det_veh), sum(demand_VKM, na.rm=T), - by = c("region", "year", "det_veh", "remind_rep") - ][, det_veh := paste0(det_veh, "|", remind_rep)], - "bn vkm/yr", "V1", "det_veh"))) - }else{ - techmap["BEV", remind_rep := "Electricity"] - techmap["Electric", remind_rep := "Electricity"] - techmap["FCEV", remind_rep := "Hydrogen"] - techmap["Hydrogen", remind_rep := "Hydrogen"] - techmap["Liquids", remind_rep := "Liquids"] - techmap["NG", remind_rep := "Gases"] - - datatable <- datatable[techmap, on="technology"] - - report_tech <- rbindlist(list( - prepare4MIF( - datatable[!is.na(aggr_mode), sum(demand_EJ, na.rm=T), - by = c("region", "year", "aggr_mode", "remind_rep") - ][, aggr_mode := paste0(aggr_mode, "|", remind_rep)], - "EJ/yr", "V1", "aggr_mode"), - prepare4MIF( - datatable[!is.na(aggr_veh), sum(demand_EJ, na.rm=T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, aggr_veh := paste0(aggr_veh, "|", remind_rep)], - "EJ/yr", "V1", "aggr_veh"), - prepare4MIF( - datatable[!is.na(det_veh), sum(demand_EJ, na.rm=T), - by = c("region", "year", "det_veh", "remind_rep") - ][, det_veh := paste0(det_veh, "|", remind_rep)], - "EJ/yr", "V1", "det_veh"))) - - df <- rbind( - datatable[!is.na(aggr_mode), sum(demand_EJ, na.rm = T), - by = c("region", "year", "aggr_mode", "remind_rep") - ][, variable := paste0(aggr_mode, "|", remind_rep)][,c("region", "year", "variable", "V1")], - datatable[!is.na(aggr_veh), sum(demand_EJ, na.rm = T), - by = c("region", "year", "aggr_veh", "remind_rep") - ][, variable := paste0(aggr_veh, "|", remind_rep)][,c("region", "year", "variable", "V1")] - ) - - # splits Liquids variables into Biomass, Fossil and Hydrogen according to FE demand shares - .split_liquids <- function(df) { - demFeSector <- readGDX(gdx, "vm_demFeSector", field = "l", restore_zeros = F) - - # biomass share in biomass+hydrogen liquids in total transport sector - bioShareTrans <- dimSums(mselect(demFeSector, all_enty = "seliqbio", emi_sectors = "trans"), dim = 3, na.rm = T) / - dimSums(mselect(demFeSector, all_enty = c("seliqbio", "seliqsyn"), emi_sectors = "trans"), dim = 3, na.rm = T) - - # hydrogen share in biomass+hydrogen liquids in total transport sector - synShareTrans <- dimSums(mselect(demFeSector, all_enty = "seliqsyn", emi_sectors = "trans"), dim = 3, na.rm = T) / - dimSums(mselect(demFeSector, all_enty = c("seliqbio", "seliqsyn"), emi_sectors = "trans"), dim = 3, na.rm = T) - - # calculate LDV share ---- - - # liquids for LDVs - demFeSectorLdv <- mselect(demFeSector, - all_enty = c("seliqfos", "seliqbio", "seliqsyn"), - all_enty1 = "fepet", emi_sectors = "trans" - ) - - feShareLdvLiqFos <- dimSums(demFeSectorLdv[, , "seliqfos.fepet"], dim = 3, na.rm = T) / dimSums(demFeSectorLdv, dim = 3, na.rm = T) - - # for non-fossil liquids we apply the share of the transport sector to the subsector - feShareLdvLiqBio <- dimSums(mselect(demFeSectorLdv, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * bioShareTrans / dimSums(demFeSectorLdv, dim = 3, na.rm = T) - feShareLdvLiqSyn <- dimSums(mselect(demFeSectorLdv, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * synShareTrans / dimSums(demFeSectorLdv, dim = 3, na.rm = T) - - # calculate share for Non-LDV (Trucks, Domestic Aviation etc.) ---- - - # liquids for Non-LDVs - demFeSectorNonLdv <- mselect(demFeSector, - all_enty = c("seliqfos", "seliqbio", "seliqsyn"), - all_enty1 = "fedie", emi_sectors = "trans", all_emiMkt = "ES" - ) - - feShareNonLdvLiqFos <- demFeSectorNonLdv[, , "seliqfos.fedie"] / dimSums(demFeSectorNonLdv, dim = 3, na.rm = T) - feShareNonLdvLiqBio <- dimSums(mselect(demFeSectorNonLdv, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * bioShareTrans / dimSums(demFeSectorNonLdv, dim = 3, na.rm = T) - feShareNonLdvLiqSyn <- dimSums(mselect(demFeSectorNonLdv, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * synShareTrans / dimSums(demFeSectorNonLdv, dim = 3, na.rm = T) - - # calculate share for Bunkers ---- - - # liquids for bunkers - demFeSectorBunkers <- mselect(demFeSector, - all_enty = c("seliqfos", "seliqbio", "seliqsyn"), - all_enty1 = "fedie", emi_sectors = "trans", all_emiMkt = "other" - ) - - feShareBunkersLiqFos <- demFeSectorBunkers[, , "seliqfos.fedie"] / dimSums(demFeSectorBunkers, dim = 3, na.rm = T) - feShareBunkersLiqBio <- dimSums(mselect(demFeSectorBunkers, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * bioShareTrans / dimSums(demFeSectorBunkers, dim = 3, na.rm = T) - feShareBunkersLiqSyn <- dimSums(mselect(demFeSectorBunkers, all_enty = c("seliqbio", "seliqsyn")), dim = 3, na.rm = T) * synShareTrans / dimSums(demFeSectorBunkers, dim = 3, na.rm = T) - - m <- as.magpie(df) - y <- intersect(getItems(m, dim = 2), getItems(demFeSector, dim = 2)) - tmp <- mbind( - setNames(m[, y, "Pass|Road|LDV|Liquids"] * feShareLdvLiqFos[, y, ], "Pass|Road|LDV|Liquids|Fossil"), - setNames(m[, y, "Pass|Road|LDV|Liquids"] * feShareLdvLiqBio[, y, ], "Pass|Road|LDV|Liquids|Biomass"), - setNames(m[, y, "Pass|Road|LDV|Liquids"] * feShareLdvLiqSyn[, y, ], "Pass|Road|LDV|Liquids|Hydrogen"), - setNames(m[, y, "Freight|Road|Liquids"] * feShareNonLdvLiqFos[, y, ], "Freight|Road|Liquids|Fossil"), - setNames(m[, y, "Freight|Road|Liquids"] * feShareNonLdvLiqBio[, y, ], "Freight|Road|Liquids|Biomass"), - setNames(m[, y, "Freight|Road|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Freight|Road|Liquids|Hydrogen"), - setNames(m[, y, "Pass|Road|Bus|Liquids"] * feShareNonLdvLiqFos[, y, ], "Pass|Road|Bus|Liquids|Fossil"), - setNames(m[, y, "Pass|Road|Bus|Liquids"] * feShareNonLdvLiqBio[, y, ], "Pass|Road|Bus|Liquids|Biomass"), - setNames(m[, y, "Pass|Road|Bus|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Pass|Road|Bus|Liquids|Hydrogen"), - setNames(m[, y, "Freight|Rail|Liquids"] * feShareNonLdvLiqFos[, y, ], "Freight|Rail|Liquids|Fossil"), - setNames(m[, y, "Freight|Rail|Liquids"] * feShareNonLdvLiqBio[, y, ], "Freight|Rail|Liquids|Biomass"), - setNames(m[, y, "Freight|Rail|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Freight|Rail|Liquids|Hydrogen"), - setNames(m[, y, "Pass|Rail|Liquids"] * feShareNonLdvLiqFos[, y, ], "Pass|Rail|Liquids|Fossil"), - setNames(m[, y, "Pass|Rail|Liquids"] * feShareNonLdvLiqBio[, y, ], "Pass|Rail|Liquids|Biomass"), - setNames(m[, y, "Pass|Rail|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Pass|Rail|Liquids|Hydrogen"), - setNames(m[, y, "Pass|Aviation|Domestic|Liquids"] * feShareNonLdvLiqFos[, y, ], "Pass|Aviation|Domestic|Liquids|Fossil"), - setNames(m[, y, "Pass|Aviation|Domestic|Liquids"] * feShareNonLdvLiqBio[, y, ], "Pass|Aviation|Domestic|Liquids|Biomass"), - setNames(m[, y, "Pass|Aviation|Domestic|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Pass|Aviation|Domestic|Liquids|Hydrogen"), - setNames(m[, y, "Freight|Navigation|Liquids"] * feShareNonLdvLiqFos[, y, ], "Freight|Navigation|Liquids|Fossil"), - setNames(m[, y, "Freight|Navigation|Liquids"] * feShareNonLdvLiqBio[, y, ], "Freight|Navigation|Liquids|Biomass"), - setNames(m[, y, "Freight|Navigation|Liquids"] * feShareNonLdvLiqSyn[, y, ], "Freight|Navigation|Liquids|Hydrogen"), - setNames(m[, y, "Pass|Aviation|International|Liquids"] * feShareBunkersLiqFos[, y, ], "Pass|Aviation|International|Liquids|Fossil"), - setNames(m[, y, "Pass|Aviation|International|Liquids"] * feShareBunkersLiqBio[, y, ], "Pass|Aviation|International|Liquids|Biomass"), - setNames(m[, y, "Pass|Aviation|International|Liquids"] * feShareBunkersLiqSyn[, y, ], "Pass|Aviation|International|Liquids|Hydrogen"), - setNames(m[, y, "Freight|International Shipping|Liquids"] * feShareBunkersLiqFos[, y, ], "Freight|International Shipping|Liquids|Fossil"), - setNames(m[, y, "Freight|International Shipping|Liquids"] * feShareBunkersLiqBio[, y, ], "Freight|International Shipping|Liquids|Biomass"), - setNames(m[, y, "Freight|International Shipping|Liquids"] * feShareBunkersLiqSyn[, y, ], "Freight|International Shipping|Liquids|Hydrogen") - ) - - as.data.frame(tmp, rev = 2) %>% - as.data.table() %>% - prepare4MIF("EJ/yr", ".value", "variable") %>% - return() - } - - report_liquids_split <- .split_liquids(df) - - report_liquids_split_w <- report_liquids_split[,.(value = sum(value), region = "World"), by = .(model, scenario, variable, unit, period)] - report_liquids_split <- rbind(report_liquids_split, report_liquids_split_w) - - } - - ## add World - report_w = report[,.(value = sum(value), region = "World"), by = .(model, scenario, variable, unit, period)] - report = rbind(report, report_w) - - report_tech_w = report_tech[,.(value = sum(value), region = "World"), by = .(model, scenario, variable, unit, period)] - report_tech = rbind(report_tech, report_tech_w) - - if (mode == "FE") { - report_complete <- rbindlist(list(report, report_tech, report_liquids_split)) - } else { - report_complete <- rbindlist(list(report, report_tech)) - } - - - ## in case the aggregation features EU sub-regions, include also the aggregated versions - return(report_complete) - } - - - ## Demand emissions - reportingEmi <- function(repFE, gdx){ - - ## load emission factors for fossil fuels - p_ef_dem <- readgdx(gdx, "p_ef_dem")[all_enty %in% c("fepet", "fedie", "fegas")] ## MtCO2/EJ - p_ef_dem[all_enty == "fegas", all_enty := "fegat"] - setnames(p_ef_dem, old = c("value", "all_regi"), new = c("ef", "region")) - ## attribute explicitly fuel used to the FE values - emidem = repFE[grepl("Liquids|Gases|Hydrogen|Electricity", variable) & region != "World"] ## EJ - emidem[, all_enty := ifelse(grepl("Liquids", variable), "fedie", NA)] - emidem[, all_enty := ifelse(grepl("LDV.+Liquids", variable), "fepet", all_enty)] - emidem[, all_enty := ifelse(grepl("Gases", variable), "fegat", all_enty)] - emidem[, all_enty := ifelse(grepl("Electricity", variable), "feelt", all_enty)] - emidem[, all_enty := ifelse(grepl("Hydrogen", variable), "feh2t", all_enty)] - ## merge with emission factors - emidem = emidem[p_ef_dem, on = c("all_enty","region")] - ## calculate emissions and attribute variable and unit names - emidem[, value := value*ef][, c("variable", "unit") := list(gsub("FE", "Emi\\|CO2", variable), "Mt CO2/yr")] - - emi = rbind(copy(emidem)[, c("type", "variable") := list("tailpipe", paste0(variable, "|Tailpipe"))], - copy(emidem)[, c("type", "variable") := list("demand", paste0(variable, "|Demand"))]) - - prodFe <- readgdx(gdx, "vm_prodFE")[, ttot := as.numeric(ttot)] - setnames(prodFe, - c("period", "region", "se", "all_enty", "te", "fe_demand")) - prodFe[, se_share := fe_demand/sum(fe_demand), by=c("period", "region", "all_enty")] - prodFe <- prodFe[all_enty %in% c("fedie", "fepet", "fegat") & se %in% c("segafos", "seliqfos")][, c("se", "te", "fe_demand") := NULL] - - emi <- prodFe[emi, on=c("period", "region", "all_enty")] - ## in case no fossil fuels are used (e.g. 100% biodiesel), the value in se_share results NA. set the NA value to 0 - emi[is.na(se_share), se_share := 0] - emi <- emi[all_enty %in% c("fedie", "fepet", "fegat") & type == "demand", value := value*se_share] - - emi[, c("se_share", "type", "ef", "all_enty") := NULL] - - ## aggregate removing the fuel dependency - emi[, variable_agg := gsub("\\|Liquids|\\|Electricity|\\|Hydrogen|\\|Gases", "", variable)] - emi = emi[, .(value = sum(value)), by = c("model", "scenario", "region", "unit", "period", "variable_agg")] - setnames(emi, old = "variable_agg", new = "variable") - emi = emi[, .(model, scenario, region, variable, unit, period, value)] - - ## add World - emi_w = emi[,.(value = sum(value), region = "World"), by = .(model, scenario, variable, unit, period)] - emi = rbind(emi, emi_w) - - return(emi) - } - - reportingVehNum <- function(demand_vkm, annual_mileage){ - venum <- copy(demand_vkm) - ## merge annual mileage - anmil <- copy(annual_mileage) - anmil[grepl("Subcompact", vehicle_type), - variable := "Pass|Road|LDV|Small"] - anmil[grepl("Mini", vehicle_type), - variable := "Pass|Road|LDV|Mini"] - anmil[vehicle_type == "Compact Car", variable := "Pass|Road|LDV|Medium"] - anmil[grepl("Large Car|Midsize Car", vehicle_type), variable := "Pass|Road|LDV|Large"] - anmil[grepl("SUV", vehicle_type), - variable := "Pass|Road|LDV|SUV"] - anmil[grepl("Van|Multipurpose", vehicle_type), - variable := "Pass|Road|LDV|Van"] - anmil[grepl("Motorcycle|Scooter|Moped", vehicle_type), - variable := "Pass|Road|LDV|Two-Wheelers"] - anmil[grepl("^Truck", vehicle_type), - variable := sprintf("Freight|Road|%s", vehicle_type)] - anmil[grepl("Bus", vehicle_type), - variable := "Pass|Road|Bus"] - - anmil <- anmil[,.(region, period = year, variable, annual_mileage)] - - anmil <- approx_dt(anmil, unique(demand_vkm$period), xcol = "period", ycol = "annual_mileage", idxcols = c("region", "variable"), extrapolate = T) - anmil<- unique(anmil[,c("period", "region", "variable", "annual_mileage")]) - anmil <- anmil[, variable := paste0("ES|Transport|VKM|", variable)] - venum <- merge(demand_vkm, anmil, by = c("variable", "region", "period")) - venum[, ven := value/annual_mileage] # billion vehicle-km -> thousand vehicles - - venum <- venum[!is.na(ven)] - venum[, variable := gsub("|VKM", "|VNUM", variable, fixed=TRUE)][, c("value", "annual_mileage") := NULL] - venum[, unit := "tsd veh"] - setnames(venum, "ven", "value") - venum = venum[,.(model, scenario, region, variable, unit, period, value)] - return(venum) - } - - reportStockAndSales <- function(annual_mileage){ - vintages_file <- file.path(output_folder, "vintcomp.csv") - if(!file.exists(vintages_file)){ - print("EDGE-T Reporting: No vintages file found.") - return(NULL) - } - - year_c <- construction_year <- Stock <- Sales <- vintage_demand_vkm <- fct <- category <- NULL - vintgs <- fread(vintages_file) - - ## backward compat. fix - fct <- 1. - if("variable" %in% colnames(vintgs)){ - fct <- 1e-6 - setnames(vintgs, "variable", "construction_year") - } - - vintgs[, year_c := as.numeric(gsub("C_", "", construction_year))] - - ## stock is the full stock up to the end of the current year - ## sales are the sales of the current year - - setnames(vintgs, "full_demand_vkm", "Stock") - vintgs[, Stock := Stock * fct] - vintgs[, Sales := Stock - sum(vintage_demand_vkm), by=.(year, region, vehicle_type, technology)] - vintgs[, c("construction_year", "vintage_demand_vkm", "year_c") := NULL] - vintgs <- unique(vintgs) - - vintgs <- data.table::melt(vintgs, measure.vars = c("Stock", "Sales"), variable.name = "category") - ## vkm -> v-num - vintgs = merge(vintgs, annual_mileage, by = c("year", "region", "vehicle_type")) - vintgs[, value := value / annual_mileage] - vintgs[, variable := ifelse( - vehicle_type == "Bus_tmp_vehicletype", - sprintf("%s|Transport|Bus|%s", category, technology), - sprintf("%s|Transport|LDV|%s|%s", category, vehicle_type, technology))] - - ## totals - vintgs <- rbindlist(list( - vintgs, - vintgs[, .(value=sum(value), variable=gsub("(.+)\\|.+$", "\\1", variable)), - by=c("category", "year", "region", "vehicle_type")], - vintgs[grepl("|LDV|", variable, fixed=TRUE), - .(value=sum(value), variable=sprintf("%s|Transport|LDV", category)), - by=c("category", "year", "region")]), fill=TRUE) - - vintgs[, c("vehicle_type", "technology", "annual_mileage", "category") := NULL] - vintgs <- unique(vintgs[!is.na(value)]) - - setnames(vintgs, "year", "period") - - vintgs = approx_dt(vintgs, c(2005, 2010, unique(vintgs$period), 2110, 2130, 2150), - xcol = "period", ycol = "value", idxcols = c("region", "variable"), extrapolate = T) - vintgs[period <= 2010|period > 2100, value := 0] - - ## remove the variable (e.g. vehicle_types) that are not present for this specific region - vintgs[, `:=`(model=cfg$model_name, scenario=cfg$title, unit="Million vehicles")] - - return(vintgs) - - } - - repFE <- reportingESandFE( - demand_ej, - mode ="FE") - - repVKM <- reportingESandFE( - datatable=demand_vkm, - mode="VKM") - - toMIF <- rbindlist(list( - repFE, - repVKM, - reportingESandFE( - datatable=demand_km, - mode="ES"), - reportingVehNum(repVKM, - annual_mileage), - reportingEmi(repFE = repFE, - gdx = gdx) - )) - - - ## add Road Totals - toMIF <- rbindlist(list( - toMIF, - toMIF[grep("ES\\|Transport\\|Pass\\|Road\\|[A-Za-z-]+$", variable), - .(variable="ES|Transport|Pass|Road", - unit="bn pkm/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|Pass\\|Road\\|[A-Za-z-]+\\|Tailpipe$", variable), - .(variable="Emi|CO2|Transport|Pass|Road|Tailpipe", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|Pass\\|Road\\|[A-Za-z-]+\\|Demand$", variable), - .(variable="Emi|CO2|Transport|Pass|Road|Demand", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("ES\\|Transport\\|VKM\\|Pass\\|Road\\|[A-Za-z-]+$", variable), - .(variable="ES|Transport|VKM|Pass|Road", - unit="bn vkm/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("FE\\|Transport\\|Pass\\|Road\\|[A-Za-z-]+$", variable), - .(variable="FE|Transport|Pass|Road", - unit="EJ/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")]), use.names = TRUE) - - ## VKM totals, Road and Rail - toMIF <- rbindlist(list( - toMIF, - toMIF[grep("ES\\|Transport\\|VKM\\|(Pass|Freight)\\|Road$", variable), - .(variable="ES|Transport|VKM|Road", - unit="bn vkm/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("ES\\|Transport\\|VKM\\|(Pass|Freight)\\|Rail$", variable), - .(variable="ES|Transport|VKM|Rail", - unit="bn vkm/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")] - ), use.names = TRUE) - - toMIF <- rbindlist(list( - toMIF, - toMIF[grep("FE\\|Transport\\|(Pass|Freight)\\|Road$", variable), - .(variable="FE|Transport|Road", - unit="EJ/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|(Pass|Freight)\\|Road\\|Tailpipe$", variable), - .(variable="Emi|CO2|Transport|Road|Tailpipe", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|(Pass|Freight)\\|Rail\\|Tailpipe$", variable), - .(variable="Emi|CO2|Transport|Rail|Tailpipe", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|(Pass|Freight)\\|Road\\|Demand$", variable), - .(variable="Emi|CO2|Transport|Road|Demand", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("Emi\\|CO2\\|Transport\\|(Pass|Freight)\\|Rail\\|Demand$", variable), - .(variable="Emi|CO2|Transport|Rail|Demand", - unit="Mt CO2/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")], - toMIF[grep("FE\\|Transport\\|(Pass|Freight)\\|Rail$", variable), - .(variable="FE|Transport|Rail", - unit="EJ/yr", value=sum(value)), - by=c("model", "scenario", "region", "period")]), use.names = TRUE) - - toMIF <- rbindlist(list(toMIF, reportStockAndSales(annual_mileage)), use.names=TRUE) - - - if (!is.null(regionSubsetList)){ - toMIF <- rbindlist(list( - toMIF, - toMIF[region %in% regionSubsetList[["EUR"]],.(value = sum(value), region = "EUR"), by = .(model, scenario, variable, unit, period)], - toMIF[region %in% regionSubsetList[["NEU"]],.(value = sum(value), region = "NEU"), by = .(model, scenario, variable, unit, period)], - toMIF[region %in% regionSubsetList[["EU27"]],.(value = sum(value), region = "EU27"), by = .(model, scenario, variable, unit, period)] - ), use.names=TRUE) - } - - - ## Make sure there are no duplicates! - idx <- anyDuplicated(toMIF, by = c("region", "variable", "period")) - if(idx){ - warning(paste0("Duplicates found in EDGE-T reporting output:", - capture.output(toMIF[idx]), collapse="\n")) - } - - toMIF <- data.table::dcast(toMIF, ... ~ period, value.var="value") - setnames(toMIF, colnames(toMIF)[1:5], c("Model", "Scenario", "Region", "Variable", "Unit")) - - if(append){ - name_mif <- list.files(output_folder, pattern = "REMIND_generic", full.names = F) %>% - .[!grepl("withoutPlu|adjustedPolicy", .)] - stopifnot(!is.na(name_mif) && length(name_mif) == 1) - - name_mif <- file.path(output_folder, name_mif) - - - writeMIF(toMIF, name_mif, append=T) - deletePlus(name_mif, writemif=T) - }else{ - return(as.quitte(toMIF)) - } -} diff --git a/R/reportFE.R b/R/reportFE.R index bd125920..5c73556b 100644 --- a/R/reportFE.R +++ b/R/reportFE.R @@ -305,10 +305,6 @@ reportFE <- function(gdx, regionSubsetList = NULL, setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fepet"),all_enty="seliqfos",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|LDV|Liquids|+|Fossil (EJ/yr)"), setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fepet"),all_enty="seliqsyn",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|LDV|Liquids|+|Hydrogen (EJ/yr)"), - setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fedie"),all_enty="seliqbio",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|non-LDV|Liquids|+|Biomass (EJ/yr)"), - setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fedie"),all_enty="seliqfos",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|non-LDV|Liquids|+|Fossil (EJ/yr)"), - setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fedie"),all_enty="seliqsyn",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|non-LDV|Liquids|+|Hydrogen (EJ/yr)"), - # transport gases setNames((dimSums(mselect(vm_demFeSector,all_enty1="fegat",emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|+|Gases (EJ/yr)"), setNames((dimSums(mselect(vm_demFeSector,all_enty1="fegat",all_enty="segabio",emi_sectors="trans"),dim=3,na.rm=T)), "FE|Transport|Gases|+|Biomass (EJ/yr)"), @@ -446,8 +442,8 @@ reportFE <- function(gdx, regionSubsetList = NULL, # quick fix: to avoid duplicates of this variable with the version with a "+" below in case of transport complex: only calculate this in case of edge_esm being used: out <- mbind(out, - setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fepet"),emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|LDV|Liquids (EJ/yr)"), - setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fedie"),emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|non-LDV|Liquids (EJ/yr)")) + setNames((dimSums(mselect(vm_demFeSector,all_enty1=c("fepet"),emi_sectors="trans") ,dim=3,na.rm=T)), "FE|Transport|LDV|Liquids (EJ/yr)") + ) @@ -521,7 +517,7 @@ reportFE <- function(gdx, regionSubsetList = NULL, getNames(out)[grep("FE\\|Transport\\|ESR", getNames(out))], function(x) { setNames(out[, , x], gsub("FE\\|Transport\\|ESR", - "FE\\|Transport\\|w/o Bunkers", x)) + "FE\\|Transport", x)) } ) ) @@ -538,7 +534,7 @@ reportFE <- function(gdx, regionSubsetList = NULL, out <- mbind(out, var_without_Bunkers, var_with_Bunkers) ## out <- mbind(out, - setNames(out[, , "FE|Transport|++|ESR (EJ/yr)"], "FE|Transport|w/o Bunkers (EJ/yr)"), + setNames(out[, , "FE|Transport|++|ESR (EJ/yr)"], "FE|Transport (EJ/yr)"), setNames(out[, , "FE|Transport|++|Outside ETS and ESR (EJ/yr)"], "FE|Transport|Bunkers (EJ/yr)") ) out <- mbind(out, diff --git a/R/reportPrices.R b/R/reportPrices.R index 6556ed3f..6f563210 100644 --- a/R/reportPrices.R +++ b/R/reportPrices.R @@ -342,7 +342,6 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, fe = c( fehos = "Liquids", fepet = "LDV|Liquids", - fedie = "non-LDV|Liquids", fesos = "Solids", feels = "Electricity", feelt = "Electricity", @@ -360,7 +359,6 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, fegas = "Stationary|Gases", fehes = "Stationary|Heat", fepet = "Transport|LDV|Liquids", - fedie = "Transport|non-LDV|Liquids", feelt = "Transport|Electricity", feh2t = "Transport|Hydrogen", fegat = "Transport|Gases" @@ -943,12 +941,7 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, "Price|Final Energy|Industry|Solids (US$2005/GJ)" = "FE|Industry|Solids (EJ/yr)" ) - # transport-specific mappings depending on realization - if (module2realisation["transport",2] == "complex") { - int2ext <- c(int2ext, - "Price|Final Energy|Transport|Liquids|HDV (US$2005/GJ)" = "FE|Transport|non-LDV|Liquids (EJ/yr)", - "Price|Final Energy|Transport|Liquids|LDV (US$2005/GJ)" = "FE|Transport|LDV|Liquids (EJ/yr)") - } else if (module2realisation["transport",2] == "edge_esm") { + if (module2realisation["transport",2] == "edge_esm") { int2ext <- c(int2ext, "Price|Final Energy|Transport|Liquids|HDV (US$2005/GJ)" = "FE|Transport|Diesel Liquids (EJ/yr)", "Price|Final Energy|Transport|Liquids|LDV (US$2005/GJ)" = "FE|Transport|Pass|Liquids (EJ/yr)") diff --git a/R/reportTax.R b/R/reportTax.R index e924178a..8d80e89a 100644 --- a/R/reportTax.R +++ b/R/reportTax.R @@ -73,7 +73,6 @@ reportTax <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060,5) Industry = commonFinalEnergyVariables, Transportation = c( "Liquids|LDV" = "fepet", - "Liquids|non-LDV" = "fedie", Gases = "fegat", Hydrogen = "feh2t", Electricity = "feelt" @@ -151,12 +150,10 @@ reportTax <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060,5) # transportation liquids aggregations out <- mbind( out, - setNames(out[,,"Taxes|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Taxes|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"] , "Taxes|Final Energy|Transportation|Liquids (billion US$2005/yr)"), - setNames(out[,,"Subsidies|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Subsidies|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"], "Subsidies|Final Energy|Transportation|Liquids (billion US$2005/yr)"), - setNames((out[,,"Tax rate|Final Energy|Transportation|Liquids|LDV (US$2005/GJ)"]*out[,,"Taxes|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Tax rate|Final Energy|Transportation|Liquids|non-LDV (US$2005/GJ)"]*out[,,"Taxes|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"])/ - (out[,,"Taxes|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Taxes|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"]) , "Tax rate|Final Energy|Transportation|Liquids (US$2005/GJ)"), - setNames((out[,,"Subsidy Rate|Final Energy|Transportation|Liquids|LDV (US$2005/GJ)"]*out[,,"Subsidies|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Subsidy Rate|Final Energy|Transportation|Liquids|non-LDV (US$2005/GJ)"]*out[,,"Subsidies|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"])/ - (out[,,"Subsidies|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] + out[,,"Subsidies|Final Energy|Transportation|Liquids|non-LDV (billion US$2005/yr)"]) , "Subsidy Rate|Final Energy|Transportation|Liquids (US$2005/GJ)") + setNames(out[,,"Taxes|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] , "Taxes|Final Energy|Transportation|Liquids (billion US$2005/yr)"), + setNames(out[,,"Subsidies|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"] , "Subsidies|Final Energy|Transportation|Liquids (billion US$2005/yr)"), + setNames((out[,,"Tax rate|Final Energy|Transportation|Liquids|LDV (US$2005/GJ)"]*out[,,"Taxes|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"]) , "Tax rate|Final Energy|Transportation|Liquids (US$2005/GJ)"), + setNames((out[,,"Subsidy Rate|Final Energy|Transportation|Liquids|LDV (US$2005/GJ)"]*out[,,"Subsidies|Final Energy|Transportation|Liquids|LDV (billion US$2005/yr)"]) , "Subsidy Rate|Final Energy|Transportation|Liquids (US$2005/GJ)") ) # total taxes/subsidies final energy diff --git a/inst/compareScenarios/cs_05_energy_demand.Rmd b/inst/compareScenarios/cs_05_energy_demand.Rmd index 5b47d4d8..1661035c 100644 --- a/inst/compareScenarios/cs_05_energy_demand.Rmd +++ b/inst/compareScenarios/cs_05_energy_demand.Rmd @@ -379,9 +379,9 @@ items_synliq <- c( "FE|Transport|Pass|Road|Bus|Liquids|Hydrogen", "FE|Transport|Freight|Rail|Liquids|Hydrogen", "FE|Transport|Pass|Rail|Liquids|Hydrogen", - "FE|Transport|Pass|Aviation|Domestic|Liquids|Hydrogen", - "FE|Transport|Pass|Aviation|International|Liquids|Hydrogen", - "FE|Transport|Freight|International Shipping|Liquids|Hydrogen", + "FE|Transport|Pass|Domestic Aviation|Liquids|Hydrogen", + "FE|Transport|Bunkers|Pass|International Aviation|Liquids|Hydrogen", + "FE|Transport|Bunkers|Freight|International Shipping|Liquids|Hydrogen", NULL ) @@ -397,9 +397,9 @@ items_bioliq <- c( "FE|Transport|Pass|Road|Bus|Liquids|Biomass", "FE|Transport|Freight|Rail|Liquids|Biomass", "FE|Transport|Pass|Rail|Liquids|Biomass", - "FE|Transport|Pass|Aviation|Domestic|Liquids|Biomass", - "FE|Transport|Pass|Aviation|International|Liquids|Biomass", - "FE|Transport|Freight|International Shipping|Liquids|Biomass", + "FE|Transport|Pass|Domestic Aviation|Liquids|Biomass", + "FE|Transport|Bunkers|Pass|International Aviation|Liquids|Biomass", + "FE|Transport|Bunkers|Freight|International Shipping|Liquids|Biomass", NULL ) @@ -424,21 +424,21 @@ showLinePlots(data, "FE|Transport|Electricity|Share") ### Basics -- w/o Bunkers ```{r Basics -- w/o Bunkers} -tot <- "FE|Transport|w/o Bunkers" +tot <- "FE|Transport" items <- c( - "FE|Transport|w/o Bunkers|Electricity", - "FE|Transport|w/o Bunkers|Hydrogen", - "FE|Transport|w/o Bunkers|Gases", - "FE|Transport|w/o Bunkers|Liquids", + "FE|Transport|Electricity", + "FE|Transport|Hydrogen", + "FE|Transport|Gases", + "FE|Transport|Liquids", NULL ) items2 <- c( - "FE|Transport|w/o Bunkers|Electricity", - "FE|Transport|w/o Bunkers|Hydrogen", - "FE|Transport|w/o Bunkers|Gases", - "FE|Transport|w/o Bunkers|Liquids|Biomass", - "FE|Transport|w/o Bunkers|Liquids|Fossil", - "FE|Transport|w/o Bunkers|Liquids|Hydrogen", + "FE|Transport|Electricity", + "FE|Transport|Hydrogen", + "FE|Transport|Gases", + "FE|Transport|Liquids|Biomass", + "FE|Transport|Liquids|Fossil", + "FE|Transport|Liquids|Hydrogen", NULL ) ``` @@ -470,10 +470,6 @@ items <- c( "FE|Transport|LDV|Hydrogen", "FE|Transport|LDV|Gases", "FE|Transport|LDV|Liquids", - "FE|Transport|non-LDV|Electricity", - "FE|Transport|non-LDV|Hydrogen", - "FE|Transport|non-LDV|Gases", - "FE|Transport|non-LDV|Liquids", NULL ) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") @@ -482,9 +478,9 @@ showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ### Bunkers ```{r FE Transport Bunkers} -tot <- "FE|Transport" +tot <- "FE|Transport with bunkers" items <- c( "FE|Transport|Bunkers", - "FE|Transport|w/o Bunkers") + "FE|Transport") showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` diff --git a/inst/compareScenarios/cs_06_energy_services.Rmd b/inst/compareScenarios/cs_06_energy_services.Rmd index d863e9ec..37306944 100644 --- a/inst/compareScenarios/cs_06_energy_services.Rmd +++ b/inst/compareScenarios/cs_06_energy_services.Rmd @@ -157,8 +157,7 @@ showMultiLinePlotsByVariable(data, items, "GDP|PPP pCap") ```{r ES Transport} items <- c( "ES|Transport|Pass pCap", - "ES|Transport|Pass|Road|LDV pCap", - "ES|Transport|Pass|non-LDV pCap") + "ES|Transport|Pass|Road|LDV pCap") showMultiLinePlots(data, items) showMultiLinePlotsByVariable(data, items, "GDP|PPP pCap") ``` @@ -169,7 +168,7 @@ items <- c( "ES|Transport|Pass|Road|LDV|BEV pCap", "ES|Transport|Pass|Road|LDV|FCEV pCap", "ES|Transport|Pass|Road|LDV|Gases pCap", - "ES|Transport|Pass|Road|LDV|Hybrid Electric pCap", + "ES|Transport|Pass|Road|LDV|Hybrid electric pCap", "ES|Transport|Pass|Road|LDV|Liquids pCap") showAreaAndBarPlots(data, items, orderVars = "user", scales = "fixed") ``` @@ -194,13 +193,13 @@ showAreaAndBarPlots(data, items, orderVars = "user", scales = "fixed") ### LDV Vehicles Stock - EDGE-T ```{r LDV Vehicles Stock - EDGE-T} -tot <- "Stock|Transport|LDV" +tot <- "Stock|Transport|Pass|Road|LDV" items <- c( - "Stock|Transport|LDV|BEV", - "Stock|Transport|LDV|Hybrid Electric", - "Stock|Transport|LDV|FCEV", - "Stock|Transport|LDV|NG", - "Stock|Transport|LDV|Liquids", + "Stock|Transport|Pass|Road|LDV|BEV", + "Stock|Transport|Pass|Road|LDV|Hybrid electric", + "Stock|Transport|Pass|Road|LDV|FCEV", + "Stock|Transport|Pass|Road|LDV|Gases", + "Stock|Transport|Pass|Road|LDV|Liquids", NULL) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` @@ -217,13 +216,13 @@ showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ### LDV Vehicles Sales - EDGE-T ```{r LDV Vehicles Sales - EDGE-T} -tot <- "Sales|Transport|LDV" +tot <- "Sales|Transport|Pass|Road|LDV" items <- c( - "Sales|Transport|LDV|BEV", - "Sales|Transport|LDV|Hybrid Electric", - "Sales|Transport|LDV|FCEV", - "Sales|Transport|LDV|NG", - "Sales|Transport|LDV|Liquids", + "Sales|Transport|Pass|Road|LDV|BEV", + "Sales|Transport|Pass|Road|LDV|Hybrid electric", + "Sales|Transport|Pass|Road|LDV|FCEV", + "Sales|Transport|Pass|Road|LDV|Gases", + "Sales|Transport|Pass|Road|LDV|Liquids", NULL ) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") @@ -241,72 +240,52 @@ showAreaAndBarPlots(data, items, tot, scales = "fixed") ### Truck Stock - EDGE-T ```{r Truck Stock} -tot <- "Stock|Transport|Truck" +tot <- "Stock|Transport|Freight|Road" items <- c( - "Stock|Transport|Truck|Electric", - "Stock|Transport|Truck|FCEV", - "Stock|Transport|Truck|NG", - "Stock|Transport|Truck|Liquids", + "Stock|Transport|Freight|Road|Electric", + "Stock|Transport|Freight|Road|FCEV", + "Stock|Transport|Freight|Road|Gases", + "Stock|Transport|Freight|Road|Liquids", NULL) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` ### Truck Sales - EDGE-T ```{r Truck Sales} -tot <- "Sales|Transport|Truck" +tot <- "Sales|Transport|Freight|Road" items <- c( - "Sales|Transport|Truck|Electric", - "Sales|Transport|Truck|FCEV", - "Sales|Transport|Truck|NG", - "Sales|Transport|Truck|Liquids", + "Sales|Transport|Freight|Road|Electric", + "Sales|Transport|Freight|Road|FCEV", + "Sales|Transport|Freight|Road|Gases", + "Sales|Transport|Freight|Road|Liquids", NULL) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` ### Bus Stock - EDGE-T ```{r Bus Stock} -tot <- "Stock|Transport|Bus" +tot <- "Stock|Transport|Pass|Road|Bus" items <- c( - "Stock|Transport|Bus|Electric", - "Stock|Transport|Bus|FCEV", - "Stock|Transport|Bus|NG", - "Stock|Transport|Bus|Liquids", + "Stock|Transport|Pass|Road|Bus|Electric", + "Stock|Transport|Pass|Road|Bus|FCEV", + "Stock|Transport|Pass|Road|Bus|Gases", + "Stock|Transport|Pass|Road|Bus|Liquids", NULL) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` ### Bus Sales - EDGE-T ```{r Bus Sales} -tot <- "Sales|Transport|Bus" +tot <- "Sales|Transport|Pass|Road|Bus" items <- c( - "Sales|Transport|Bus|Electric", - "Sales|Transport|Bus|FCEV", - "Sales|Transport|Bus|NG", - "Sales|Transport|Bus|Liquids", + "Sales|Transport|Pass|Road|Bus|Electric", + "Sales|Transport|Pass|Road|Bus|FCEV", + "Sales|Transport|Pass|Road|Bus|Gases", + "Sales|Transport|Pass|Road|Bus|Liquids", NULL) showAreaAndBarPlots(data, items, tot, orderVars = "user", scales = "fixed") ``` -### non-LDV Vehicles Stock - TransportComplex -```{r non-LDV Vehicles Stock} -tot <- "Services and Products|Transport|non-LDV|Stock|uedit" -items <- c( - "Services and Products|Transport|non-LDV|Stock|apCarDiT", - "Services and Products|Transport|non-LDV|Stock|apcarDiEffT", - "Services and Products|Transport|non-LDV|Stock|apcarDiEffH2T") -showAreaAndBarPlots(data, items, tot, scales = "fixed") -``` - -### non-LDV Vehicles Sales - TransportComplex -```{r non-LDV Vehicles Sales} -tot <- "Services and Products|Transport|non-LDV|Sales|uedit" -items <- c( - "Services and Products|Transport|non-LDV|Sales|apCarDiT", - "Services and Products|Transport|non-LDV|Sales|apcarDiEffT", - "Services and Products|Transport|non-LDV|Sales|apcarDiEffH2T") -showAreaAndBarPlots(data, items, tot, scales = "fixed") -``` - ## Industry Production ### Subsector Production ```{r plot industry subsector production} diff --git a/inst/compareScenarios/preprocessing.R b/inst/compareScenarios/preprocessing.R index eed8aa2f..23976986 100644 --- a/inst/compareScenarios/preprocessing.R +++ b/inst/compareScenarios/preprocessing.R @@ -50,14 +50,13 @@ pCapVariables <- tribble( "UE|Buildings|Heating", "GJ/yr", 1e9, "ES|Transport|Pass", "km/yr", 1e9, "ES|Transport|Pass|Road|LDV", "km/yr", 1e9, - "ES|Transport|Pass|non-LDV", "km/yr", 1e9, "ES|Transport|Pass|Road|LDV|BEV", "km/yr", 1e9, "ES|Transport|Pass|Road|LDV|FCEV", "km/yr", 1e9, "ES|Transport|Pass|Road|LDV|Gases", "km/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Hybrid Electric", "km/yr", 1e9, + "ES|Transport|Pass|Road|LDV|Hybrid electric", "km/yr", 1e9, "ES|Transport|Pass|Road|LDV|Liquids", "km/yr", 1e9, "ES|Transport|Freight", "tkm/yr", 1e9, - "ES|Transport|Freight|Road|Electric", "tkm/yr", 1e9, + "ES|Transport|Freight|Road|BEV", "tkm/yr", 1e9, "ES|Transport|Freight|Road|FCEV", "tkm/yr", 1e9, "ES|Transport|Freight|Road|Gases", "tkm/yr", 1e9, "ES|Transport|Freight|Road|Liquids", "tkm/yr", 1e9, diff --git a/man/reportEDGETransport.Rd b/man/reportEDGETransport.Rd deleted file mode 100644 index 0ae81c90..00000000 --- a/man/reportEDGETransport.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reportEDGETransport.R -\name{reportEDGETransport} -\alias{reportEDGETransport} -\title{Reporting for the coupled EDGE-T Transport Sector Model (REMIND Module edge_esm)} -\usage{ -reportEDGETransport(output_folder = ".", remind_root = NULL, append = TRUE) -} -\arguments{ -\item{output_folder}{path to the output folder, default is current folder.} - -\item{remind_root}{path to the REMIND root directory, defaults to two levels up from output_folder.} - -\item{append}{try to find the REMIND output file in the output folder and append to it. If FALSE, the function returns a quitte object with the reporting variables.} -} -\description{ -Data is loaded from the EDGE-T subfolder in the output folder. -The input files can be (re-) generated calling -`Rscript EDGETransport.R --reporting` -from the output folder. -} -\details{ -*Warning* The function modifies the "REMIND_generic_.mif" file by appending the -additional reporting variables and replaces the "_withoutPlus" version. - -Region subsets are obtained from fulldata.gdx -} -\author{ -Alois Dirnaichner Marianna Rottoli -}