diff --git a/Makefile.depends b/Makefile.depends index 9ae925d43e2..977e82b8dc0 100644 --- a/Makefile.depends +++ b/Makefile.depends @@ -18,13 +18,13 @@ $(call depends,models/fates): | .install/base/logger .install/base/remote .insta $(call depends,models/gday): | .install/base/logger .install/base/remote .install/base/utils $(call depends,models/jules): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere $(call depends,models/ldndc): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere .install/modules/data.land -$(call depends,models/linkages): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere +$(call depends,models/linkages): | .install/base/db .install/base/logger .install/base/remote .install/base/utils .install/modules/data.land $(call depends,models/lpjguess): | .install/base/logger .install/base/remote .install/base/utils $(call depends,models/maat): | .install/base/logger .install/base/remote .install/base/settings .install/base/utils .install/modules/data.atmosphere $(call depends,models/maespa): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere $(call depends,models/preles): | .install/base/logger .install/base/utils .install/modules/data.atmosphere -$(call depends,models/sibcasa): | .install/base/logger .install/base/utils -$(call depends,models/sipnet): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere +$(call depends,models/sibcasa): | .install/base/logger +$(call depends,models/sipnet): | .install/base/logger .install/base/remote .install/base/utils .install/modules/data.atmosphere .install/modules/data.land $(call depends,models/stics): | .install/base/logger .install/base/remote .install/base/settings .install/base/utils $(call depends,models/template): | .install/base/db .install/base/logger .install/base/utils $(call depends,modules/allometry): | .install/base/db diff --git a/base/db/tests/Rcheck_reference.log b/base/db/tests/Rcheck_reference.log index 87ade55021c..cbc3757f683 100644 --- a/base/db/tests/Rcheck_reference.log +++ b/base/db/tests/Rcheck_reference.log @@ -62,8 +62,7 @@ The Date field is over a month old. * checking package directory ... OK * checking for future file timestamps ... OK * checking ‘build’ directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/base/qaqc/tests/Rcheck_reference.log b/base/qaqc/tests/Rcheck_reference.log index 593c738f659..fa634d61096 100644 --- a/base/qaqc/tests/Rcheck_reference.log +++ b/base/qaqc/tests/Rcheck_reference.log @@ -21,10 +21,6 @@ * checking package directory ... OK * checking DESCRIPTION meta-information ... NOTE Malformed Description field: should contain one or more complete sentences. -Authors@R field gives no person with name and roles. -Authors@R field gives no person with maintainer role, valid email -address and non-empty name. -License stub is invalid DCF. * checking top-level files ... NOTE Non-standard file/directory found at top level: ‘README.Rmd’ diff --git a/base/remote/tests/Rcheck_reference.log b/base/remote/tests/Rcheck_reference.log index ca6f1d67b77..71001fb962e 100644 --- a/base/remote/tests/Rcheck_reference.log +++ b/base/remote/tests/Rcheck_reference.log @@ -19,8 +19,7 @@ * checking whether package ‘PEcAn.remote’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/base/settings/tests/Rcheck_reference.log b/base/settings/tests/Rcheck_reference.log index 8dcb48578fa..19c37863095 100644 --- a/base/settings/tests/Rcheck_reference.log +++ b/base/settings/tests/Rcheck_reference.log @@ -73,8 +73,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... NOTE Non-standard file/directory found at top level: ‘examples’ diff --git a/base/visualization/tests/Rcheck_reference.log b/base/visualization/tests/Rcheck_reference.log index 0c65006916e..a578ea6cf0c 100644 --- a/base/visualization/tests/Rcheck_reference.log +++ b/base/visualization/tests/Rcheck_reference.log @@ -71,8 +71,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/base/workflow/DESCRIPTION b/base/workflow/DESCRIPTION index 247b17b3c14..252ac4d9fe7 100644 --- a/base/workflow/DESCRIPTION +++ b/base/workflow/DESCRIPTION @@ -17,9 +17,6 @@ Authors@R: c(person("Mike", "Dietze", role = c("aut"), person("Shawn", "Serbin", role = c("aut"), email = "sserbin@bnl.gov"), person("University of Illinois, NCSA", role = c("cph"))) -Author: David LeBauer, Mike Dietze, Xiaohui Feng, Dan Wang, - Mike Dietze, Carl Davidson, Rob Kooper, Shawn Serbin -Maintainer: David LeBauer Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific workflow management tool that is designed to simplify the management of model diff --git a/base/workflow/tests/Rcheck_reference.log b/base/workflow/tests/Rcheck_reference.log index f6fb0254800..68accd78d29 100644 --- a/base/workflow/tests/Rcheck_reference.log +++ b/base/workflow/tests/Rcheck_reference.log @@ -62,15 +62,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘David LeBauer, Mike Dietze, Xiaohui Feng, Dan Wang, Mike Dietze, Carl Davidson, Rob Kooper, Shawn Serbin’ - Authors@R: ‘Mike Dietze [aut], David LeBauer [aut, cre], Xiaohui Feng [aut], Dan Wang [aut], Carl Davidson [aut], Rob Kooper [aut], Shawn Serbin [aut], University of Illinois, NCSA [cph]’ - -Maintainer field differs from that derived from Authors@R - Maintainer: ‘David LeBauer ’ - Authors@R: ‘David LeBauer ’ -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/docker/depends/pecan_deps_from_github.txt b/docker/depends/pecan_deps_from_github.txt index 9633af2d3be..043892f37d7 100644 --- a/docker/depends/pecan_deps_from_github.txt +++ b/docker/depends/pecan_deps_from_github.txt @@ -3,6 +3,7 @@ araiho/linkages_package chuhousen/amerifluxr ebimodeling/biocro@0.951 MikkoPeltoniemi/Rpreles +RemkoDuursma/Maeswrap ropensci/geonames ropensci/nneo SticsRPacks/SticsOnR diff --git a/docker/depends/pecan_package_dependencies.csv b/docker/depends/pecan_package_dependencies.csv index 42e3077f261..c332b010bc0 100644 --- a/docker/depends/pecan_package_dependencies.csv +++ b/docker/depends/pecan_package_dependencies.csv @@ -49,6 +49,7 @@ "dplyr","*","models/biocro","Imports",FALSE "dplyr","*","models/ed","Imports",FALSE "dplyr","*","models/ldndc","Imports",FALSE +"dplyr","*","models/sipnet","Imports",FALSE "dplyr","*","models/stics","Imports",FALSE "dplyr","*","modules/assim.sequential","Imports",FALSE "dplyr","*","modules/benchmark","Imports",FALSE @@ -123,6 +124,9 @@ "jsonlite","*","modules/data.remote","Suggests",FALSE "keras3",">= 1.0.0","modules/assim.sequential","Suggests",FALSE "knitr","*","base/visualization","Suggests",FALSE +"knitr","*","models/biocro","Suggests",FALSE +"knitr","*","models/ed","Suggests",FALSE +"knitr","*","models/maat","Suggests",FALSE "knitr","*","modules/data.atmosphere","Suggests",FALSE "knitr","*","modules/priors","Suggests",FALSE "knitr",">= 1.42","base/db","Suggests",FALSE @@ -262,16 +266,17 @@ "PEcAn.data.atmosphere","*","models/ed","Imports",TRUE "PEcAn.data.atmosphere","*","models/jules","Imports",TRUE "PEcAn.data.atmosphere","*","models/ldndc","Imports",TRUE -"PEcAn.data.atmosphere","*","models/linkages","Imports",TRUE "PEcAn.data.atmosphere","*","models/maat","Imports",TRUE "PEcAn.data.atmosphere","*","models/maespa","Imports",TRUE "PEcAn.data.atmosphere","*","models/preles","Imports",TRUE -"PEcAn.data.atmosphere","*","models/sipnet","Depends",TRUE +"PEcAn.data.atmosphere","*","models/sipnet","Imports",TRUE "PEcAn.data.land","*","base/all","Depends",TRUE "PEcAn.data.land","*","base/workflow","Imports",TRUE "PEcAn.data.land","*","models/biocro","Imports",TRUE "PEcAn.data.land","*","models/ed","Imports",TRUE "PEcAn.data.land","*","models/ldndc","Imports",TRUE +"PEcAn.data.land","*","models/linkages","Imports",TRUE +"PEcAn.data.land","*","models/sipnet","Imports",TRUE "PEcAn.data.land","*","modules/assim.sequential","Suggests",TRUE "PEcAn.data.land","*","modules/benchmark","Suggests",TRUE "PEcAn.data.remote","*","base/all","Depends",TRUE @@ -281,6 +286,7 @@ "PEcAn.DB","*","base/settings","Imports",TRUE "PEcAn.DB","*","base/workflow","Imports",TRUE "PEcAn.DB","*","models/biocro","Suggests",TRUE +"PEcAn.DB","*","models/linkages","Imports",TRUE "PEcAn.DB","*","models/template","Imports",TRUE "PEcAn.DB","*","modules/allometry","Imports",TRUE "PEcAn.DB","*","modules/assim.batch","Imports",TRUE @@ -395,11 +401,10 @@ "PEcAn.utils","*","models/fates","Imports",TRUE "PEcAn.utils","*","models/gday","Depends",TRUE "PEcAn.utils","*","models/jules","Imports",TRUE -"PEcAn.utils","*","models/linkages","Depends",TRUE +"PEcAn.utils","*","models/linkages","Imports",TRUE "PEcAn.utils","*","models/lpjguess","Imports",TRUE "PEcAn.utils","*","models/maat","Imports",TRUE "PEcAn.utils","*","models/maespa","Imports",TRUE -"PEcAn.utils","*","models/preles","Depends",TRUE "PEcAn.utils","*","models/preles","Imports",TRUE "PEcAn.utils","*","models/sipnet","Imports",TRUE "PEcAn.utils","*","modules/assim.batch","Imports",TRUE @@ -416,7 +421,6 @@ "PEcAn.utils",">= 1.4.8","models/cable","Imports",TRUE "PEcAn.utils",">= 1.4.8","models/dvmdostem","Imports",TRUE "PEcAn.utils",">= 1.4.8","models/ldndc","Imports",TRUE -"PEcAn.utils",">= 1.4.8","models/sibcasa","Imports",TRUE "PEcAn.utils",">= 1.4.8","models/stics","Imports",TRUE "PEcAn.utils",">= 1.4.8","models/template","Imports",TRUE "PEcAn.visualization","*","modules/assim.sequential","Suggests",TRUE @@ -488,6 +492,9 @@ "rlang",">= 0.2.0","modules/data.atmosphere","Imports",FALSE "rlist","*","modules/assim.sequential","Suggests",FALSE "rmarkdown","*","base/visualization","Suggests",FALSE +"rmarkdown","*","models/biocro","Suggests",FALSE +"rmarkdown","*","models/ed","Suggests",FALSE +"rmarkdown","*","models/maat","Suggests",FALSE "rmarkdown","*","modules/priors","Suggests",FALSE "rmarkdown","*","modules/rtm","Suggests",FALSE "rmarkdown",">= 2.19","base/db","Suggests",FALSE @@ -556,6 +563,7 @@ "sp","*","modules/data.land","Imports",FALSE "sp","*","modules/data.remote","Imports",FALSE "stats","*","base/qaqc","Imports",FALSE +"stats","*","models/sipnet","Imports",FALSE "stats","*","modules/allometry","Imports",FALSE "stats","*","modules/assim.batch","Imports",FALSE "stats","*","modules/assim.sequential","Suggests",FALSE @@ -613,9 +621,9 @@ "testthat",">= 2.0.0","base/utils","Suggests",FALSE "testthat",">= 2.0.0","models/biocro","Suggests",FALSE "testthat",">= 2.0.0","modules/benchmark","Suggests",FALSE -"testthat",">= 2.0.0","modules/data.atmosphere","Suggests",FALSE "testthat",">= 3.0.0","models/sibcasa","Suggests",FALSE "testthat",">= 3.0.4","base/qaqc","Suggests",FALSE +"testthat",">= 3.1.7","modules/data.atmosphere","Suggests",FALSE "tibble","*","base/db","Imports",FALSE "tibble","*","models/ed","Imports",FALSE "tibble","*","models/fates","Imports",FALSE @@ -645,6 +653,7 @@ "utils","*","base/all","Imports",FALSE "utils","*","base/logger","Imports",FALSE "utils","*","models/ed","Imports",FALSE +"utils","*","models/linkages","Imports",FALSE "utils","*","modules/allometry","Imports",FALSE "utils","*","modules/assim.batch","Imports",FALSE "utils","*","modules/assim.sequential","Suggests",FALSE diff --git a/models/biocro/.Rbuildignore b/models/biocro/.Rbuildignore new file mode 100644 index 00000000000..2d28facae40 --- /dev/null +++ b/models/biocro/.Rbuildignore @@ -0,0 +1,2 @@ +Dockerfile +model_info.json diff --git a/models/biocro/DESCRIPTION b/models/biocro/DESCRIPTION index 9f509131deb..981621c2129 100644 --- a/models/biocro/DESCRIPTION +++ b/models/biocro/DESCRIPTION @@ -27,15 +27,16 @@ Imports: rlang Suggests: BioCro, + knitr, testthat (>= 2.0.0), mockery (>= 0.3.0), PEcAn.DB, + rmarkdown, RPostgreSQL Remotes: github::ebimodeling/biocro@0.951 License: BSD_3_clause + file LICENSE Copyright: Energy Biosciences Institute, Authors -LazyLoad: yes -LazyData: FALSE Encoding: UTF-8 +VignetteBuilder: knitr RoxygenNote: 7.3.2 diff --git a/models/biocro/R/get_biocro_defaults.R b/models/biocro/R/get_biocro_defaults.R index c470c80967d..ac729d90511 100644 --- a/models/biocro/R/get_biocro_defaults.R +++ b/models/biocro/R/get_biocro_defaults.R @@ -13,7 +13,7 @@ from_bc <- function(dfname){ #' *_initial_values, *_parameters, *_modules #' #' @param genus Name of the genus (or really any string BioCro uses as a *_parameters prefix) -#' @return a list in the format expected by \code{BioCro::\link[BioCro:Gro]{Gro}}, +#' @return a list in the format expected by `BioCro::Gro()`, #' containing four lists named `type`, `initial_values`, `parameters`, and `modules`, #' or NULL if genus not found #' @export diff --git a/models/biocro/R/met2model.BIOCRO.R b/models/biocro/R/met2model.BIOCRO.R index dee2e84566f..7cffbd98b62 100644 --- a/models/biocro/R/met2model.BIOCRO.R +++ b/models/biocro/R/met2model.BIOCRO.R @@ -107,37 +107,37 @@ met2model.BIOCRO <- function(in.path, in.prefix, outfolder, overwrite = FALSE, ##' @name cf2biocro ##' @title Convert CF-formatted met data to BioCro met ##' @param met data.table object with met for a single site; output from \code{\link{load.cfmet}} -##' \itemize{ -##' \item {year} {int} -##' \item {month} {int} -##' \item {day} {int: day of month (1-31)} -##' \item {doy} {int: day of year (1-366)} -##' \item {hour} {int (0-23)} -##' \item {date} {YYYY-MM-DD HH:MM:SS POSIXct} -##' \item {wind_speed} {num m/s} -##' \item {northward_wind} -##' \item {eastward_wind} -##' \item {ppfd} {optional; if missing, requires surface_downwelling_shortwave_flux_in_air} -##' \item {surface_downwelling_shortwave_flux_in_air} -##' \item {air_pressure (Pa)} {optional; if missing, requires relative_humidity} -##' \item {specific_humidity} {optional; if missing, requires relative_humidity} -##' \item {relative_humidity} {optional; if missing, requires air_pressure and specific_humidity} -##' \item {precipitation_flux} -##' \item {air_temperature} +##' \describe{ +##' \item{year}{int} +##' \item{month}{int} +##' \item{day}{int: day of month (1-31)} +##' \item{doy}{int: day of year (1-366)} +##' \item{hour}{int (0-23)} +##' \item{date}{YYYY-MM-DD HH:MM:SS POSIXct} +##' \item{wind_speed}{num m/s} +##' \item{northward_wind}{} +##' \item{eastward_wind}{} +##' \item{ppfd}{optional; if missing, requires surface_downwelling_shortwave_flux_in_air} +##' \item{surface_downwelling_shortwave_flux_in_air}{} +##' \item{air_pressure (Pa)}{optional; if missing, requires relative_humidity} +##' \item{specific_humidity}{optional; if missing, requires relative_humidity} +##' \item{relative_humidity}{optional; if missing, requires air_pressure and specific_humidity} +##' \item{precipitation_flux}{} +##' \item{air_temperature}{} ##' } ##' @param longitude in degrees east, used for calculating solar noon ##' @param zulu2solarnoon logical; if TRUE, convert time from GMT to local solar time. ##' @return data.table / data.frame with fields -##' \itemize{ -##' \item {doy} {day of year} -##' \item {hr} {hour} -##' \item {solar} {solar radiation (PPFD)} -##' \item {temp} {temperature, degrees celsius} -##' \item {rh} {relative humidity, as fraction (0-1)} -##' \item {windspeed} {m/s} -##' \item {precip} {cm/h} +##' \describe{ +##' \item{doy}{day of year} +##' \item{hr}{hour} +##' \item{solar}{solar radiation (PPFD)} +##' \item{temp}{temperature, degrees celsius} +##' \item{rh}{relative humidity, as fraction (0-1)} +##' \item{windspeed}{m/s} +##' \item{precip}{cm/h} ##' } -##' @export cf2biocro +##' @export ##' @importFrom data.table := ##' @author David LeBauer cf2biocro <- function(met, longitude = NULL, zulu2solarnoon = FALSE) { diff --git a/models/biocro/man/cf2biocro.Rd b/models/biocro/man/cf2biocro.Rd index 975d23d8436..30d359bc3e8 100644 --- a/models/biocro/man/cf2biocro.Rd +++ b/models/biocro/man/cf2biocro.Rd @@ -8,23 +8,23 @@ cf2biocro(met, longitude = NULL, zulu2solarnoon = FALSE) } \arguments{ \item{met}{data.table object with met for a single site; output from \code{\link{load.cfmet}} -\itemize{ -\item {year} {int} -\item {month} {int} -\item {day} {int: day of month (1-31)} -\item {doy} {int: day of year (1-366)} -\item {hour} {int (0-23)} -\item {date} {YYYY-MM-DD HH:MM:SS POSIXct} -\item {wind_speed} {num m/s} -\item {northward_wind} -\item {eastward_wind} -\item {ppfd} {optional; if missing, requires surface_downwelling_shortwave_flux_in_air} -\item {surface_downwelling_shortwave_flux_in_air} -\item {air_pressure (Pa)} {optional; if missing, requires relative_humidity} -\item {specific_humidity} {optional; if missing, requires relative_humidity} -\item {relative_humidity} {optional; if missing, requires air_pressure and specific_humidity} -\item {precipitation_flux} -\item {air_temperature} +\describe{ +\item{year}{int} +\item{month}{int} +\item{day}{int: day of month (1-31)} +\item{doy}{int: day of year (1-366)} +\item{hour}{int (0-23)} +\item{date}{YYYY-MM-DD HH:MM:SS POSIXct} +\item{wind_speed}{num m/s} +\item{northward_wind}{} +\item{eastward_wind}{} +\item{ppfd}{optional; if missing, requires surface_downwelling_shortwave_flux_in_air} +\item{surface_downwelling_shortwave_flux_in_air}{} +\item{air_pressure (Pa)}{optional; if missing, requires relative_humidity} +\item{specific_humidity}{optional; if missing, requires relative_humidity} +\item{relative_humidity}{optional; if missing, requires air_pressure and specific_humidity} +\item{precipitation_flux}{} +\item{air_temperature}{} }} \item{longitude}{in degrees east, used for calculating solar noon} @@ -33,14 +33,14 @@ cf2biocro(met, longitude = NULL, zulu2solarnoon = FALSE) } \value{ data.table / data.frame with fields -\itemize{ -\item {doy} {day of year} -\item {hr} {hour} -\item {solar} {solar radiation (PPFD)} -\item {temp} {temperature, degrees celsius} -\item {rh} {relative humidity, as fraction (0-1)} -\item {windspeed} {m/s} -\item {precip} {cm/h} +\describe{ +\item{doy}{day of year} +\item{hr}{hour} +\item{solar}{solar radiation (PPFD)} +\item{temp}{temperature, degrees celsius} +\item{rh}{relative humidity, as fraction (0-1)} +\item{windspeed}{m/s} +\item{precip}{cm/h} } } \description{ diff --git a/models/biocro/man/get_biocro_defaults.Rd b/models/biocro/man/get_biocro_defaults.Rd index 7d39aa0f35b..75d628fac4f 100644 --- a/models/biocro/man/get_biocro_defaults.Rd +++ b/models/biocro/man/get_biocro_defaults.Rd @@ -10,7 +10,7 @@ get_biocro_defaults(genus) \item{genus}{Name of the genus (or really any string BioCro uses as a *_parameters prefix)} } \value{ -a list in the format expected by \code{BioCro::\link[BioCro:Gro]{Gro}}, +a list in the format expected by `BioCro::Gro()`, containing four lists named `type`, `initial_values`, `parameters`, and `modules`, or NULL if genus not found } diff --git a/models/biocro/tests/Rcheck_reference.log b/models/biocro/tests/Rcheck_reference.log index 20da0a9ad2a..98b0a701e11 100644 --- a/models/biocro/tests/Rcheck_reference.log +++ b/models/biocro/tests/Rcheck_reference.log @@ -73,17 +73,8 @@ The Date field is over a month old. * checking package directory ... OK * checking for future file timestamps ... OK * checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘David LeBauer, Deepak Jaiswal, Christopher Black’ - Authors@R: ‘David LeBauer [aut, cre], Chris Black [aut], Deepak Jaiswal [aut], University of Illinois, NCSA [cph]’ - -Maintainer field differs from that derived from Authors@R - Maintainer: ‘David LeBauer ’ - Authors@R: ‘David LeBauer ’ - -* checking top-level files ... NOTE -Non-standard files/directories found at top level: - ‘Dockerfile’ ‘model_info.json’ +License stub is invalid DCF. +* checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK diff --git a/models/biocro/vignettes/C4grass_sa_vd.Rmd b/models/biocro/vignettes/C4grass_sa_vd.Rmd index a248465c89d..5e9e4126e08 100644 --- a/models/biocro/vignettes/C4grass_sa_vd.Rmd +++ b/models/biocro/vignettes/C4grass_sa_vd.Rmd @@ -1,6 +1,13 @@ +--- +title: "Sensitivity analysis on C4 grass model" +output: html_vignette +vignette: > + %\VignetteIndexEntry{Sensitivity analysis on C4 grass model} + %\VignetteEngine{knitr::rmarkdown} +--- -```{r} +```{r eval=FALSE} library(PEcAn.all) logger.setQuitOnSevere(FALSE) diff --git a/models/biocro/vignettes/workflow.R b/models/biocro/vignettes/workflow.R deleted file mode 100644 index f47d8c812ee..00000000000 --- a/models/biocro/vignettes/workflow.R +++ /dev/null @@ -1,46 +0,0 @@ - -## @knitr , echo=FALSE,warning=FALSE -library(PEcAn.all) - - -## @knitr , echo=FALSE,warning=FALSE -settings <- read.settings(system.file("extdata/pecan.biocro.xml", package = "PEcAn.BIOCRO")) - -### limit scope for initial testing -settings$sensitivity.analysis$quantiles <- list(sigma = 0.5) -model <- settings$model$type - - - - -## @knitr , echo=FALSE,warning=FALSE,cache=TRUE - -# Query the trait database for data and priors -settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$database$dbfiles, - settings$database$bety, settings$meta.analysis$update) - -# Run the PEcAn meta.analysis -run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects$on, - settings$meta.analysis$threshold, settings$database$dbfiles, settings$database$bety) - -## @knitr , echo=FALSE,warning=FALSE,cache=TRUE -run.write.configs(model) # Calls model specific write.configs e.g. write.config.ed.R -## load met data -PEcAn.workflow::start_model_runs(model) # Start ecosystem model runs -read.outputs(settings$model$type, settings) -# read.outputs(model, settings) #, variables = 'StemBiom') - -get.results(settings) # Get results of model runs - -# run.sensitivity.analysis() # Run sensitivity analysis and variance -# decomposition on model output - -# run.ensemble.analysis() # Run ensemble analysis on model output. OPTIONAL: -# run.ensemble.analysis(plot.timeseries=TRUE) to get an esemble time-series -# output for the target variables set in the PEcAn.xml file - -### PEcAn workflow run complete -print("---------- PEcAn Workflow Complete ----------") -#--------------------------------------------------------------------------------------------------# - - diff --git a/models/biocro/vignettes/workflow.Rmd b/models/biocro/vignettes/workflow.Rmd deleted file mode 100644 index c8e8f32b263..00000000000 --- a/models/biocro/vignettes/workflow.Rmd +++ /dev/null @@ -1,54 +0,0 @@ -BioCro PEcAn workflow -====================== - -```{r, echo=FALSE,warning=FALSE} -library(PEcAn.all) -``` -### Load PEcAn settings file. - -Open and read in settings file for PEcAn run. - - -```{r, echo=FALSE,warning=FALSE} -library(PEcAn.settings) -settings <- read.settings("~/dev/willow_da/vignettes/pecan.biocro.xml") -settings$sensitivity.analysis <- settings$ensemble -model <- settings$model$type - -``` -### Query database for trait data - -```{r, echo=FALSE,warning=FALSE,cache=TRUE} -library(PEcAn.DB) -settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run$dbfiles, settings$database$bety, settings$meta.analysis$update)# Query the trait database for data and priors -``` - -### Run Meta-analysis -```{r, echo=FALSE,warning=FALSE,cache=TRUE} -run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects$on, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety) -``` - - - -```{r, echo=FALSE,warning=FALSE,cache=TRUE} -run.write.configs(settings, settings$database$bety$write) -``` - -```{r, echo=FALSE,warning=FALSE,cache=TRUE} -## load met data -PEcAn.workflow::start_model_runs(settings, settings$database$bety$write) # Start ecosystem model runs -``` - -```{r, echo=FALSE,warning=FALSE,cache=TRUE} -convert.outputs(model = settings$model$name, settings = settings) - -run.sensitivity.analysis() # Run sensitivity analysis and variance decomposition on model output - -run.ensemble.analysis() # Run ensemble analysis on model output. - # OPTIONAL: run.ensemble.analysis(plot.timeseries=TRUE) to get an esemble - # time-series output for the target variables set in the PEcAn.xml file - -### PEcAn workflow run complete -print("---------- PEcAn Workflow Complete ----------") -#--------------------------------------------------------------------------------------------------# -``` diff --git a/models/clm45/DESCRIPTION b/models/clm45/DESCRIPTION index e7ebda0e4cd..363b065e63c 100644 --- a/models/clm45/DESCRIPTION +++ b/models/clm45/DESCRIPTION @@ -5,8 +5,6 @@ Version: 1.7.3.9000 Authors@R: c(person("Mike", "Dietze", role = c("aut", "cre"), email = "dietze@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Mike Dietze -Maintainer: Mike Dietze Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific workflow management tool that is designed to simplify the management of model parameterization, execution, and analysis. The goal of PECAn is to diff --git a/models/clm45/R/met2model.CLM45.R b/models/clm45/R/met2model.CLM45.R index f8759922a13..26aa11935a0 100644 --- a/models/clm45/R/met2model.CLM45.R +++ b/models/clm45/R/met2model.CLM45.R @@ -10,6 +10,8 @@ ##' @param start_date the start date of the data to be downloaded (will only use the year part of the date) ##' @param end_date the end date of the data to be downloaded (will only use the year part of the date) ##' @param lst timezone offset to GMT in hours +##' @param lat,lon site coordinates +##' @param ... other arguments, currently ignored ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbosefor(year in start_year:end_year) met2model.CLM45 <- function(in.path,in.prefix,outfolder,start_date, end_date, lst=0,lat,lon,..., overwrite=FALSE,verbose=FALSE){ diff --git a/models/clm45/R/write.configs.CLM45.R b/models/clm45/R/write.configs.CLM45.R index 7c4c6a88b33..b2ed9ea6ed6 100644 --- a/models/clm45/R/write.configs.CLM45.R +++ b/models/clm45/R/write.configs.CLM45.R @@ -3,7 +3,7 @@ ##' @name write.config.CLM45 ##' @title Write CLM4.5 configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return none diff --git a/models/clm45/man/met2model.CLM45.Rd b/models/clm45/man/met2model.CLM45.Rd index 16d89ea6bd7..c2a76033f27 100644 --- a/models/clm45/man/met2model.CLM45.Rd +++ b/models/clm45/man/met2model.CLM45.Rd @@ -31,6 +31,10 @@ met2model.CLM45( \item{lst}{timezone offset to GMT in hours} +\item{lat, lon}{site coordinates} + +\item{...}{other arguments, currently ignored} + \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbosefor(year in start_year:end_year)} diff --git a/models/clm45/man/write.config.CLM45.Rd b/models/clm45/man/write.config.CLM45.Rd index 83ca34b8c32..2532a4ceca7 100644 --- a/models/clm45/man/write.config.CLM45.Rd +++ b/models/clm45/man/write.config.CLM45.Rd @@ -9,11 +9,11 @@ write.config.CLM45(defaults, trait.values, settings, run.id) \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ none diff --git a/models/clm45/tests/Rcheck_reference.log b/models/clm45/tests/Rcheck_reference.log index 3675c3c1761..bd8698df72d 100644 --- a/models/clm45/tests/Rcheck_reference.log +++ b/models/clm45/tests/Rcheck_reference.log @@ -61,11 +61,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Mike Dietze’ - Authors@R: ‘Mike Dietze [aut, cre], University of Illinois, NCSA [cph]’ - +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/models/dalec/R/met2model.DALEC.R b/models/dalec/R/met2model.DALEC.R index 8658471f972..0ce459df567 100644 --- a/models/dalec/R/met2model.DALEC.R +++ b/models/dalec/R/met2model.DALEC.R @@ -15,6 +15,9 @@ ##' @param end_date the end date of the data to be downloaded (will only use the year part of the date) ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose +##' @param spin_nyear,spin_nsample,spin_resample passed on to +##' `PEcAn.data.atmosphere::spin.met()` +##' @param ... additional arguments, currently ignored met2model.DALEC <- function(in.path, in.prefix, outfolder, start_date, end_date, overwrite = FALSE, verbose = FALSE, spin_nyear=NULL,spin_nsample=NULL,spin_resample=NULL, ...) { diff --git a/models/dalec/R/write.configs.dalec.R b/models/dalec/R/write.configs.dalec.R index 863e5fc1ecf..64859b1c1fe 100644 --- a/models/dalec/R/write.configs.dalec.R +++ b/models/dalec/R/write.configs.dalec.R @@ -72,10 +72,11 @@ convert.samples.DALEC <- function(trait.samples) { ##' write Dalec Configuration files ##' ##' @title write.config.DALEC -##' @param defaults -##' @param trait.values -##' @param settings -##' @param run.id +##' @param defaults ignored +##' @param trait.values vector of samples for a given trait +##' @param settings a PEcAn settings object +##' @param run.id Unique identifier for the run, +##' used here to construct output directories and filenames. ##' @return configuration files ##' @export write.config.DALEC write.config.DALEC <- function(defaults, trait.values, settings, run.id) { diff --git a/models/dalec/man/met2model.DALEC.Rd b/models/dalec/man/met2model.DALEC.Rd index 66ef48f260a..f6fff625826 100644 --- a/models/dalec/man/met2model.DALEC.Rd +++ b/models/dalec/man/met2model.DALEC.Rd @@ -32,6 +32,11 @@ met2model.DALEC( \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbose} + +\item{spin_nyear, spin_nsample, spin_resample}{passed on to +`PEcAn.data.atmosphere::spin.met()`} + +\item{...}{additional arguments, currently ignored} } \description{ met2model for DALEC diff --git a/models/dalec/man/write.config.DALEC.Rd b/models/dalec/man/write.config.DALEC.Rd index 4d0329829db..559b3ca3cd6 100644 --- a/models/dalec/man/write.config.DALEC.Rd +++ b/models/dalec/man/write.config.DALEC.Rd @@ -6,6 +6,16 @@ \usage{ write.config.DALEC(defaults, trait.values, settings, run.id) } +\arguments{ +\item{defaults}{ignored} + +\item{trait.values}{vector of samples for a given trait} + +\item{settings}{a PEcAn settings object} + +\item{run.id}{Unique identifier for the run, +used here to construct output directories and filenames.} +} \value{ configuration files } diff --git a/models/dalec/tests/Rcheck_reference.log b/models/dalec/tests/Rcheck_reference.log index a4ac261c1d4..97412f1c129 100644 --- a/models/dalec/tests/Rcheck_reference.log +++ b/models/dalec/tests/Rcheck_reference.log @@ -66,11 +66,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Mike Dietze, Tristain Quaife’ - Authors@R: ‘Mike Dietze [aut, cre], Tristan Quaife [aut], University of Illinois, NCSA [cph]’ - +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/models/dvmdostem/R/write.config.dvmdostem.R b/models/dvmdostem/R/write.config.dvmdostem.R index 96ec59805bb..9e0298b2040 100644 --- a/models/dvmdostem/R/write.config.dvmdostem.R +++ b/models/dvmdostem/R/write.config.dvmdostem.R @@ -191,20 +191,25 @@ requested_vars_string2list <- function(req_v_str, outspec_path) { return(req_v_list) } -##------------------------------------------------------------------------------------------------# -##' convert parameters, do unit conversions and update parameter names from PEcAn database default -##' to units/names within dvmdostem -##' -##' Performs model specific unit conversions on a a list of trait values, -##' such as those provided to write.config -##' -##' @name convert.samples.dvmdostem -##' @title Convert samples for dvmdostem -##' @param trait_samples a matrix or dataframe of samples from the trait distribution -##' @return matrix or dataframe with values transformed -##' @export -##' @author Shawn Serbin, Tobey Carman -##' + + + + + + +#' Convert samples for dvmdostem +#' +#' convert parameters, do unit conversions and update parameter names from PEcAn database default +#' to units/names within dvmdostem +#' +#' Performs model specific unit conversions on a a list of trait values, +#' such as those provided to write.config +#' +#' @param trait_values a matrix or dataframe of samples from the trait distribution +#' @return matrix or dataframe with values transformed +#' @export +#' @author Shawn Serbin, Tobey Carman +#' convert.samples.dvmdostem <- function(trait_values) { if("SLA" %in% names(trait_values)) { diff --git a/models/dvmdostem/man/convert.samples.dvmdostem.Rd b/models/dvmdostem/man/convert.samples.dvmdostem.Rd index ef1b77e7819..8e8bdeaa29e 100644 --- a/models/dvmdostem/man/convert.samples.dvmdostem.Rd +++ b/models/dvmdostem/man/convert.samples.dvmdostem.Rd @@ -7,7 +7,7 @@ convert.samples.dvmdostem(trait_values) } \arguments{ -\item{trait_samples}{a matrix or dataframe of samples from the trait distribution} +\item{trait_values}{a matrix or dataframe of samples from the trait distribution} } \value{ matrix or dataframe with values transformed diff --git a/models/ed/DESCRIPTION b/models/ed/DESCRIPTION index 7ec7dc534fb..91181d1f474 100644 --- a/models/ed/DESCRIPTION +++ b/models/ed/DESCRIPTION @@ -31,7 +31,7 @@ Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific efficacy of scientific investigation. This package provides functions to link the Ecosystem Demography Model, version 2, to PEcAn. Depends: - R (>= 2.10) + R (>= 3.5) Imports: abind (>= 1.4.5), assertthat, @@ -57,11 +57,13 @@ Imports: Suggests: testthat (>= 1.0.2), devtools, + knitr, + rmarkdown, withr Additional_repositories: https://pecanproject.r-universe.dev/ License: BSD_3_clause + file LICENSE Copyright: Authors -LazyLoad: yes +VignetteBuilder: knitr LazyData: true Encoding: UTF-8 RoxygenNote: 7.3.2 diff --git a/models/ed/R/check_veg.R b/models/ed/R/check_veg.R index d8b4b53f12b..b69c1be2cbb 100644 --- a/models/ed/R/check_veg.R +++ b/models/ed/R/check_veg.R @@ -9,12 +9,13 @@ #' @return `NULL` (invisibly) #' @export check_css <- function(css, pss = NULL) { - if(!inherits(css, "data.frame") | nrow(css) == 0) { + if(!inherits(css, "data.frame") || nrow(css) == 0) { stop("css file should be a data frame") } - if(colnames(css) != c("time", "patch", "cohort", "dbh", "hite", "pft", - "n", "bdead", "balive", "lai")) { + expected_colnames <- c("time", "patch", "cohort", "dbh", "hite", "pft", + "n", "bdead", "balive", "lai") + if (!identical(colnames(css), expected_colnames)) { stop("css file is formatted incorrectly") } @@ -29,7 +30,7 @@ check_css <- function(css, pss = NULL) { #' @rdname check_css #' @export check_pss <- function(pss, site = NULL) { - if(!inherits(pss, "data.frame") | nrow(pss) == 0) { + if (!inherits(pss, "data.frame") || nrow(pss) == 0) { stop("css file should be a data frame") } if (!is.null(site)) { @@ -43,8 +44,9 @@ check_pss <- function(pss, site = NULL) { #' @rdname check_css #' @export check_site <- function(site) { - stopifnot(nrow(site) >= 1) - stopifnot(!is.null(attributes(site))) - stopifnot(attr(site, "nsite") == "numeric") - stopifnot(attr(site, "file_format") %in% c(1, 2, 3)) + stopifnot( + nrow(site) >= 1, + !is.null(attributes(site)), + is.numeric(attr(site, "nsite")), + attr(site, "file_format") %in% c(1, 2, 3)) } diff --git a/models/ed/R/modify_ed2in.R b/models/ed/R/modify_ed2in.R index 3cd6a4549f7..9cc843659db 100644 --- a/models/ed/R/modify_ed2in.R +++ b/models/ed/R/modify_ed2in.R @@ -30,7 +30,7 @@ #' - "restart" -- Restart file for HISTORY runs. (`ISOUTPUT`) #' - "all" -- All output types #' -#' @inheritParams read_ed2in +#' @param ed2in list to modify #' @param ... Namelist arguments (see Description and Details) #' @param veg_prefix Vegetation file prefix (`SFILIN`). If `lat` and `lon` are part of the prefix, #' @param latitude Run latitude coordinate. If `veg_prefix` is also provided, diff --git a/models/ed/R/read_ed_metheader.R b/models/ed/R/read_ed_metheader.R index bcc285a2d3d..640a531cde1 100644 --- a/models/ed/R/read_ed_metheader.R +++ b/models/ed/R/read_ed_metheader.R @@ -25,7 +25,7 @@ #' - `flag_description` -- Description of variable flag #' #' The formatting of a meteorology header file is as follows (from the [ED -#' GitHub Wiki][https://github.com/EDmodel/ED2/wiki/Drivers]): +#' GitHub Wiki](https://github.com/EDmodel/ED2/wiki/Drivers)): #' #' ``` #' # Repeat lines below this number of times diff --git a/models/ed/R/write.configs.ed.R b/models/ed/R/write.configs.ed.R index f4446a29e92..a0da36fb94d 100644 --- a/models/ed/R/write.configs.ed.R +++ b/models/ed/R/write.configs.ed.R @@ -399,13 +399,13 @@ write.config.ED2 <- function(trait.values, settings, run.id, defaults = settings # ==================================================================================================# ##-------------------------------------------------------------------------------------------------# -##' Clear out old config and ED model run files. -##' -##' @name remove.config.ED2 -##' @title Clear out old config and ED model run files. -##' @return nothing, removes config files as side effect -##' @export -##' @author Shawn Serbin, David LeBauer, Alexey Shikomanov +#' Clear out old config and ED model run files. +#' +#' @param main.outdir ignored +#' @param settings PEcAn settings object +#' @return nothing, removes config files as side effect +#' @export +#' @author Shawn Serbin, David LeBauer, Alexey Shikomanov remove.config.ED2 <- function(main.outdir = settings$outdir, settings) { print(" ") diff --git a/models/ed/man/modify_ed2in.Rd b/models/ed/man/modify_ed2in.Rd index 26b8d093ca4..ce341cea301 100644 --- a/models/ed/man/modify_ed2in.Rd +++ b/models/ed/man/modify_ed2in.Rd @@ -27,6 +27,8 @@ modify_ed2in( ) } \arguments{ +\item{ed2in}{list to modify} + \item{...}{Namelist arguments (see Description and Details)} \item{veg_prefix}{Vegetation file prefix (\code{SFILIN}). If \code{lat} and \code{lon} are part of the prefix,} diff --git a/models/ed/man/read_ed_metheader.Rd b/models/ed/man/read_ed_metheader.Rd index c35941ddc0a..04c58f16eb8 100644 --- a/models/ed/man/read_ed_metheader.Rd +++ b/models/ed/man/read_ed_metheader.Rd @@ -48,7 +48,7 @@ Starred columns are required for writing. This table is left joined with } } -The formatting of a meteorology header file is as follows (from the \link[=https://github.com/EDmodel/ED2/wiki/Drivers]{ED GitHub Wiki}): +The formatting of a meteorology header file is as follows (from the \href{https://github.com/EDmodel/ED2/wiki/Drivers}{ED GitHub Wiki}): \if{html}{\out{
}}\preformatted{ # Repeat lines below this number of times diff --git a/models/ed/man/remove.config.ED2.Rd b/models/ed/man/remove.config.ED2.Rd index 10c1e6cd7dc..40b8e992899 100644 --- a/models/ed/man/remove.config.ED2.Rd +++ b/models/ed/man/remove.config.ED2.Rd @@ -6,6 +6,11 @@ \usage{ remove.config.ED2(main.outdir = settings$outdir, settings) } +\arguments{ +\item{main.outdir}{ignored} + +\item{settings}{PEcAn settings object} +} \value{ nothing, removes config files as side effect } diff --git a/models/ed/tests/Rcheck_reference.log b/models/ed/tests/Rcheck_reference.log index d478d30d2ae..0b419885b14 100644 --- a/models/ed/tests/Rcheck_reference.log +++ b/models/ed/tests/Rcheck_reference.log @@ -23,7 +23,8 @@ use conditionally. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... OK +* checking DESCRIPTION meta-information ... NOTE +License stub is invalid DCF. * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK @@ -46,25 +47,10 @@ File ‘PEcAn.ED2/R/model2netcdf.ED2.R’: * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK -* checking Rd cross-references ... WARNING -Missing link or links in documentation object 'read_ed_metheader.Rd': - ‘https://github.com/EDmodel/ED2/wiki/Drivers’ - -See section 'Cross-references' in the 'Writing R Extensions' manual. +* checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'modify_ed2in' - ‘ed2in’ - -Undocumented arguments in documentation object 'remove.config.ED2' - ‘main.outdir’ ‘settings’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK @@ -72,10 +58,7 @@ Extensions’ manual. * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK * checking R/sysdata.rda ... OK -* checking files in ‘vignettes’ ... WARNING -Files in the 'vignettes' directory but no files in 'inst/doc': - ‘running_ed_from_R.Rmd’ -Package has no Sweave vignette sources and no VignetteBuilder field. +* checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... diff --git a/models/ed/vignettes/running_ed_from_R.Rmd b/models/ed/vignettes/running_ed_from_R.Rmd index 4e590f035f4..39393384bdc 100644 --- a/models/ed/vignettes/running_ed_from_R.Rmd +++ b/models/ed/vignettes/running_ed_from_R.Rmd @@ -1,6 +1,10 @@ --- title: "Running ED from R" author: "Alexey Shiklomanov" +output_format: rmarkdown::html_vignette +vignette: | + %\VignetteIndexEntry{Running ED from R} + %\VignetteEngine{knitr::rmarkdown} --- # Introduction @@ -17,13 +21,15 @@ This tutorial describes these utilites and provides examples of common use cases The `PEcAn.ED2` package and its PEcAn dependencies can be installed from GitHub as follows (all CRAN package dependencies should be installed automatically): -```{r install, eval = -(1:5)} +```{r install, eval = FALSE} devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/logger") devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/utils") devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/settings") devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "modules/data.atmosphere") devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "models/ed") +``` +```{r library} library(PEcAn.ED2) ``` @@ -46,8 +52,7 @@ These can be customized to some extent, but this package provides a version of t These inputs, stored in an "EDI" directory, can be downloaded via the `download_edi` function: ```{r get_edi} -library(here) -rundir <- here("vignettes", "ed_run_data") +rundir <- file.path(tempdir(), "ed_run_data") dir.create(rundir, showWarnings = FALSE) edi_dir <- file.path(rundir, "EDI") @@ -164,6 +169,7 @@ ed2in <- modify_ed2in( run_dir = file.path(rundir, "run"), output_dir = file.path(rundir, "out"), runtype = "INITIAL", + pecan_defaults = TRUE, EXPNME = "ED test run" ) ``` diff --git a/models/fates/R/met2model.FATES.R b/models/fates/R/met2model.FATES.R index 8794c779993..0398ff7a547 100755 --- a/models/fates/R/met2model.FATES.R +++ b/models/fates/R/met2model.FATES.R @@ -11,8 +11,10 @@ ##' @param start_date the start date of the data to be downloaded ##' @param end_date the end date of the data to be downloaded ##' @param lst timezone offset to GMT in hours +##' @param lat,lon latitude and longitude of site in decimal degrees ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose for(year in start_year:end_year) +##' @param ... additional arguments, currently ignored ##' @importFrom ncdf4 ncvar_get ncdim_def ncatt_get ncvar_put met2model.FATES <- function(in.path,in.prefix,outfolder,start_date,end_date,lst=0,lat, lon, overwrite = FALSE, verbose = FALSE, ...) { diff --git a/models/fates/man/met2model.FATES.Rd b/models/fates/man/met2model.FATES.Rd index 9ad044a42a4..681e180d99e 100644 --- a/models/fates/man/met2model.FATES.Rd +++ b/models/fates/man/met2model.FATES.Rd @@ -31,9 +31,13 @@ met2model.FATES( \item{lst}{timezone offset to GMT in hours} +\item{lat, lon}{latitude and longitude of site in decimal degrees} + \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbose for(year in start_year:end_year)} + +\item{...}{additional arguments, currently ignored} } \description{ met2model wrapper for FATES diff --git a/models/fates/tests/Rcheck_reference.log b/models/fates/tests/Rcheck_reference.log index 2d8774fc596..9a243925f81 100644 --- a/models/fates/tests/Rcheck_reference.log +++ b/models/fates/tests/Rcheck_reference.log @@ -90,15 +90,7 @@ Author field differs from that derived from Authors@R * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.FATES' - ‘lat’ ‘lon’ ‘...’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... OK diff --git a/models/gday/R/met2model.GDAY.R b/models/gday/R/met2model.GDAY.R index 2c8081814ad..c38338f2aba 100644 --- a/models/gday/R/met2model.GDAY.R +++ b/models/gday/R/met2model.GDAY.R @@ -23,6 +23,7 @@ ##' the year part of the date) ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose +##' @param ... additional arguments, currently ignored ##' @return generates GDAY formatted met file as a side affect, returns file metadata ##' that will be inserted into database ##' @author Martin De Kauwe, Tony Gardella diff --git a/models/gday/R/write.config.GDAY.R b/models/gday/R/write.config.GDAY.R index 8e0d4a4503e..cd7267327c0 100644 --- a/models/gday/R/write.config.GDAY.R +++ b/models/gday/R/write.config.GDAY.R @@ -6,7 +6,7 @@ ##' @name write.config.GDAY ##' @title Write GDAY configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for GDAY for given run diff --git a/models/gday/man/met2model.GDAY.Rd b/models/gday/man/met2model.GDAY.Rd index 3d162c93932..5a180d85eb5 100644 --- a/models/gday/man/met2model.GDAY.Rd +++ b/models/gday/man/met2model.GDAY.Rd @@ -31,6 +31,8 @@ the year part of the date)} \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbose} + +\item{...}{additional arguments, currently ignored} } \value{ generates GDAY formatted met file as a side affect, returns file metadata diff --git a/models/gday/man/write.config.GDAY.Rd b/models/gday/man/write.config.GDAY.Rd index a014a94e23e..eaec14b8082 100644 --- a/models/gday/man/write.config.GDAY.Rd +++ b/models/gday/man/write.config.GDAY.Rd @@ -9,11 +9,11 @@ write.config.GDAY(defaults, trait.values, settings, run.id) \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for GDAY for given run diff --git a/models/gday/tests/Rcheck_reference.log b/models/gday/tests/Rcheck_reference.log index 38b4086117a..2b67a250978 100644 --- a/models/gday/tests/Rcheck_reference.log +++ b/models/gday/tests/Rcheck_reference.log @@ -100,20 +100,7 @@ Package in Depends field not imported from: ‘PEcAn.utils’ * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.GDAY' - ‘...’ - -Undocumented arguments in documentation object 'write.config.GDAY' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.GDAY': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... NONE diff --git a/models/jules/DESCRIPTION b/models/jules/DESCRIPTION index d4fbb5852ef..3e6210fee3e 100644 --- a/models/jules/DESCRIPTION +++ b/models/jules/DESCRIPTION @@ -5,8 +5,6 @@ Version: 1.7.3.9000 Authors@R: c(person("Mike", "Dietze", role = c("aut", "cre"), email = "dietze@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Mike Dietze -Maintainer: Mike Dietze Description: This module provides functions to link the (JULES) to PEcAn. Imports: PEcAn.data.atmosphere, diff --git a/models/jules/R/write.config.JULES.R b/models/jules/R/write.config.JULES.R index 1f01f7b60be..a4843cc7a29 100644 --- a/models/jules/R/write.config.JULES.R +++ b/models/jules/R/write.config.JULES.R @@ -3,10 +3,8 @@ ##' Requires a pft xml object, a list of trait values for a single model run, ##' and the name of the file to create ##' -##' @name write.config.JULES -##' @title Write JULES configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for JULES for given run @@ -581,14 +579,15 @@ write.config.JULES <- function(defaults, trait.values, settings, run.id) { #' Detect timestep of JULES met files #' -#' @param met.dir -#' @param met.regexp -#' @param start_date +#' @param met.dir path to directory containing met files +#' @param met.regexp pattern to match to find a met file in met.dir. +#' If more than one file matches, only the first will be used. +#' @param start_date When in file to start checking deltas. +#' Not used if timestep can be detected from the CDF header. #' #' @return a difftime object #' @export #' -#' @examples detect.timestep <- function(met.dir,met.regexp,start_date){ met.file <- dir(met.dir, pattern = met.regexp, full.names = TRUE)[1] PEcAn.logger::logger.info("Detect timestep:",met.dir,met.regexp) diff --git a/models/jules/man/detect.timestep.Rd b/models/jules/man/detect.timestep.Rd index 4ce5e36b155..05394f44327 100644 --- a/models/jules/man/detect.timestep.Rd +++ b/models/jules/man/detect.timestep.Rd @@ -7,7 +7,13 @@ detect.timestep(met.dir, met.regexp, start_date) } \arguments{ -\item{start_date}{} +\item{met.dir}{path to directory containing met files} + +\item{met.regexp}{pattern to match to find a met file in met.dir. +If more than one file matches, only the first will be used.} + +\item{start_date}{When in file to start checking deltas. +Not used if timestep can be detected from the CDF header.} } \value{ a difftime object diff --git a/models/jules/man/write.config.JULES.Rd b/models/jules/man/write.config.JULES.Rd index 57668954e59..379f67feb8c 100644 --- a/models/jules/man/write.config.JULES.Rd +++ b/models/jules/man/write.config.JULES.Rd @@ -2,26 +2,23 @@ % Please edit documentation in R/write.config.JULES.R \name{write.config.JULES} \alias{write.config.JULES} -\title{Write JULES configuration files} +\title{Writes a JULES config file.} \usage{ write.config.JULES(defaults, trait.values, settings, run.id) } \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for JULES for given run } \description{ -Writes a JULES config file. -} -\details{ Requires a pft xml object, a list of trait values for a single model run, and the name of the file to create } diff --git a/models/jules/tests/Rcheck_reference.log b/models/jules/tests/Rcheck_reference.log index de6178b607e..9e6edfb8888 100644 --- a/models/jules/tests/Rcheck_reference.log +++ b/models/jules/tests/Rcheck_reference.log @@ -12,47 +12,9 @@ Maintainer: ‘Mike Dietze ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Strong dependencies not in mainstream repositories: PEcAn.data.atmosphere, PEcAn.logger, PEcAn.remote, PEcAn.utils -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -66,11 +28,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Mike Dietze’ - Authors@R: ‘Mike Dietze [aut, cre], University of Illinois, NCSA [cph]’ - +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK @@ -95,24 +53,8 @@ Author field differs from that derived from Authors@R * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'detect.timestep' - ‘met.dir’ ‘met.regexp’ - -Undocumented arguments in documentation object 'write.config.JULES' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.JULES': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. -* checking Rd contents ... WARNING -Argument items with no description in Rd object 'detect.timestep': - ‘start_date’ - +* checking Rd \usage sections ... OK +* checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK @@ -121,4 +63,4 @@ Argument items with no description in Rd object 'detect.timestep': * checking for detritus in the temp directory ... OK * DONE -Status: 3 WARNINGs, 1 NOTEs +Status: 0 WARNINGs, 0 NOTEs diff --git a/models/linkages/DESCRIPTION b/models/linkages/DESCRIPTION index 1af0e98ffb0..79e0b26d0fb 100644 --- a/models/linkages/DESCRIPTION +++ b/models/linkages/DESCRIPTION @@ -7,17 +7,16 @@ Authors@R: c(person("Mike", "Dietze", role = c("aut"), person("Ann", "Raiho", role = c("aut", "cre"), email = "araiho@nd.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Ann Raiho, Mike Dietze -Maintainer: Ann Raiho Description: This module provides functions to link the (LINKAGES) to PEcAn. -Depends: - PEcAn.utils Imports: - PEcAn.data.atmosphere, + PEcAn.data.land, + PEcAn.DB, PEcAn.logger, PEcAn.remote, + PEcAn.utils, lubridate (>= 1.6.0), ncdf4 (>= 1.15), + utils Suggests: testthat (>= 1.0.2), linkages diff --git a/models/linkages/NAMESPACE b/models/linkages/NAMESPACE index cfd232ec26b..2897d5a0467 100644 --- a/models/linkages/NAMESPACE +++ b/models/linkages/NAMESPACE @@ -6,5 +6,3 @@ export(read_restart.LINKAGES) export(split_inputs.LINKAGES) export(write.config.LINKAGES) export(write_restart.LINKAGES) -importFrom(ncdf4,ncdim_def) -importFrom(ncdf4,ncvar_def) diff --git a/models/linkages/R/met2model.LINKAGES.R b/models/linkages/R/met2model.LINKAGES.R index f1db9f3e2b5..f73a2008fd6 100644 --- a/models/linkages/R/met2model.LINKAGES.R +++ b/models/linkages/R/met2model.LINKAGES.R @@ -1,18 +1,22 @@ -##' Converts a met CF file to a model specific met file. The input -##' files are calld /.YYYY.cf -##' -##' @name met2model.LINKAGES -##' @title Write LINKAGES met files -##' @param in.path path on disk where CF file lives -##' @param in.prefix prefix for each file -##' @param outfolder location where model specific output is written. -##' @return OK if everything was succesful. -##' @export -##' @author Ann Raiho, Betsy Cowdery -##-------------------------------------------------------------------------------------------------# +#' Write LINKAGES met files +#' +#' Converts a met CF file to a model specific met file. The input +#' files are calld /.YYYY.cf +#' +#' @param in.path path on disk where CF file lives +#' @param in.prefix prefix for each file +#' @param outfolder location where model specific output is written +#' @param start_date,end_date when to start and end conversion. +#' Only year portion is used +#' @param overwrite Force replacement of an existing output file? +#' @param verbose ignored +#' @param ... Additional arguments, currently ignored +#' @return OK if everything was succesful. +#' @export +#' @author Ann Raiho, Betsy Cowdery +#' met2model.LINKAGES <- function(in.path, in.prefix, outfolder, start_date, end_date, overwrite = FALSE, verbose = FALSE, ...) { - library(PEcAn.utils) start_date <- as.POSIXlt(start_date, tz = "GMT") end_date <- as.POSIXlt(end_date, tz = "GMT") @@ -50,8 +54,6 @@ met2model.LINKAGES <- function(in.path, in.prefix, outfolder, start_date, end_da } } - library(PEcAn.data.atmosphere) - ## check to see if the outfolder is defined, if not create directory for output if (!file.exists(outfolder)) { dir.create(outfolder) @@ -88,7 +90,7 @@ met2model.LINKAGES <- function(in.path, in.prefix, outfolder, start_date, end_da month_matrix_precip[i, m] <- (sum(ncprecipf[DOY_vec_hr[m]:(DOY_vec_hr[m + 1] - 1)]) * dt / 10) } ncdf4::nc_close(ncin) - # if(i%%100==0) cat(i,' '); flush.console() + # if(i%%100==0) cat(i,' '); utils::flush.console() } month_matrix_temp_mean <- matrix(NA, nyear, 12) @@ -110,7 +112,7 @@ met2model.LINKAGES <- function(in.path, in.prefix, outfolder, start_date, end_da if (i %% 100 == 0) { cat(i, " ") } - flush.console() + utils::flush.console() } precip.mat <- month_matrix_precip diff --git a/models/linkages/R/model2netcdf.LINKAGES.R b/models/linkages/R/model2netcdf.LINKAGES.R index a24b9f017f7..68afa4ecd6f 100644 --- a/models/linkages/R/model2netcdf.LINKAGES.R +++ b/models/linkages/R/model2netcdf.LINKAGES.R @@ -1,23 +1,21 @@ -##' Convert MODEL output into the NACP Intercomparison format (ALMA using netCDF) -##' -##' @name model2netcdf.LINKAGES -##' @title Code to convert LINKAGES's output into netCDF format -##' -##' @param outdir Location of model output -##' @param sitelat Latitude of the site -##' @param sitelon Longitude of the site -##' @param start_date Start time of the simulation -##' @param end_date End time of the simulation -##' @export -##' -##' @author Ann Raiho, Betsy Cowdery -##' @importFrom ncdf4 ncdim_def ncvar_def +#' Convert LINKAGES's output into netCDF format +#' +#' Convert MODEL output into the NACP Intercomparison format (ALMA using netCDF) +#' +#' @param outdir Location of model output +#' @param sitelat Latitude of the site +#' @param sitelon Longitude of the site +#' @param start_date Start time of the simulation +#' @param end_date End time of the simulation +#' @param pft_names names of PFTs to use in output labels +#' @export +#' +#' @author Ann Raiho, Betsy Cowdery +#' model2netcdf.LINKAGES <- function(outdir, sitelat, sitelon, start_date = NULL, end_date = NULL, pft_names = NULL) { # , PFTs) { logger.severe('NOT IMPLEMENTED') - library(PEcAn.utils) - ### Read in model output in linkages format load(file.path(outdir, "linkages.out.Rdata")) # linkages.output.dims <- dim(linkages.output) diff --git a/models/linkages/R/read_restart.LINKAGES.R b/models/linkages/R/read_restart.LINKAGES.R index c5d59f2957d..2fa8d820ba4 100644 --- a/models/linkages/R/read_restart.LINKAGES.R +++ b/models/linkages/R/read_restart.LINKAGES.R @@ -1,24 +1,23 @@ -##' @title read_restart.LINKAGES -##' @name read_restart.LINKAGES -##' @author Ann Raiho \email{araiho@@nd.edu} -##' -##' @param outdir output directory -##' @param runid run ID -##' @param stop.time year that is being read -##' @param multi.settings PEcAn settings object -##' @param var.names var.names to be extracted -##' -##' @description Read Restart for LINKAGES -##' -##' @return X.vec vector of forecasts -##' @export -##' +#' Read Restart for LINKAGES +#' +#' @author Ann Raiho \email{araiho@@nd.edu} +#' +#' @param outdir output directory +#' @param runid run ID +#' @param stop.time year that is being read +#' @param settings PEcAn settings object +#' @param var.names var.names to be extracted +#' @param params passed on to return value +#' +#' @return X.vec vector of forecasts +#' @export +#' read_restart.LINKAGES <- function(outdir, runid, stop.time, settings, var.names = NULL, params = NULL) { - + # Read ensemble output - ens <- read.output(runid = runid, - outdir = file.path(outdir, runid), - start.year = lubridate::year(stop.time), + ens <- PEcAn.utils::read.output(runid = runid, + outdir = file.path(outdir, runid), + start.year = lubridate::year(stop.time), end.year = lubridate::year(stop.time), variables = var.names, pft.name = unlist(sapply(settings$pfts,'[[', "name"))) # change to just 'AGB' for plot level biomass if(!is.na(ens)){ @@ -29,21 +28,21 @@ read_restart.LINKAGES <- function(outdir, runid, stop.time, settings, var.names } #ens.pft.names <- grep("pft", names(ens)) #names(ens[[grep("pft", names(ens))]]) <- pft.names - + forecast <- list() if ("Fcomp" %in% var.names) { - forecast[[length(forecast)+1]] <- ens$AGB.pft #already has C #* unit.conv + forecast[[length(forecast)+1]] <- ens$AGB.pft #already has C #* unit.conv names(forecast[[length(forecast)]]) <- paste0('Fcomp.',pft.names) } - + if ("AGB.pft" %in% var.names) { - forecast[[length(forecast)+1]] <- ens$AGB.pft #already has C #* unit.conv + forecast[[length(forecast)+1]] <- ens$AGB.pft #already has C #* unit.conv names(forecast[[length(forecast)]]) <- paste0('AGB.pft.',pft.names) } - + if ("TotSoilCarb" %in% var.names) { - forecast[[length(forecast)+1]] <- ens$TotSoilCarb #PEcAn.utils::ud_convert(ens$TotSoilCarb, "kg/m^2", "Mg/ha") #* unit.conv + forecast[[length(forecast)+1]] <- ens$TotSoilCarb #PEcAn.utils::ud_convert(ens$TotSoilCarb, "kg/m^2", "Mg/ha") #* unit.conv names(forecast[[length(forecast)]]) <- c("TotSoilCarb") } @@ -63,7 +62,6 @@ read_restart.LINKAGES <- function(outdir, runid, stop.time, settings, var.names # Put forecast into vector print(runid) X_tmp <- list(X = unlist(forecast), params = params) - + return(X_tmp) } - diff --git a/models/linkages/R/sample.IC.LINKAGES.R b/models/linkages/R/sample.IC.LINKAGES.R index 0b278c74e55..a1d5b18e1fd 100644 --- a/models/linkages/R/sample.IC.LINKAGES.R +++ b/models/linkages/R/sample.IC.LINKAGES.R @@ -2,15 +2,15 @@ sample.IC.LINKAGES <- function(ne, state, year = NULL) { ## g C * m-2 ground area in wood (above-ground + roots) biomass_tsca = ifelse(rep("biomass_tsca" %in% names(state), ne), state$biomass_tsca[1, sample.int(ncol(state$biomass_tsca),ne), 1] * 0.1, ## unit Mg/ha ->kg/m2 - runif(ne, 0, 14000)) ## prior + stats::runif(ne, 0, 14000)) ## prior biomass_acsa3 = ifelse(rep("biomass_acsa3" %in% names(state), ne), state$biomass_acsa3[1, sample.int(ncol(state$biomass_acsa3), ne), 1] * 0.1, ## unit Mg/ha ->kg/m2 - runif(ne, 0, 14000)) ## prior + stats::runif(ne, 0, 14000)) ## prior biomass_beal2 = ifelse(rep("biomass_beal2" %in% names(state),ne), state$biomass_beal2[1, sample.int(ncol(state$biomass_beal2),ne), 1] * 0.1, ## unit Mg/ha ->kg/m2 - runif(ne, 0, 14000)) ## prior + stats::runif(ne, 0, 14000)) ## prior biomass_thoc2 = ifelse(rep("biomass_thoc2" %in% names(state),ne), state$biomass_thoc2[1, sample.int(ncol(state$biomass_thoc2), ne), 1] * 0.1, ## unit Mg/ha ->kg/m2 - runif(ne, 0, 14000)) ## prior + stats::runif(ne, 0, 14000)) ## prior return(data.frame(biomass_tsca, biomass_acsa3, biomass_beal2, biomass_thoc2)) } # sample.IC.LINKAGES diff --git a/models/linkages/R/split_inputs.LINKAGES.R b/models/linkages/R/split_inputs.LINKAGES.R index 9be21c69ddb..24e7d68051e 100644 --- a/models/linkages/R/split_inputs.LINKAGES.R +++ b/models/linkages/R/split_inputs.LINKAGES.R @@ -1,17 +1,20 @@ -##' @title split_inputs.LINKAGES -##' @name split_inputs.LINKAGES -##' @author Ann Raiho -##' -##' @param settings -##' @param start.time -##' @param stop.time -##' @description Splits climate met for LINKAGES -##' -##' @return files split up climate files -##' @export -##' +#' split_inputs.LINKAGES +#' +#' Splits climate met for LINKAGES +#' +#' Stub implementation -- currently returns `inputs` and ignores all other arguments +#' +#' @author Ann Raiho +#' +#' @param settings ignored +#' @param start.time,stop.time ignored +#' @param inputs returned +#' +#' @return files split up climate files +#' @export +#' split_inputs.LINKAGES <- function(settings, start.time, stop.time, inputs) { - + return(inputs) - + } # split_inputs.LINKAGES diff --git a/models/linkages/R/write.config.LINKAGES.R b/models/linkages/R/write.config.LINKAGES.R index 3cb2dec58fe..43c300a33ca 100644 --- a/models/linkages/R/write.config.LINKAGES.R +++ b/models/linkages/R/write.config.LINKAGES.R @@ -1,18 +1,25 @@ -##' Writes a LINKAGES config file. -##' -##' Requires a pft xml object, a list of trait values for a single model run, -##' and the name of the file to create -##' -##' @name write.config.LINKAGES -##' @title Write LINKAGES configuration files -##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait -##' @param settings list of settings from pecan settings file -##' @param run.id id of run -##' @return configuration file for LINKAGES for given run -##' @export -##' @author Ann Raiho, Betsy Cowdery -##-------------------------------------------------------------------------------------------------# +#' Writes a LINKAGES config file. +#' +#' Requires a pft xml object, a list of trait values for a single model run, +#' and the name of the file to create +#' +#' @param defaults list of defaults to process +#' @param trait.values vector of samples for a given trait +#' @param settings list of settings from pecan settings file +#' @param run.id id of run +#' @param restart logical: Write a restart file? +#' If NULL (default), treated as FALSE +#' @param spinup logical: perform spinup using `spinup.LINKAGES()`? +#' If NULL (default), treated as FALSE +#' @param inputs inputs section of a PEcAn settings object. +#' Currently only used for climate file (inputs$met$path), +#' which is taken from `settings$input$met$path` if `inputs` is NULL. +#' @param IC TODO currently ignored +#' +#' @return configuration file for LINKAGES for given run +#' @export +#' @author Ann Raiho, Betsy Cowdery +#' write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.id, restart = NULL, spinup = FALSE, inputs = NULL, IC = NULL) { @@ -25,9 +32,7 @@ write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.i } ##TO DO add restart file as IC for HF - - library(linkages) - + # find out where to write run/ouput rundir <- file.path(settings$host$rundir, run.id) if (!file.exists(rundir)) { # why not use `dir.exists`? @@ -52,10 +57,10 @@ write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.i bgs <- 120 egs <- 273 - texture <- read.csv(system.file("texture.csv", package = "PEcAn.LINKAGES")) + texture <- utils::read.csv(system.file("texture.csv", package = "PEcAn.LINKAGES")) - dbcon <- db.open(settings$database$bety) - on.exit(db.close(dbcon), add = TRUE) + dbcon <- PEcAn.DB::db.open(settings$database$bety) + on.exit(PEcAn.DB::db.close(dbcon), add = TRUE) if("soil" %in% names(settings$run$inputs)){ ## open soil file @@ -68,11 +73,11 @@ write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.i if(length(fc) > 1) fc <- mean(fc) if(length(dry) > 1) dry <- mean(dry) ncdf4::nc_close(nc.soil) - + }else{ - soils <- db.query(paste("SELECT soil,som,sand_pct,clay_pct,soilnotes FROM sites WHERE id =", settings$run$site$id), + soils <- PEcAn.DB::db.query(paste("SELECT soil,som,sand_pct,clay_pct,soilnotes FROM sites WHERE id =", settings$run$site$id), con = dbcon) - + soil.dat <- PEcAn.data.land::soil_params(sand = soils$sand_pct/100, clay = soils$clay_pct/100, silt = 100 - soils$sand_pct - soils$clay_pct) fc <- soil.dat$volume_fraction_of_water_in_soil_at_field_capacity * 100 @@ -81,11 +86,11 @@ write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.i if(is.na(fc)) fc = 5 if(is.na(dry)) dry = 5 } - - fdat <- read.csv(system.file("fdat.csv", package = "linkages"), header = FALSE) #litter quality parameters - clat <- read.csv(system.file("clat.csv", package = "linkages"), header = FALSE) + + fdat <- utils::read.csv(system.file("fdat.csv", package = "linkages"), header = FALSE) #litter quality parameters + clat <- utils::read.csv(system.file("clat.csv", package = "linkages"), header = FALSE) load(system.file("switch.mat.Rdata", package = "linkages")) - + if(!is.null(inputs)){ climate_file <- inputs$met$path load(climate_file) @@ -99,8 +104,8 @@ write.config.LINKAGES <- function(defaults = NULL, trait.values, settings, run.i basesc <- 74 basesn <- 1.64 - - spp.params.default <- read.csv(system.file("spp_matrix.csv", package = "linkages")) # default spp.params + + spp.params.default <- utils::read.csv(system.file("spp_matrix.csv", package = "linkages")) # default spp.params nspec <- length(settings$pfts) spp.params.save <- numeric(nspec) for (i in seq_len(nspec)) { diff --git a/models/linkages/R/write_restart.LINKAGES.R b/models/linkages/R/write_restart.LINKAGES.R index 39b0a24cec4..8e0b442048a 100644 --- a/models/linkages/R/write_restart.LINKAGES.R +++ b/models/linkages/R/write_restart.LINKAGES.R @@ -4,23 +4,19 @@ ##' ##' @param outdir output directory ##' @param runid run ID -##' @param time year that is being read +##' @param start.time,stop.time year that is being read ##' @param settings PEcAn settings object ##' @param new.state analysis vector ##' @param RENAME flag to either rename output file or not -##' @param variables -##' @param sample_parameters -##' @param trait.values +##' @param new.params updated parameter values to write. +## Format is named list with each entry matching a PFT +##' @param inputs passed on to `write.config.LINKAGES()` ##' ##' @description Write restart files for LINKAGES ##' ##' @return NONE ##' @export ##' - -# outdir, runid, time, settings, new.state, variables, sample_parameters = FALSE, trait.values = -# NA,met=NULL,RENAME = TRUE - write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, settings, new.state, RENAME = TRUE, new.params, inputs) { @@ -81,7 +77,7 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, #distance.matrix <- rbind(c(0,3,1,2), c(3,0,2,1), c(1,2,0,3), c(2,1,3,0)) ## HACK - spp.params.default <- read.csv(system.file("spp_matrix.csv", package = "linkages")) #default spp.params + spp.params.default <- utils::read.csv(system.file("spp_matrix.csv", package = "linkages")) #default spp.params nspec <- length(settings$pfts) spp.params.save <- numeric(nspec) for (i in seq_len(nspec)) { @@ -133,7 +129,7 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, if (!file.exists(outfile)) { outfile <- file.path(outdir, runid, paste0(start.time, "linkages.out.Rdata")) if (!file.exists(outfile)) { - logger.severe(paste0("missing outfile ens #", runid)) + PEcAn.logger::logger.severe(paste0("missing outfile ens #", runid)) } } print(paste0("runid = ", runid)) @@ -208,7 +204,7 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, data2 <- data.frame(ind.biomass = ind.biomass, n.index = n.index) - mean.biomass.spp <- aggregate(ind.biomass ~ n.index, mean, data = data2) # calculate mean individual biomass for each species + mean.biomass.spp <- stats::aggregate(ind.biomass ~ n.index, mean, data = data2) # calculate mean individual biomass for each species #browser() # calculate number of individuals needed to match new.state for (s in seq_along(settings$pfts)) { @@ -233,7 +229,7 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, #making sure to stick with density dependence rules in linkages (< 198 trees per 800/m^2) #someday we could think about estimating this parameter from data - if(sum(new.ntrees,na.rm = T) > 198) new.ntrees <- round((new.ntrees / sum(new.ntrees)) * runif(1,195,198)) + if(sum(new.ntrees,na.rm = T) > 198) new.ntrees <- round((new.ntrees / sum(new.ntrees)) * stats::runif(1,195,198)) print(paste0("new.ntrees =", new.ntrees)) @@ -310,10 +306,13 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, spp.biomass.params = spp.biomass.params) * as.numeric(bcorr[s]) bMax <- 200 for (j in nl:nu) { - dbh.temp[j] <- optimize(merit, c(1, bMax), b_obs = b_obs[j], - spp.biomass.params = spp.biomass.params)$minimum + dbh.temp[j] <- stats::optimize( + merit, + c(1, bMax), + b_obs = b_obs[j], + spp.biomass.params = spp.biomass.params)$minimum } - + b_calc1[s] <- sum(biomass_function(dbh.temp[nl:nu], spp.biomass.params = spp.biomass.params)) * (1 / 833) * 0.48 nl <- nu + 1 @@ -366,14 +365,18 @@ write_restart.LINKAGES <- function(outdir, runid, start.time, stop.time, save(dbh, tyl, ntrees, nogro, ksprt, iage, C.mat, ncohrt, file = restart.file) # make a new settings with the right years min start date and end date - fail in informative way - - settings$run$start.date <- paste0(formatC(year(start.time + 1), width = 4, format = "d", flag = "0"), "/01/01") - settings$run$end.date <- paste0(formatC(year(stop.time), width = 4, format = "d", flag = "0"), "/12/31") - - do.call(write.config.LINKAGES, - args = list(trait.values = new.params, settings = settings, run.id = runid, + + settings$run$start.date <- paste0( + formatC(lubridate::year(start.time + 1), width = 4, format = "d", flag = "0"), + "/01/01") + settings$run$end.date <- paste0( + formatC(lubridate::year(stop.time), width = 4, format = "d", flag = "0"), + "/12/31") + + do.call(write.config.LINKAGES, + args = list(trait.values = new.params, settings = settings, run.id = runid, restart = TRUE, spinup = FALSE, inputs = inputs)) - + # save original output if (RENAME) { file.rename(file.path(outdir, runid, "linkages.out.Rdata"), diff --git a/models/linkages/man/met2model.LINKAGES.Rd b/models/linkages/man/met2model.LINKAGES.Rd index 35882a7da11..966f45db05b 100644 --- a/models/linkages/man/met2model.LINKAGES.Rd +++ b/models/linkages/man/met2model.LINKAGES.Rd @@ -20,7 +20,16 @@ met2model.LINKAGES( \item{in.prefix}{prefix for each file} -\item{outfolder}{location where model specific output is written.} +\item{outfolder}{location where model specific output is written} + +\item{start_date, end_date}{when to start and end conversion. +Only year portion is used} + +\item{overwrite}{Force replacement of an existing output file?} + +\item{verbose}{ignored} + +\item{...}{Additional arguments, currently ignored} } \value{ OK if everything was succesful. diff --git a/models/linkages/man/model2netcdf.LINKAGES.Rd b/models/linkages/man/model2netcdf.LINKAGES.Rd index e3f9704f144..5d54201fbb6 100644 --- a/models/linkages/man/model2netcdf.LINKAGES.Rd +++ b/models/linkages/man/model2netcdf.LINKAGES.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/model2netcdf.LINKAGES.R \name{model2netcdf.LINKAGES} \alias{model2netcdf.LINKAGES} -\title{Code to convert LINKAGES's output into netCDF format} +\title{Convert LINKAGES's output into netCDF format} \usage{ model2netcdf.LINKAGES( outdir, @@ -23,6 +23,8 @@ model2netcdf.LINKAGES( \item{start_date}{Start time of the simulation} \item{end_date}{End time of the simulation} + +\item{pft_names}{names of PFTs to use in output labels} } \description{ Convert MODEL output into the NACP Intercomparison format (ALMA using netCDF) diff --git a/models/linkages/man/read_restart.LINKAGES.Rd b/models/linkages/man/read_restart.LINKAGES.Rd index 5599ca9ee14..3c8875bea83 100644 --- a/models/linkages/man/read_restart.LINKAGES.Rd +++ b/models/linkages/man/read_restart.LINKAGES.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/read_restart.LINKAGES.R \name{read_restart.LINKAGES} \alias{read_restart.LINKAGES} -\title{read_restart.LINKAGES} +\title{Read Restart for LINKAGES} \usage{ read_restart.LINKAGES( outdir, @@ -20,9 +20,11 @@ read_restart.LINKAGES( \item{stop.time}{year that is being read} +\item{settings}{PEcAn settings object} + \item{var.names}{var.names to be extracted} -\item{multi.settings}{PEcAn settings object} +\item{params}{passed on to return value} } \value{ X.vec vector of forecasts diff --git a/models/linkages/man/split_inputs.LINKAGES.Rd b/models/linkages/man/split_inputs.LINKAGES.Rd index 5d9e120bc26..f740553713c 100644 --- a/models/linkages/man/split_inputs.LINKAGES.Rd +++ b/models/linkages/man/split_inputs.LINKAGES.Rd @@ -6,12 +6,22 @@ \usage{ split_inputs.LINKAGES(settings, start.time, stop.time, inputs) } +\arguments{ +\item{settings}{ignored} + +\item{start.time, stop.time}{ignored} + +\item{inputs}{returned} +} \value{ files split up climate files } \description{ Splits climate met for LINKAGES } +\details{ +Stub implementation -- currently returns `inputs` and ignores all other arguments +} \author{ Ann Raiho } diff --git a/models/linkages/man/write.config.LINKAGES.Rd b/models/linkages/man/write.config.LINKAGES.Rd index 339dfcb89db..042c524976f 100644 --- a/models/linkages/man/write.config.LINKAGES.Rd +++ b/models/linkages/man/write.config.LINKAGES.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/write.config.LINKAGES.R \name{write.config.LINKAGES} \alias{write.config.LINKAGES} -\title{Write LINKAGES configuration files} +\title{Writes a LINKAGES config file.} \usage{ write.config.LINKAGES( defaults = NULL, @@ -18,19 +18,28 @@ write.config.LINKAGES( \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} -\item{trait.samples}{vector of samples for a given trait} +\item{restart}{logical: Write a restart file? +If NULL (default), treated as FALSE} + +\item{spinup}{logical: perform spinup using `spinup.LINKAGES()`? +If NULL (default), treated as FALSE} + +\item{inputs}{inputs section of a PEcAn settings object. +Currently only used for climate file (inputs$met$path), +which is taken from `settings$input$met$path` if `inputs` is NULL.} + +\item{IC}{TODO currently ignored} } \value{ configuration file for LINKAGES for given run } \description{ -Writes a LINKAGES config file. -} -\details{ Requires a pft xml object, a list of trait values for a single model run, and the name of the file to create } diff --git a/models/linkages/man/write_restart.LINKAGES.Rd b/models/linkages/man/write_restart.LINKAGES.Rd index 884d7aaacc7..12491874cab 100644 --- a/models/linkages/man/write_restart.LINKAGES.Rd +++ b/models/linkages/man/write_restart.LINKAGES.Rd @@ -21,15 +21,17 @@ write_restart.LINKAGES( \item{runid}{run ID} +\item{start.time, stop.time}{year that is being read} + \item{settings}{PEcAn settings object} \item{new.state}{analysis vector} \item{RENAME}{flag to either rename output file or not} -\item{time}{year that is being read} +\item{new.params}{updated parameter values to write.} -\item{trait.values}{} +\item{inputs}{passed on to `write.config.LINKAGES()`} } \value{ NONE diff --git a/models/linkages/tests/Rcheck_reference.log b/models/linkages/tests/Rcheck_reference.log index d0faa922ec8..9f1e55a1c55 100644 --- a/models/linkages/tests/Rcheck_reference.log +++ b/models/linkages/tests/Rcheck_reference.log @@ -12,43 +12,6 @@ Maintainer: ‘Ann Raiho ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Unknown, possibly misspelled, fields in DESCRIPTION: ‘Remotes’ @@ -56,8 +19,6 @@ Strong dependencies not in mainstream repositories: PEcAn.utils, PEcAn.data.atmosphere, PEcAn.logger, PEcAn.remote Suggests or Enhances not in mainstream repositories: linkages - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -71,11 +32,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Ann Raiho, Mike Dietze’ - Authors@R: ‘Mike Dietze [aut], Ann Raiho [aut, cre], University of Illinois, NCSA [cph]’ - +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK @@ -89,26 +46,11 @@ Author field differs from that derived from Authors@R * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK -* checking dependencies in R code ... WARNING -'::' or ':::' import not declared from: ‘PEcAn.data.land’ -'library' or 'require' call not declared from: ‘PEcAn.data.atmosphere’ -'library' or 'require' call to ‘PEcAn.utils’ which was already attached by Depends. - Please remove these calls from your code. -'library' or 'require' calls in package code: - ‘PEcAn.data.atmosphere’ ‘linkages’ - Please use :: or requireNamespace() instead. - See section 'Suggested packages' in the 'Writing R Extensions' manual. -Namespace in Imports field not imported from: ‘PEcAn.data.atmosphere’ - All declared Imports should be used. -Package in Depends field not imported from: ‘PEcAn.utils’ - These packages need to be imported from (in the NAMESPACE file) - for when this namespace is loaded but not attached. +* checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE -met2model.LINKAGES: no visible global function definition for - ‘flush.console’ model2netcdf.LINKAGES: no visible binding for global variable ‘ag.biomass’ model2netcdf.LINKAGES: no visible binding for global variable @@ -126,21 +68,6 @@ model2netcdf.LINKAGES: no visible binding for global variable ‘f.comp’ model2netcdf.LINKAGES: no visible binding for global variable ‘water’ model2netcdf.LINKAGES: no visible binding for global variable ‘abvgroundwood.biomass’ -read_restart.LINKAGES: no visible global function definition for - ‘read.output’ -sample.IC.LINKAGES: no visible global function definition for ‘runif’ -write.config.LINKAGES: no visible global function definition for - ‘read.csv’ -write.config.LINKAGES: no visible global function definition for - ‘db.open’ -write.config.LINKAGES: no visible global function definition for - ‘db.close’ -write.config.LINKAGES: no visible global function definition for - ‘db.query’ -write_restart.LINKAGES: no visible global function definition for - ‘read.csv’ -write_restart.LINKAGES: no visible global function definition for - ‘logger.severe’ write_restart.LINKAGES: no visible binding for global variable ‘ntrees.kill’ write_restart.LINKAGES: no visible binding for global variable @@ -149,64 +76,19 @@ write_restart.LINKAGES: no visible binding for global variable ‘iage.save’ write_restart.LINKAGES: no visible binding for global variable ‘dbh.save’ -write_restart.LINKAGES: no visible global function definition for - ‘aggregate’ -write_restart.LINKAGES: no visible global function definition for - ‘runif’ -write_restart.LINKAGES: no visible global function definition for - ‘optimize’ -write_restart.LINKAGES: no visible global function definition for - ‘year’ Undefined global functions or variables: - abvgroundwood.biomass ag.biomass ag.npp agb.pft aggregate area - db.close db.open db.query dbh.save et f.comp flush.console - hetero.resp iage.save leaf.litter logger.severe nee nogro.save - ntrees.kill optimize read.csv read.output runif total.soil.carbon - water year -Consider adding - importFrom("stats", "aggregate", "optimize", "runif") - importFrom("utils", "flush.console", "read.csv") -to your NAMESPACE file. + abvgroundwood.biomass ag.biomass ag.npp agb.pft area + db.close db.open db.query dbh.save et f.comp + hetero.resp iage.save leaf.litter nee nogro.save + ntrees.kill total.soil.carbon water * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.LINKAGES' - ‘start_date’ ‘end_date’ ‘overwrite’ ‘verbose’ ‘...’ - -Undocumented arguments in documentation object 'model2netcdf.LINKAGES' - ‘pft_names’ - -Undocumented arguments in documentation object 'read_restart.LINKAGES' - ‘settings’ ‘params’ -Documented arguments not in \usage in documentation object 'read_restart.LINKAGES': - ‘multi.settings’ - -Undocumented arguments in documentation object 'split_inputs.LINKAGES' - ‘settings’ ‘start.time’ ‘stop.time’ ‘inputs’ - -Undocumented arguments in documentation object 'write.config.LINKAGES' - ‘trait.values’ ‘restart’ ‘spinup’ ‘inputs’ ‘IC’ -Documented arguments not in \usage in documentation object 'write.config.LINKAGES': - ‘trait.samples’ - -Undocumented arguments in documentation object 'write_restart.LINKAGES' - ‘start.time’ ‘stop.time’ ‘new.params’ ‘inputs’ -Documented arguments not in \usage in documentation object 'write_restart.LINKAGES': - ‘trait.values’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. -* checking Rd contents ... WARNING -Argument items with no description in Rd object 'write_restart.LINKAGES': - ‘trait.values’ - +* checking Rd \usage sections ... OK +* checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... NONE * checking for unstated dependencies in ‘tests’ ... OK diff --git a/models/lpjguess/DESCRIPTION b/models/lpjguess/DESCRIPTION index 9571d45b842..24be2ede757 100644 --- a/models/lpjguess/DESCRIPTION +++ b/models/lpjguess/DESCRIPTION @@ -7,8 +7,6 @@ Authors@R: c(person("Istem", "Fer", role = c("aut", "cre"), person("Tony", "Gardella", role = c("aut"), email = "tonygard@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Istem Fer, Tony Gardella -Maintainer: Istem Fer Description: This module provides functions to link LPJ-GUESS to PEcAn. Imports: PEcAn.logger, diff --git a/models/lpjguess/R/met2model.LPJGUESS.R b/models/lpjguess/R/met2model.LPJGUESS.R index 3b719881d14..ec898e203fb 100644 --- a/models/lpjguess/R/met2model.LPJGUESS.R +++ b/models/lpjguess/R/met2model.LPJGUESS.R @@ -15,6 +15,7 @@ ##' @param end_date the end date of the data to be downloaded (will only use the year part of the date) ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose +##' @param ... additional arguments, currently ignored ##' @author Istem Fer ##' @importFrom ncdf4 ncvar_get ncvar_def ncdim_def ncatt_get ncatt_put nc_close met2model.LPJGUESS <- function(in.path, in.prefix, outfolder, start_date, end_date, diff --git a/models/lpjguess/R/write.config.LPJGUESS.R b/models/lpjguess/R/write.config.LPJGUESS.R index c326edab6ec..43251103d1c 100644 --- a/models/lpjguess/R/write.config.LPJGUESS.R +++ b/models/lpjguess/R/write.config.LPJGUESS.R @@ -6,7 +6,7 @@ ##' @name write.config.LPJGUESS ##' @title Write LPJ-GUESS configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for LPJ-GUESS for given run diff --git a/models/lpjguess/man/met2model.LPJGUESS.Rd b/models/lpjguess/man/met2model.LPJGUESS.Rd index 2f0ae4ee03d..bc3e16a7ca3 100644 --- a/models/lpjguess/man/met2model.LPJGUESS.Rd +++ b/models/lpjguess/man/met2model.LPJGUESS.Rd @@ -29,6 +29,8 @@ met2model.LPJGUESS( \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbose} + +\item{...}{additional arguments, currently ignored} } \description{ met2model wrapper for LPJ-GUESS diff --git a/models/lpjguess/man/write.config.LPJGUESS.Rd b/models/lpjguess/man/write.config.LPJGUESS.Rd index abeda198864..82a6aedfafc 100644 --- a/models/lpjguess/man/write.config.LPJGUESS.Rd +++ b/models/lpjguess/man/write.config.LPJGUESS.Rd @@ -9,11 +9,11 @@ write.config.LPJGUESS(defaults, trait.values, settings, run.id) \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for LPJ-GUESS for given run diff --git a/models/lpjguess/tests/Rcheck_reference.log b/models/lpjguess/tests/Rcheck_reference.log index a96020fb789..15fb2464393 100644 --- a/models/lpjguess/tests/Rcheck_reference.log +++ b/models/lpjguess/tests/Rcheck_reference.log @@ -12,47 +12,8 @@ Maintainer: ‘Istem Fer ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Strong dependencies not in mainstream repositories: PEcAn.logger, PEcAn.remote, PEcAn.utils - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -66,15 +27,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Istem Fer, Tony Gardella’ - Authors@R: ‘Istem Fer [aut, cre], Tony Gardella [aut], University of Illinois, NCSA [cph]’ - -Maintainer field differs from that derived from Authors@R - Maintainer: ‘Istem Fer ’ - Authors@R: ‘Istem Fer ’ - +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK @@ -132,20 +85,7 @@ All user-level objects in a package should have documentation entries. See chapter ‘Writing R documentation files’ in the ‘Writing R Extensions’ manual. * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.LPJGUESS' - ‘...’ - -Undocumented arguments in documentation object 'write.config.LPJGUESS' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.LPJGUESS': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK diff --git a/models/maat/DESCRIPTION b/models/maat/DESCRIPTION index af87fcf000d..47d8001c379 100644 --- a/models/maat/DESCRIPTION +++ b/models/maat/DESCRIPTION @@ -2,11 +2,9 @@ Package: PEcAn.MAAT Type: Package Title: PEcAn Package for Integration of the MAAT Model Version: 1.7.3.9000 -Authors@R: as.person(c( - "Shawn Serbin [aut, cre]", - "Anthony Walker [aut]" - )) -Maintainer: Shawn Serbin +Authors@R: c( + person("Shawn", "Serbin", role = c("aut", "cre"), email="sserbin@bnl.gov"), + person("Anthony", "Walker", role = "aut", email="walkerap@ornl.gov")) Description: This module provides functions to wrap the MAAT model into the PEcAn workflows. Imports: PEcAn.data.atmosphere, @@ -18,11 +16,14 @@ Imports: ncdf4 (>= 1.15), XML Suggests: + knitr, + rmarkdown, testthat (>= 1.0.2) SystemRequirements: MAAT OS_type: unix License: BSD_3_clause + file LICENSE Copyright: Authors +VignetteBuilder: knitr LazyLoad: yes LazyData: FALSE Encoding: UTF-8 diff --git a/models/maat/R/met2model.MAAT.R b/models/maat/R/met2model.MAAT.R index d331bdda86d..c7609bad305 100644 --- a/models/maat/R/met2model.MAAT.R +++ b/models/maat/R/met2model.MAAT.R @@ -22,6 +22,7 @@ PREFIX_XML <- "\n" ##' @param verbose should the function be very verbose ##' @param leap_year Enforce Leap-years? If set to TRUE, will require leap years to have 366 days. ##' If set to false, will require all years to have 365 days. Default = TRUE. +##' @param ... additional arguments, currently ignored ##' @export ##' @author Shawn P. Serbin ##' diff --git a/models/maat/R/write.config.MAAT.R b/models/maat/R/write.config.MAAT.R index dacd5fd0289..825cefe061f 100644 --- a/models/maat/R/write.config.MAAT.R +++ b/models/maat/R/write.config.MAAT.R @@ -4,12 +4,13 @@ PREFIX_XML <- "\n" ##-------------------------------------------------------------------------------------------------# ##------------------------------------------------------------------------------------------------# +##' Convert samples for MAAT +##' ##' convert parameters and parameter names from PEcAn database default units/names with MAAT ##' ##' Performs model specific unit conversions on a a list of trait values, ##' such as those provided to write.config -##' @name convert.samples.MAAT -##' @title Convert samples for MAAT +##' ##' @param trait.samples a matrix or dataframe of samples from the trait distribution ##' @param runid optional parameter for debugging ##' @return matrix or dataframe with values transformed @@ -94,10 +95,8 @@ convert.samples.MAAT <- function(trait.samples, runid) { ##' Requires a pft xml object, a list of trait values for a single model run, ##' and the name of the file to create ##' -##' @name write.config.MAAT -##' @title Write MAAT model configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for MAAT for given run diff --git a/models/maat/man/met2model.MAAT.Rd b/models/maat/man/met2model.MAAT.Rd index 237b8b816c2..b6e4ce7f27e 100644 --- a/models/maat/man/met2model.MAAT.Rd +++ b/models/maat/man/met2model.MAAT.Rd @@ -33,6 +33,8 @@ met2model.MAAT( \item{leap_year}{Enforce Leap-years? If set to TRUE, will require leap years to have 366 days. If set to false, will require all years to have 365 days. Default = TRUE.} + +\item{...}{additional arguments, currently ignored} } \description{ met2model wrapper for MAAT diff --git a/models/maat/man/write.config.MAAT.Rd b/models/maat/man/write.config.MAAT.Rd index e1704cf03a8..1ef53872054 100644 --- a/models/maat/man/write.config.MAAT.Rd +++ b/models/maat/man/write.config.MAAT.Rd @@ -2,26 +2,23 @@ % Please edit documentation in R/write.config.MAAT.R \name{write.config.MAAT} \alias{write.config.MAAT} -\title{Write MAAT model configuration files} +\title{Writes a MAAT config file.} \usage{ write.config.MAAT(defaults = NULL, trait.values, settings, run.id) } \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for MAAT for given run } \description{ -Writes a MAAT config file. -} -\details{ Requires a pft xml object, a list of trait values for a single model run, and the name of the file to create } diff --git a/models/maat/tests/Rcheck_reference.log b/models/maat/tests/Rcheck_reference.log index 57d8d7f45c7..251779d0728 100644 --- a/models/maat/tests/Rcheck_reference.log +++ b/models/maat/tests/Rcheck_reference.log @@ -12,50 +12,9 @@ Maintainer: ‘Shawn Serbin ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Strong dependencies not in mainstream repositories: PEcAn.data.atmosphere, PEcAn.logger, PEcAn.remote, PEcAn.settings, PEcAn.utils - -Authors@R field should be a call to person(), or combine such calls. - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -109,20 +68,7 @@ to your NAMESPACE file. * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.MAAT' - ‘...’ - -Undocumented arguments in documentation object 'write.config.MAAT' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.MAAT': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking files in ‘vignettes’ ... WARNING diff --git a/models/maat/vignettes/create_amerifluxLBL_drivers_for_maat.Rmd b/models/maat/vignettes/create_amerifluxLBL_drivers_for_maat.Rmd index 8dabad23071..a5be19dd635 100644 --- a/models/maat/vignettes/create_amerifluxLBL_drivers_for_maat.Rmd +++ b/models/maat/vignettes/create_amerifluxLBL_drivers_for_maat.Rmd @@ -2,7 +2,10 @@ title: "PEcAn: Generating met drivers for the MAAT model using AmerifluxLBL tower observations" author: "Shawn Serbin" date: "2018-08-28" -output: html_document +output: rmarkdown::html_vignette +vignette: | + %\VignetteIndexEntry{PEcAn: Generating met drivers for the MAAT model using AmerifluxLBL tower observations} + %\VignetteEngine{knitr::rmarkdown} --- # Overview @@ -13,27 +16,25 @@ In this example we will download 6 years of met data from the [Willow Creek Eddy The PEcAn.data.atmosphere source code is in [`modules/data.atmosphere`](https://github.com/PecanProject/pecan/tree/develop/modules/data.atmosphere) and the documentation can be found with either `package?PEcAn.data.atmosphere` or in the [data.atmosphere package documentation](https://pecanproject.github.io/pecan//modules/data.atmosphere/inst/web/index.html). First make sure you have the nescessary PEcAn package for processing met data -```{r install} -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "modules/data.atmosphere") +```{r install, eval=FALSE} +options(repos = c(getOption("repos"), PEcAn = "pecanproject.r-universe.dev")) +install.packages("PEcAn.data.atmosphere") ``` ```{r} -library(knitr) -library(ggplot2) -library(ggthemes) library(PEcAn.data.atmosphere) ``` ```{r echo=FALSE} -knitr::opts_chunk$set(message = FALSE, warnings = FALSE, cache = FALSE, +knitr::opts_chunk$set(message = FALSE, warnings = FALSE, cache = FALSE, fig.height= 3, fig.width = 8) ``` ## Connect to BETY database and retrieve appropriate format for AmerifluxLBL datasets [TODO: Update to work with R-OpenSci traits BETY] -```{r bety} +```{r bety, eval = FALSE} con <- PEcAn.DB::db.open( list(user='bety', password='bety', host='localhost', @@ -42,30 +43,94 @@ format.id <- 5000000002 format <- PEcAn.DB::query.format.vars(format.id=format.id,bety = con) format$time_zone <- "America/Chicago" ``` +(Note: To avoid needing a database connection at vignette build time, we use code that does not display in the compiled vignette to construct a static version of the `format` object. When running this document interactively, with a live database connention, you can use the result from `query.format.vars` directly.) + +```{r dummy-format, show = FALSE} +# copy-pasted from `dput(format)` after evaluating the `bety` chunk above +# using Chris Black's development version of BeTY on 2024-09-16 +format <- list( + file_name = "AMERIFLUX_BASE_HH", + mimetype = "csv", + vars = structure( + list( + bety_name = c("air_pressure", "airT", "co2atm", "datetime", "FC", "H", + "LE", "NEE", "PAR", "precipitation_flux", "relative_humidity", + "soilM", "soilT", "solar_radiation", "specific_humidity", + "surface_downwelling_longwave_flux_in_air", "TotalResp", "UST", + "VPD", "wind_direction", "Wspd"), + variable_id = c(554, 86, 135, 5000000001, 1000000042, 299, 298, 297, + 136, 555, 556, 391, 379, 547, 557, 561, 1000000206, 1000000041, 387, + 560, 390), + input_name = c("PA", "TA", "CO2_1", "TIMESTAMP_START", "FC", "H", "LE", + "NEE_PI", "PPFD_IN", "P", "RH", "SWC_1", "TS_1", "SW_IN", "H2O", + "LW_IN", "RECO_PI", "USTAR", "VPD", "WD", "WS"), + input_units = c("kPa", "celsius", "umol mol-1", "ymd_hms", + "umol C m-2 s-1", "W m-2","W m-2", "umol C m-2 s-1", "umol m-2 s-1", + "kg m-2 (30 minute)-1", "percent", "%", "celsius", "W m-2", + "g kg-1", "W m-2", "umol C m-2 s-1", "m s-1", "hPa", "degrees", + "m s-1"), + storage_type = c("", "", "", "%Y%m%d%H%M", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", ""), + column_number = c(19L, 4L, 20L, 1L, 8L, 10L, 12L, 7L, 26L, 17L, 18L, + 23L, 15L, 27L, 33L, 31L, NA, 3L, NA, 5L, 6L), + bety_units = c("Pa", "degrees C", "ppm (= umol mol-1)", "ymd_hms", + "umol C m-2 s-1", "W m-2", "W m-2", "umol C m-2 s-1", + "umol m-2 s-1", "Kg/m2/s", "%", "%", "degrees C", "W/m^2", "g g-1", + "W m-2", "kg C m-2 s-1", "m s-1", "Pa", "degrees", "m s-1"), + mstmip_name = c("Psurf", "Tair", "CO2air", NA, "FC", "Qh", "Qle", + "NEE", NA, "Rainf", NA, "SoilMoistFrac", "SoilTemp", "SWdown", + "Qair", "LWdown", "TotalResp", NA, NA, NA, NA), + mstmip_units = c("Pa", "K", "micromol mol-1", NA, "kg C m-2 s-1", + "W m-2", "W m-2", "kg C m-2 s-1", NA, "kg m-2 s-1", NA, "1", "K", + "W/m^2", "kg kg-1", "W/m2", "kg C m-2 s-1", NA, NA, NA, NA), + pecan_name = c("Psurf", "Tair", "CO2air", "datetime", "FC", "Qh", + "Qle", "NEE", "PAR", "Rainf", "relative_humidity", "SoilMoistFrac", + "SoilTemp", "SWdown", "Qair", "LWdown", "TotalResp", "UST", "VPD", + "wind_direction", "Wspd"), + pecan_units = c("Pa", "K", "micromol mol-1", "ymd_hms", "kg C m-2 s-1", + "W m-2", "W m-2", "kg C m-2 s-1", "umol m-2 s-1", "kg m-2 s-1", "%", + "1", "K", "W/m^2", "kg kg-1", "W/m2", "kg C m-2 s-1", "m s-1", "Pa", + "degrees", "m s-1")), + row.names = c(NA, -21L), + class = "data.frame"), + skip = 2, + header = 1, + na.strings = c("-9999", "-6999", "9999", "NA"), + time.row = 4L, + site = NULL, + lat = NULL, + lon = NULL, + time_zone = "America/Chicago") +``` + ## Download AmerifluxLBL data for selected site and dates (US-WCr, 2000 to 2005) ```{r download} -download.AmerifluxLBL(sitename = "US-WCr", outfolder = "~/scratch/met2model_testing", +m2mdir <- tempfile("met2model_testing") +dir.create(m2mdir) +download.AmerifluxLBL(sitename = "US-WCr", outfolder = m2mdir, start_date = "2000-01-01", end_date = "2005-12-31", overwrite = TRUE, verbose = TRUE) ``` ## Convert downloaded AmerifluxLBL data to CF format ```{r met2cf} -met2CF.AmerifluxLBL(in.path = "~/scratch/met2model_testing/", in.prefix = "AMF_US-WCr", outfolder = "~/scratch/met2model_testing/CF/", +cfdir <- file.path(m2mdir, "CF") +met2CF.AmerifluxLBL(in.path = m2mdir, in.prefix = "AMF_US-WCr", outfolder = cfdir, start_date = "2000-01-01", end_date = "2005-12-31",format=format) ``` ## Gapfill CF met drivers ```{r metgapfill} -metgapfill(in.path = "~/scratch/met2model_testing/CF/", in.prefix = "AMF_US-WCr_BASE_HH_14-5", - outfolder = "~/scratch/met2model_testing/CF/gapfill/", start_date = "2000-01-01", end_date = "2005-12-31") +gapfilldir <- file.path(cfdir, "gapfill") +metgapfill(in.path = cfdir, in.prefix = "AMF_US-WCr_BASE_HH_14-5", + outfolder = gapfilldir, start_date = "2000-01-01", end_date = "2005-12-31") ``` ## Create MAAT model-specific met drivers ```{r met2model} -in.path <- "~/scratch/met2model_testing/CF/gapfill/" +in.path <- gapfilldir in.prefix <- "AMF_US-WCr_BASE_HH_14-5" -outfolder <- "~/scratch/met2model_testing/CF/gapfill/maat_drivers/" +outfolder <- file.path(gapfilldir, "maat_drivers") start_date <- "2000-01-01" end_date <- "2005-12-31" overwrite <- TRUE diff --git a/models/maat/vignettes/running_maat_in_pecan.Rmd b/models/maat/vignettes/running_maat_in_pecan.Rmd index 19682997c80..9a0a5890ea0 100644 --- a/models/maat/vignettes/running_maat_in_pecan.Rmd +++ b/models/maat/vignettes/running_maat_in_pecan.Rmd @@ -1,8 +1,10 @@ --- title: "Running MAAT in PEcAn" author: "Shawn Serbin" -date: "2018-08-28" -output: html_document +output: rmarkdown::html_vignette +vignette: | + %\VignetteIndexEntry{Running MAAT in PEcAn} + %\VignetteEngine{knitr::rmarkdown} --- ```{r echo=FALSE} @@ -23,21 +25,19 @@ Follow the instructions found here: https://github.com/walkeranthonyp/MAAT/blob/ ## Installing the R packages -```{r install, eval = -(1:6)} -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/logger") -devtools::install_github("PecanProject/pecan", ref = "develop", subdir= "base/remote") -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/utils") -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "base/settings") -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "modules/data.atmosphere") -devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "models/maat") +```{r install, eval = FALSE} +options(repos = c(getOption("repos"), PEcAn = "pecanproject.r-universe.dev")) +install.packages("PEcAn.MAAT") +``` +```{r load-pkg} library(PEcAn.MAAT) ``` ## MAAT XML configuration ### E.g. Running without met drivers and using user-specified met conditions -```{xml maat_nomet} +```{cat maat_nomet} leaf @@ -65,7 +65,7 @@ library(PEcAn.MAAT) ``` ### E.g. Running with met drivers -```{xml maat_met} +```{cat maat_met} leaf @@ -85,7 +85,7 @@ library(PEcAn.MAAT) ### E.g. pecan.xml file with MAAT configuration options. In this example the MAAT model is configured for a temperate deciduous forest based on the temperate.deciduous PFT in the BETYdb database (https://www.betydb.org/pfts/2000000044). -```{xml pecan_xml} +```{cat pecan_xml} ~/scratch/maat_pecan_test_run/ @@ -187,13 +187,14 @@ In this example the MAAT model is configured for a temperate deciduous forest ba ## Simple MAAT run in PEcAn In this example we will run ten MAAT model ensembles in serial based on parameter values derived from the temperate.deciduous PFT in the BETYdb database (https://www.betydb.org/pfts/2000000044) and the PEcAn meta analysis step -```{r run_maat} -library(PEcAn.all) -library(PEcAn.utils) +This chunk is shown but is not currently executed at vignette build time, because running it requires a connection to the PEcAn database. -setwd("~") -getwd() +```{r run_maat, eval = FALSE} +rundir <- tempfile("maat_pecan_test_run") +dir.create(rundir) +setwd(rundir) settings <- PEcAn.settings::read.settings(system.file("pecan.maat.xml", package="PEcAn.MAAT", mustWork = TRUE)) +settings$outdir <- rundir settings <- PEcAn.settings::prepare.settings(settings, force=FALSE) PEcAn.logger::logger.info(paste0("Main output directory: ",settings$outdir)) diff --git a/models/maespa/.Rbuildignore b/models/maespa/.Rbuildignore new file mode 100644 index 00000000000..12ebc8111ea --- /dev/null +++ b/models/maespa/.Rbuildignore @@ -0,0 +1,2 @@ +Dockerfile +model_info.json \ No newline at end of file diff --git a/models/maespa/DESCRIPTION b/models/maespa/DESCRIPTION index 869f97a3fa0..40d1f78eaa3 100644 --- a/models/maespa/DESCRIPTION +++ b/models/maespa/DESCRIPTION @@ -5,8 +5,6 @@ Version: 1.7.3.9000 Authors@R: c(person("Tony", "Gardella", role = c("aut", "cre"), email = "tonygard@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Tony Gardella -Maintainer: Tony Gardella Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific workflow management tool that is designed to simplify the management of model parameterization, execution, and analysis. The goal of PECAn is to @@ -24,12 +22,12 @@ Suggests: Maeswrap, coda, testthat (>= 1.0.2) +Remotes: + github::RemkoDuursma/Maeswrap SystemRequirements: MAESPA ecosystem model OS_type: unix License: BSD_3_clause + file LICENSE Copyright: Authors -LazyLoad: yes LazyData: FALSE -Require: Encoding: UTF-8 RoxygenNote: 7.3.2 diff --git a/models/maespa/R/met2model.MAESPA.R b/models/maespa/R/met2model.MAESPA.R index 5422c1f92de..e24aa9d1c51 100755 --- a/models/maespa/R/met2model.MAESPA.R +++ b/models/maespa/R/met2model.MAESPA.R @@ -16,6 +16,7 @@ ##' @param end_date the end date of the data to be downloaded (will only use the year part of the date) ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose +##' @param ... further arguments, currently ignored ##' ##' @author Tony Gardella met2model.MAESPA <- function(in.path, in.prefix, outfolder, start_date, end_date, diff --git a/models/maespa/R/write.config.MAESPA.R b/models/maespa/R/write.config.MAESPA.R index 7e1b21dfa2b..6adfd849eea 100755 --- a/models/maespa/R/write.config.MAESPA.R +++ b/models/maespa/R/write.config.MAESPA.R @@ -6,7 +6,7 @@ ##' @name write.config.MAESPA ##' @title Write MAESPA configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for MAESPA for given run @@ -15,8 +15,8 @@ ##-------------------------------------------------------------------------------------------------# write.config.MAESPA <- function(defaults, trait.values, settings, run.id) { - if(!require("Maeswrap")){ - logger.severe("The Maeswrap package is not installed. + if(!requireNamespace("Maeswrap", quietly = TRUE)){ + PEcAn.logger::logger.severe("The Maeswrap package is not installed. Please consult PEcAn documentation for install notes: https://pecanproject.github.io/pecan-documentation/latest/pecan-models.html#maespa") } diff --git a/models/maespa/README.md b/models/maespa/README.md index 21fab390d62..876659bbe20 100644 --- a/models/maespa/README.md +++ b/models/maespa/README.md @@ -30,6 +30,11 @@ library(remotes) install_github('pecanproject/pecan', subdir = "models/maespa") ``` +When writing configurations files PEcAn.MAESPA uses the `Maeswrap` package. +We recommend Maeswrap 1.8.0 or later, which you can install from GitHub with `remotes::install_github("RemkoDuursma/Maeswrap")`. +An older version of Maeswrap (1.7 at this writing in September 2024) is also available from CRAN and does provide the functionality PEcAn.MAESPA needs, but this version has a strong dependency on the `rgl` package, which can be hard to install and are not needed by PEcAn. If you have trouble installing the extra dependencies or if you are annoyed by an unwanted plot window opening every time you use PEcAn.MAESPA, try upgrading Maeswrap to 1.8 or later. + + ## Example This is a basic example which shows you how to solve a common problem: diff --git a/models/maespa/man/met2model.MAESPA.Rd b/models/maespa/man/met2model.MAESPA.Rd index b6809be239b..f261a78c777 100644 --- a/models/maespa/man/met2model.MAESPA.Rd +++ b/models/maespa/man/met2model.MAESPA.Rd @@ -29,6 +29,8 @@ met2model.MAESPA( \item{overwrite}{should existing files be overwritten} \item{verbose}{should the function be very verbose} + +\item{...}{further arguments, currently ignored} } \description{ met2model wrapper for MAESPA diff --git a/models/maespa/man/write.config.MAESPA.Rd b/models/maespa/man/write.config.MAESPA.Rd index b830dba5daa..855f2aedb2f 100644 --- a/models/maespa/man/write.config.MAESPA.Rd +++ b/models/maespa/man/write.config.MAESPA.Rd @@ -9,11 +9,11 @@ write.config.MAESPA(defaults, trait.values, settings, run.id) \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for MAESPA for given run diff --git a/models/maespa/tests/Rcheck_reference.log b/models/maespa/tests/Rcheck_reference.log index 9916a699928..afacbd204ec 100644 --- a/models/maespa/tests/Rcheck_reference.log +++ b/models/maespa/tests/Rcheck_reference.log @@ -12,50 +12,11 @@ Maintainer: ‘Tony Gardella ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Unknown, possibly misspelled, fields in DESCRIPTION: ‘Require’ Strong dependencies not in mainstream repositories: PEcAn.data.atmosphere, PEcAn.logger, PEcAn.remote, PEcAn.utils - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -69,14 +30,8 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Tony Gardella’ - Authors@R: ‘Tony Gardella [aut, cre], University of Illinois, NCSA [cph]’ - -* checking top-level files ... NOTE -Non-standard files/directories found at top level: - ‘Dockerfile’ ‘model_info.json’ +* checking DESCRIPTION meta-information ... OK +* checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK @@ -107,20 +62,7 @@ Undefined global functions or variables: * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.MAESPA' - ‘...’ - -Undocumented arguments in documentation object 'write.config.MAESPA' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.MAESPA': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... NONE diff --git a/models/preles/DESCRIPTION b/models/preles/DESCRIPTION index e86b293ced4..125a9ffddbe 100644 --- a/models/preles/DESCRIPTION +++ b/models/preles/DESCRIPTION @@ -7,8 +7,6 @@ Authors@R: c(person("Mike", "Dietze", role = c("aut"), person("Tony", "Gardella", role = c("aut", "cre"), email = "tonygard@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Tony Gardella, Mike Dietze -Maintainer: Tony Gardella Description: This module provides functions to run the PREdict Light use efficiency Evapotranspiration and Soil moisture (PRELES) model on the PEcAn project. The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific @@ -16,8 +14,6 @@ Description: This module provides functions to run the PREdict Light use parameterization,execution, and analysis. The goal of PECAn is to streamline the interaction between data and models, and to improve the efficacy of scientific investigation. -Depends: - PEcAn.utils Imports: PEcAn.logger, lubridate (>= 1.6.0), @@ -32,7 +28,5 @@ Remotes: OS_type: unix License: BSD_3_clause + file LICENSE Copyright: Authors -LazyLoad: yes -LazyData: FALSE Encoding: UTF-8 RoxygenNote: 7.3.2 diff --git a/models/preles/R/runPRELES.jobsh.R b/models/preles/R/runPRELES.jobsh.R index 26237e003d5..db3dbc8f46d 100644 --- a/models/preles/R/runPRELES.jobsh.R +++ b/models/preles/R/runPRELES.jobsh.R @@ -1,16 +1,22 @@ -##' @title Function to process ncdf file, run PRELES model, and convert output .nc file in CF standard -##' @param in.path location on disk where inputs are stored -##' @param in.prefix prefix of input and output files -##' @param outdir Location of PRELES model output -##' @param start_date Start time of the simulation -##' @param end_date End time of the simulation -##' @export -##' @author Tony Gardella, Michael Dietze +#' Process ncdf file, run PRELES model, and convert output .nc file in CF standard +#' +#' @param met.file base name for yearly nc files containing met data. +#' Example: `met.file="somefile"` matches somefile.2004.nc, somefile.2005.nc, etc. +#' @param outdir Location of PRELES model output +#' @param parameters An R data file containing parameter values. +#' Must be an Rda file written via `save()`, and must define an object named +#' `trait.values` +#' @param sitelat,sitelon Latitude and longitude of site in decimal degrees +#' @param start.date,end.date Start and end time of the simulation +#' +#' @export +#' @author Tony Gardella, Michael Dietze runPRELES.jobsh <- function(met.file, outdir, parameters, sitelat, sitelon, start.date, end.date) { - if(!require("Rpreles")){ - logger.severe("The Rpreles package is not installed. - Please execute- devtools::install_github('MikkoPeltoniemi/Rpreles')") + if (!requireNamespace("Rpreles", quietly = TRUE)) { + PEcAn.logger::logger.severe( + "The Rpreles package is not installed. + Please execute- devtools::install_github('MikkoPeltoniemi/Rpreles')") } # Process start and end dates @@ -110,10 +116,10 @@ runPRELES.jobsh <- function(met.file, outdir, parameters, sitelat, sitelon, star #30.tsumcrit -999 fPheno_budburst_Tsum, 134 birch ## Replace default with sampled parameters - load(parameters) - params <- data.frame(trait.values) - colnames <- c(names(trait.values[[1]])) - colnames(params) <- colnames + param_objs <- new.env() + load(parameters, envir = param_objs) + params <- data.frame(param_objs$trait.values) + colnames(params) <- names(param_objs$trait.values[[1]]) param.def[5] <- as.numeric(params["bGPP"]) param.def[9] <- as.numeric(params["kGPP"]) diff --git a/models/preles/R/write.config.PRELES.R b/models/preles/R/write.config.PRELES.R index 9a7e6423247..42e8433c241 100644 --- a/models/preles/R/write.config.PRELES.R +++ b/models/preles/R/write.config.PRELES.R @@ -3,7 +3,7 @@ ##' @name write.config.PRELES ##' @title Write PRELES configuration files ##' @param defaults list of defaults to process -##' @param trait.samples vector of samples for a given trait +##' @param trait.values vector of samples for a given trait ##' @param settings list of settings from pecan settings file ##' @param run.id id of run ##' @return configuration file for PRELES for given run diff --git a/models/preles/man/runPRELES.jobsh.Rd b/models/preles/man/runPRELES.jobsh.Rd index 6588c3971d2..3890dca8f4b 100644 --- a/models/preles/man/runPRELES.jobsh.Rd +++ b/models/preles/man/runPRELES.jobsh.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/runPRELES.jobsh.R \name{runPRELES.jobsh} \alias{runPRELES.jobsh} -\title{Function to process ncdf file, run PRELES model, and convert output .nc file in CF standard} +\title{Process ncdf file, run PRELES model, and convert output .nc file in CF standard} \usage{ runPRELES.jobsh( met.file, @@ -15,18 +15,21 @@ runPRELES.jobsh( ) } \arguments{ -\item{outdir}{Location of PRELES model output} +\item{met.file}{base name for yearly nc files containing met data. +Example: `met.file="somefile"` matches somefile.2004.nc, somefile.2005.nc, etc.} -\item{in.path}{location on disk where inputs are stored} +\item{outdir}{Location of PRELES model output} -\item{in.prefix}{prefix of input and output files} +\item{parameters}{An R data file containing parameter values. +Must be an Rda file written via `save()`, and must define an object named +`trait.values`} -\item{start_date}{Start time of the simulation} +\item{sitelat, sitelon}{Latitude and longitude of site in decimal degrees} -\item{end_date}{End time of the simulation} +\item{start.date, end.date}{Start and end time of the simulation} } \description{ -Function to process ncdf file, run PRELES model, and convert output .nc file in CF standard +Process ncdf file, run PRELES model, and convert output .nc file in CF standard } \author{ Tony Gardella, Michael Dietze diff --git a/models/preles/man/write.config.PRELES.Rd b/models/preles/man/write.config.PRELES.Rd index ae20b961c74..a3068c26cf4 100644 --- a/models/preles/man/write.config.PRELES.Rd +++ b/models/preles/man/write.config.PRELES.Rd @@ -9,11 +9,11 @@ write.config.PRELES(defaults, trait.values, settings, run.id) \arguments{ \item{defaults}{list of defaults to process} +\item{trait.values}{vector of samples for a given trait} + \item{settings}{list of settings from pecan settings file} \item{run.id}{id of run} - -\item{trait.samples}{vector of samples for a given trait} } \value{ configuration file for PRELES for given run diff --git a/models/preles/tests/Rcheck_reference.log b/models/preles/tests/Rcheck_reference.log index a82d631af9a..a7c0c05acb7 100644 --- a/models/preles/tests/Rcheck_reference.log +++ b/models/preles/tests/Rcheck_reference.log @@ -12,43 +12,6 @@ Maintainer: ‘Tony Gardella ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Unknown, possibly misspelled, fields in DESCRIPTION: ‘Remotes’ @@ -56,8 +19,6 @@ Strong dependencies not in mainstream repositories: PEcAn.utils, PEcAn.logger, PEcAn.data.atmosphere Suggests or Enhances not in mainstream repositories: Rpreles - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -71,14 +32,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Tony Gardella, Mike Dietze’ - Authors@R: ‘Mike Dietze [aut], Tony Gardella [aut, cre], University of Illinois, NCSA [cph]’ - -Package listed in more than one of Depends, Imports, Suggests, Enhances: - ‘PEcAn.utils’ -A package should be listed in only one of these fields. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK @@ -92,44 +46,18 @@ A package should be listed in only one of these fields. * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK -* checking dependencies in R code ... NOTE -'library' or 'require' call to ‘Rpreles’ in package code. - Please use :: or requireNamespace() instead. - See section 'Suggested packages' in the 'Writing R Extensions' manual. -Package in Depends field not imported from: ‘PEcAn.utils’ - These packages need to be imported from (in the NAMESPACE file) - for when this namespace is loaded but not attached. +* checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK -* checking R code for possible problems ... NOTE -runPRELES.jobsh: no visible global function definition for - ‘logger.severe’ -runPRELES.jobsh: no visible binding for global variable ‘trait.values’ -Undefined global functions or variables: - logger.severe trait.values +* checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'runPRELES.jobsh' - ‘met.file’ ‘parameters’ ‘sitelat’ ‘sitelon’ ‘start.date’ ‘end.date’ -Documented arguments not in \usage in documentation object 'runPRELES.jobsh': - ‘in.path’ ‘in.prefix’ ‘start_date’ ‘end_date’ - -Undocumented arguments in documentation object 'write.config.PRELES' - ‘trait.values’ -Documented arguments not in \usage in documentation object 'write.config.PRELES': - ‘trait.samples’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... NONE @@ -139,4 +67,4 @@ Extensions’ manual. * checking for detritus in the temp directory ... OK * DONE -Status: 2 WARNINGs, 3 NOTEs +Status: 1 WARNING, 0 NOTEs diff --git a/models/sibcasa/DESCRIPTION b/models/sibcasa/DESCRIPTION index f9ce83c2b96..0c3bae6faed 100644 --- a/models/sibcasa/DESCRIPTION +++ b/models/sibcasa/DESCRIPTION @@ -14,8 +14,7 @@ Description: This module provides functions to link (SiBCASA) to PEcAn. It is a work in progress and is not yet fully functional. Imports: ncdf4, - PEcAn.logger, - PEcAn.utils (>= 1.4.8) + PEcAn.logger Suggests: testthat (>= 3.0.0), withr diff --git a/models/sibcasa/tests/Rcheck_reference.log b/models/sibcasa/tests/Rcheck_reference.log index af5be9bc108..8ce4873d212 100644 --- a/models/sibcasa/tests/Rcheck_reference.log +++ b/models/sibcasa/tests/Rcheck_reference.log @@ -12,47 +12,8 @@ Maintainer: ‘Rob Kooper ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - Strong dependencies not in mainstream repositories: PEcAn.logger, PEcAn.utils - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -80,9 +41,7 @@ The Date field is over a month old. * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK -* checking dependencies in R code ... NOTE -Namespace in Imports field not imported from: ‘PEcAn.utils’ - All declared Imports should be used. +* checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK @@ -109,4 +68,4 @@ Namespace in Imports field not imported from: ‘PEcAn.utils’ * checking for detritus in the temp directory ... OK * DONE -Status: 1 WARNING, 1 NOTE +Status: 1 WARNING, 0 NOTEs diff --git a/models/sibcasa/tests/testthat.R b/models/sibcasa/tests/testthat.R index f44dabc6ffb..b82fe6345ad 100644 --- a/models/sibcasa/tests/testthat.R +++ b/models/sibcasa/tests/testthat.R @@ -1,5 +1,4 @@ library(testthat) -library(PEcAn.utils) PEcAn.logger::logger.setQuitOnSevere(FALSE) #test_check("PEcAn.ModelName") diff --git a/models/sipnet/.Rbuildignore b/models/sipnet/.Rbuildignore new file mode 100644 index 00000000000..2d28facae40 --- /dev/null +++ b/models/sipnet/.Rbuildignore @@ -0,0 +1,2 @@ +Dockerfile +model_info.json diff --git a/models/sipnet/DESCRIPTION b/models/sipnet/DESCRIPTION index 4caf6639e0e..0a79488bbe5 100644 --- a/models/sipnet/DESCRIPTION +++ b/models/sipnet/DESCRIPTION @@ -5,21 +5,21 @@ Version: 1.8.0.9000 Authors@R: c(person("Mike", "Dietze", role = c("aut", "cre"), email = "dietze@bu.edu"), person("University of Illinois, NCSA", role = c("cph"))) -Author: Mike Dietze -Maintainer: Mike Dietze Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific workflow management tool that is designed to simplify the management of model parameterization, execution, and analysis. The goal of PECAn is to streamline the interaction between data and models, and to improve the efficacy of scientific investigation. -Depends: - PEcAn.data.atmosphere Imports: + dplyr, + lubridate (>= 1.6.0), + ncdf4 (>= 1.15), + PEcAn.data.atmosphere, + PEcAn.data.land, PEcAn.logger, PEcAn.remote, PEcAn.utils, - lubridate (>= 1.6.0), - ncdf4 (>= 1.15), + stats Suggests: coda, testthat (>= 1.0.2) @@ -27,8 +27,5 @@ SystemRequirements: SIPNET ecosystem model OS_type: unix License: BSD_3_clause + file LICENSE Copyright: Authors -LazyLoad: yes -LazyData: FALSE Encoding: UTF-8 -Require: RoxygenNote: 7.3.2 diff --git a/models/sipnet/NAMESPACE b/models/sipnet/NAMESPACE index cdef11b5367..c1a2cf4a98e 100644 --- a/models/sipnet/NAMESPACE +++ b/models/sipnet/NAMESPACE @@ -11,3 +11,4 @@ export(split_inputs.SIPNET) export(veg2model.SIPNET) export(write.config.SIPNET) export(write_restart.SIPNET) +importFrom(dplyr,"%>%") diff --git a/models/sipnet/R/met2model.SIPNET.R b/models/sipnet/R/met2model.SIPNET.R index 919137eadbf..d1c57084318 100644 --- a/models/sipnet/R/met2model.SIPNET.R +++ b/models/sipnet/R/met2model.SIPNET.R @@ -16,6 +16,7 @@ ##' @param overwrite should existing files be overwritten ##' @param verbose should the function be very verbose ##' @param year.fragment the function should ignore whether or not the data is stored as a set of complete years (such as for forecasts). +##' @param ... Additional arguments, currently ignored ##' @author Luke Dramko, Michael Dietze, Alexey Shiklomanov, Rob Kooper met2model.SIPNET <- function(in.path, in.prefix, outfolder, start_date, end_date, overwrite = FALSE, verbose = FALSE, year.fragment = FALSE, ...) { @@ -154,7 +155,7 @@ met2model.SIPNET <- function(in.path, in.prefix, outfolder, start_date, end_date tau <- 15 * tstep filt <- exp(-(1:length(Tair)) / tau) filt <- (filt / sum(filt)) - soilT <- convolve(Tair, filt) + soilT <- stats::convolve(Tair, filt) soilT <- PEcAn.utils::ud_convert(soilT, "K", "degC") PEcAn.logger::logger.info("soil_temperature absent; soilT approximated from Tair") } else { diff --git a/models/sipnet/R/model2netcdf.SIPNET.R b/models/sipnet/R/model2netcdf.SIPNET.R index 96a2b016abc..438a5c43de3 100644 --- a/models/sipnet/R/model2netcdf.SIPNET.R +++ b/models/sipnet/R/model2netcdf.SIPNET.R @@ -77,8 +77,6 @@ sipnet2datetime <- function(sipnet_tval, base_year, base_month = 1, ##' Convert SIPNET output to netCDF ##' ##' Converts all output contained in a folder to netCDF. -##' @name model2netcdf.SIPNET -##' @title Function to convert SIPNET model output to standard netCDF format ##' ##' @param outdir Location of SIPNET model output ##' @param sitelat Latitude of the site @@ -89,7 +87,7 @@ sipnet2datetime <- function(sipnet_tval, base_year, base_month = 1, ##' @param overwrite Flag for overwriting nc files or not ##' @param conflict Flag for dealing with conflicted nc files, if T we then will merge those, if F we will jump to the next. ##' @param prefix prefix to read the output files -##' @param delete.raw Flag to remove sipnet.out files, FALSE = do not remove files TRUE = remove files +##' @param delete.raw logical: remove sipnet.out files after converting? ##' ##' @export ##' @author Shawn Serbin, Michael Dietze diff --git a/models/sipnet/R/sample.IC.SIPNET.R b/models/sipnet/R/sample.IC.SIPNET.R index 0a68647d4fc..540a7bf5006 100644 --- a/models/sipnet/R/sample.IC.SIPNET.R +++ b/models/sipnet/R/sample.IC.SIPNET.R @@ -1,22 +1,21 @@ -## samples intial conditions for SIPNET -##' @title sample.IC.SIPNET -##' @name sample.IC.SIPNET -##' @author Mike Dietze and Ann Raiho -##' -##' @param ne number of ensembles -##' @param state state variables you want to pull -##' @description samples intial conditions for SIPNET -##' -##' @return IC matrix of initial conditions -##' @export -##' +#' Sample initial conditions for SIPNET +#' +#' @author Mike Dietze and Ann Raiho +#' +#' @param ne number of ensembles +#' @param state state variables you want to pull +#' @param year year to pull from +#' +#' @return IC matrix of initial conditions +#' @export +#' sample.IC.SIPNET <- function(ne, state, year = 1) { ## Mg C / ha / yr GWBI ## no conversion needed because SIPNET doesn't take GWBI as IC anyway GWBI <- ifelse(rep("GWBI" %in% names(state), ne), state$GWBI[sample.int(length(state$GWBI), ne)], ## unit MgC ha-1 yr-1 - runif(ne, 0, 10)) ## prior + stats::runif(ne, 0, 10)) ## prior # g C * m-2 ground area in wood (above-ground + roots) Mgha2gm <- (1000000) / (10000) # these unit conversions are for testing @@ -24,12 +23,12 @@ sample.IC.SIPNET <- function(ne, state, year = 1) { # using MgC ha-1 yr-1 for NPP in SDA and also brought back AbvGrndWood to MgC ha-1 for sanity reasons AbvGrndWood <- ifelse(rep("AbvGrndWood" %in% names(state), ne), PEcAn.utils::ud_convert(state$AbvGrndWood[sample.int(length(state$AbvGrndWood), ne)], "Mg/ha", "g/m^2"), - runif(ne, 700, 15000)) ## prior + stats::runif(ne, 700, 15000)) ## prior # sipnet accepts a plantWoodC pool that is above-ground + roots # instead of roots having their own state, we'll pass around fractions to update them deterministically - fine_root_carbon_content <- runif(ne, 100, 1000) - coarse_root_carbon_content <- runif(ne, 200, 2000) + fine_root_carbon_content <- stats::runif(ne, 100, 1000) + coarse_root_carbon_content <- stats::runif(ne, 200, 2000) wood_total_C <- AbvGrndWood + fine_root_carbon_content + coarse_root_carbon_content @@ -39,39 +38,39 @@ sample.IC.SIPNET <- function(ne, state, year = 1) { # initial leaf area, m2 leaves * m-2 ground area (multiply by leafCSpWt to ## get initial plant leaf C) - lai <- ifelse(rep("LAI" %in% names(state), ne), - state$LAI[1, sample.int(ncol(state$LAI), ne), year], - runif(ne, 0, 7)) ## prior - + lai <- ifelse(rep("LAI" %in% names(state), ne), + state$LAI[1, sample.int(ncol(state$LAI), ne), year], + stats::runif(ne, 0, 7)) ## prior + ## g C * m-2 ground area - litter <- ifelse(rep("litter" %in% names(state), ne), - state$litter[1, sample.int(ncol(state$litter), ne), year], - runif(ne, 130, 1200)) ## prior - + litter <- ifelse(rep("litter" %in% names(state), ne), + state$litter[1, sample.int(ncol(state$litter), ne), year], + stats::runif(ne, 130, 1200)) ## prior + ## g C * m-2 ground area - soil <- ifelse(rep("soil" %in% names(state), ne), - state$soil[1, sample.int(ncol(state$soil), ne), year], - runif(ne, 1200, 2000)) ## prior - + soil <- ifelse(rep("soil" %in% names(state), ne), + state$soil[1, sample.int(ncol(state$soil), ne), year], + stats::runif(ne, 1200, 2000)) ## prior + ## unitless: fraction of litterWHC - litterWFrac <- ifelse(rep("litterW" %in% names(state), ne), - state$litterW[1, sample.int(ncol(state$litterW), ne), year], - runif(ne)) ## prior - + litterWFrac <- ifelse(rep("litterW" %in% names(state), ne), + state$litterW[1, sample.int(ncol(state$litterW), ne), year], + stats::runif(ne)) ## prior + ## unitless: fraction of soilWHC - soilWFrac <- ifelse(rep("soilW" %in% names(state), ne), + soilWFrac <- ifelse(rep("soilW" %in% names(state), ne), state$soilW[1, sample.int(ncol(state$soilW), ne), year], - runif(ne)) ## prior - + stats::runif(ne)) ## prior + ## cm water equiv - snow <- ifelse(rep("snow" %in% names(state), ne), - state$snow[1, sample.int(ncol(state$snow), ne), year], - runif(ne, 0, 2000)) ## prior - - microbe <- ifelse(rep("microbe" %in% names(state), ne), - state$microbe[1, sample.int(ncol(state$microbe), ne), year], - runif(ne, 0.02, 1)) ## prior - + snow <- ifelse(rep("snow" %in% names(state), ne), + state$snow[1, sample.int(ncol(state$snow), ne), year], + stats::runif(ne, 0, 2000)) ## prior + + microbe <- ifelse(rep("microbe" %in% names(state), ne), + state$microbe[1, sample.int(ncol(state$microbe), ne), year], + stats::runif(ne, 0.02, 1)) ## prior + return(data.frame(GWBI, AbvGrndWood, abvGrndWoodFrac, coarseRootFrac, fineRootFrac, lai, litter, soil, litterWFrac, soilWFrac, snow, microbe)) } # sample.IC.SIPNET diff --git a/models/sipnet/R/split_inputs.SIPNET.R b/models/sipnet/R/split_inputs.SIPNET.R index b47289d567a..4bc6de7dfa6 100644 --- a/models/sipnet/R/split_inputs.SIPNET.R +++ b/models/sipnet/R/split_inputs.SIPNET.R @@ -12,6 +12,8 @@ ##' @description Splits climate met for SIPNET ##' ##' @return file split up climate file +##' +##' @importFrom dplyr %>% ##' @export split_inputs.SIPNET <- function(settings, start.time, stop.time, inputs, overwrite = FALSE, outpath = NULL) { #### Get met paths diff --git a/models/sipnet/R/write_restart.SIPNET.R b/models/sipnet/R/write_restart.SIPNET.R index 6bd62c3b3a7..32d2736312e 100755 --- a/models/sipnet/R/write_restart.SIPNET.R +++ b/models/sipnet/R/write_restart.SIPNET.R @@ -1,5 +1,8 @@ -##' @title write_restart.SIPNET -##' @name write_restart.SIPNET +##' write_restart.SIPNET +##' +##' Write restart files for SIPNET. +##' WARNING: Some variables produce illegal values < 0 and have been hardcoded to correct these values!! +##' ##' @author Ann Raiho \email{araiho@@nd.edu} ##' ##' @param outdir output directory @@ -12,10 +15,10 @@ ##' @param new.params list of parameters to convert between different states ##' @param inputs list of model inputs to use in write.configs.SIPNET ##' @param verbose decide if we want to print the outputs. -##' -##' @description Write restart files for SIPNET. WARNING: Some variables produce illegal values < 0 and have been hardcoded to correct these values!! ##' ##' @return NONE +##' +##' @importFrom dplyr %>% ##' @export write_restart.SIPNET <- function(outdir, runid, start.time, stop.time, settings, new.state, RENAME = TRUE, new.params = FALSE, inputs, verbose = FALSE) { diff --git a/models/sipnet/man/met2model.SIPNET.Rd b/models/sipnet/man/met2model.SIPNET.Rd index c6ef948abc6..5b138640ea8 100644 --- a/models/sipnet/man/met2model.SIPNET.Rd +++ b/models/sipnet/man/met2model.SIPNET.Rd @@ -32,6 +32,8 @@ met2model.SIPNET( \item{verbose}{should the function be very verbose} \item{year.fragment}{the function should ignore whether or not the data is stored as a set of complete years (such as for forecasts).} + +\item{...}{Additional arguments, currently ignored} } \description{ met2model wrapper for SIPNET diff --git a/models/sipnet/man/model2netcdf.SIPNET.Rd b/models/sipnet/man/model2netcdf.SIPNET.Rd index 3853c307e6a..b88a96198cf 100644 --- a/models/sipnet/man/model2netcdf.SIPNET.Rd +++ b/models/sipnet/man/model2netcdf.SIPNET.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/model2netcdf.SIPNET.R \name{model2netcdf.SIPNET} \alias{model2netcdf.SIPNET} -\title{Function to convert SIPNET model output to standard netCDF format} +\title{Convert SIPNET output to netCDF} \usage{ model2netcdf.SIPNET( outdir, @@ -28,7 +28,7 @@ model2netcdf.SIPNET( \item{end_date}{End time of the simulation} -\item{delete.raw}{Flag to remove sipnet.out files, FALSE = do not remove files TRUE = remove files} +\item{delete.raw}{logical: remove sipnet.out files after converting?} \item{revision}{model revision} @@ -39,9 +39,6 @@ model2netcdf.SIPNET( \item{conflict}{Flag for dealing with conflicted nc files, if T we then will merge those, if F we will jump to the next.} } \description{ -Convert SIPNET output to netCDF -} -\details{ Converts all output contained in a folder to netCDF. } \author{ diff --git a/models/sipnet/man/sample.IC.SIPNET.Rd b/models/sipnet/man/sample.IC.SIPNET.Rd index 1e29bb2e456..055aa0f7508 100644 --- a/models/sipnet/man/sample.IC.SIPNET.Rd +++ b/models/sipnet/man/sample.IC.SIPNET.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/sample.IC.SIPNET.R \name{sample.IC.SIPNET} \alias{sample.IC.SIPNET} -\title{sample.IC.SIPNET} +\title{Sample initial conditions for SIPNET} \usage{ sample.IC.SIPNET(ne, state, year = 1) } @@ -10,12 +10,14 @@ sample.IC.SIPNET(ne, state, year = 1) \item{ne}{number of ensembles} \item{state}{state variables you want to pull} + +\item{year}{year to pull from} } \value{ IC matrix of initial conditions } \description{ -samples intial conditions for SIPNET +Sample initial conditions for SIPNET } \author{ Mike Dietze and Ann Raiho diff --git a/models/sipnet/man/write_restart.SIPNET.Rd b/models/sipnet/man/write_restart.SIPNET.Rd index 22d7f885d7b..cc3264ec23a 100644 --- a/models/sipnet/man/write_restart.SIPNET.Rd +++ b/models/sipnet/man/write_restart.SIPNET.Rd @@ -42,7 +42,8 @@ write_restart.SIPNET( NONE } \description{ -Write restart files for SIPNET. WARNING: Some variables produce illegal values < 0 and have been hardcoded to correct these values!! +Write restart files for SIPNET. +WARNING: Some variables produce illegal values < 0 and have been hardcoded to correct these values!! } \author{ Ann Raiho \email{araiho@nd.edu} diff --git a/models/sipnet/tests/Rcheck_reference.log b/models/sipnet/tests/Rcheck_reference.log index 016fcbe1a07..92231b20a86 100644 --- a/models/sipnet/tests/Rcheck_reference.log +++ b/models/sipnet/tests/Rcheck_reference.log @@ -12,50 +12,8 @@ Maintainer: ‘Mike Dietze ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - ## This is the master copy of the PEcAn License - - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - PEcAn project - www.pecanproject.org - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal with the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - Neither the names of University of Illinois, NCSA, nor the names - of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - -Unknown, possibly misspelled, fields in DESCRIPTION: - ‘Require’ - Strong dependencies not in mainstream repositories: PEcAn.data.atmosphere, PEcAn.logger, PEcAn.remote, PEcAn.utils - -The Date field is over a month old. * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -69,14 +27,8 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -Author field differs from that derived from Authors@R - Author: ‘Mike Dietze’ - Authors@R: ‘Mike Dietze [aut, cre], University of Illinois, NCSA [cph]’ - -* checking top-level files ... NOTE -Non-standard files/directories found at top level: - ‘Dockerfile’ ‘model_info.json’ +* checking DESCRIPTION meta-information ... OK +* checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK @@ -89,57 +41,26 @@ Non-standard files/directories found at top level: * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK -* checking dependencies in R code ... WARNING -'::' or ':::' imports not declared from: - ‘PEcAn.data.land’ ‘dplyr’ -Package in Depends field not imported from: ‘PEcAn.data.atmosphere’ - These packages need to be imported from (in the NAMESPACE file) - for when this namespace is loaded but not attached. +* checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE -met2model.SIPNET: no visible binding for global variable ‘i’ -met2model.SIPNET: no visible global function definition for ‘convolve’ model2netcdf.SIPNET: no visible binding for global variable ‘year’ -sample.IC.SIPNET: no visible global function definition for ‘runif’ -split_inputs.SIPNET: no visible global function definition for ‘%>%’ split_inputs.SIPNET: no visible binding for global variable ‘.’ split_inputs.SIPNET: no visible binding for global variable ‘V2’ split_inputs.SIPNET: no visible binding for global variable ‘V3’ split_inputs.SIPNET: no visible binding for global variable ‘Date’ split_inputs.SIPNET: no visible binding for global variable ‘V4’ -write_restart.SIPNET: no visible global function definition for ‘%>%’ Undefined global functions or variables: - %>% . Date V2 V3 V4 convolve i runif year -Consider adding - importFrom("stats", "convolve", "runif") -to your NAMESPACE file. + %>% . Date V2 V3 V4 year * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'met2model.SIPNET' - ‘...’ - -Undocumented arguments in documentation object 'model2netcdf.SIPNET' - ‘delete.raw’ - -Undocumented arguments in documentation object 'sample.IC.SIPNET' - ‘year’ - -Undocumented arguments in documentation object 'write.config.SIPNET' - ‘defaults’ ‘trait.values’ ‘settings’ ‘run.id’ ‘inputs’ ‘IC’ ‘restart’ - ‘spinup’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... NONE @@ -149,4 +70,4 @@ Extensions’ manual. * checking for detritus in the temp directory ... OK * DONE -Status: 3 WARNINGs, 3 NOTEs +Status: 1 WARNING, 1 NOTE diff --git a/modules/allometry/tests/Rcheck_reference.log b/modules/allometry/tests/Rcheck_reference.log index 2f3c924d380..8f31a1cde0b 100644 --- a/modules/allometry/tests/Rcheck_reference.log +++ b/modules/allometry/tests/Rcheck_reference.log @@ -20,8 +20,7 @@ Requires (indirectly) orphaned package: ‘udunits2’ * checking whether package ‘PEcAn.allometry’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/modules/assim.batch/tests/Rcheck_reference.log b/modules/assim.batch/tests/Rcheck_reference.log index 41a05fee54e..ceaf7cc3ef1 100644 --- a/modules/assim.batch/tests/Rcheck_reference.log +++ b/modules/assim.batch/tests/Rcheck_reference.log @@ -25,8 +25,7 @@ use conditionally. * checking package directory ... OK * checking for future file timestamps ... OK * checking ‘build’ directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/modules/assim.sequential/tests/Rcheck_reference.log b/modules/assim.sequential/tests/Rcheck_reference.log index 2efbc68b8c0..6a75286ad87 100644 --- a/modules/assim.sequential/tests/Rcheck_reference.log +++ b/modules/assim.sequential/tests/Rcheck_reference.log @@ -119,40 +119,11 @@ File ‘PEcAnAssimSequential/R/Analysis_sda_multiSite.R’: * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'Contruct.Pf' - ‘t’ ‘blocked.dis’ ‘...’ - -Undocumented arguments in documentation object 'GEF' - ‘H’ - -Undocumented arguments in documentation object 'SDA_remote_launcher' - ‘run.bash.args’ - -Undocumented arguments in documentation object 'hop_test' - ‘ens.runid’ - -Undocumented arguments in documentation object 'interactive.plotting.sda' - ‘aqq’ ‘bqq’ ‘facetg’ ‘readsFF’ - -Undocumented arguments in documentation object 'sda.enkf' - ‘...’ - -Undocumented arguments in documentation object 'sda.enkf.multisite' - ‘...’ - -Undocumented arguments in documentation object 'tobit_model_censored' - ‘t’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE -Status: 2 WARNINGs, 1 NOTE +Status: 2 NOTEs diff --git a/modules/data.atmosphere/DESCRIPTION b/modules/data.atmosphere/DESCRIPTION index 32ecfce8a76..fceb2f2d7f1 100644 --- a/modules/data.atmosphere/DESCRIPTION +++ b/modules/data.atmosphere/DESCRIPTION @@ -69,7 +69,7 @@ Suggests: PEcAn.settings, progress, reticulate, - testthat (>= 2.0.0), + testthat (>= 3.1.7), withr Remotes: github::adokter/suntools, diff --git a/modules/data.atmosphere/NEWS.md b/modules/data.atmosphere/NEWS.md index ecd7801d184..13ca4a1b686 100644 --- a/modules/data.atmosphere/NEWS.md +++ b/modules/data.atmosphere/NEWS.md @@ -1,5 +1,8 @@ # PEcAn.data.atmosphere 1.8.0.9000 +## Fixed + +* `download.AmerifluxLBL` no longer wrongly re-fetches raw zipfiles when `overwrite = FALSE` # PEcAn.data.atmosphere 1.8.0 diff --git a/modules/data.atmosphere/R/download.AmerifluxLBL.R b/modules/data.atmosphere/R/download.AmerifluxLBL.R index 677266ffa8a..8a2ff965f3f 100644 --- a/modules/data.atmosphere/R/download.AmerifluxLBL.R +++ b/modules/data.atmosphere/R/download.AmerifluxLBL.R @@ -4,11 +4,11 @@ ##' to download a zip-file of data. The zip-file is extracted to a csv-file that is stored ##' to the given outfolder. Details about amf_download_base function can be found here: ##' https://github.com/chuhousen/amerifluxr/blob/master/R/amf_download_base.R -##' +##' ##' Uses Ameriflux LBL JSON API to download met data from Ameriflux towers in CSV format -##' +##' ##' @export -##' @param sitename the Ameriflux ID of the site to be downloaded, used as file name prefix. +##' @param sitename the Ameriflux ID of the site to be downloaded, used as file name prefix. ##' The 'SITE_ID' field in \href{http://ameriflux.lbl.gov/sites/site-list-and-pages/}{list of Ameriflux sites} ##' @param outfolder location on disk where outputs will be stored ##' @param start_date the start date of the data to be downloaded. Format is YYYY-MM-DD (will only use the year part of the date) @@ -26,115 +26,118 @@ ##' \dontrun{ ##' result <- download.AmerifluxLBL("US-Akn","~/","2011-01-01","2011-12-31",overwrite=TRUE) ##' } -##' +##' ##' @author Ankur Desai, Henri Kajasilta based on download.Ameriflux.R by Josh Mantooth, Rob Kooper, Shawn Serbin download.AmerifluxLBL <- function(sitename, outfolder, start_date, end_date, overwrite = FALSE, verbose = FALSE, username = "pecan", method, useremail = "@", data_product = "BASE-BADM", data_policy = "CCBY4.0", ...) { - + # Initial set-ups for amerifluxr packages # get start/end year code works on whole years only start_date <- as.POSIXlt(start_date, tz = "UTC") end_date <- as.POSIXlt(end_date, tz = "UTC") - + start_year <- lubridate::year(start_date) end_year <- lubridate::year(end_date) - - + + site <- sub(".* \\((.*)\\)", "\\1", sitename) - - - - - + + # make sure output folder exists if (!file.exists(outfolder)) { dir.create(outfolder, showWarnings = FALSE, recursive = TRUE) } - - - - repeat { - tout <- options("timeout") - zip_file <- try(amerifluxr::amf_download_base(user_id = username, - user_email = useremail, - site_id = site, - data_product = data_product, - data_policy = data_policy, - agree_policy = TRUE, - intended_use = "model", - intended_use_text = "PEcAn download", - verbose = verbose, - out_dir = outfolder) - ) - if (!inherits(zip_file, "try-error")){ - break - }else if(tout$timeout > 250 ){ - PEcAn.logger::logger.severe("Download takes too long, check your connection.") - break + + version <- amerifluxr::amf_var_info() + version <- unique(version[version$Site_ID == site,]$BASE_Version) + if (length(version) != 1) { + PEcAn.logger::logger.error("Could not find AmerifluxLBL version info for site", site) + } + expected_filename <- paste0("AMF_", site, "_", data_product, "_", version, ".zip") + expected_fullpath <- file.path(outfolder, expected_filename) + + if (!overwrite && file.exists(expected_fullpath)) { + PEcAn.logger::logger.debug("File '", expected_filename, "' already exists, skipping download") + zip_file <- expected_fullpath + } else { + repeat { + tout <- getOption("timeout") + zip_file <- try( + amerifluxr::amf_download_base( + user_id = username, + user_email = useremail, + site_id = site, + data_product = data_product, + data_policy = data_policy, + agree_policy = TRUE, + intended_use = "model", + intended_use_text = "PEcAn download", + verbose = verbose, + out_dir = outfolder) + ) + if (!inherits(zip_file, "try-error")){ + break + }else if(tout > 250 ){ + PEcAn.logger::logger.severe("Download takes too long, check your connection.") + break + } + PEcAn.logger::logger.info("Added 100 seconds before the download timeouts") + options(timeout = tout + 100) } - PEcAn.logger::logger.info("Added 100 seconds before the download timeouts") - options(timeout = tout$timeout + 100) } - - - - + + # Path to created zip-file - ftplink <- zip_file - if(!grepl(".zip", ftplink)){ - PEcAn.logger::logger.info("Not able to download a zip-file. Check download.AmerifluxLBL inputs") + if(!grepl(".zip", zip_file)){ + PEcAn.logger::logger.error("Not able to download a zip-file. Check download.AmerifluxLBL inputs") } - + # get zip and csv filenames - outfname <- strsplit(ftplink, "/") - outfname <- outfname[[1]][length(outfname[[1]])] - output_zip_file <- file.path(outfolder, outfname) + outfname <- basename(zip_file) + + if (outfname != expected_filename) { + PEcAn.logger::logger.info( + "Downloaded a file named", sQuote(outfname), + "but download.AmerifluxLBL was expecting", sQuote(expected_filename), ". This may be a PEcAn bug.") + } + file_timestep_hh <- "HH" file_timestep_hr <- "HR" file_timestep <- file_timestep_hh - + + # TODO: Are values of data_product other than "BASE-BADM" actually supported? + # If not, this whole block reduces to + # outcsvname <- sub("-BADM(.*).zip", "_HH\\1.csv", outfname) + # And: if other values _are_ supported, are the fixed-length substrings below + # still correct? endname <- strsplit(outfname, "_") endname <- endname[[1]][length(endname[[1]])] - endname <- gsub("\\..*", "", endname) + endname <- gsub("\\..*", "", endname) outcsvname <- paste0(substr(outfname, 1, 15), "_", file_timestep_hh, "_", endname, ".csv") output_csv_file <- file.path(outfolder, outcsvname) outcsvname_hr <- paste0(substr(outfname, 1, 15), "_", file_timestep_hr, "_", endname, ".csv") output_csv_file_hr <- file.path(outfolder, outcsvname_hr) - - download_file_flag <- TRUE + extract_file_flag <- TRUE - if (!overwrite && file.exists(output_zip_file)) { - PEcAn.logger::logger.debug("File '", output_zip_file, "' already exists, skipping download") - download_file_flag <- FALSE - } if (!overwrite && file.exists(output_csv_file)) { PEcAn.logger::logger.debug("File '", output_csv_file, "' already exists, skipping extraction.") - download_file_flag <- FALSE extract_file_flag <- FALSE file_timestep <- "HH" } else { if (!overwrite && file.exists(output_csv_file_hr)) { PEcAn.logger::logger.debug("File '", output_csv_file_hr, "' already exists, skipping extraction.") - download_file_flag <- FALSE extract_file_flag <- FALSE file_timestep <- "HR" outcsvname <- outcsvname_hr output_csv_file <- output_csv_file_hr } } - - if (download_file_flag) { - extract_file_flag <- TRUE - PEcAn.utils::download_file(ftplink, output_zip_file, method) - if (!file.exists(output_zip_file)) { - PEcAn.logger::logger.severe("FTP did not download ", output_zip_file, " from ", ftplink) - } - } + if (extract_file_flag) { - avail_file <- utils::unzip(output_zip_file, list = TRUE) + avail_file <- utils::unzip(zip_file, list = TRUE) if (length(grep("HH", avail_file)) > 0) { file_timestep <- "HH" } else { @@ -143,62 +146,62 @@ download.AmerifluxLBL <- function(sitename, outfolder, start_date, end_date, output_csv_file <- output_csv_file_hr outcsvname <- outcsvname_hr } else { - PEcAn.logger::logger.severe("Half-hourly or Hourly data file was not found in ", output_zip_file) + PEcAn.logger::logger.severe("Half-hourly or Hourly data file was not found in ", zip_file) } } - utils::unzip(output_zip_file, outcsvname, exdir = outfolder) + utils::unzip(zip_file, outcsvname, exdir = outfolder) if (!file.exists(output_csv_file)) { - PEcAn.logger::logger.severe("ZIP file ", output_zip_file, " did not contain CSV file ", outcsvname) + PEcAn.logger::logger.severe("ZIP file ", zip_file, " did not contain CSV file ", outcsvname) } } - + dbfilename <- paste0(substr(outfname, 1, 15), "_", file_timestep, "_", endname) - + # get start and end year of data from file firstline <- system(paste0("head -4 ", output_csv_file), intern = TRUE) firstline <- firstline[4] lastline <- system(paste0("tail -1 ", output_csv_file), intern = TRUE) - - firstdate_st <- paste0(substr(firstline, 1, 4), "-", + + firstdate_st <- paste0(substr(firstline, 1, 4), "-", substr(firstline, 5, 6), "-", substr(firstline, 7, 8), " ", substr(firstline, 9, 10), ":", substr(firstline, 11, 12)) firstdate <- as.POSIXlt(firstdate_st) - lastdate_st <- paste0(substr(lastline, 1, 4), "-", - substr(lastline, 5, 6), "-", - substr(lastline, 7, 8), " ", - substr(lastline, 9, 10), ":", + lastdate_st <- paste0(substr(lastline, 1, 4), "-", + substr(lastline, 5, 6), "-", + substr(lastline, 7, 8), " ", + substr(lastline, 9, 10), ":", substr(lastline, 11, 12)) lastdate <- as.POSIXlt(lastdate_st) - + syear <- lubridate::year(firstdate) eyear <- lubridate::year(lastdate) - + if (start_year > eyear) { PEcAn.logger::logger.severe("Start_Year", start_year, "exceeds end of record ", eyear, " for ", site) } if (end_year < syear) { PEcAn.logger::logger.severe("End_Year", end_year, "precedes start of record ", syear, " for ", site) } - + rows <- 1 - results <- data.frame(file = character(rows), - host = character(rows), - mimetype = character(rows), - formatname = character(rows), - startdate = character(rows), - enddate = character(rows), - dbfile.name = dbfilename, + results <- data.frame(file = character(rows), + host = character(rows), + mimetype = character(rows), + formatname = character(rows), + startdate = character(rows), + enddate = character(rows), + dbfile.name = dbfilename, stringsAsFactors = FALSE) - + results$file[rows] <- output_csv_file results$host[rows] <- PEcAn.remote::fqdn() results$startdate[rows] <- firstdate_st results$enddate[rows] <- lastdate_st results$mimetype[rows] <- "text/csv" results$formatname[rows] <- "AMERIFLUX_BASE_HH" - + # return list of files downloaded return(results) } # download.AmerifluxLBL diff --git a/modules/data.atmosphere/man/download.AmerifluxLBL.Rd b/modules/data.atmosphere/man/download.AmerifluxLBL.Rd index 9b8fa2290ad..813388c04b6 100644 --- a/modules/data.atmosphere/man/download.AmerifluxLBL.Rd +++ b/modules/data.atmosphere/man/download.AmerifluxLBL.Rd @@ -20,7 +20,7 @@ download.AmerifluxLBL( ) } \arguments{ -\item{sitename}{the Ameriflux ID of the site to be downloaded, used as file name prefix. +\item{sitename}{the Ameriflux ID of the site to be downloaded, used as file name prefix. The 'SITE_ID' field in \href{http://ameriflux.lbl.gov/sites/site-list-and-pages/}{list of Ameriflux sites}} \item{outfolder}{location on disk where outputs will be stored} diff --git a/modules/data.atmosphere/tests/testthat/test.download.AmerifluxLBL.R b/modules/data.atmosphere/tests/testthat/test.download.AmerifluxLBL.R new file mode 100644 index 00000000000..4ca10b43afe --- /dev/null +++ b/modules/data.atmosphere/tests/testthat/test.download.AmerifluxLBL.R @@ -0,0 +1,76 @@ + +test_that("download respects overwrite argument", { + outdir <- withr::local_tempdir() + zippath <- file.path(outdir, "AMF_US-Akn_BASE-BADM_6-5.zip") + csvpath <- sub("-BADM(.*).zip", "_HH\\1.csv", zippath) + + # Mock out amerifluxr functions to test our code without network calls + local_mocked_bindings( + amf_download_base = \(...) { + tmp_csv <- basename(csvpath) + withr::with_tempdir({ + writeLines( + c( "# fake file", + "#", + "TIMESTAMP_START,TIMESTAMP_END", + "201101010000,201101010030", + "201112310000,201112310030"), + tmp_csv) + zip(zippath, tmp_csv, flags = "-qr0X")}) + zippath + }, + amf_var_info = \(...) data.frame( + Site_ID = "US-Akn", + BASE_Version = "6-5"), + .package = "amerifluxr" + ) + + # wrapper, just to skip retyping args + dl_akn <- function(...) download.AmerifluxLBL( + site = "US-Akn", + outfolder = outdir, + start_date = "2011-01-01", + end_date = "2011-10-01", + ...) + + # Case 0: new download + expect_false(file.exists(zippath)) + expect_false(file.exists(csvpath)) + dl_akn() + expect_true(file.exists(zippath)) + expect_true(file.exists(csvpath)) + + + # Case 1: reuse existing download + ziptime <- file.mtime(zippath) + csvtime <- file.mtime(csvpath) + expect_log( + dl_akn(overwrite = FALSE), + "skipping download.*skipping extraction") + expect_equal(file.mtime(zippath), ziptime) + expect_equal(file.mtime(csvpath), csvtime) + + # Case 2: overwrite existing download + dl_akn(overwrite = TRUE) + expect_gt(file.mtime(zippath), ziptime) + expect_gt(file.mtime(csvpath), csvtime) + + # Case 3: Freshen csv without clobbering zip + file.remove(csvpath) + ziptime <- file.mtime(zippath) + expect_log(dl_akn(overwrite = FALSE), "skipping download") + expect_true(file.exists(csvpath)) + expect_equal(file.mtime(zippath), ziptime) + + # Case 4: Re-download zip without clobbering CSV + # (Note: I'm not sure this is desirable! For consistency it may be better + # to overwrite the CSV so we know it matches the zip file. + # If you change the behavior, go ahead and update this test to match.) + file.remove(zippath) + csvtime <- file.mtime(csvpath) + expect_log( + dl_akn(overwrite = FALSE), + "skipping extraction") + expect_true(file.exists(zippath)) + expect_equal(file.mtime(csvpath), csvtime) +}) diff --git a/modules/meta.analysis/tests/Rcheck_reference.log b/modules/meta.analysis/tests/Rcheck_reference.log index 77794a06240..eac377f0dd3 100644 --- a/modules/meta.analysis/tests/Rcheck_reference.log +++ b/modules/meta.analysis/tests/Rcheck_reference.log @@ -62,8 +62,7 @@ The Date field is over a month old. * checking package directory ... OK * checking for future file timestamps ... OK * checking ‘build’ directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/modules/photosynthesis/tests/Rcheck_reference.log b/modules/photosynthesis/tests/Rcheck_reference.log index b9013d0ac02..1c31c51ed0c 100644 --- a/modules/photosynthesis/tests/Rcheck_reference.log +++ b/modules/photosynthesis/tests/Rcheck_reference.log @@ -19,8 +19,7 @@ * checking whether package ‘PEcAn.photosynthesis’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK diff --git a/modules/priors/tests/Rcheck_reference.log b/modules/priors/tests/Rcheck_reference.log index 00d0afa3d48..27f73151394 100644 --- a/modules/priors/tests/Rcheck_reference.log +++ b/modules/priors/tests/Rcheck_reference.log @@ -68,8 +68,7 @@ The Date field is over a month old. * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... NOTE -License stub is invalid DCF. +* checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK