Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidhoPIK committed Jul 9, 2024
2 parents a83bb29 + 49417f1 commit 93cbe97
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '28117287'
ValidationKey: '28269360'
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: 'mrcommons: MadRat commons Input Data Library'
version: 1.41.3
date-released: '2024-06-25'
version: 1.42.0
date-released: '2024-07-04'
abstract: Provides useful functions and a common structure to all the input data required
to run models like MAgPIE and REMIND of model input data.
authors:
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: mrcommons
Type: Package
Title: MadRat commons Input Data Library
Version: 1.41.3
Date: 2024-06-25
Version: 1.42.0
Date: 2024-07-04
Authors@R: c(person("Benjamin Leon", "Bodirsky", email = "[email protected]", role = "aut"),
person("Kristine", "Karstens", role = "aut"),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down Expand Up @@ -84,6 +84,6 @@ URL:
BugReports: https://github.com/pik-piam/mrcommons/issues
LazyData: no
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
10 changes: 5 additions & 5 deletions R/calcAtmosphericDeposition.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ calcAtmosphericDeposition <- function(datasource = "ACCMIP", glo_incl_oceans = F
out <- dimOrder(out, perm = c(2, 1))
if (cellular) {
weight <- collapseNames(calcOutput("AtmosphericDeposition", datasource = "ACCMIP", glo = FALSE, cellular = TRUE,
cells = "lpjcell", emission = FALSE, scenario = NULL, aggregate = FALSE))
cells = "lpjcell", emission = FALSE, scenario = NULL, aggregate = FALSE))
commonCtries <- intersect(getItems(weight, dim = "iso"), getItems(out, dim = 1))
out <- out[commonCtries, , ]
getSets(out) <- c("iso", "year", "landuse", "data1")
weight <- weight[, getItems(out, dim = 2), ]
weight <- weight[, , getItems(out, dim = 3)]
coordMapping <- toolGetMappingCoord2Country()
out <- toolAggregate(out, weight = weight,
rel = coordMapping, from = "iso", to = "coords",
partrel = FALSE)
out <- toolAggregate(out, weight = weight + 10^-10,
rel = coordMapping, from = "iso", to = "coords",
partrel = FALSE)
out <- toolCoord2Isocoord(out)
}
}
Expand All @@ -106,5 +106,5 @@ calcAtmosphericDeposition <- function(datasource = "ACCMIP", glo_incl_oceans = F
min = 0,
max = 200,
description = paste0("Atmospheric deposition, natural (1870 levels) and anthropogenic in the ",
"year 1995 (actually 1993) for different landuse classes.")))
"year 1995 (actually 1993) for different landuse classes.")))
}
2 changes: 1 addition & 1 deletion R/calcGrowingStockpha.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ calcGrowingStockpha <- function() {
getNames(area) <- FRAnames(getNames(area))
vars <- intersect(getNames(area), getNames(x))
x <- x[, , vars]
weight <- area[, , vars]
weight <- area[, , vars] + 10^-10

x <- setYears(collapseNames(x[, "y2000", "Plantations"]), NULL)
weight <- setYears(collapseNames(weight[, "y2000", "Plantations"]), NULL)
Expand Down
6 changes: 3 additions & 3 deletions R/calcNitrogenFixationRateNatural.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ calcNitrogenFixationRateNatural <- function(cells = "lpjcell") {

# evapotranspiration (in m^3 per ha)
etRate <- collapseNames(calcOutput("LPJmL_new", version = "LPJmL4_for_MAgPIE_44ac93de",
climatetype = "GSWP3-W5E5:historical", subtype = "aet",
stage = "smoothed", aggregate = FALSE)[, years, ])
climatetype = "GSWP3-W5E5:historical", subtype = "aet",
stage = "smoothed", aggregate = FALSE)[, years, ])

startYear <- "y1965"

Expand All @@ -48,7 +48,7 @@ calcNitrogenFixationRateNatural <- function(cells = "lpjcell") {
}

return(list(x = bnfRate,
weight = dimSums(land, dim = 3),
weight = dimSums(land, dim = 3) + 10^-10,
unit = "Mt Nr / Mha",
description = "Nitrogen fixation freeliving bacteria",
isocountries = FALSE))
Expand Down
10 changes: 5 additions & 5 deletions R/calcPriceAgriculture.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = "
names(dimnames(out))[3] <- "scenario.model.variable"

description <- paste0("Prices from the IMPACT model projections. There are ",
length(ktradeSet) - length(commodities),
" missing MAgPIE commodities: ",
paste(ktradeSet[!ktradeSet %in% commodities], collapse = " "))
length(ktradeSet) - length(commodities),
" missing MAgPIE commodities: ",
paste(ktradeSet[!ktradeSet %in% commodities], collapse = " "))
weight <- NULL
isocountries <- FALSE

Expand Down Expand Up @@ -165,7 +165,7 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = "
qprod[out == 0] <- 0

# weighted aggregation of fao prices to magpie commodities
out <- toolAggregate(out, rel = aggregation, weight = qprod, from = "ProductionItem",
out <- toolAggregate(out, rel = aggregation, weight = qprod + 10^-10, from = "ProductionItem",
to = "k", dim = 3, partrel = TRUE, verbosity = 2)
out <- out[, , -which(getNames(out) %in% c("remaining", "not_clear"), arr.ind = TRUE)]

Expand Down Expand Up @@ -193,7 +193,7 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = "
}

