-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added disaggregation of other land to reporting
- Loading branch information
Showing
8 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Type: Package | ||
Package: magpie4 | ||
Title: MAgPIE outputs R package for MAgPIE version 4.x | ||
Version: 2.13.10 | ||
Date: 2024-10-21 | ||
Version: 2.13.11 | ||
Date: 2024-10-22 | ||
Authors@R: c( | ||
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")), | ||
person("Florian", "Humpenoeder", , "[email protected]", role = "aut"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' @title OtherLand | ||
#' @description Disaggregation of other land into initial, restored and recovered land based on a MAgPIE gdx file | ||
#' | ||
#' @export | ||
#' | ||
#' @param gdx GDX file | ||
#' @param level Level of regional aggregation; "cell", "reg" (regional), "glo" (global), "regglo" (regional and global) or any aggregation level defined in superAggregate. In addition "climate" for the 3 climate regions tropical, temperate and boreal is available. | ||
#' @details initial, restored and recovered land | ||
#' @return Other land area in Mha | ||
#' @author Florian Humpenoeder | ||
#' @importFrom magclass dimSums collapseNames | ||
#' @importFrom luscale superAggregate | ||
#' @examples | ||
#' | ||
#' \dontrun{ | ||
#' x <- PeatlandArea(gdx) | ||
#' } | ||
|
||
OtherLand <- function(gdx, level="reg"){ | ||
|
||
a <- dimSums(readGDX(gdx,"ov_land_other",select=list(type="level"),react = "silent"),dim="othertype35") | ||
b <- readGDX(gdx,"pm_land_conservation",react = "silent") | ||
x <- m_yeardiff(gdx) | ||
x[,1,] <- 5 | ||
ac <- readGDX(gdx,"ac") | ||
ac_est <- new.magpie("GLO",getYears(x),ac,fill=0) | ||
for(t in getYears(x)) { | ||
ac_est[,t,getNames(ac_est[,t,])[1:(x[,t,]/5)]] <- 1 | ||
} | ||
ac_sub <- 1 - ac_est | ||
ac_sub[,,"acx"] <- 0 | ||
|
||
restoredEst <- collapseDim(b[,,"other.restore"]) | ||
restoredSub <- collapseDim(as.magpie(apply(b[, , "other.restore"], c(1, 3), cumsum))) | ||
recoveredEst <- dimSums(a*ac_est,dim=3) - restoredEst | ||
recoveredSub <- dimSums(a*ac_sub,dim=3) - restoredSub | ||
|
||
initial <- setNames(collapseDim(a[,,"acx"]), "other_initial") | ||
recovered <- setNames(recoveredEst+recoveredSub, "other_recovered") | ||
restored <- setNames(restoredEst+restoredSub, "other_restored") | ||
z <- mbind(initial, recovered, restored) | ||
|
||
#check | ||
indicator <- sum(dimSums(a,dim=3) - dimSums(z,dim=3)) | ||
if(abs(indicator) > 1e-6) warning("Other land sub-categories don't add-up to total. Check OtherLand.R function") | ||
|
||
if (level != "cell") z <- superAggregate(z, aggr_type = "sum", level = level,na.rm = FALSE) | ||
|
||
return(z) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.