#' nr_feed2
#'
#' @param gdx data to perform actions on
#' @param nutrient the nutrient
#'
#' @author Jan-Philipp Dietrich
nr_feed2<-function(gdx,nutrient="nr"){
#sets:
kli<-readGDX(gdx,"kli")
kve<-readGDX(gdx,"kve")
#attributes:
im_attributes_harvest <-readGDX(gdx,"im_attributes_harvest")
f55_attributes_livstproducts <-readGDX(gdx,"f55_attributes_livstproducts","f51_attributes_livstproducts")
getNames(f55_attributes_livstproducts,dim = 2) <- paste(kli,"2",sep="_")
#Magpie output:
ov_dem_convby_substitutes<-collapseNames(readGDX(gdx,"ov_dem_convby_substitutes")[,,"level"])
ov_prod_reg<-collapseNames(readGDX(gdx,"ov_prod_reg")[,,"level"]) #sets: i,t,k;
ov_dem_feed<-collapseNames(readGDX(gdx,"ov_dem_feed")[,,"level"]) #sets: i,t,kli.kbio; for kcr: incl. res&convby-substitutes
ov_res_use_feed <-collapseNames(readGDX(gdx,"ov_res_use_feed")[,,"level"]) #captures scarcity of residues
ov_convby_feed <-collapseNames(readGDX(gdx,"ov_convby_feed")[,,"level"]) #captures scarcity of convbyproducts
ov_scp_feed <-readGDX(gdx,"ov_scp_feed",select = list(type="level"),react = "silent") #incl. res&convby-substitutes(scp)
f20_attributes_scp <- readGDX(gdx,"f20_attributes_scp",react = "silent")
fm_scavenging_1995 <- readGDX(gdx,"fm_scavenging_1995","ov_scavenging_1995",react = "silent",select = list(type="level"))*collapseNames(im_attributes_harvest[,,"pasture"])
feed_kve<-(ov_dem_feed[,,kve]*im_attributes_harvest[,,kve])[,,nutrient]
feed_kli <- mselect(ov_dem_feed,kbio=kli)
getNames(feed_kli,dim = 2) <- paste(kli,"2",sep="_")
feed_kli <- feed_kli*f55_attributes_livstproducts[,,nutrient]
feed_convby<-add_dimension(ov_convby_feed[,,nutrient],dim = 3.2,add = "kbio",nm="convby")
if(!is.null(f20_attributes_scp)) feed_scp<-add_dimension(ov_scp_feed[,,"nr"],dim = 3.2,add = "kbio",nm="SCP")/(f20_attributes_scp[,,"nr"]*f20_attributes_scp[,,nutrient]) else feed_scp <- NULL
feed_scav_res<-add_dimension(ov_res_use_feed[,,nutrient],dim = 3.2,add = "kbio",nm="residues")
feed_scav_res <- add_columns(feed_scav_res,addnm = "scavenging",dim = 3.2)
feed_scav_res[,,"scavenging"] <- fm_scavenging_1995[,,nutrient]
feed<-mbind(feed_kve,feed_kli,feed_convby,feed_scp,feed_scav_res)
return(feed)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.