-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from FelicitasBeier/Clustering
magpie 67k
- Loading branch information
Showing
37 changed files
with
627 additions
and
504 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
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: mrvalidation | ||
Title: madrat data preparation for validation purposes | ||
Version: 2.51.7 | ||
Date: 2023-10-23 | ||
Version: 2.52.0 | ||
Date: 2023-11-08 | ||
Authors@R: c( | ||
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")), | ||
person("Stephen", "Wirth", role = "aut"), | ||
|
@@ -35,9 +35,9 @@ Depends: | |
R (>= 2.10.0), | ||
madrat (>= 2.11.3), | ||
magclass (>= 3.17), | ||
mrcommons (>= 1.0.0), | ||
mrcommons (>= 1.37.0), | ||
mrdrivers (>= 0.2.2), | ||
mrmagpie, | ||
mrmagpie (>= 1.39.0), | ||
mrfactors | ||
Imports: | ||
GDPuc, | ||
|
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,43 +1,42 @@ | ||
#' @title calcValidAAI | ||
#' | ||
#' | ||
#' @description Returns historical area actually irrigated. | ||
#' | ||
#' @param datasource Currently available: \code{"LUH2v2"} and \code{"GMIA"} | ||
#' | ||
#' @param datasource Currently available: \code{"LUH2v2"} and \code{"GMIA"} | ||
#' @return list of magpie object with data and weight | ||
#' @author Stephen Wirth, Anne Biewald | ||
#' @importFrom magpiesets reportingnames | ||
#' @importFrom madrat readSource calcOutput | ||
#' @importFrom magclass dimSums add_dimension | ||
|
||
calcValidAAI <- function(datasource="LUH2v2"){ | ||
|
||
if(datasource=="LUH2v2"){ | ||
|
||
#out <- readSource("LUH2v2","irrigation")[,,c("irrig_c3ann", "irrig_c4ann")] | ||
|
||
out <- calcOutput("LUH2v2", landuse_types = "LUH2v2", irrigation = TRUE, cellular = FALSE, selectyears = "past", aggregate = FALSE) | ||
out <- collapseNames(out[,,c("c3ann","c4ann")][,,"irrigated"]) | ||
calcValidAAI <- function(datasource = "LUH2v2") { | ||
|
||
out <- dimSums(out, dim=3) | ||
|
||
out <- add_dimension(out, dim=3.1, add="scenario", nm="historical") | ||
out <- add_dimension(out, dim=3.2, add="model", nm=datasource) | ||
} | ||
else if(datasource=="GMIA"){ | ||
out <- calcOutput("GMIA", aggregate = FALSE)[,,"AAI_ha_"]/10^6 | ||
|
||
out <- add_dimension(out, dim=3.1, add="scenario", nm="historical") | ||
out <- add_dimension(out, dim=3.2, add="model", nm=datasource) | ||
if (datasource == "LUH2v2") { | ||
|
||
out <- calcOutput("LUH2v2", landuse_types = "LUH2v2", irrigation = TRUE, | ||
cellular = FALSE, selectyears = "past", aggregate = FALSE) | ||
out <- collapseNames(out[, , c("c3ann", "c4ann")][, , "irrigated"]) | ||
|
||
out <- dimSums(out, dim = 3) | ||
|
||
out <- add_dimension(out, dim = 3.1, add = "scenario", nm = "historical") | ||
out <- add_dimension(out, dim = 3.2, add = "model", nm = datasource) | ||
} else if (datasource == "GMIA") { | ||
out <- calcOutput("GMIA", aggregate = FALSE)[, , "AAI_ha_"] / 10^6 | ||
|
||
out <- add_dimension(out, dim = 3.1, add = "scenario", nm = "historical") | ||
out <- add_dimension(out, dim = 3.2, add = "model", nm = datasource) | ||
} else { | ||
stop("Given datasource currently not supported!") | ||
} | ||
getNames(out, dim=3) <- paste("Resources|Land Cover|Cropland|Area actually irrigated","(million ha)",sep=" ") | ||
getNames(out, dim = 3) <- paste("Resources|Land Cover|Cropland|Area actually irrigated", | ||
"(million ha)", sep = " ") | ||
names(dimnames(out))[3] <- "scenario.model.variable" | ||
return(list(x=out, | ||
weight=NULL, | ||
unit="million ha", | ||
min=0, | ||
description="Area actually irrigated in Mha") | ||
|
||
return(list(x = out, | ||
weight = NULL, | ||
unit = "million ha", | ||
min = 0, | ||
description = "Area actually irrigated in Mha") | ||
) | ||
} |
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
Oops, something went wrong.