Skip to content

Commit

Permalink
Merge branch 'treecover' into 'main'
Browse files Browse the repository at this point in the history
adding TimeAvgMapTreeCover metric also as a default

See merge request lpjml/lpjmlstats!21
  • Loading branch information
DavidhoPIK committed Nov 8, 2024
2 parents 21edf74 + d9c612b commit f1b35c9
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ValidationKey: '1000700'
ValidationKey: '1202100'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
AcceptedNotes: checking installed package size
allowLinterWarnings: no
enforceVersionUpdate: no
skipCoverage: no
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ jobs:
shell: Rscript {0}
run: |
nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps"))
if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE)
if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE)
env:
NOT_CRAN: "true"
8 changes: 6 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: 'lpjmlstats: Statistical tools for LPJmL data analysis'
version: 0.5.0
date-released: '2024-10-18'
version: 0.6.0
date-released: '2024-11-08'
abstract: This package provides statistical tools for LPJmL data analysis to be used
for benchmarking LPJmL outputs.
authors:
Expand All @@ -14,6 +14,10 @@ authors:
given-names: Jannes
email: [email protected]
orcid: https://orcid.org/0000-0002-9055-6904
- family-names: Müller
given-names: Christoph
email: [email protected]
orcid: https://orcid.org/0000-0002-9491-3550
license: AGPL-3.0
repository-code: https://github.com/PIK-LPJmL/lpjmlstats

7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Package: lpjmlstats
Title: Statistical tools for LPJmL data analysis
Version: 0.5.0
Version: 0.6.0
Authors@R: c(
person("David","Hötten", , "[email protected]", role = c("aut", "cre")),
person("Jannes","Breier", , "[email protected]", role = c("aut"), comment = c(ORCID = "0000-0002-9055-6904"))
person("Jannes","Breier", , "[email protected]", role = c("aut"), comment = c(ORCID = "0000-0002-9055-6904")),
person("Christoph","Müller", , "[email protected]", role = c("aut"), comment = c(ORCID = "0000-0002-9491-3550"))
)
Description: This package provides statistical tools for LPJmL data analysis
to be used for benchmarking LPJmL outputs.
Expand Down Expand Up @@ -44,4 +45,4 @@ Config/testthat/edition: 3
VignetteBuilder: knitr
Depends:
R (>= 3.5.0)
Date: 2024-10-18
Date: 2024-11-08
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export(GlobSumTimeseries)
export(LPJmLDataCalc)
export(Metric)
export(TimeAvgMap)
export(TimeAvgMapTreeCover)
export(TimeAvgMapWithAbs)
export(aggregate)
export(benchmark)
Expand Down
47 changes: 47 additions & 0 deletions R/Metric_subclasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -691,3 +691,50 @@ GlobSumAnnTimeseriesFPC <- R6::R6Class( # nolint: object_name_linter.
}
)
)

#' @title TimeAvgMapTreeCover
#' @description
#' TimeAvgMapTreeCover metric
#' @export
TimeAvgMapTreeCover <- # nolint: object_name_linter.
R6::R6Class(
"TimeAvgMapTreeCover",
inherit = TimeAvgMapWithAbs,
public = list(
#' @description
#' add up bands for tree fpcs
#' @param data LPJmLDataCalc object to be summarized
summarize = function(data) {
bands <- data$meta$band_names
data <- subset(data, band = bands[grep("tree", bands)])
data$add_band("treecover_band", function(x) sum(x))
data <- subset(data, band = "treecover_band")
data <- aggregate(data, time = list(to = "sim_period", stat = "mean"))
},

#' @field m_options
#' See \link{TimeAvgMapWithAbs} for the documentation of the options of this metric.
m_options = list(
font_size = 4,
highlight = NULL,
quantiles = c(0.05, 0.95),
sep_cmp_lims = TRUE,
year_subset = as.character(1991:2000),
cell_subset = NULL,
n_breaks = 8,
num_cols = 3,
var_subheading = FALSE,
band_subheading = FALSE
),

#' @field title
#' Section header used in the report
title = "Time Average Maps With Absolute Values of total Tree Cover",

#' @field description
#' Description used in the report
description = "The cell-time values of each variable are averaged over time.
Bands that contain the string `tree` are added up.
The resulting sum is then plotted on a map. \n"
)
)
2 changes: 1 addition & 1 deletion R/default_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default_settings <- list(
mbnf = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
firec = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
flux_estab = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
fpc = c(GlobSumTimeAvgTableFPC, GlobSumAnnTimeseriesFPC, TimeAvgMap),
fpc = c(GlobSumTimeAvgTableFPC, GlobSumAnnTimeseriesFPC, TimeAvgMap, TimeAvgMapTreeCover),
mgpp = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
mnpp = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
anbp = c(GlobSumTimeAvgTable, GlobSumAnnAvgTimeseries, TimeAvgMap),
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Statistical tools for LPJmL data analysis

R package **lpjmlstats**, version **0.5.0**
R package **lpjmlstats**, version **0.6.0**

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

Expand Down Expand Up @@ -48,16 +48,16 @@ In case of questions / problems please contact David Hötten <davidho@pik-potsda

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

Hötten D, Breier J (2024). _lpjmlstats: Statistical tools for LPJmL data analysis_. R package version 0.5.0, <https://github.com/PIK-LPJmL/lpjmlstats>.
Hötten D, Breier J, Müller C (2024). _lpjmlstats: Statistical tools for LPJmL data analysis_. R package version 0.6.0, <https://github.com/PIK-LPJmL/lpjmlstats>.

A BibTeX entry for LaTeX users is

```latex
@Manual{,
title = {lpjmlstats: Statistical tools for LPJmL data analysis},
author = {David Hötten and Jannes Breier},
author = {David Hötten and Jannes Breier and Christoph Müller},
year = {2024},
note = {R package version 0.5.0},
note = {R package version 0.6.0},
url = {https://github.com/PIK-LPJmL/lpjmlstats},
}
```
82 changes: 82 additions & 0 deletions man/TimeAvgMapTreeCover.Rd

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

1 change: 1 addition & 0 deletions man/lpjmlstats-package.Rd

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

0 comments on commit f1b35c9

Please sign in to comment.