Skip to content

Commit

Permalink
Merge pull request #633 from fbenke-pik/update_2024
Browse files Browse the repository at this point in the history
switch to US017 in reporting functions
  • Loading branch information
fbenke-pik authored Sep 23, 2024
2 parents 443e733 + 9e98c8b commit 57c1fa0
Show file tree
Hide file tree
Showing 22 changed files with 696 additions and 698 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '231038160'
ValidationKey: '231092829'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'remind2: The REMIND R package (2nd generation)'
version: 1.156.0
date-released: '2024-09-20'
version: 1.156.1
date-released: '2024-09-23'
abstract: Contains the REMIND-specific routines for data and model output manipulation.
authors:
- family-names: Rodrigues
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: remind2
Title: The REMIND R package (2nd generation)
Version: 1.156.0
Date: 2024-09-20
Version: 1.156.1
Date: 2024-09-23
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down
14 changes: 7 additions & 7 deletions R/readConsumption.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#' Read Consumption from GDX file
#'
#'
#' Read Consumption data from a GDX file into a magpie object.
#'
#'
#'
#'
#' @param gdx a GDX list as created by readGDX, or the file name of a gdx
#' file(file name is recommended as this speeds up the code)
#' @param field one of 'l', 'm', 's', 'lo', 'up'
#' @author Jonas Hoersch
#' @examples
#'
#'
#' \dontrun{cons <- readConsumption(gdx)}
#'
#'
#' @export
#' @importFrom gdx readGDX
#' @importFrom magclass mbind getNames<-
Expand All @@ -19,6 +19,6 @@ readConsumption <- function(gdx, field="l"){
tmp <- readGDX(gdx, name='vm_cons', field=field, format="first_found")
tmp <- tmp * 1000
tmp <- mbind(tmp["GLO",,,invert=T],dimSums(tmp,dim=1))
getNames(tmp) <- "Consumption (billion US$2005/yr)"
getNames(tmp) <- "Consumption (billion US$2017/yr)"
return(tmp)
}
}
8 changes: 4 additions & 4 deletions R/reportCapitalStock.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ reportCapitalStock <- function(gdx,regionSubsetList=NULL,t=c(seq(2005,2060,5),se
if (tran_mod == "complex"){
LDV35 <- readGDX(gdx,name=c("LDV35"),format="first_found")
tmp <- mbind(tmp,setNames(dimSums( (vm_cap * v_investcost)[teue2rlf]
,dim=c(3.1,3.2)) * 1000, "Est Capital Stock|ESM|Transp vehic (billion US$2005)"))
,dim=c(3.1,3.2)) * 1000, "Est Capital Stock|ESM|Transp vehic (billion US$2017)"))
tmp <- mbind(tmp,setNames(dimSums( (vm_cap * v_investcost)[teall2rlf][,,LDV35]
,dim=c(3.1,3.2)) * 1000, "Est Capital Stock|ESM|Pet/EV LDV (billion US$2005)"))
,dim=c(3.1,3.2)) * 1000, "Est Capital Stock|ESM|Pet/EV LDV (billion US$2017)"))

tmp <- mbind(tmp,
setNames(
dimSums(mbind(vm_cap * v_investcost),
dim = 3) * 1000,
"Estimated Capital Stock|ESM (billion US$2005)"
"Estimated Capital Stock|ESM (billion US$2017)"
)
)

Expand Down Expand Up @@ -124,7 +124,7 @@ reportCapitalStock <- function(gdx,regionSubsetList=NULL,t=c(seq(2005,2060,5),se
eek_Ind <- setNames(vm_cesIO[,y,ppfKap_Ind],
paste0('Capital|Energy Efficiency|Industry|',
mixer[mixer$pf %in% ppfKap_Ind,][['name']],
' (billion US$2005)'))
' (billion US$2017)'))
# add industry EEK and global totals
tmp <- mbind(tmp, mbind(eek_Ind, dimSums(eek_Ind, dim = 1)))
}
Expand Down
184 changes: 92 additions & 92 deletions R/reportCosts.R

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions R/reportCrossVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,