return(list(x = out,
weight = weight,
weight = weight + 10^-10,
unit = unit,
description = description,
isocountries = isocountries))
Expand Down
17 changes: 8 additions & 9 deletions R/calcSOCLossShare.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ calcSOCLossShare <- function(subsystems = FALSE, rate = "change", factor = "ipcc
cells = "lpjcell") {

ipccClimate <- calcOutput("ClimateClass", aggregate = FALSE,
datasource = factor, cells = cells)
datasource = factor, cells = cells)

factor2SCF <- c(ipccReduced = "SCF_sub",
ipccReduced2019 = "SCF_sub2019")
Expand Down Expand Up @@ -52,12 +52,11 @@ calcSOCLossShare <- function(subsystems = FALSE, rate = "change", factor = "ipcc
}

weight <- dimSums(calcOutput("LanduseInitialisation", aggregate = FALSE, cellular = TRUE,
cells = cells, years = "y1995", round = 6), dim = 3)

return(list(
x = socLossShare,
weight = weight,
unit = "tC/tC",
description = "Soil organic carbon loss share per crop type",
isocountries = FALSE))
cells = cells, years = "y1995", round = 6), dim = 3) + 10^-10

return(list(x = socLossShare,
weight = weight,
unit = "tC/tC",
description = "Soil organic carbon loss share per crop type",
isocountries = FALSE))
}
8 changes: 4 additions & 4 deletions R/convertGTAPv8v9.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ convertGTAPv8v9 <- function(x, subtype) {
dim = 3, partrel = TRUE)

if (split$header %in% c("VIWS", "VIMS")) {
w1 <- faoI
w2 <- faoX
w1 <- faoI + 10^-10
w2 <- faoX + 10^-10
} else {
w1 <- faoX
w2 <- faoI
w1 <- faoX + 10^-10
w2 <- faoI + 10^-10
}


Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MadRat commons Input Data Library

R package **mrcommons**, version **1.41.3**
R package **mrcommons**, version **1.42.0**

[![CRAN status](https://www.r-pkg.org/badges/version/mrcommons)](https://cran.r-project.org/package=mrcommons) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3822009.svg)](https://doi.org/10.5281/zenodo.3822009) [![R build status](https://github.com/pik-piam/mrcommons/workflows/check/badge.svg)](https://github.com/pik-piam/mrcommons/actions) [![codecov](https://codecov.io/gh/pik-piam/mrcommons/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrcommons) [![r-universe](https://pik-piam.r-universe.dev/badges/mrcommons)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **mrcommons** in publications use:

Bodirsky B, Karstens K, Baumstark L, Weindl I, Wang X, Mishra A, Wirth S, Stevanovic M, Steinmetz N, Kreidenweis U, Rodrigues R, Popov R, Humpenoeder F, Giannousakis A, Levesque A, Klein D, Araujo E, Beier F, Oeser J, Pehl M, Leip D, Crawford M, Molina Bacca E, von Jeetze P, Martinelli E, Schreyer F, Soergel B, Sauer P, Hötten D, Hasse R, Abrahão G, Weigmann P, Dietrich J (2024). _mrcommons: MadRat commons Input Data Library_. doi: 10.5281/zenodo.3822009 (URL: https://doi.org/10.5281/zenodo.3822009), R package version 1.41.3, <URL: https://github.com/pik-piam/mrcommons>.
Bodirsky B, Karstens K, Baumstark L, Weindl I, Wang X, Mishra A, Wirth S, Stevanovic M, Steinmetz N, Kreidenweis U, Rodrigues R, Popov R, Humpenoeder F, Giannousakis A, Levesque A, Klein D, Araujo E, Beier F, Oeser J, Pehl M, Leip D, Crawford M, Molina Bacca E, von Jeetze P, Martinelli E, Schreyer F, Soergel B, Sauer P, Hötten D, Hasse R, Abrahão G, Weigmann P, Dietrich J (2024). _mrcommons: MadRat commons Input Data Library_. doi: 10.5281/zenodo.3822009 (URL: https://doi.org/10.5281/zenodo.3822009), R package version 1.42.0, <URL: https://github.com/pik-piam/mrcommons>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {mrcommons: MadRat commons Input Data Library},
author = {Benjamin Leon Bodirsky and Kristine Karstens and Lavinia Baumstark and Isabelle Weindl and Xiaoxi Wang and Abhijeet Mishra and Stephen Wirth and Mishko Stevanovic and Nele Steinmetz and Ulrich Kreidenweis and Renato Rodrigues and Roman Popov and Florian Humpenoeder and Anastasis Giannousakis and Antoine Levesque and David Klein and Ewerton Araujo and Felicitas Beier and Julian Oeser and Michaja Pehl and Debbora Leip and Michael Crawford and Edna {Molina Bacca} and Patrick {von Jeetze} and Eleonora Martinelli and Felix Schreyer and Bjoern Soergel and Pascal Sauer and David Hötten and Robin Hasse and Gabriel Abrahão and Pascal Weigmann and Jan Philipp Dietrich},
year = {2024},
note = {R package version 1.41.3},
note = {R package version 1.42.0},
doi = {10.5281/zenodo.3822009},
url = {https://github.com/pik-piam/mrcommons},
}
Expand Down

0 comments on commit 93cbe97

Please sign in to comment.