Skip to content

Commit

Permalink
bugfix net forest area change
Browse files Browse the repository at this point in the history
  • Loading branch information
flohump committed Feb 11, 2025
1 parent 2a13746 commit 09734f9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '435029430'
ValidationKey: '435049560'
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: 2.16.11
version: 2.16.12
date-released: '2025-02-11'
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: 2.16.11
Version: 2.16.12
Date: 2025-02-11
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
Expand Down
8 changes: 4 additions & 4 deletions R/NetForestChange.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param gdx GDX file
#' @param file a file name the output should be written to using write.magpie
#' @param level Level of regional aggregation; "reg" (regional), "glo" (global), "regglo" (regional and global) or any other aggregation level defined in superAggregate
#' @param lowpass number of lowpass filter iterations (default = 3)
#' @param lowpass number of lowpass filter iterations (default = 1)
#' @return Net Forest Change as MAgPIE object (Mha per year)
#' @author Florian Humpenoeder
#' @importFrom magclass new.magpie getCells lowpass setNames getNames getYears setYears
Expand All @@ -15,7 +15,7 @@
#' x <- NetForestChange(gdx)
#' }
#'
NetForestChange <- function(gdx, file = NULL, level = "cell", lowpass = 3) {
NetForestChange <- function(gdx, file = NULL, level = "cell", lowpass = 1) {
# get year diff
im_years <- collapseNames(m_yeardiff(gdx))
# get forest area
Expand All @@ -32,8 +32,8 @@ NetForestChange <- function(gdx, file = NULL, level = "cell", lowpass = 3) {

# years
years <- getYears(a, as.integer = T)
yr_hist <- years[years > 1995 & years <= 2020]
yr_fut <- years[years >= 2020]
yr_hist <- years[years > 1995 & years <= 2025]
yr_fut <- years[years >= 2025]

# apply lowpass filter (not applied on 1st time step, applied seperatly on historic and future period)
if (!is.null(lowpass)) a <- mbind(a[, 1995, ], lowpass(a[, yr_hist, ], i = lowpass), lowpass(a[, yr_fut, ], i = lowpass)[, -1, ])
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 **2.16.11**
R package **magpie4**, version **2.16.12**

[![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, Bonsch M, Vartika S (2025). "magpie4: MAgPIE outputs R package for MAgPIE version 4.x." doi:10.5281/zenodo.1158582 <https://doi.org/10.5281/zenodo.1158582>, Version: 2.16.11, <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, Bonsch M, Vartika S (2025). "magpie4: MAgPIE outputs R package for MAgPIE version 4.x." doi:10.5281/zenodo.1158582 <https://doi.org/10.5281/zenodo.1158582>, Version: 2.16.12, <https://github.com/pik-piam/magpie4>.

A BibTeX entry for LaTeX users is

Expand All @@ -51,6 +51,6 @@ A BibTeX entry for LaTeX users is
date = {2025-02-11},
year = {2025},
url = {https://github.com/pik-piam/magpie4},
note = {Version: 2.16.11},
note = {Version: 2.16.12},
}
```
4 changes: 2 additions & 2 deletions man/NetForestChange.Rd

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

0 comments on commit 09734f9

Please sign in to comment.