Skip to content

Commit

Permalink
renamed managed to planted forest
Browse files Browse the repository at this point in the history
  • Loading branch information
flohump committed Oct 19, 2024
1 parent 9052181 commit 8c6c708
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '52331380'
ValidationKey: '52359240'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package .* was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mrvalidation: madrat data preparation for validation purposes'
version: 2.61.5
date-released: '2024-10-16'
version: 2.61.6
date-released: '2024-10-19'
abstract: Package contains routines to prepare data for validation exercises.
authors:
- family-names: Bodirsky
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
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.61.5
Date: 2024-10-16
Version: 2.61.6
Date: 2024-10-19
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
person("Stephen", "Wirth", role = "aut"),
Expand Down
95 changes: 47 additions & 48 deletions R/calcValidLand.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ calcValidLand <- function(datasource = "MAgPIEown") {

fraForest2020 <- readSource("FRA2020", "forest_area")[, , c("plantedForest", "plantationForest",
"otherPlantedForest")]
getNames(fraForest2020, dim = 1) <- c("Resources|Land Cover|Forest|Managed Forest",
"Resources|Land Cover|Forest|Managed Forest|+|Plantations",
"Resources|Land Cover|Forest|Managed Forest|+|NPI/NDC")
getNames(fraForest2020, dim = 1) <- c("Resources|Land Cover|Forest|Planted Forest",
"Resources|Land Cover|Forest|Planted Forest|Plantations|+|Timber",
"Resources|Land Cover|Forest|Planted Forest|Natural|+|NPI_NDC AR")
yPast <- magpiesets::findset("past", noset = "original")
yPast <- as.integer(substring(yPast, 2, 5))
yData <- getYears(fraForest2020, as.integer = TRUE)
Expand Down Expand Up @@ -96,42 +96,41 @@ calcValidLand <- function(datasource = "MAgPIEown") {
out <- mbind(main, forest, natrforest, grassland)
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 == "SSPResults") {

# Pick out Land Cover categories in SSPResults
out <- calcOutput("ValidSSPResults", warnNA = FALSE, aggregate = FALSE)

# for some unknown reason MESSAGE-GLOBIOM repots negative other land
# which is why we have to lower the minimum value check to -100
minValue <- -100

selection <- c(
"Land Cover (million ha)",
"Land Cover|Built-up Area (million ha)",
"Land Cover|Cropland (million ha)",
"Land Cover|Cropland|Energy Crops (million ha)",
"Land Cover|Forest (million ha)",
"Land Cover|Forest|Forestry (million ha)",
"Land Cover|Forest|Forestry|Harvested Area (million ha)",
"Land Cover|Forest|Natural Forest (million ha)",
"Land Cover|Other Arable Land (million ha)",
"Land Cover|Other Land (million ha)",
"Land Cover|Other Natural Land (million ha)",
"Land Cover|Pasture (million ha)"
)

out <- out[, , selection]

# Renaming reporting categories from SSPResults to MAgPie validation names
# (not all SSP-categories have MAgPIE-equivalents)

mapping <- toolGetMapping(type = "sectoral", name = "mappingSSPResultsToMAgPIEValid.csv", where = "mappingfolder")
mappingFrom <- as.vector(mapping[, "SSPResults"])
mappingTo <- as.vector(mapping[, "MAgPIEValid"])
names(mappingTo) <- mappingFrom
aNames <- getNames(out, dim = 3)
getNames(out, dim = 3) <- mappingTo[aNames]
getNames(out, dim = 3) <- paste0("Resources|", getNames(out, dim = 3))
} else if (datasource == "SSPResults") {
# Pick out Land Cover categories in SSPResults
out <- calcOutput("ValidSSPResults", warnNA = FALSE, aggregate = FALSE)

# for some unknown reason MESSAGE-GLOBIOM repots negative other land
# which is why we have to lower the minimum value check to -100
minValue <- -100

selection <- c(
"Land Cover (million ha)",
"Land Cover|Built-up Area (million ha)",
"Land Cover|Cropland (million ha)",
"Land Cover|Cropland|Energy Crops (million ha)",
"Land Cover|Forest (million ha)",
"Land Cover|Forest|Forestry (million ha)",
"Land Cover|Forest|Forestry|Harvested Area (million ha)",
"Land Cover|Forest|Natural Forest (million ha)",
"Land Cover|Other Arable Land (million ha)",
"Land Cover|Other Land (million ha)",
"Land Cover|Other Natural Land (million ha)",
"Land Cover|Pasture (million ha)"
)

out <- out[, , selection]

# Renaming reporting categories from SSPResults to MAgPie validation names
# (not all SSP-categories have MAgPIE-equivalents)

mapping <- toolGetMapping(type = "sectoral", name = "mappingSSPResultsToMAgPIEValid.csv", where = "mappingfolder")
mappingFrom <- as.vector(mapping[, "SSPResults"])
mappingTo <- as.vector(mapping[, "MAgPIEValid"])
names(mappingTo) <- mappingFrom
aNames <- getNames(out, dim = 3)
getNames(out, dim = 3) <- mappingTo[aNames]
getNames(out, dim = 3) <- paste0("Resources|", getNames(out, dim = 3))

} else {
stop("Given datasource currently not supported!")
Expand All @@ -141,15 +140,15 @@ calcValidLand <- function(datasource = "MAgPIEown") {
names(dimnames(out))[1] <- "ISO"

desc <- paste0("Cropland, pasture, urban, other land and forest area from FAO, LUH2v2, MAgPIE-Input and SSPresults.",
"\n Cropland: is the land under temporary agricultural crops (multiple-cropped areas are counted only",
"\n once), temporary meadows for mowing or pasture, land under market and kitchen gardens",
"\n and land temporarily fallow, and cultivated with long-term crops which do not have to",
"\n be replanted for several years (such as cocoa and coffee); land under trees and shrubs",
"\n producing flowers, such as roses and jasmine;",
"\n Pasture: is the land used permanently (for a period of five years or more) for herbaceous forage crops,",
"\n either cultivated or naturally growing.",
"\n Forest: is the land spanning more than 0.5 hectares with trees higher than 5 metres and a canopy cover",
"\n of more than 10 percent (includes temporarily unstocked areas)")
"\n Cropland: is the land under temporary agricultural crops (multiple-cropped areas are counted only",
"\n once), temporary meadows for mowing or pasture, land under market and kitchen gardens",
"\n and land temporarily fallow, and cultivated with long-term crops which do not have to",
"\n be replanted for several years (such as cocoa and coffee); land under trees and shrubs",
"\n producing flowers, such as roses and jasmine;",
"\n Pasture: is the land used permanently (for a period of five years or more) for herbaceous,",
"\n forage crops either cultivated or naturally growing.",
"\n Forest: is the land spanning more than 0.5 hectares with trees higher than 5 metres and a",
"\n canopy cover of more than 10 percent (includes temporarily unstocked areas)")

return(list(x = out,
weight = NULL,
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 data preparation for validation purposes

R package **mrvalidation**, version **2.61.5**
R package **mrvalidation**, version **2.61.6**

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

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky <bodirsky@

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

Bodirsky B, Wirth S, Karstens K, Humpenoeder F, Stevanovic M, Mishra A, Biewald A, Weindl I, Beier F, Chen D, Crawford M, Leip D, Molina Bacca E, Kreidenweis U, W. Yalew A, von Jeetze P, Wang X, Dietrich J, Alves M (2024). _mrvalidation: madrat data preparation for validation purposes_. doi:10.5281/zenodo.4317826 <https://doi.org/10.5281/zenodo.4317826>, R package version 2.61.5, <https://github.com/pik-piam/mrvalidation>.
Bodirsky B, Wirth S, Karstens K, Humpenoeder F, Stevanovic M, Mishra A, Biewald A, Weindl I, Beier F, Chen D, Crawford M, Leip D, Molina Bacca E, Kreidenweis U, W. Yalew A, von Jeetze P, Wang X, Dietrich J, Alves M (2024). _mrvalidation: madrat data preparation for validation purposes_. doi:10.5281/zenodo.4317826 <https://doi.org/10.5281/zenodo.4317826>, R package version 2.61.6, <https://github.com/pik-piam/mrvalidation>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {mrvalidation: madrat data preparation for validation purposes},
author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves},
year = {2024},
note = {R package version 2.61.5},
note = {R package version 2.61.6},
url = {https://github.com/pik-piam/mrvalidation},
doi = {10.5281/zenodo.4317826},
}
Expand Down

0 comments on commit 8c6c708

Please sign in to comment.