R/nr_bg_res.R

Defines functions nr_bg_res

#' nr_bg_res
#'
#' @param fulldata data to perform actions on
#' @param nutrient the nutrient
#'
#' @author Jan-Philipp Dietrich
# belowground crop residues (roots etc)
nr_bg_res<-function(fulldata, nutrient="nr") {
    if (nutrient=="dm"){
        dm  <- collapseNames(readGDX(fulldata, "ov_prod_res_bg_reg", format="first_found")[,,"level"])
        out <- dm[,,-which(dimnames(dm)[[3]]=="pasture")]
    } else if (nutrient=="nr") {
        dm<-collapseNames(readGDX(fulldata, "ov_prod_res_bg_reg", format="first_found")[,,"level"])
        nr<- readGDX(fulldata, "f51_nr_residue_bg", format="first_found")
        out<-dm[,,-which(getNames(dm)=="pasture")]*nr[,,-which(getNames(nr)=="pasture")]
    } else {stop("currently only values for nr and dm exist")}
    return(out)
}
pik-piam/nitrogen documentation built on Nov. 5, 2019, 12:48 a.m.