Skip to content

Commit

Permalink
bugfix init switches
Browse files Browse the repository at this point in the history
  • Loading branch information
k4rst3ns committed Feb 11, 2022
1 parent 834bf0c commit d0fe82a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '222888140'
ValidationKey: '222907174'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "mrsoil: MadRat Soil Organic Carbon Budget Library",
"version": "1.17.10",
"version": "1.17.11",
"description": "<p>This packages provides functions for soil organic carbon budget for mineral soils using the steady-state method (Tier 2) of the 2019 Refinement to the 2006 IPP Guidelines for National Greenhouse Gas Inventories.<\/p>",
"creators": [
{
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mrsoil
Type: Package
Title: MadRat Soil Organic Carbon Budget Library
Version: 1.17.10
Version: 1.17.11
Date: 2022-02-11
Authors@R: c(person("Kristine", "Karstens", email = "karstens@pik-potsdam.de", role = c("aut","cre")),
person("Jan Philipp", "Dietrich", email = "dietrich@pik-potsdam.de", role = "aut"))
Expand Down
25 changes: 19 additions & 6 deletions R/calcSoilCarbon.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,33 @@ calcSoilCarbon <- function(output="full", cfg=NULL, cfg_default=NULL){

if(cfg$soilinit>1900){

#change: add natural
years <- getYears(Landuse, as.integer=TRUE)
years <- years[years >= cfg$soilinit]
SoilCarbonInit <- mbind(setNames(setYears(SoilCarbonSteadyState[,years[1],"natveg"],years[1]-1),
paste0("crop.",getNames(SoilCarbonSteadyState[,,"natveg"], dim=2))),
setYears(SoilCarbonSteadyState[,years[1],"natveg"],years[1]-1))

names <- as.vector(outer(c("actualstate", "naturalstate"),
getItems(Decay, dim = 3),
paste, sep = "."))

SoilCarbonInit <- new.magpie(getItems(Decay, dim = 1), years[1]-1, names)
SoilCarbonInit[, , "actualstate.crop"] <- SoilCarbonSteadyState[,years[1],"natveg"]
SoilCarbonInit[, , "actualstate.natveg"] <- SoilCarbonSteadyState[,years[1],"natveg"]
SoilCarbonInit[, , "naturalstate.crop"] <- SoilCarbonSteadyState[,years[1],"natveg"]
SoilCarbonInit[, , "naturalstate.natveg"] <- SoilCarbonSteadyState[,years[1],"natveg"]

SoilCarbonSteadyState <- SoilCarbonSteadyState[,years,]
Decay <- Decay[,years,]
Landuse <- Landuse[,c(years[1]-1,years),]

} else if(cfg$soilinit<1){

#change: add natural
SoilCarbonInit <- setYears(SoilCarbonSteadyState[,"y1901",],"y1900")
names <- as.vector(outer(c("actualstate", "naturalstate"),
getItems(Decay, dim = 3),
paste, sep = "."))

SoilCarbonInit <- new.magpie(getItems(Decay, dim = 1), "y1900", names)

SoilCarbonInit[, , "actualstate"] <- SoilCarbonSteadyState[, "y1901", ]
SoilCarbonInit[, , "naturalstate"] <- SoilCarbonSteadyState[, "y1901", ]

} else {

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 Soil Organic Carbon Budget Library

R package **mrsoil**, version **1.17.10**
R package **mrsoil**, version **1.17.11**

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

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Kristine Karstens <karstens@pik-p

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

Karstens K, Dietrich J (2022). _mrsoil: MadRat Soil Organic Carbon Budget Library_. doi: 10.5281/zenodo.4317933 (URL: https://doi.org/10.5281/zenodo.4317933), R package version 1.17.10, <URL: https://github.com/pik-piam/mrsoil>.
Karstens K, Dietrich J (2022). _mrsoil: MadRat Soil Organic Carbon Budget Library_. doi: 10.5281/zenodo.4317933 (URL: https://doi.org/10.5281/zenodo.4317933), R package version 1.17.11, <URL: https://github.com/pik-piam/mrsoil>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {mrsoil: MadRat Soil Organic Carbon Budget Library},
author = {Kristine Karstens and Jan Philipp Dietrich},
year = {2022},
note = {R package version 1.17.10},
note = {R package version 1.17.11},
doi = {10.5281/zenodo.4317933},
url = {https://github.com/pik-piam/mrsoil},
}
Expand Down

0 comments on commit d0fe82a

Please sign in to comment.