Skip to content

Commit

Permalink
Deleted commented out peatlands code
Browse files Browse the repository at this point in the history
  • Loading branch information
mscrawford committed Aug 7, 2023
1 parent 17084f7 commit 322c00c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '232954400'
ValidationKey: '232973976'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'magpie4: MAgPIE outputs R package for MAgPIE version 4.x'
version: 1.190.0
version: 1.190.1
date-released: '2023-08-07'
abstract: Common output routines for extracting results from the MAgPIE framework
(versions 4.x).
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: magpie4
Title: MAgPIE outputs R package for MAgPIE version 4.x
Version: 1.190.0
Version: 1.190.1
Date: 2023-08-07
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
Expand Down
52 changes: 18 additions & 34 deletions R/reportEmissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
}
}

# # No lowpass filter applied to peatland emissions
# No lowpass filter applied to peatland emissions
co2Emissions <- Emissions(gdx, level = "regglo", type = "co2", unit = "gas",
subcategories = TRUE, inorg_fert_split = TRUE,
lowpass = NULL, cumulative = .cumulative)
Expand All @@ -159,22 +159,6 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
total <- total + peatland
landuseTotal <- landuseTotal + peatland
}


# # Never apply lowpass filter on peatland emissions
# peatland <- PeatlandEmissions(gdx, level = "regglo", unit = "gas", cumulative = .cumulative)
# if (!is.null(peatland)) {

# peatland <- collapseNames(peatland[, , "co2"])

# if (.cumulative) {
# peatland <- peatland / 1000
# }

# total <- total + peatland
# landuseTotal <- landuseTotal + peatland
# }


# Generate return list
if (.raw) {
Expand Down Expand Up @@ -224,7 +208,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {

yearlyCO2 <- .calcCO2(.lowpass = 3, .cumulative = FALSE)

# nolint
# nolint start
emissionsReport <- with(yearlyCO2,
mbind(
setNames(total, "Emissions|CO2|Land (Mt CO2/yr)"), # all human-induced land-related CO2 emissions
Expand Down Expand Up @@ -265,15 +249,15 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
)
)
}
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
# RAW yearly CO2 emissions, lowpass = 0

rawYearlyCO2 <- .calcCO2(.lowpass = 0, .cumulative = FALSE, .raw = TRUE)

# nolint
# nolint start
emissionsReport <- with(rawYearlyCO2,
mbind(
emissionsReport,
Expand All @@ -282,15 +266,15 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
setNames(climateChange, "Emissions|CO2|Land RAW|+|Indirect RAW (Mt CO2/yr)")
)
)
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
# Cumulative CO2 emissions, lowpass = 3

cumulativeCO2 <- .calcCO2(.lowpass = 3, .cumulative = TRUE)

# nolint
# nolint start
emissionsReport <- with(cumulativeCO2,
mbind(
emissionsReport,
Expand Down Expand Up @@ -327,7 +311,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
)
)
}
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -390,7 +374,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {

landCarbonSink <- .calcLandCarbonSink()

# nolint
# nolint start
emissionsReport <- with(landCarbonSink,
mbind(
emissionsReport,
Expand All @@ -411,15 +395,15 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
setNames(unmanagedLandOther, "Emissions|CO2|Land Carbon Sink|LPJmL|Unmanaged Land|+|Other Land (Mt CO2/yr)")
)
)
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
# Cumulative indirect CO2 emissions from land-use change (land-carbon sink) reporting

cumulativeLandCarbonSink <- .calcLandCarbonSink(.cumulative = TRUE)

# nolint
# nolint start
emissionsReport <- with(cumulativeLandCarbonSink,
mbind(
emissionsReport,
Expand All @@ -440,7 +424,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
setNames(unmanagedLandOther, "Emissions|CO2|Land Carbon Sink|Cumulative|LPJmL|Unmanaged Land|+|Other Land (Gt CO2)")
)
)
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -481,7 +465,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
}