tmp <- mbind(tmp,setNames(
output[r,,"Energy Investments (billion US$2005/yr)"]
-output[r,,"Energy Investments|Electricity (billion US$2005/yr)"],"Energy Investments|Non-Electricity (billion US$2005/yr)"))
output[r,,"Energy Investments (billion US$2017/yr)"]
-output[r,,"Energy Investments|Electricity (billion US$2017/yr)"],"Energy Investments|Non-Electricity (billion US$2017/yr)"))
# gas capacity factor
tmp <- mbind(tmp,setNames(
output[r,,"SE|Electricity|Gas (EJ/yr)"] / output[r,,"Cap|Electricity|Gas (GW)"] / TWa_2_EJ * 1000 * 100,
Expand Down Expand Up @@ -143,18 +143,18 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,

setNames(
output[,,"FE (EJ/yr)"] * 1000
/ output[,,"GDP|MER (billion US$2005/yr)"],
"Intensity|GDP|Final Energy (MJ/US$2005)"),
/ output[,,"GDP|MER (billion US$2017/yr)"],
"Intensity|GDP|Final Energy (MJ/US$2017)"),

setNames(
output[,,"GDP|MER (billion US$2005/yr)"]
output[,,"GDP|MER (billion US$2017/yr)"]
/ output[,,"FE (EJ/yr)"],
"Productivity|GDP|MER|Final Energy (US$2005/GJ)"),
"Productivity|GDP|MER|Final Energy (US$2017/GJ)"),

setNames(
output[,,"GDP|PPP (billion US$2005/yr)"]
output[,,"GDP|PPP (billion US$2017/yr)"]
/ output[,,"FE (EJ/yr)"],
"Productivity|GDP|PPP|Final Energy (US$2005/GJ)"),
"Productivity|GDP|PPP|Final Energy (US$2017/GJ)"),

setNames(
output[,,"Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)"]
Expand All @@ -168,18 +168,18 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,

setNames(
output[,,"Emi|GHG (Mt CO2eq/yr)"]
/ output[,,"GDP|MER (billion US$2005/yr)"],
"Intensity|GDP|GHG (Mt CO2-equiv/US$2005)"),
/ output[,,"GDP|MER (billion US$2017/yr)"],
"Intensity|GDP|GHG (Mt CO2-equiv/US$2017)"),

setNames(
output[,,"GDP|MER (billion US$2005/yr)"]
output[,,"GDP|MER (billion US$2017/yr)"]
/ output[,,"Population (million)"],
"GDP|per capita|MER (kUS$2005/per capita)"),
"GDP|per capita|MER (kUS$2017/per capita)"),

setNames(
output[,,"GDP|PPP (billion US$2005/yr)"]
output[,,"GDP|PPP (billion US$2017/yr)"]
/ output[,,"Population (million)"],
"GDP|per capita|PPP (kUS$2005/per capita)"),
"GDP|per capita|PPP (kUS$2017/per capita)"),

setNames(
output[,,"Welfare|Real and undiscounted|Yearly (arbitrary unit/yr)"]
Expand Down Expand Up @@ -232,10 +232,10 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,

# Energy expenditures
tmp <- mbind(tmp,setNames(
output[,,"FE|Transport|Liquids (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Liquids (US$2005/GJ)"] +
output[,,"FE|Transport|Hydrogen (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Hydrogen (US$2005/GJ)"] +
output[,,"FE|Transport|Electricity (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Electricity (US$2005/GJ)"],
"Expenditure|Transport|Fuel (billion US$2005/yr)"))
output[,,"FE|Transport|Liquids (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Liquids (US$2017/GJ)"] +
output[,,"FE|Transport|Hydrogen (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Hydrogen (US$2017/GJ)"] +
output[,,"FE|Transport|Electricity (EJ/yr)"] * output[,,"Price|Final Energy|Transport|Electricity (US$2017/GJ)"],
"Expenditure|Transport|Fuel (billion US$2017/yr)"))

