Skip to content

Commit

Permalink
add nitrogen fertilizer reporting for agmip
Browse files Browse the repository at this point in the history
  • Loading branch information
caviddhen committed Feb 27, 2024
1 parent 5dd26ae commit fac4326
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '2377673148'
ValidationKey: '2377813140'
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: 'magpie4: MAgPIE outputs R package for MAgPIE version 4.x'
version: 1.202.12
date-released: '2024-02-26'
version: 1.202.13
date-released: '2024-02-27'
abstract: Common output routines for extracting results from the MAgPIE framework
(versions 4.x).
authors:
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: magpie4
Title: MAgPIE outputs R package for MAgPIE version 4.x
Version: 1.202.12
Date: 2024-02-26
Version: 1.202.13
Date: 2024-02-27
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
person("Florian", "Humpenoeder", , "[email protected]", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export(reportExpenditureFoodIndex)
export(reportFactorCostShares)
export(reportFeed)
export(reportFeedConversion)
export(reportFertilizerNitrogen)
export(reportFoodExpenditure)
export(reportForestYield)
export(reportGraslandSoilCarbon)
Expand Down
1 change: 1 addition & 0 deletions R/getReportAgMIP.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ getReportAgMIP <- function(gdx, file = NULL, scenario = NULL, filter = c(1, 2, 7
# "reportProtectedArea(gdx)", #nolint
"reportCroparea(gdx, detail = detail)",
"reportNitrogenPollution(gdx, dir = dir)",
"reportFertilizerNitrogen(gdx)",
# "reportNitrogenBudgetCropland(gdx)", #nolint
# "reportNitrogenBudgetPasture(gdx)", #nolint
# "reportManure(gdx)", #nolint
Expand Down
31 changes: 31 additions & 0 deletions R/reportFertilizerNitrogen.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' @title reportFertilizerNitrogen
#' @description Reports inorganic nitrogen application on crops
#'
#' @importFrom magpiesets reporthelper summationhelper
#' @export
#'
#' @param gdx GDX file
#' @param level level of output
#'
#' @author David M Chen
#' @seealso
#' \code{\link{NitrogenBudget}}
#'
#' @examples
#' \dontrun{
#' x <- reportFertilizerNitrogen(gdx)
#' }
#'
reportFertilizerNitrogen <- function(gdx, level = "regglo") {

budget <- NitrogenBudget(gdx, level = level, cropTypes = TRUE )

out <- collapseNames(budget[, , "fertilizer"])

out <- reporthelper(out, level_zero_name = "Resources|Nitrogen|Inorganic Fertilizer Application", partly = TRUE )
out <- summationhelper(out)
getNames(out) <- paste0(getNames(out), "Mt Nr/yr")

return(out)

}
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.202.12**
R package **magpie4**, version **1.202.13**

[![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 (2024). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi:10.5281/zenodo.1158582 <https://doi.org/10.5281/zenodo.1158582>, R package version 1.202.12, <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 (2024). _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.202.13, <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 = {2024},
note = {R package version 1.202.12},
note = {R package version 1.202.13},
doi = {10.5281/zenodo.1158582},
url = {https://github.com/pik-piam/magpie4},
}
Expand Down
28 changes: 28 additions & 0 deletions man/reportFertilizerNitrogen.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fac4326

Please sign in to comment.