# nolint
# nolint start
.x <- mbind(
.createReport(nEmissions, c(agriculture, burn, peatland_n2o)),
.createReport(nEmissions, agriculture, "|+|Agriculture"),
Expand All @@ -498,7 +482,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
.createReport(nEmissions, burn, "|+|Biomass Burning"),
.createReport(nEmissions, c("resid_burn"), "|Biomass Burning|+|Burning of Crop Residues")
)
# end nolint
# nolint end

# Old versions of MAgPIE may not include peatlands
if ("peatland" %in% getItems(nEmissions, dim = 3.1)) {
Expand Down Expand Up @@ -540,7 +524,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
ch4 <- mbind(ch4, peatlandEmissions)
}

# nolint
# nolint start
emissionsReport <- mbind(
emissionsReport,
setNames(dimSums(ch4[, , c(agricult_ch4, burn_ch4, peatland_ch4)], dim = 3), "Emissions|CH4|Land (Mt CH4/yr)"),
Expand All @@ -553,7 +537,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
setNames(dimSums(ch4[, , c(peatland_ch4)], dim = 3), "Emissions|CH4|Land|+|Peatland (Mt CH4/yr)"),
setNames(dimSums(ch4[, , c("peatland")], dim = 3), "Emissions|CH4|Land|Peatland|+|Managed (Mt CH4/yr)")
)
# end nolint
# nolint end


# -----------------------------------------------------------------------------------------------------------------
Expand All @@ -572,7 +556,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
return(setNames(t, n))
}

# nolint
# nolint start
.x <- mbind(
.createReport(c(agriculture, "resid_burn", "peatland")),
.createReport(c(agriculture), "|+|Agriculture"),
Expand All @@ -590,7 +574,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
.createReport(c("peatland"), "|+|Peatland"),
.createReport(c("peatland"), "|Peatland|+|Managed")
)
# end nolint
# nolint end

return(.x)
}
Expand All @@ -615,7 +599,7 @@ reportEmissions <- function(gdx, storageWood = TRUE) {
return(setNames(t, n))
}

# nolint
# nolint start
.x <- mbind(
.createReport(c("rice", "awms", "ent_ferm", "resid_burn", "peatland")),
.createReport(c("rice", "awms", "ent_ferm"), "|+|Agriculture"),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MAgPIE outputs R package for MAgPIE version 4.x

R package **magpie4**, version **1.190.0**
R package **magpie4**, version **1.190.1**

[![CRAN status](https://www.r-pkg.org/badges/version/magpie4)](https://cran.r-project.org/package=magpie4) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158582.svg)](https://doi.org/10.5281/zenodo.1158582) [![R build status](https://github.com/pik-piam/magpie4/workflows/check/badge.svg)](https://github.com/pik-piam/magpie4/actions) [![codecov](https://codecov.io/gh/pik-piam/magpie4/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magpie4) [![r-universe](https://pik-piam.r-universe.dev/badges/magpie4)](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 **magpie4** in publications use:

Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2023). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi: 10.5281/zenodo.1158582 (URL: https://doi.org/10.5281/zenodo.1158582), R package version 1.190.0, <URL: https://github.com/pik-piam/magpie4>.
Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2023). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi: 10.5281/zenodo.1158582 (URL: https://doi.org/10.5281/zenodo.1158582), R package version 1.190.1, <URL: https://github.com/pik-piam/magpie4>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {magpie4: MAgPIE outputs R package for MAgPIE version 4.x},
author = {Benjamin Leon Bodirsky and Florian Humpenoeder and Jan Philipp Dietrich and Miodrag Stevanovic and Isabelle Weindl and Kristine Karstens and Xiaoxi Wang and Abhijeet Mishra and Felicitas Beier and Jannes Breier and Amsalu Woldie Yalew and David Chen and Anne Biewald and Stephen Wirth and Patrick {von Jeetze} and Debbora Leip and Michael Crawford and Marcos Alves},
year = {2023},
note = {R package version 1.190.0},
note = {R package version 1.190.1},
doi = {10.5281/zenodo.1158582},
url = {https://github.com/pik-piam/magpie4},
}
Expand Down

0 comments on commit 322c00c

Please sign in to comment.