# calculate intensities growth
int_gr <- new.magpie(getRegions(tmp),getYears(tmp),c("Intensity Growth|GDP|Final Energy (% pa)","Intensity Growth|GDP|Final Energy to 2005 (% pa)",
Expand All @@ -246,14 +246,14 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
int_gr[,t,"Intensity Growth|GDP|Final Energy (% pa)"] <-
(
(
(tmp[,t,"Intensity|GDP|Final Energy (MJ/US$2005)"] / setYears(tmp[,(which(getYears(tmp)==t)-1),"Intensity|GDP|Final Energy (MJ/US$2005)"],t))
(tmp[,t,"Intensity|GDP|Final Energy (MJ/US$2017)"] / setYears(tmp[,(which(getYears(tmp)==t)-1),"Intensity|GDP|Final Energy (MJ/US$2017)"],t))
^ (1 / ( getYears(tmp[,t,],as.integer=TRUE) - getYears(tmp[,(which(getYears(tmp)==t)-1),],as.integer=TRUE) ) )
) - 1
) * 100
int_gr[,t,"Intensity Growth|GDP|Final Energy to 2005 (% pa)"] <-
(
(
(tmp[,t,"Intensity|GDP|Final Energy (MJ/US$2005)"] / setYears(tmp[,2005,"Intensity|GDP|Final Energy (MJ/US$2005)"],t))
(tmp[,t,"Intensity|GDP|Final Energy (MJ/US$2017)"] / setYears(tmp[,2005,"Intensity|GDP|Final Energy (MJ/US$2017)"],t))
^ (1 / ( getYears(tmp[,t,],as.integer=TRUE) - 2005 ) )
) - 1
) * 100
Expand All @@ -274,14 +274,14 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
int_gr[,t,"Intensity Growth|GDP|CO2-equiv (% pa)"] <-
(
(
(tmp[,t,"Intensity|GDP|GHG (Mt CO2-equiv/US$2005)"] / setYears(tmp[,(which(getYears(tmp)==t)-1),"Intensity|GDP|GHG (Mt CO2-equiv/US$2005)"],t))
(tmp[,t,"Intensity|GDP|GHG (Mt CO2-equiv/US$2017)"] / setYears(tmp[,(which(getYears(tmp)==t)-1),"Intensity|GDP|GHG (Mt CO2-equiv/US$2017)"],t))
^ (1 / ( getYears(tmp[,t,],as.integer=TRUE) - getYears(tmp[,(which(getYears(tmp)==t)-1),],as.integer=TRUE) ) )
) - 1
) * 100
int_gr[,t,"Intensity Growth|GDP|CO2-equiv to 2005 (% pa)"] <-
(
(
(tmp[,t,"Intensity|GDP|GHG (Mt CO2-equiv/US$2005)"] / setYears(tmp[,2005,"Intensity|GDP|GHG (Mt CO2-equiv/US$2005)"],t))
(tmp[,t,"Intensity|GDP|GHG (Mt CO2-equiv/US$2017)"] / setYears(tmp[,2005,"Intensity|GDP|GHG (Mt CO2-equiv/US$2017)"],t))
^ (1 / ( getYears(tmp[,t,],as.integer=TRUE) - 2005 ) )
) - 1
) * 100
Expand Down Expand Up @@ -335,7 +335,7 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
tribble(
~unit, ~new.unit, ~factor,
'Mt/yr', 't/yr', 1,
'billion US$2005/yr', 'US$2005/yr', 1e-3),
'billion US$2017/yr', 'US$2017/yr', 1e-3),

'unit'
) %>%
Expand All @@ -362,7 +362,7 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
select(-'Cell') %>%
# join with population numbers
left_join(
output[,,'GDP|PPP (billion US$2005/yr)'] %>%
output[,,'GDP|PPP (billion US$2017/yr)'] %>%
as.data.frame() %>%
as_tibble() %>%
select('Region', 'Year', population = 'Value'),
Expand All @@ -375,8 +375,8 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
tribble(
~unit, ~new.unit, ~factor,
# Mt/$bn * 1e6 t/Mt * 1e-3 $bn/$m = t/$m
'Mt/yr', 't/million US$2005', 1e3,
'billion US$2005/yr', 'US$2005/US$2005', 1 # $bn/$bn = $/$
'Mt/yr', 't/million US$2017', 1e3,
'billion US$2017/yr', 'US$2017/US$2017', 1 # $bn/$bn = $/$
),

'unit'
Expand Down
48 changes: 24 additions & 24 deletions R/reportEmployment.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,30 @@ reportEmployment <- function(gdx, improvements, multiplier, subtype, shareManf,
reportTech <- reportTechnology(gdx)
reportTech <- collapseNames(reportTech)
var <- c(
"Tech|Electricity|Coal|Pulverised Coal w/o CC|Capital Costs (US$2005/kW)",
"Tech|Electricity|Gas|Combined Cycle w/o CC|Capital Costs (US$2005/kW)",
"Tech|Electricity|Hydro|Capital Costs (US$2005/kW)",
"Tech|Electricity|Nuclear|Capital Costs (US$2005/kW)",
"Tech|Electricity|Solar|PV|Capital Costs (US$2005/kW)",
"Tech|Electricity|Solar|CSP|Capital Costs (US$2005/kW)",
"Tech|Electricity|Wind|Onshore|Capital Costs (US$2005/kW)",
"Tech|Electricity|Wind|Offshore|Capital Costs (US$2005/kW)",
"Tech|Electricity|Biomass|Combined Heat and Power w/o CC|Capital Costs (US$2005/kW)",
"Tech|Electricity|Storage|Battery|For PV|Capital Costs (US$2005/kW)",
"Tech|Electricity|Oil|DOT|Capital Costs (US$2005/kW)",
"Tech|Electricity|Geothermal|Capital Costs (US$2005/kW)",
"Tech|Electricity|Coal|Pulverised Coal w/o CC|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Gas|Combined Cycle w/o CC|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Hydro|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Nuclear|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Solar|PV|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Solar|CSP|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Wind|Onshore|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Wind|Offshore|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Biomass|Combined Heat and Power w/o CC|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Oil|DOT|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Geothermal|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Storage|Battery|For PV|OM Cost|fixed (US$2005/kW/yr)",
"Tech|Electricity|Coal|Pulverised Coal w/o CC|Capital Costs (US$2017/kW)",
"Tech|Electricity|Gas|Combined Cycle w/o CC|Capital Costs (US$2017/kW)",
"Tech|Electricity|Hydro|Capital Costs (US$2017/kW)",
"Tech|Electricity|Nuclear|Capital Costs (US$2017/kW)",
"Tech|Electricity|Solar|PV|Capital Costs (US$2017/kW)",
"Tech|Electricity|Solar|CSP|Capital Costs (US$2017/kW)",
"Tech|Electricity|Wind|Onshore|Capital Costs (US$2017/kW)",
"Tech|Electricity|Wind|Offshore|Capital Costs (US$2017/kW)",
"Tech|Electricity|Biomass|Combined Heat and Power w/o CC|Capital Costs (US$2017/kW)",
"Tech|Electricity|Storage|Battery|For PV|Capital Costs (US$2017/kW)",
"Tech|Electricity|Oil|DOT|Capital Costs (US$2017/kW)",
"Tech|Electricity|Geothermal|Capital Costs (US$2017/kW)",
"Tech|Electricity|Coal|Pulverised Coal w/o CC|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Gas|Combined Cycle w/o CC|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Hydro|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Nuclear|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Solar|PV|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Solar|CSP|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Wind|Onshore|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Wind|Offshore|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Biomass|Combined Heat and Power w/o CC|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Oil|DOT|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Geothermal|OM Cost|fixed (US$2017/kW/yr)",
"Tech|Electricity|Storage|Battery|For PV|OM Cost|fixed (US$2017/kW/yr)",
NULL
)
# only capital costs
Expand Down
Loading

0 comments on commit 57c1fa0

Please sign in to comment.