From 8fd24df264d908dd8c6fa9d4473b51646ff5f6a4 Mon Sep 17 00:00:00 2001 From: Chris Black Date: Mon, 30 Sep 2024 00:48:23 -0700 Subject: [PATCH] Update license for PEcAn.utils and PEcAn.BIOCRO With agreement from all crontributors whose code is still present in PEcAn Plus misc. Roxygen formatting fixes --- .github/PULL_REQUEST_TEMPLATE.md | 3 + CONTRIBUTING.md | 4 + base/utils/LICENSE | 32 +- base/utils/NEWS.md | 3 + base/utils/R/Defunct.R | 5 +- base/utils/R/cf2date.R | 2 +- base/utils/R/clear.scratch.R | 30 +- base/utils/R/distn.stats.R | 42 +- base/utils/R/download.url.R | 42 +- base/utils/R/full.path.R | 34 +- base/utils/R/get.ensemble.inputs.R | 22 +- base/utils/R/help.R | 77 +- base/utils/R/listToArgString.R | 16 +- base/utils/R/mail.R | 35 +- base/utils/R/n_leap_day.R | 12 +- base/utils/R/r2bugs.distributions.R | 61 +- base/utils/R/read.output.R | 110 ++- base/utils/R/remove.config.R | 9 - base/utils/R/status.R | 3 +- base/utils/R/timezone_hour.R | 22 +- base/utils/R/to_nc.R | 34 +- base/utils/R/transformstats.R | 36 +- base/utils/R/ud_convert.R | 26 +- base/utils/R/unit_is_parseable.R | 30 +- base/utils/R/utils.R | 678 +++++++++--------- base/utils/R/write.config.utils.R | 86 +-- base/utils/inst/clear.scratch.sh | 10 +- base/utils/man/PEcAn.Rd | 36 +- base/utils/man/as.sequence.Rd | 5 +- base/utils/man/bibtexify.Rd | 5 +- base/utils/man/bugs.rdist.Rd | 5 +- base/utils/man/clear.scratch.Rd | 2 +- base/utils/man/convert.expr.Rd | 2 +- base/utils/man/distn.table.stats.Rd | 6 +- base/utils/man/download.url.Rd | 5 +- base/utils/man/download_file.Rd | 3 +- base/utils/man/full.path.Rd | 5 +- base/utils/man/get.run.id.Rd | 5 +- base/utils/man/get.stats.mcmc.Rd | 2 +- base/utils/man/load.modelpkg.Rd | 2 +- base/utils/man/misc.are.convertible.Rd | 2 +- base/utils/man/misc.convert.Rd | 2 +- base/utils/man/mstmipvar.Rd | 5 +- base/utils/man/newxtable.Rd | 5 +- base/utils/man/pdf.stats.Rd | 2 +- base/utils/man/r2bugs.distributions.Rd | 3 - base/utils/man/read.output.Rd | 1 + base/utils/man/retry.func.Rd | 9 +- base/utils/man/rsync.Rd | 5 +- base/utils/man/ssh.Rd | 2 +- base/utils/man/summarize.result.Rd | 2 +- base/utils/man/temp.settings.Rd | 5 +- base/utils/man/timezone_hour.Rd | 4 +- base/utils/man/tryl.Rd | 5 +- base/utils/man/vecpaste.Rd | 5 +- base/utils/man/zero.bounded.density.Rd | 5 +- base/utils/scripts/metutils.R | 8 - base/utils/scripts/time.constants.R | 9 - base/utils/tests/Rcheck_reference.log | 47 +- base/utils/tests/testthat.R | 8 - .../tests/testthat/test.trait.dictionary.R | 9 - base/utils/tests/testthat/test.utils.R | 8 - models/biocro/LICENSE | 37 +- models/biocro/NEWS.md | 7 + models/biocro/R/met2model.BIOCRO.R | 114 ++- models/biocro/R/model2netcdf.BIOCRO.R | 38 +- models/biocro/R/read.biocro.config.R | 13 +- models/biocro/R/write.configs.BIOCRO.R | 69 +- models/biocro/man/cf2biocro.Rd | 2 +- models/biocro/man/convert.samples.BIOCRO.Rd | 5 +- models/biocro/man/model2netcdf.BIOCRO.Rd | 6 +- models/biocro/man/read.biocro.config.Rd | 2 +- models/biocro/man/remove.config.BIOCRO.Rd | 2 +- models/biocro/man/write.config.BIOCRO.Rd | 2 +- models/biocro/tests/Rcheck_reference.log | 46 +- models/biocro/tests/testthat.R | 7 - 76 files changed, 861 insertions(+), 1187 deletions(-) create mode 100644 models/biocro/NEWS.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1293b3e5332..a5c26141117 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -26,6 +26,9 @@ - [ ] My change requires a change to the documentation. - [ ] My name is in the list of CITATION.cff +- [ ] I agree that PEcAn Project may distribute my contribution under any or all of + - the same license as the existing code, + - and/or the BSD 3-clause license. - [ ] I have updated the CHANGELOG.md. - [ ] I have updated the documentation accordingly. - [ ] I have read the **CONTRIBUTING** document. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eb1ce470e0a..1ec2e870917 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,6 +110,10 @@ git push -u origin GH-issuenumber-title-of-issue When finished create a pull request from your branch to the main pecan repository. + When submitting a pull request, you retain authorship of the code you contribute. However, you are giving the PEcAn Project permission to distribute your contributions under either or both, at our discretion, of: + - The license listed at PR opening time for the code you are contributing to, + - and/or the BSD 3-clause license. + ## Additional Resources - [Adding models to PEcAn](https://pecanproject.github.io/pecan-documentation/latest/adding-an-ecosystem-model.html) diff --git a/base/utils/LICENSE b/base/utils/LICENSE index 9e38c2dc685..09ef35a60b4 100644 --- a/base/utils/LICENSE +++ b/base/utils/LICENSE @@ -1,29 +1,3 @@ -University of Illinois/NCSA Open Source License - -Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - -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. - +YEAR: 2024 +COPYRIGHT HOLDER: PEcAn Project +ORGANIZATION: PEcAn Project, authors affiliations diff --git a/base/utils/NEWS.md b/base/utils/NEWS.md index 2832fad34ff..05aa69b5d67 100644 --- a/base/utils/NEWS.md +++ b/base/utils/NEWS.md @@ -1,5 +1,8 @@ # PEcAn.utils 1.8.0.9000 +## License change +* PEcAn.utils is now distributed under the BSD three-clause license instead of the NCSA Open Source license. + ## Added * utility function `zero.bounded.density` is now exported. diff --git a/base/utils/R/Defunct.R b/base/utils/R/Defunct.R index e74d3e3c425..4533ce75891 100644 --- a/base/utils/R/Defunct.R +++ b/base/utils/R/Defunct.R @@ -1,5 +1,6 @@ -#' @title Defunct functions in PEcAn.utils -#' @description The functions listed below are defunct and have been removed from the package. +#' Defunct functions in PEcAn.utils +#' +#' The functions listed below are defunct and have been removed from the package. #' Calling them will produce a message indicating what function, if any, has replaced it. #' #' @name PEcAn.utils-defunct diff --git a/base/utils/R/cf2date.R b/base/utils/R/cf2date.R index bef5fb9d795..79380c8fc50 100644 --- a/base/utils/R/cf2date.R +++ b/base/utils/R/cf2date.R @@ -81,4 +81,4 @@ datetime2doy <- function(datetime, tz = "UTC") { #' #' @author Alexey Shiklomanov #' -cf2doy <- function(value, unit, tz = "UTC") datetime2doy(cf2datetime(value, unit, tz), tz) \ No newline at end of file +cf2doy <- function(value, unit, tz = "UTC") datetime2doy(cf2datetime(value, unit, tz), tz) diff --git a/base/utils/R/clear.scratch.R b/base/utils/R/clear.scratch.R index afc37df0221..924f8e3d149 100644 --- a/base/utils/R/clear.scratch.R +++ b/base/utils/R/clear.scratch.R @@ -1,24 +1,14 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- -##' Removes previous model run output from worker node local scratch directories on EBI-CLUSTER -##' -##' @title Clear EBI-CLUSTER worker node local scratch directories of old PEcAn output -##' @name clear.scratch -##' @author Shawn Serbin -##' @param settings list of PEcAn settings. Only \code{settings$host$name} is used -##' @return nothing -##' @export -##' @examples -##' \dontrun{ -##' clear.scratch(settings) -##' } +#' Removes previous model run output from worker node local scratch directories on EBI-CLUSTER +#' +#' @author Shawn Serbin +#' @param settings list of PEcAn settings. Only \code{settings$host$name} is used +#' @return nothing +#' @export +#' @examples +#' \dontrun{ +#' clear.scratch(settings) +#' } clear.scratch <- function(settings) { ### Setup script diff --git a/base/utils/R/distn.stats.R b/base/utils/R/distn.stats.R index 6cf66acaac5..f8ee4ddd1df 100644 --- a/base/utils/R/distn.stats.R +++ b/base/utils/R/distn.stats.R @@ -1,15 +1,16 @@ -##' Implementation of standard equations used to calculate mean and sd for a variety of -##' named distributions different -##' -##' @title Distribution Stats -##' @param distn named distribution, one of 'beta', 'exp', 'f', 'gamma', 'lnorm', 'norm', 't', -##' @param a numeric; first parameter of \code{distn} -##' @param b numeric; second parameter of \code{distn} -##' @return vector with mean and standard deviation -##' @export -##' @author David LeBauer -##' @examples -##' distn.stats('norm', 0, 1) +#' Distribution Stats +#' +#' Implementation of standard equations used to calculate mean and sd for a variety of +#' named distributions different +#' +#' @param distn named distribution, one of 'beta', 'exp', 'f', 'gamma', 'lnorm', 'norm', 't', +#' @param a numeric; first parameter of \code{distn} +#' @param b numeric; second parameter of \code{distn} +#' @return vector with mean and standard deviation +#' @export +#' @author David LeBauer +#' @examples +#' distn.stats('norm', 0, 1) distn.stats <- function(distn, a, b) { mean <- sd <- NULL if (distn == "beta") { @@ -44,14 +45,15 @@ distn.stats <- function(distn, a, b) { } # distn.stats -##' a helper function for computing summary statistics of a parametric distribution -##' -##' @title return mean and standard deviation of a distribution for each distribution in a table with \code{colnames = c('distn', 'a', 'b')}, -##' e.g. in a table of priors -##' @param distns table of distributions; see examples -##' @return named vector of mean and SD -##' @export -##' @author David LeBauer +#' Helper function for computing summary statistics of a parametric distribution +#' +#' return mean and standard deviation of a distribution for each distribution in a table with \code{colnames = c('distn', 'a', 'b')}, +#' e.g. in a table of priors +#' +#' @param distns table of distributions; see examples +#' @return named vector of mean and SD +#' @export +#' @author David LeBauer distn.table.stats <- function(distns) { y <- as.data.frame(matrix(NA, nrow(distns), 2)) for (i in seq_len(nrow(distns))) { diff --git a/base/utils/R/download.url.R b/base/utils/R/download.url.R index 557493ee80c..06561891332 100644 --- a/base/utils/R/download.url.R +++ b/base/utils/R/download.url.R @@ -1,25 +1,23 @@ -##' Try and download a file. -##' -##' This will download a file, if retry is set and 404 is returned it will -##' wait until the file is available. If the file is still not available -##' after timeout tries, it will return NA. If the file is downloaded -##' it will return the name of the file -##' -##' @name download.url -##' @title Download file from the url. -##' @export -##' @param url the url of the file to download -##' @param file the filename -##' @param timeout number of seconds to wait for file (default 600) -##' @param .opts list of options for curl, for example to download from a -##' protected site use list(userpwd=userpass, httpauth = 1L) -##' @param retry retry if url not found yet, this is used by Brown Dog -##' @return returns name of file if successful or NA if not. -##' -##' @examples -##' \dontrun{ -##' download.url('http://localhost/', index.html) -##' } +#' Try and download a file. +#' +#' This will download a file, if retry is set and 404 is returned it will +#' wait until the file is available. If the file is still not available +#' after timeout tries, it will return NA. If the file is downloaded +#' it will return the name of the file +#' +#' @export +#' @param url the url of the file to download +#' @param file the filename +#' @param timeout number of seconds to wait for file (default 600) +#' @param .opts list of options for curl, for example to download from a +#' protected site use list(userpwd=userpass, httpauth = 1L) +#' @param retry retry if url not found yet, this is used by Brown Dog +#' @return returns name of file if successful or NA if not. +#' +#' @examples +#' \dontrun{ +#' download.url('http://localhost/', index.html) +#' } download.url <- function(url, file, timeout = 600, .opts = list(), retry = TRUE) { count <- 0 while (retry && !url_found(url) && count < timeout) { diff --git a/base/utils/R/full.path.R b/base/utils/R/full.path.R index 7a0b681cdb0..1221a81513a 100644 --- a/base/utils/R/full.path.R +++ b/base/utils/R/full.path.R @@ -1,26 +1,16 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- -##' Creates an absolute path to a folder. -##' -##' This will take a folder and make it into an absolute folder name. It -##' will normalize the path and prepend it with the current working folder -##' if needed to get an absolute path name. -##' -##' @title Creates an absolute path to a folder -##' @name full.path -##' @param folder folder for file paths. -##' @author Rob Kooper -##' @return absolute path -##' @export -##' @examples -##' full.path('pecan') +#' Creates an absolute path to a folder. +#' +#' This will take a folder and make it into an absolute folder name. It +#' will normalize the path and prepend it with the current working folder +#' if needed to get an absolute path name. +#' +#' @param folder folder for file paths. +#' @author Rob Kooper +#' @return absolute path +#' @export +#' @examples +#' full.path('pecan') full.path <- function(folder) { # normalize pathname folder <- normalizePath(folder, mustWork = FALSE) diff --git a/base/utils/R/get.ensemble.inputs.R b/base/utils/R/get.ensemble.inputs.R index bcc7a5553ea..3377dd507ea 100644 --- a/base/utils/R/get.ensemble.inputs.R +++ b/base/utils/R/get.ensemble.inputs.R @@ -1,14 +1,16 @@ ## split clim file into smaller time units to use in KF -##' @title get.ensemble.inputs -##' @name get.ensemble.inputs -##' @author Mike Dietze and Ann Raiho -##' -##' @param settings PEcAn settings list -##' @param ens ensemble number. default = 1 -##' @description Splits climate met for SIPNET -##' -##' @return find correct ensemble inputs -##' @export + +#' get.ensemble.inputs +#' +#' Splits climate met for SIPNET +#' +#' @author Mike Dietze and Ann Raiho +#' +#' @param settings PEcAn settings list +#' @param ens ensemble number. default = 1 +#' +#' @return find correct ensemble inputs +#' @export get.ensemble.inputs <- function(settings, ens = 1){ diff --git a/base/utils/R/help.R b/base/utils/R/help.R index dbc5281dbdd..175d8f302ef 100644 --- a/base/utils/R/help.R +++ b/base/utils/R/help.R @@ -1,36 +1,43 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - -##' R package to support PEcAn, the Predictive Ecosystem Analyzer -##' -##' Instructions for the use of this package are provided in the project documentation \url{https://pecanproject.github.io/documentation.html}. -##' -##' Project homepage: \url{pecanproject.org} -##' -##' Description of PEcAn -##' -##' The Predictive Ecosystem 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. PEcAn is an open source utility that encapsulates: -##' -##' 1. acquisition of meteorological inputs -##' 2. synthesis of physiological trait data as the posterior distribution of a Bayesian meta-analysis -##' 3. sampling trait meta-analysis posterior distributions to parameterize ensembles of ED2 and other ecophysiological models -##' 4. probabilistic forecasts -##' 5. postprocessing to constrain forecasts and model parameters with field, meterological, eddy flux, and spectral data, and -##' 6. provenance tracking -##' -##' PECAn integrates available data into ecological forecasts by running ensembles of a terrestrial ecosystem model that is parameterized by the posterior distribution from a meta-analysis of available plant trait data. -##' These trait data are assembled from field research and primary literature, and are stored in a PostgreSQL database. Current development focused on biofuel crops uses BETYdb. -##' In addition to generating forecasts that reflect available data, PEcAn quantifies the contribution of each parameter to model uncertainty. -##' This information informs targeted data collection and synthesis efforts that most efficiently reduce forecast uncertainty. -##' -##' Current development is focused on developing PEcAn into a real-time data assimilation and forecasting system. This system will provide a detailed analysis of the past and present ecosystem functioning that seamlessly transitions into forecasts. -##' -##' @name PEcAn -##' @aliases PECAn pecan package-pecan +#' R package to support PEcAn, the Predictive Ecosystem Analyzer +#' +#' Instructions for the use of this package are provided in the project +#' documentation \url{https://pecanproject.github.io/documentation.html}. +#' +#' Project homepage: \url{pecanproject.org} +#' +#' Description of PEcAn +#' +#' The Predictive Ecosystem 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. PEcAn is an open source utility that encapsulates: +#' +#' 1. acquisition of meteorological inputs +#' 2. synthesis of physiological trait data as the posterior distribution of a +#' Bayesian meta-analysis +#' 3. sampling trait meta-analysis posterior distributions to parameterize +#' ensembles of ED2 and other ecophysiological models +#' 4. probabilistic forecasts +#' 5. postprocessing to constrain forecasts and model parameters with field, +#' meterological, eddy flux, and spectral data, and +#' 6. provenance tracking +#' +#' PECAn integrates available data into ecological forecasts by running +#' ensembles of a terrestrial ecosystem model that is parameterized by the +#' posterior distribution from a meta-analysis of available plant trait data. +#' These trait data are assembled from field research and primary literature, +#' and are stored in a PostgreSQL database. Current development focused on +#' biofuel crops uses BETYdb. In addition to generating forecasts that reflect +#' available data, PEcAn quantifies the contribution of each parameter to model +#' uncertainty. This information informs targeted data collection and synthesis +#' efforts that most efficiently reduce forecast uncertainty. +#' +#' Current development is focused on developing PEcAn into a real-time data +#' assimilation and forecasting system. This system will provide a detailed +#' analysis of the past and present ecosystem functioning that seamlessly +#' transitions into forecasts. +#' +#' @name PEcAn +#' @aliases PECAn pecan package-pecan "_PACKAGE" diff --git a/base/utils/R/listToArgString.R b/base/utils/R/listToArgString.R index 68d56d599d2..880c07d0007 100644 --- a/base/utils/R/listToArgString.R +++ b/base/utils/R/listToArgString.R @@ -1,11 +1,11 @@ -##' format a list of arguments as one comma-separated string -##' -##' @export -##' -##' @param l a named list of function arguments -##' @return A string containing named argument/value pairs separated by commas -##' -##' @author Ryan Kelly +#' format a list of arguments as one comma-separated string +#' +#' @export +#' +#' @param l a named list of function arguments +#' @return A string containing named argument/value pairs separated by commas +#' +#' @author Ryan Kelly ## This little utility is used in a few places in data.atmosphere. listToArgString <- function(l) { arg.string <- "" diff --git a/base/utils/R/mail.R b/base/utils/R/mail.R index d188b43275b..35735aab676 100644 --- a/base/utils/R/mail.R +++ b/base/utils/R/mail.R @@ -1,25 +1,17 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- -##' Sends email. This assumes the program sendmail is installed. -##' -##' @param from the sender of the mail message -##' @param to the receipient of the mail message -##' @param subject the subject of the mail message -##' @param body the body of the mail message -##' @author Rob Kooper -##' @return nothing -##' @export -##' @examples -##' \dontrun{ -##' sendmail('bob@@example.com', 'joe@@example.com', 'Hi', 'This is R.') -##' } +#' Sends email. This assumes the program sendmail is installed. +#' +#' @param from the sender of the mail message +#' @param to the receipient of the mail message +#' @param subject the subject of the mail message +#' @param body the body of the mail message +#' @author Rob Kooper +#' @return nothing +#' @export +#' @examples +#' \dontrun{ +#' sendmail('bob@@example.com', 'joe@@example.com', 'Hi', 'This is R.') +#' } sendmail <- function(from, to, subject, body) { if (is.null(to)) { PEcAn.logger::logger.error("No receipient specified, mail is not send.") @@ -38,4 +30,3 @@ sendmail <- function(from, to, subject, body) { unlink(mailfile) } } # sendmail - diff --git a/base/utils/R/n_leap_day.R b/base/utils/R/n_leap_day.R index 0bbdae568e2..fffa28c3f09 100644 --- a/base/utils/R/n_leap_day.R +++ b/base/utils/R/n_leap_day.R @@ -1,9 +1,9 @@ -##' @name n_leap_day -##' @title n_leap_day -##' @description number of leap days between two dates -##' @author Mike Dietze -##' @param start_date,end_date dates in any format recognized by \code{\link[base]{as.Date}} -##' @export +#' n_leap_day +#' +#' number of leap days between two dates +#' @author Mike Dietze +#' @param start_date,end_date dates in any format recognized by \code{\link[base]{as.Date}} +#' @export n_leap_day <- function(start_date, end_date) { ## make sure dates are formatted correctly diff --git a/base/utils/R/r2bugs.distributions.R b/base/utils/R/r2bugs.distributions.R index 0e832c3183d..1ec86414388 100644 --- a/base/utils/R/r2bugs.distributions.R +++ b/base/utils/R/r2bugs.distributions.R @@ -1,26 +1,17 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - -##' convert R parameterizations to BUGS paramaterizations -##' -##' R and BUGS have different parameterizations for some distributions. This function transforms the distributions from R defaults to BUGS defaults. BUGS is an implementation of the BUGS language, and these transformations are expected to work for bugs. -##' @title convert R parameterizations to BUGS paramaterizations -##' @param priors data.frame with columns distn = distribution name, parama, paramb using R default parameterizations. -##' @param direction One of "r2bugs" or "bugs2r" -##' @return priors dataframe using JAGS default parameterizations -##' @author David LeBauer, Ben Bolker -##' @export -##' @examples -##' priors <- data.frame(distn = c('weibull', 'lnorm', 'norm', 'gamma'), -##' parama = c(1, 1, 1, 1), -##' paramb = c(2, 2, 2, 2)) -##' r2bugs.distributions(priors) +#' convert R parameterizations to BUGS paramaterizations +#' +#' R and BUGS have different parameterizations for some distributions. This function transforms the distributions from R defaults to BUGS defaults. BUGS is an implementation of the BUGS language, and these transformations are expected to work for bugs. +#' +#' @param priors data.frame with columns distn = distribution name, parama, paramb using R default parameterizations. +#' @param direction One of "r2bugs" or "bugs2r" +#' @return priors dataframe using JAGS default parameterizations +#' @author David LeBauer, Ben Bolker +#' @export +#' @examples +#' priors <- data.frame(distn = c('weibull', 'lnorm', 'norm', 'gamma'), +#' parama = c(1, 1, 1, 1), +#' paramb = c(2, 2, 2, 2)) +#' r2bugs.distributions(priors) r2bugs.distributions <- function(priors, direction = "r2bugs") { priors$distn <- as.character(priors$distn) @@ -76,19 +67,19 @@ bugs2r.distributions <- function(..., direction = "bugs2r") { } # bugs2r.distributions -##' Sample from an R distribution using JAGS -##' -##' Takes a distribution with R parameterization, converts it to a -##' BUGS parameterization, and then samples from the distribution using -##' JAGS -##' @title bugs.rdist -##' @param prior dataframe with distribution name and parameters -##' @param n.iter number of MCMC samples. Output will have n.iter/4 samples -##' @param n number of randomly chosen samples to return. +#' Sample from an R distribution using JAGS +#' +#' Takes a distribution with R parameterization, converts it to a +#' BUGS parameterization, and then samples from the distribution using +#' JAGS +#' +#' @param prior dataframe with distribution name and parameters +#' @param n.iter number of MCMC samples. Output will have n.iter/4 samples +#' @param n number of randomly chosen samples to return. ## If NULL, returns all n.iter/4 of them -##' @return vector of samples -##' @export -##' @author David LeBauer +#' @return vector of samples +#' @export +#' @author David LeBauer bugs.rdist <- function(prior = data.frame(distn = "norm", parama = 0, paramb = 1), n.iter = 1e+05, n = NULL) { need_packages("rjags") diff --git a/base/utils/R/read.output.R b/base/utils/R/read.output.R index 2929c3cb76b..a641b113aa3 100644 --- a/base/utils/R/read.output.R +++ b/base/utils/R/read.output.R @@ -1,62 +1,54 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - -##' Read model output -##' -##' Reads the output of a single model run -##' -##' Generic function to convert model output from model-specific format to -##' a common PEcAn format. This function uses MsTMIP variables except that units of -##' (kg m-2 d-1) are converted to kg ha-1 y-1. Currently this function converts -##' Carbon fluxes: GPP, NPP, NEE, TotalResp, AutoResp, HeteroResp, -##' DOC_flux, Fire_flux, and Stem (Stem is specific to the BioCro model) -##' and Water fluxes: Evaporation (Evap), Transpiration (TVeg), -##' surface runoff (Qs), subsurface runoff (Qsb), and rainfall (Rainf). -##' For more details, see the [MsTMIP -##' variables](http://nacp.ornl.gov/MsTMIP_variables.shtml) -##' documentation. -##' -##' @param runid the ID distinguishing the model run. Can be omitted -##' if `ncfiles` is set. -##' @param outdir the directory that the model's output was sent to. -##' Can be omitted if `ncfiles` is set. -##' @param variables Character vector of variables to be read from -##' model output. Default = `"GPP"`. If `NULL`, try to read all -##' variables in output file.. -##' @param dataframe Logical: if TRUE, will return output in a -##' `data.frame` format with a posix column. Useful for -##' `PEcAn.benchmark::align.data` and plotting. -##' @param pft.name character string, name of the plant functional -##' type (PFT) to read PFT-specific output. If `NULL` no -##' PFT-specific output will be read even the variable has PFT as a -##' dimension. -##' @param ncfiles Custom character vector of full paths to NetCDF -##' files. If `NULL` (default), this list is constructed -##' automatically by looking for `YYYY.nc` files in -##' `file.path(outdir, runid)`. -##' @param verbose Logical. If `TRUE`, print status as every year and -##' variable is read, as well as all NetCDF diagnostics (from -##' `verbose` argument to, e.g., [ncdf4::nc_open()]) (default = -##' `FALSE`). -##' @param print_summary Logical. If `TRUE` (default), calculate and -##' print a summary of the means of each variable for each year. -##' @param start.year,end.year first and last year of output to read. -##' Specify as a date-time (only the year portion is used) or as a -##' four-digit number or string. If `NA`, reads all years found in -##' `outdir`. -##' @return If `dataframe = FALSE`, a vector of output variables. If -##' `dataframe = TRUE`, a `data.frame` of output variables with -##' POSIXct timestamps added (`posix` column). The `posix` column -##' is in seconds after January 1 of `start.year`, or 1970 if -##' `start.year` is not provided. -##' @export -##' @author Michael Dietze, David LeBauer, Alexey Shiklomanov +#' Read model output +#' +#' Reads the output of a single model run +#' +#' Generic function to convert model output from model-specific format to +#' a common PEcAn format. This function uses MsTMIP variables except that units of +#' (kg m-2 d-1) are converted to kg ha-1 y-1. Currently this function converts +#' Carbon fluxes: GPP, NPP, NEE, TotalResp, AutoResp, HeteroResp, +#' DOC_flux, Fire_flux, and Stem (Stem is specific to the BioCro model) +#' and Water fluxes: Evaporation (Evap), Transpiration (TVeg), +#' surface runoff (Qs), subsurface runoff (Qsb), and rainfall (Rainf). +#' +#' For more details, see the [MsTMIP +#' variables](http://nacp.ornl.gov/MsTMIP_variables.shtml) +#' documentation. +#' +#' @param runid the ID distinguishing the model run. Can be omitted +#' if `ncfiles` is set. +#' @param outdir the directory that the model's output was sent to. +#' Can be omitted if `ncfiles` is set. +#' @param variables Character vector of variables to be read from +#' model output. Default = `"GPP"`. If `NULL`, try to read all +#' variables in output file.. +#' @param dataframe Logical: if TRUE, will return output in a +#' `data.frame` format with a posix column. Useful for +#' `PEcAn.benchmark::align.data` and plotting. +#' @param pft.name character string, name of the plant functional +#' type (PFT) to read PFT-specific output. If `NULL` no +#' PFT-specific output will be read even the variable has PFT as a +#' dimension. +#' @param ncfiles Custom character vector of full paths to NetCDF +#' files. If `NULL` (default), this list is constructed +#' automatically by looking for `YYYY.nc` files in +#' `file.path(outdir, runid)`. +#' @param verbose Logical. If `TRUE`, print status as every year and +#' variable is read, as well as all NetCDF diagnostics (from +#' `verbose` argument to, e.g., [ncdf4::nc_open()]) (default = +#' `FALSE`). +#' @param print_summary Logical. If `TRUE` (default), calculate and +#' print a summary of the means of each variable for each year. +#' @param start.year,end.year first and last year of output to read. +#' Specify as a date-time (only the year portion is used) or as a +#' four-digit number or string. If `NA`, reads all years found in +#' `outdir`. +#' @return If `dataframe = FALSE`, a vector of output variables. If +#' `dataframe = TRUE`, a `data.frame` of output variables with +#' POSIXct timestamps added (`posix` column). The `posix` column +#' is in seconds after January 1 of `start.year`, or 1970 if +#' `start.year` is not provided. +#' @export +#' @author Michael Dietze, David LeBauer, Alexey Shiklomanov read.output <- function(runid, outdir, start.year = NA, end.year = NA, diff --git a/base/utils/R/remove.config.R b/base/utils/R/remove.config.R index 2f40a353fa1..b9407fdb90d 100644 --- a/base/utils/R/remove.config.R +++ b/base/utils/R/remove.config.R @@ -1,12 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - remove.config <- function(dir, settings, model) { fcn.name <- paste0("remove.config.", model) diff --git a/base/utils/R/status.R b/base/utils/R/status.R index 868be2d091f..41e340d0ebf 100644 --- a/base/utils/R/status.R +++ b/base/utils/R/status.R @@ -7,8 +7,7 @@ #' Records the progress of a PEcAn workflow by writing statuses and timestamps #' to a STATUS file. Use these each time a module starts, finishes, #' or is skipped. - -#' @details +#' #' All of these functions write to or read from a STATUS file in your run's #' output directory. If the file is not specified in the call, they will look #' for a `settings` object in the global environment and use diff --git a/base/utils/R/timezone_hour.R b/base/utils/R/timezone_hour.R index 0ea9a63b0af..b61c450d817 100644 --- a/base/utils/R/timezone_hour.R +++ b/base/utils/R/timezone_hour.R @@ -1,14 +1,14 @@ -##' @name timezone_hour -##' @title timezone_hour -##' @description return the number of hours offset to UTC for a timezone. -##' @author Rob Kooper -##' @param timezone to be converted -##' @return hours offset of the timezone -##' @examples -##' \dontrun{ -##' timezone_hour('America/New_York') -##' } -##' @export +#' Timezone Hour +#' +#' Returns the number of hours offset to UTC for a timezone. +#' @author Rob Kooper +#' @param timezone to be converted +#' @return hours offset of the timezone +#' @examples +#' \dontrun{ +#' timezone_hour('America/New_York') +#' } +#' @export timezone_hour <- function(timezone) { if (is.numeric(timezone)) { return(timezone) diff --git a/base/utils/R/to_nc.R b/base/utils/R/to_nc.R index 6b244be05c0..9ee1d38e047 100644 --- a/base/utils/R/to_nc.R +++ b/base/utils/R/to_nc.R @@ -1,12 +1,12 @@ -##' Make some values into an NCDF dimension variable -##' -##' Units and longnames are looked up from the \code{\link{standard_vars}} table -##' @export -##' -##' @param dimname character vector, standard dimension name (must be in PEcAn.utils::standard_vars) -##' @param vals values of dimension; can be single value or vector -##' @return ncdim defined according to standard_vars -##' @author Anne Thomas +#' Make some values into an NCDF dimension variable +#' +#' Units and longnames are looked up from the \code{\link{standard_vars}} table +#' @export +#' +#' @param dimname character vector, standard dimension name (must be in PEcAn.utils::standard_vars) +#' @param vals values of dimension; can be single value or vector +#' @return ncdim defined according to standard_vars +#' @author Anne Thomas to_ncdim <- function(dimname,vals){ dim <- PEcAn.utils::standard_vars[which(PEcAn.utils::standard_vars$Variable.Name == dimname),] #check dim exists @@ -30,14 +30,14 @@ to_ncdim <- function(dimname,vals){ } #to_ncdim -##' Define an NCDF variable -##' -##' @export -##' -##' @param varname character vector, standard variable name (must be in PEcAn.utils::standard_vars) -##' @param dims list of previously defined ncdims (function will match subset of dims for this variable in standard_vars; can include other dims--enables lapply.) -##' @return ncvar defined according to standard_vars -##' @author Anne Thomas +#' Define an NCDF variable +#' +#' @export +#' +#' @param varname character vector, standard variable name (must be in PEcAn.utils::standard_vars) +#' @param dims list of previously defined ncdims (function will match subset of dims for this variable in standard_vars; can include other dims--enables lapply.) +#' @return ncvar defined according to standard_vars +#' @author Anne Thomas to_ncvar <- function(varname,dims){ nc_var <- PEcAn.utils::standard_vars[which(PEcAn.utils::standard_vars$Variable.Name == varname),] #check nc_var exists diff --git a/base/utils/R/transformstats.R b/base/utils/R/transformstats.R index d128f0d785a..6c3bf7e4bc3 100644 --- a/base/utils/R/transformstats.R +++ b/base/utils/R/transformstats.R @@ -1,22 +1,22 @@ -##' Transform misc. statistics to SE -##' -##' Automates transformations of SD, MSE, LSD, 95%CI, HSD, and MSD -##' to conservative estimates of SE. -##' Method details and assumptions described in -##' LeBauer 2020 Transforming ANOVA and Regression statistics for Meta-analysis. -##' Authorea. DOI: https://doi.org/10.22541/au.158359749.96662550 -##' @param data data frame with columns for mean, statistic, n, -##' and statistic name -##' @return data frame with statistics transformed to SE -##' @author David LeBauer -##' @export -##' @examples -##' statdf <- data.frame(Y=rep(1,5), -##' stat=rep(1,5), -##' n=rep(4,5), -##' statname=c('SD', 'MSE', 'LSD', 'HSD', 'MSD')) -##' transformstats(statdf) +#' Transform misc. statistics to SE +#' +#' Automates transformations of SD, MSE, LSD, 95%CI, HSD, and MSD +#' to conservative estimates of SE. +#' Method details and assumptions described in +#' LeBauer 2020 Transforming ANOVA and Regression statistics for Meta-analysis. +#' Authorea. DOI: https://doi.org/10.22541/au.158359749.96662550 +#' @param data data frame with columns for mean, statistic, n, +#' and statistic name +#' @return data frame with statistics transformed to SE +#' @author David LeBauer +#' @export +#' @examples +#' statdf <- data.frame(Y=rep(1,5), +#' stat=rep(1,5), +#' n=rep(4,5), +#' statname=c('SD', 'MSE', 'LSD', 'HSD', 'MSD')) +#' transformstats(statdf) transformstats <- function(data) { if (is.factor(data$statname) && !"SE" %in% levels(data$statname)) { data$statname <- factor( diff --git a/base/utils/R/ud_convert.R b/base/utils/R/ud_convert.R index 242b3ece006..ee96bf60cd9 100644 --- a/base/utils/R/ud_convert.R +++ b/base/utils/R/ud_convert.R @@ -1,16 +1,16 @@ -##' Convert units -##' -##' Unit conversion to replace the now-unmaintained `udunits2::ud.convert` -##' @author Chris Black -##' -##' @param x vector of class "numeric" or "difftime" -##' @param u1 string parseable as the units in which `x` is provided. If `x` is -##' class "difftime", then `u1` is not actually used. However, it still needs -##' to be supplied and needs to be convertible to `u2` for consistency. -##' @param u2 string parseable as the units to convert to -##' -##' @return numeric vector with values converted to units in `u2` -##' @export +#' Convert units +#' +#' Unit conversion to replace the now-unmaintained `udunits2::ud.convert` +#' @author Chris Black +#' +#' @param x vector of class "numeric" or "difftime" +#' @param u1 string parseable as the units in which `x` is provided. If `x` is +#' class "difftime", then `u1` is not actually used. However, it still needs +#' to be supplied and needs to be convertible to `u2` for consistency. +#' @param u2 string parseable as the units to convert to +#' +#' @return numeric vector with values converted to units in `u2` +#' @export ud_convert <- function(x, u1, u2) { stopifnot(units::ud_are_convertible(u1, u2)) if(inherits(x, "difftime")) { diff --git a/base/utils/R/unit_is_parseable.R b/base/utils/R/unit_is_parseable.R index 17b3779537d..7ec67361258 100644 --- a/base/utils/R/unit_is_parseable.R +++ b/base/utils/R/unit_is_parseable.R @@ -1,17 +1,17 @@ -##' Check whether a string can be interpreted as a unit -##' -##' Function will replace the now-unmaintained `udunits2::ud.is.parseable` -##' @author Tanishq Jain -##' -##' @param unit A character string representing a type of units -##' -##' @return TRUE if the units is parseable, FALSE otherwise. -##' -##' @examples -##' unit_is_parseable("g/sec^2") -##' unit_is_parseable("kiglometters") -##' -##' @export +#' Check whether a string can be interpreted as a unit +#' +#' Function will replace the now-unmaintained `udunits2::ud.is.parseable` +#' @author Tanishq Jain +#' +#' @param unit A character string representing a type of units +#' +#' @return TRUE if the units is parseable, FALSE otherwise. +#' +#' @examples +#' unit_is_parseable("g/sec^2") +#' unit_is_parseable("kiglometters") +#' +#' @export unit_is_parseable <- function(unit){ tryCatch({ if(units::as_units(unit)) @@ -19,4 +19,4 @@ unit_is_parseable <- function(unit){ }, error = function(e) FALSE ) -} # unit_is_parseable \ No newline at end of file +} # unit_is_parseable diff --git a/base/utils/R/utils.R b/base/utils/R/utils.R index e7e0381f146..1bb2174ad35 100644 --- a/base/utils/R/utils.R +++ b/base/utils/R/utils.R @@ -1,32 +1,23 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - -#--------------------------------------------------------------------------------------------------# -# Small, miscellaneous functions for use throughout PECAn -#--------------------------------------------------------------------------------------------------# - -#--------------------------------------------------------------------------------------------------# -##' return MstMIP variable as ncvar -##' -##' returns a MstMIP variable as a ncvar based on name and other parameters -##' passed in. -##' -##' @title MstMIP variable -##' @export -##' @param name of variable -##' @param lat latitude if dimension requests it -##' @param lon longitude if dimension requests it -##' @param time time if dimension requests it -##' @param nsoil nsoil if dimension requests it -##' @param silent logical: suppress log messages about missing variables? -##' @return ncvar based on MstMIP definition -##' @author Rob Kooper + +#--------------------------------------------------------------------------------------------------# +# Small, miscellaneous functions for use throughout PEcAn +#--------------------------------------------------------------------------------------------------# + +#--------------------------------------------------------------------------------------------------# +#' return MstMIP variable as ncvar +#' +#' returns a MstMIP variable as a ncvar based on name and other parameters +#' passed in. +#' +#' @export +#' @param name of variable +#' @param lat latitude if dimension requests it +#' @param lon longitude if dimension requests it +#' @param time time if dimension requests it +#' @param nsoil nsoil if dimension requests it +#' @param silent logical: suppress log messages about missing variables? +#' @return ncvar based on MstMIP definition +#' @author Rob Kooper mstmipvar <- function(name, lat = NULL, lon = NULL, time = NULL, nsoil = NULL, silent = FALSE) { nc_var <- PEcAn.utils::standard_vars[PEcAn.utils::standard_vars$Variable.Name == name, ] @@ -72,29 +63,31 @@ mstmipvar <- function(name, lat = NULL, lon = NULL, time = NULL, nsoil = NULL, s #--------------------------------------------------------------------------------------------------# -##' left padded by zeros up to a given number of digits. -##' -##' returns a string representing a given number -##' @title Left Pad Zeros -##' @export -##' @param num number to be padded (integer) -##' @param digits number of digits to add -##' @return num with zeros to the left -##' @export -##' @author Carl Davidson +#' Left Pad Zeros +#' +#' left padded by zeros up to a given number of digits. +#' +#' returns a string representing a given number +#' @export +#' @param num number to be padded (integer) +#' @param digits number of digits to add +#' @return num with zeros to the left +#' @export +#' @author Carl Davidson left.pad.zeros <- function(num, digits = 5) { format_string <- paste0("%", sprintf("0%.0f.0f", digits)) return(sprintf(format_string, num)) } # left.pad.zeros -##' Truncates vector at 0 -##' @name zero.truncate -##' @title Zero Truncate -##' @param y numeric vector -##' @return numeric vector with all values less than 0 set to 0 -##' @export -##' @author unknown +#' Zero Truncate +#' +#' Truncates vector at 0 +#' +#' @param y numeric vector +#' @return numeric vector with all values less than 0 set to 0 +#' @export +#' @author unknown zero.truncate <- function(y) { y[y < 0 | is.na(y)] <- 0 return(y) @@ -102,18 +95,17 @@ zero.truncate <- function(y) { #--------------------------------------------------------------------------------------------------# -##' R implementation of rsync -##' -##' rsync is a file copying tool in bash -##' @title rsync -##' @param args rsync arguments (see man rsync) -##' @param from source -##' @param to destination -##' @param pattern file pattern to be matched -##' @return nothing, transfers files as a side effect -##' @export -##' @author David LeBauer -##' @author Shawn Serbin +#' R implementation of rsync +#' +#' rsync is a file copying tool in bash +#' @param args rsync arguments (see man rsync) +#' @param from source +#' @param to destination +#' @param pattern file pattern to be matched +#' @return nothing, transfers files as a side effect +#' @export +#' @author David LeBauer +#' @author Shawn Serbin rsync <- function(args, from, to, pattern = "") { PEcAn.logger::logger.warn("NEED TO USE TUNNEL") system(paste0("rsync", " ", args, " ", from, pattern, " ", to), intern = TRUE) @@ -121,13 +113,12 @@ rsync <- function(args, from, to, pattern = "") { #--------------------------------------------------------------------------------------------------# -##' R implementation of SSH -##' -##' @title SSH -##' @param host (character) machine to connect to -##' @param ... Commands to execute. Will be passed as a single quoted string -##' @param args futher arguments -##' @export +#' R implementation of SSH +#' +#' @param host (character) machine to connect to +#' @param ... Commands to execute. Will be passed as a single quoted string +#' @param args futher arguments +#' @export ssh <- function(host, ..., args = "") { PEcAn.logger::logger.warn("NEED TO USE TUNNEL") if (host == "localhost") { @@ -140,53 +131,50 @@ ssh <- function(host, ..., args = "") { #--------------------------------------------------------------------------------------------------# -##' Convert vector to comma delimited string -##' -##' vecpaste, turns vector into comma delimited string fit for SQL statements. -##' @title vecpaste -##' @param x vector -##' @return comma delimited string -##' @export +#' Convert vector to comma delimited string +#' +#' vecpaste, turns vector into comma delimited string fit for SQL statements. +#' @param x vector +#' @return comma delimited string +#' @export vecpaste <- function(x) paste(paste0("'", x, "'"), collapse = ",") #--------------------------------------------------------------------------------------------------# -##' returns an id representing a model run -##' -##' Provides a consistent method of naming runs; for use in model input files and indices -##' @title Get Run ID -##' @param run.type character, can be any character; currently 'SA' is used for sensitivity analysis, 'ENS' for ensemble run. -##' @param index unique index for different runs, e.g. integer counting members of an -##' ensemble or a quantile used to which a trait has been perturbed for sensitivity analysis -##' @param trait name of trait being sampled (for sensitivity analysis) -##' @param pft.name name of PFT (value from pfts.names field in database) -##' @param site.id optional site id .This is could be necessary for multisite write=false ensembles. -##' @return id representing a model run -##' @export -##' @examples -##' get.run.id('ENS', left.pad.zeros(1, 5)) -##' get.run.id('SA', round(qnorm(-3),3), trait = 'Vcmax') -##' @author Carl Davidson, David LeBauer +#' returns an id representing a model run +#' +#' Provides a consistent method of naming runs; for use in model input files and indices +#' @param run.type character, can be any character; currently 'SA' is used for sensitivity analysis, 'ENS' for ensemble run. +#' @param index unique index for different runs, e.g. integer counting members of an +#' ensemble or a quantile used to which a trait has been perturbed for sensitivity analysis +#' @param trait name of trait being sampled (for sensitivity analysis) +#' @param pft.name name of PFT (value from pfts.names field in database) +#' @param site.id optional site id .This is could be necessary for multisite write=false ensembles. +#' @return id representing a model run +#' @export +#' @examples +#' get.run.id('ENS', left.pad.zeros(1, 5)) +#' get.run.id('SA', round(qnorm(-3),3), trait = 'Vcmax') +#' @author Carl Davidson, David LeBauer get.run.id <- function(run.type, index, trait = NULL, pft.name = NULL, site.id=NULL) { result <- paste(c(run.type, pft.name, trait, index, site.id), collapse = "-") return(result) } # get.run.id #--------------------------------------------------------------------------------------------------# -##' Zero bounded density using log density transform -##' -##' Provides a zero bounded density estimate of a parameter. -##' Kernel Density Estimation used by the \code{\link[stats]{density}} function will cause problems -##' at the left hand end because it will put some weight on negative values. -##' One useful approach is to transform to logs, estimate the density using KDE, and then transform back. -##' @title Zero Bounded Density -##' @param x data, as a numeric vector -##' @param bw The smoothing bandwidth to be used. See 'bw.nrd' -##' @param n number of points to use in kernel density estimate. See \code{\link[stats]{density}} -##' @return data frame with back-transformed log density estimate -##' @author \href{https://stats.stackexchange.com/q/6588/2750}{Rob Hyndman} -##' @references M. P. Wand, J. S. Marron and D. Ruppert, 1991. Transformations in Density Estimation. Journal of the American Statistical Association. 86(414):343-353 \url{http://www.jstor.org/stable/2290569} -##' @export +#' Zero bounded density using log density transform +#' +#' Provides a zero bounded density estimate of a parameter. +#' Kernel Density Estimation used by the \code{\link[stats]{density}} function will cause problems +#' at the left hand end because it will put some weight on negative values. +#' One useful approach is to transform to logs, estimate the density using KDE, and then transform back. +#' @param x data, as a numeric vector +#' @param bw The smoothing bandwidth to be used. See 'bw.nrd' +#' @param n number of points to use in kernel density estimate. See \code{\link[stats]{density}} +#' @return data frame with back-transformed log density estimate +#' @author \href{https://stats.stackexchange.com/q/6588/2750}{Rob Hyndman} +#' @references M. P. Wand, J. S. Marron and D. Ruppert, 1991. Transformations in Density Estimation. Journal of the American Statistical Association. 86(414):343-353 \url{http://www.jstor.org/stable/2290569} +#' @export zero.bounded.density <- function(x, bw = "SJ", n = 1001) { y <- log(x) g <- stats::density(y, bw = bw, n = n) @@ -198,16 +186,14 @@ zero.bounded.density <- function(x, bw = "SJ", n = 1001) { #--------------------------------------------------------------------------------------------------# -##' Summarize results of replicate observations in trait data query -##' -##' @title Summarize Results -##' @param result dataframe with results of trait data query -##' @return result with replicate observations summarized -##' @export summarize.result -##' @usage summarize.result(result) -##' @importFrom rlang .data -##' @importFrom magrittr %>% -##' @author David LeBauer, Alexey Shiklomanov +#' Summarize results of replicate observations in trait data query +#' +#' @param result dataframe with results of trait data query +#' @return result with replicate observations summarized +#' @export summarize.result +#' @importFrom rlang .data +#' @importFrom magrittr %>% +#' @author David LeBauer, Alexey Shiklomanov summarize.result <- function(result) { ans1 <- result %>% dplyr::filter(.data$n == 1) %>% @@ -234,13 +220,12 @@ summarize.result <- function(result) { #--------------------------------------------------------------------------------------------------# -##' Further summarizes output from summary.mcmc -##' -##' @title Get stats for parameters in MCMC output -##' @param mcmc.summary probably produced by \code{\link[coda]{summary.mcmc}} -##' @param sample.size passed as 'n' in returned list -##' @return list with summary statistics for parameters in an MCMC chain -##' @author David LeBauer +#' Further summarizes output from summary.mcmc +#' +#' @param mcmc.summary probably produced by \code{\link[coda]{summary.mcmc}} +#' @param sample.size passed as 'n' in returned list +#' @return list with summary statistics for parameters in an MCMC chain +#' @author David LeBauer get.stats.mcmc <- function(mcmc.summary, sample.size) { a <- list(n = sample.size) for (parm in c("beta.o", "sd.y", "sd.site", "sd.trt", "beta.ghs[2]")) { @@ -256,20 +241,21 @@ get.stats.mcmc <- function(mcmc.summary, sample.size) { #--------------------------------------------------------------------------------------------------# -##' A helper function for building a LaTex table. -##' -##' Used by \code{\link{get.parameter.stat}}. -##' @title Paste Stats -##' @name paste.stats -##' @param median 50-percent quantile -##' @param lcl lower confidence limit -##' @param ucl upper confidence limit -##' @param n significant digits for printing. Passed to \code{\link{tabnum}} -##' @export -##' @author David LeBauer -##' @examples -##' paste.stats(3.333333, 5.00001, 6.22222, n = 3) -##' # [1] "$3.33(5,6.22)$" +#' Paste Stats +#' +#' A helper function for building a LaTex table. +#' +#' Used by \code{\link{get.parameter.stat}}. +#' @name paste.stats +#' @param median 50-percent quantile +#' @param lcl lower confidence limit +#' @param ucl upper confidence limit +#' @param n significant digits for printing. Passed to \code{\link{tabnum}} +#' @export +#' @author David LeBauer +#' @examples +#' paste.stats(3.333333, 5.00001, 6.22222, n = 3) +#' # [1] "$3.33(5,6.22)$" paste.stats <- function(median, lcl, ucl, n = 2) { paste0("$", tabnum(median, n), "(", tabnum(lcl, n), ",", tabnum(ucl, n), ")", @@ -278,16 +264,17 @@ paste.stats <- function(median, lcl, ucl, n = 2) { #--------------------------------------------------------------------------------------------------# -##' Gets statistics for LaTeX - formatted table -##' -##' @title Get Parameter Statistics -##' @param mcmc.summary probably produced by \code{\link[coda]{summary.mcmc}} -##' @param parameter name of parameter to extract, as character -##' @return table with parameter statistics -##' @author David LeBauer -##' @export -##' @examples -##' \dontrun{get.parameter.stat(mcmc.summaries[[1]], 'beta.o')} +#' Get Parameter Statistics +#' +#' Gets statistics for LaTeX - formatted table +#' +#' @param mcmc.summary probably produced by \code{\link[coda]{summary.mcmc}} +#' @param parameter name of parameter to extract, as character +#' @return table with parameter statistics +#' @author David LeBauer +#' @export +#' @examples +#' \dontrun{get.parameter.stat(mcmc.summaries[[1]], 'beta.o')} get.parameter.stat <- function(mcmc.summary, parameter) { paste.stats(median = mcmc.summary$quantiles[parameter, "50%"], lcl = mcmc.summary$quantiles[parameter, c("2.5%")], @@ -298,14 +285,15 @@ get.parameter.stat <- function(mcmc.summary, parameter) { #--------------------------------------------------------------------------------------------------# -##' Calculate mean, variance statistics, and CI from a known distribution -##' -##' @title Probability Distirbution Function Statistics -##' @param distn name of distribution used by R (beta, f, gamma, lnorm, norm, weibull) -##' @param A first parameter -##' @param B second parameter -##' @return list with mean, variance, and 95 CI -##' @author David LeBauer +#' Probability Distribution Function Statistics +#' +#' Calculate mean, variance statistics, and CI from a known distribution +#' +#' @param distn name of distribution used by R (beta, f, gamma, lnorm, norm, weibull) +#' @param A first parameter +#' @param B second parameter +#' @return list with mean, variance, and 95 CI +#' @author David LeBauer ## in future, perhaps create S3 functions: get.stats.pdf <- pdf.stats pdf.stats <- function(distn, A, B) { distn <- as.character(distn) @@ -339,23 +327,23 @@ pdf.stats <- function(distn, A, B) { #--------------------------------------------------------------------------------------------------# -##' Dictionary of terms used to identify traits in ed, filenames, and figures -##' -##' @return a dataframe with id, the name used by ED and PEcAn database for a parameter; fileid, an abbreviated -##' name used for files; figid, the parameter name written out as best known in english for figures -##' and tables. -##' -##' @param traits a vector of trait names, if traits = NULL, all of the traits will be returned. -##' @export -##' @examples -##' # convert parameter name to a string appropriate for end-use plotting -##' \dontrun{ -##' trait.lookup('growth_resp_factor') -##' trait.lookup('growth_resp_factor')$figid -##' -##' # get a list of all traits and units in dictionary -##' trait.lookup()[,c('figid', 'units')] -##' } +#' Dictionary of terms used to identify traits in ed, filenames, and figures +#' +#' @return a dataframe with id, the name used by ED and PEcAn database for a parameter; fileid, an abbreviated +#' name used for files; figid, the parameter name written out as best known in english for figures +#' and tables. +#' +#' @param traits a vector of trait names, if traits = NULL, all of the traits will be returned. +#' @export +#' @examples +#' # convert parameter name to a string appropriate for end-use plotting +#' \dontrun{ +#' trait.lookup('growth_resp_factor') +#' trait.lookup('growth_resp_factor')$figid +#' +#' # get a list of all traits and units in dictionary +#' trait.lookup()[,c('figid', 'units')] +#' } trait.lookup <- function(traits = NULL) { if (is.null(traits)) { return(PEcAn.utils::trait.dictionary) @@ -365,17 +353,18 @@ trait.lookup <- function(traits = NULL) { #--------------------------------------------------------------------------------------------------# -##' Convert number to n significant digits -##' -##' @title Table numbers -##' @param x numeric value or vector -##' @param n number of significant figures -##' @export -##' @author David LeBauer -##' @return x rounded to n significant figures -##' @examples -##' tabnum(1.2345) -##' tabnum(1.2345, n = 4) +#' Table numbers +#' +#' Convert number to n significant digits +#' +#' @param x numeric value or vector +#' @param n number of significant figures +#' @export +#' @author David LeBauer +#' @return x rounded to n significant figures +#' @examples +#' tabnum(1.2345) +#' tabnum(1.2345, n = 4) tabnum <- function(x, n = 3) { ans <- as.numeric(signif(x, n)) names(ans) <- names(x) @@ -385,15 +374,16 @@ tabnum <- function(x, n = 3) { #--------------------------------------------------------------------------------------------------# -##' Scale temperature dependent trait from measurement temperature to reference temperature -##' -##' @title Arrhenius scaling -##' @param observed.value observed value of temperature dependent trait, e.g. Vcmax, root respiration rate -##' @param old.temp temperature at which measurement was taken or previously scaled to -##' @param new.temp temperature to be scaled to, default = 25 C -##' @return numeric value at reference temperature -##' @export -##' @author unknown +#' Arrhenius scaling +#' +#' Scale temperature dependent trait from measurement temperature to reference temperature +#' +#' @param observed.value observed value of temperature dependent trait, e.g. Vcmax, root respiration rate +#' @param old.temp temperature at which measurement was taken or previously scaled to +#' @param new.temp temperature to be scaled to, default = 25 C +#' @return numeric value at reference temperature +#' @export +#' @author unknown arrhenius.scaling <- function(observed.value, old.temp, new.temp = 25) { new.temp.K <- ud_convert(new.temp, "degC", "K") old.temp.K <- ud_convert(old.temp, "degC", "K") @@ -403,32 +393,28 @@ arrhenius.scaling <- function(observed.value, old.temp, new.temp = 25) { #--------------------------------------------------------------------------------------------------# -##' Capitalize a string -##' -##' @title Capitalize a string -##' @param x string -##' @return x, capitalized -##' @author David LeBauer +#' Capitalize a string +#' +#' @param x string +#' @return x, capitalized +#' @author David LeBauer capitalize <- function(x) { x <- as.character(x) s <- strsplit(x, " ")[[1]] return(paste(toupper(substring(s, 1, 1)), substring(s, 2), sep = "", collapse = " ")) } # capitalize -# isFALSE <- function(x) !isTRUE(x) -#--------------------------------------------------------------------------------------------------# - #--------------------------------------------------------------------------------------------------# -##' New xtable -##' -##' utility to properly escape the '%' sign for latex -##' @title newxtable -##' @param x data.frame to be converted to latex table -##' @param environment can be 'table'; 'sidewaystable' if using latex rotating package -##' @param table.placement,label,caption,caption.placement,align passed to \code{\link[xtable]{xtable}} -##' @return Latex version of table, with percentages properly formatted -##' @author David LeBauer +#' New xtable +#' +#' utility to properly escape the '%' sign for latex +#' +#' @param x data.frame to be converted to latex table +#' @param environment can be 'table'; 'sidewaystable' if using latex rotating package +#' @param table.placement,label,caption,caption.placement,align passed to \code{\link[xtable]{xtable}} +#' @return Latex version of table, with percentages properly formatted +#' @author David LeBauer newxtable <- function(x, environment = "table", table.placement = "ht", label = NULL, caption = NULL, caption.placement = NULL, align = NULL) { need_packages("xtable") @@ -443,15 +429,15 @@ newxtable <- function(x, environment = "table", table.placement = "ht", label = #--------------------------------------------------------------------------------------------------# -##' Convert author, year, title to bibtex citation format -##' -##' Converts author year title to author1999abc format -##' @title bibtexify -##' @param author name of first author -##' @param year year of publication -##' @param title manuscript title -##' @return bibtex citation -##' @author unknown +#' bibtexify +#' +#' Converts author year title to bibtex `author1999abc` format +#' +#' @param author name of first author +#' @param year year of publication +#' @param title manuscript title +#' @return bibtex citation +#' @author unknown bibtexify <- function(author, year, title) { acronym <- abbreviate(title, minlength = 3, strict = TRUE) return(paste0(author, year, acronym)) @@ -460,16 +446,16 @@ bibtexify <- function(author, year, title) { #--------------------------------------------------------------------------------------------------# -##' Convert categorical variable into sequential integers -##' -##' Turns any categorical variable into a sequential integer. -##' This transformation is required for using data in BUGS/JAGS -##' @title as.sequence -##' @param x categorical variable as vector -##' @param na.rm logical: return NA's or replace with max(x) + 1 -##' @return sequence from 1:length(unique(x)) -##' @export -##' @author David LeBauer +#' Convert categorical variable into sequential integers +#' +#' Turns any categorical variable into a sequential integer. +#' This transformation is required for using data in BUGS/JAGS +#' +#' @param x categorical variable as vector +#' @param na.rm logical: return NA's or replace with max(x) + 1 +#' @return sequence from 1:length(unique(x)) +#' @export +#' @author David LeBauer as.sequence <- function(x, na.rm = TRUE) { x2 <- as.integer(factor(x, unique(x))) if (all(is.na(x2))) { @@ -484,16 +470,16 @@ as.sequence <- function(x, na.rm = TRUE) { #--------------------------------------------------------------------------------------------------# -##' Create a temporary settings file -##' -##' Uses \code{\link{tempfile}} function to provide a valid temporary file (OS independent) -##' Useful for testing functions that depend on settings file -##' Reference: http://stackoverflow.com/a/12940705/199217 -##' @title temp.settings -##' @param settings.txt character vector to be written -##' @return character vector written to and read from a temporary file -##' @export -##' @author David LeBauer +#' Create a temporary settings file +#' +#' Uses \code{\link{tempfile}} function to provide a valid temporary file (OS independent) +#' Useful for testing functions that depend on settings file +#' Reference: http://stackoverflow.com/a/12940705/199217 +#' +#' @param settings.txt character vector to be written +#' @return character vector written to and read from a temporary file +#' @export +#' @author David LeBauer temp.settings <- function(settings.txt) { temp <- tempfile() on.exit(unlink(temp), add = TRUE) @@ -505,19 +491,19 @@ temp.settings <- function(settings.txt) { #--------------------------------------------------------------------------------------------------# -##' Test if function gives an error -##' -##' adaptation of try that returns a logical value (FALSE if error) -##' @title tryl -##' @param FUN function to be evaluated for error -##' @return FALSE if function returns error; else TRUE -##' @export -##' @examples -##' tryl(1+1) -##' # TRUE -##' tryl(sum('a')) -##' # FALSE -##' @author David LeBauer +#' Test if function gives an error +#' +#' adaptation of try that returns a logical value (FALSE if error) +#' +#' @param FUN function to be evaluated for error +#' @return FALSE if function returns error; else TRUE +#' @export +#' @examples +#' tryl(1+1) +#' # TRUE +#' tryl(sum('a')) +#' # FALSE +#' @author David LeBauer tryl <- function(FUN) { out <- tryCatch(FUN, error = function(e) e) ans <- !inherits(out, "error") @@ -527,14 +513,14 @@ tryl <- function(FUN) { #--------------------------------------------------------------------------------------------------# -##' load model package -##' @title Load model package -##' @param model name of model -##' @return FALSE if function returns error; else TRUE -##' @export -##' @examples -##' \dontrun{require.modelpkg(BioCro)} -##' @author David LeBauer +#' Load model package +#' +#' @param model name of model +#' @return FALSE if function returns error; else TRUE +#' @export +#' @examples +#' \dontrun{require.modelpkg(BioCro)} +#' @author David LeBauer load.modelpkg <- function(model) { pecan.modelpkg <- paste0("PEcAn.", model) if (!pecan.modelpkg %in% names(utils::sessionInfo()$otherPkgs)) { @@ -550,14 +536,14 @@ load.modelpkg <- function(model) { #--------------------------------------------------------------------------------------------------# -##' conversion function for the unit conversions that udunits cannot handle but often needed in PEcAn calculations -##' @title misc.convert -##' @export -##' @param x convertible values -##' @param u1 unit to be converted from, character -##' @param u2 unit to be converted to, character -##' @return val converted values -##' @author Istem Fer, Shawn Serbin +#' conversion function for the unit conversions that udunits cannot handle but often needed in PEcAn calculations +#' +#' @export +#' @param x convertible values +#' @param u1 unit to be converted from, character +#' @param u2 unit to be converted to, character +#' @return val converted values +#' @author Istem Fer, Shawn Serbin misc.convert <- function(x, u1, u2) { amC <- 12.0107 # atomic mass of carbon @@ -589,13 +575,13 @@ misc.convert <- function(x, u1, u2) { #--------------------------------------------------------------------------------------------------# -##' function to check whether units are convertible by misc.convert function -##' @title misc.are.convertible -##' @export -##' @param u1 unit to be converted from, character -##' @param u2 unit to be converted to, character -##' @return logical -##' @author Istem Fer, Shawn Serbin +#' function to check whether units are convertible by misc.convert function +#' +#' @export +#' @param u1 unit to be converted from, character +#' @param u2 unit to be converted to, character +#' @return logical +#' @author Istem Fer, Shawn Serbin misc.are.convertible <- function(u1, u2) { # make sure the order of vectors match @@ -620,12 +606,12 @@ misc.are.convertible <- function(u1, u2) { #--------------------------------------------------------------------------------------------------# -##' Convert expression to variable names -##' @title convert.expr -##' @param expression expression string -##' @return list -##' @export -##' @author Istem Fer +#' Convert expression to variable names +#' +#' @param expression expression string +#' @return list +#' @export +#' @author Istem Fer convert.expr <- function(expression) { # split equation to LHS and RHS deri.var <- gsub("=.*$", "", expression) # name of the derived variable @@ -647,27 +633,28 @@ convert.expr <- function(expression) { #--------------------------------------------------------------------------------------------------# -##' Simple function to use ncftpget for FTP downloads behind a firewall. -##' Requires ncftpget and a properly formatted config file in the users -##' home directory -##' @title download_file -##' @param url complete URL for file download -##' @param filename destination file name -##' @param method Method of file retrieval. Can set this using the `options(download.ftp.method=[method])` in your Rprofile. -##' example options(download.ftp.method="ncftpget") -##' -##' @examples -##' \dontrun{ -##' download_file("http://lib.stat.cmu.edu/datasets/csb/ch11b.txt","~/test.download.txt") -##' -##' download_file(" -##' ftp://ftp.cdc.noaa.gov/Datasets/NARR/monolevel/pres.sfc.2000.nc", -##' "~/pres.sfc.2000.nc") -##' } -##' -##' @export -##' -##' @author Shawn Serbin, Rob Kooper +#' Simple function to use ncftpget for FTP downloads behind a firewall. +#' +#' Requires ncftpget and a properly formatted config file in the users +#' home directory +#' +#' @param url complete URL for file download +#' @param filename destination file name +#' @param method Method of file retrieval. Can set this using the `options(download.ftp.method=[method])` in your Rprofile. +#' example options(download.ftp.method="ncftpget") +#' +#' @examples +#' \dontrun{ +#' download_file("http://lib.stat.cmu.edu/datasets/csb/ch11b.txt","~/test.download.txt") +#' +#' download_file(" +#' ftp://ftp.cdc.noaa.gov/Datasets/NARR/monolevel/pres.sfc.2000.nc", +#' "~/pres.sfc.2000.nc") +#' } +#' +#' @export +#' +#' @author Shawn Serbin, Rob Kooper download_file <- function(url, filename, method) { if (startsWith(url, "ftp://")) { if (missing(method)) method <- getOption("download.ftp.method", default = "auto") @@ -686,34 +673,30 @@ download_file <- function(url, filename, method) { #--------------------------------------------------------------------------------------------------# -##' Retry function X times before stopping in error -##' -##' @title retry.func -##' @name retry.func -##' @description Retry function X times before stopping in error -##' -##' @param expr The function to try running -##' @param maxErrors The number of times to retry the function -##' @param sleep How long to wait before retrying the function call -##' @param isError function to use for checking whether to try again. -##' Must take one argument that contains the result of evaluating `expr` -##' and return TRUE if another retry is needed -##' -##' @return retval returns the results of the function call -##' -##' @examples -##' \dontrun{ -##' file_url <- paste0("https://thredds.daac.ornl.gov/", -##' "thredds/dodsC/ornldaac/1220", -##' "/mstmip_driver_global_hd_climate_lwdown_1999_v1.nc4") -##' dap <- retry.func( -##' ncdf4::nc_open(file_url), -##' maxErrors=10, -##' sleep=2) -##' } -##' -##' @export -##' @author Shawn Serbin +#' Retry function X times before stopping in error +#' +#' @param expr The function to try running +#' @param maxErrors The number of times to retry the function +#' @param sleep How long to wait before retrying the function call +#' @param isError function to use for checking whether to try again. +#' Must take one argument that contains the result of evaluating `expr` +#' and return TRUE if another retry is needed +#' +#' @return retval returns the results of the function call +#' +#' @examples +#' \dontrun{ +#' file_url <- paste0("https://thredds.daac.ornl.gov/", +#' "thredds/dodsC/ornldaac/1220", +#' "/mstmip_driver_global_hd_climate_lwdown_1999_v1.nc4") +#' dap <- retry.func( +#' ncdf4::nc_open(file_url), +#' maxErrors=10, +#' sleep=2) +#' } +#' +#' @export +#' @author Shawn Serbin retry.func <- function(expr, isError = function(x) inherits(x, "try-error"), maxErrors = 5, sleep = 0) { attempts = 0 retval = try(eval(expr)) @@ -738,25 +721,25 @@ retry.func <- function(expr, isError = function(x) inherits(x, "try-error"), max #--------------------------------------------------------------------------------------------------# -##' Adverb to try calling a function `n` times before giving up -##' -##' @param .f Function to call. -##' @param n Number of attempts to try -##' @param timeout Timeout between attempts, in seconds -##' @param silent Silence error messages? -##' @return Modified version of input function -##' @examples -##' rlog <- robustly(log, timeout = 0.3) -##' try(rlog("fail")) -##' \dontrun{ -##' nc_openr <- robustly(ncdf4::nc_open, n = 10, timeout = 0.5) -##' nc <- nc_openr(url) -##' # ...or just call the function directly -##' nc <- robustly(ncdf4::nc_open, n = 20)(url) -##' # Useful in `purrr` maps -##' many_vars <- purrr::map(varnames, robustly(ncdf4::ncvar_get), nc = nc) -##' } -##' @export +#' Adverb to try calling a function `n` times before giving up +#' +#' @param .f Function to call. +#' @param n Number of attempts to try +#' @param timeout Timeout between attempts, in seconds +#' @param silent Silence error messages? +#' @return Modified version of input function +#' @examples +#' rlog <- robustly(log, timeout = 0.3) +#' try(rlog("fail")) +#' \dontrun{ +#' nc_openr <- robustly(ncdf4::nc_open, n = 10, timeout = 0.5) +#' nc <- nc_openr(url) +#' # ...or just call the function directly +#' nc <- robustly(ncdf4::nc_open, n = 20)(url) +#' # Useful in `purrr` maps +#' many_vars <- purrr::map(varnames, robustly(ncdf4::ncvar_get), nc = nc) +#' } +#' @export robustly <- function(.f, n = 10, timeout = 0.2, silent = TRUE) { .f <- purrr::as_mapper(.f) function(...) { @@ -771,8 +754,3 @@ robustly <- function(.f, n = 10, timeout = 0.2, silent = TRUE) { } } #--------------------------------------------------------------------------------------------------# - - -#################################################################################################### -### EOF. End of R script file. -#################################################################################################### diff --git a/base/utils/R/write.config.utils.R b/base/utils/R/write.config.utils.R index f4a481bd53a..06c2bb4a379 100644 --- a/base/utils/R/write.config.utils.R +++ b/base/utils/R/write.config.utils.R @@ -1,24 +1,16 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------# ### TODO: Generalize this code for all ecosystem models (e.g. ED2.2, SiPNET, etc). #--------------------------------------------------------------------------------------------------# -##' Get Quantiles -##' -##' Returns a vector of quantiles specified by a given `` xml tag -##' -##' @param quantiles.tag specifies tag used to specify quantiles -##' @return vector of quantiles -##' @export -##' @author David LeBauer +#' Get Quantiles +#' +#' Returns a vector of quantiles specified by a given `` xml tag +#' +#' @param quantiles.tag specifies tag used to specify quantiles +#' @return vector of quantiles +#' @export +#' @author David LeBauer get.quantiles <- function(quantiles.tag) { quantiles <- vector() if (!is.null(quantiles.tag$quantile)) { @@ -38,14 +30,14 @@ get.quantiles <- function(quantiles.tag) { } # get.quantiles -##' get sensitivity samples as a list -##' -##' @param pft list of samples from Plant Functional Types -##' @param env list of samples from environment parameters -##' @param quantiles quantiles at which to obtain samples from parameter for -##' sensitivity analysis -##' @export -##' @return sa.sample.list +#' get sensitivity samples as a list +#' +#' @param pft list of samples from Plant Functional Types +#' @param env list of samples from environment parameters +#' @param quantiles quantiles at which to obtain samples from parameter for +#' sensitivity analysis +#' @export +#' @return sa.sample.list get.sa.sample.list <- function(pft, env, quantiles) { sa.sample.list <- list() for (i in seq_along(pft)) { @@ -57,23 +49,23 @@ get.sa.sample.list <- function(pft, env, quantiles) { } # get.sa.sample.list -##' Get sensitivity analysis samples -##' -##' Samples parameters for a model run at specified quantiles. -##' -##' Samples from long (>2000) vectors that represent random samples from a -##' trait distribution. -##' Samples are either the MCMC chains output from the Bayesian meta-analysis -##' or are randomly sampled from the closed-form distribution of the -##' parameter probability distribution function. -##' The list is indexed first by trait, then by quantile. -##' -##' @param samples random samples from trait distribution -##' @param quantiles list of quantiles to at which to sample, -##' set in settings file -##' @return a list of lists representing quantile values of trait distributions -##' @export -##' @author David LeBauer +#' Get sensitivity analysis samples +#' +#' Samples parameters for a model run at specified quantiles. +#' +#' Samples from long (>2000) vectors that represent random samples from a +#' trait distribution. +#' Samples are either the MCMC chains output from the Bayesian meta-analysis +#' or are randomly sampled from the closed-form distribution of the +#' parameter probability distribution function. +#' The list is indexed first by trait, then by quantile. +#' +#' @param samples random samples from trait distribution +#' @param quantiles list of quantiles to at which to sample, +#' set in settings file +#' @return a list of lists representing quantile values of trait distributions +#' @export +#' @author David LeBauer get.sa.samples <- function(samples, quantiles) { sa.samples <- data.frame() for (trait in names(samples)) { @@ -86,12 +78,12 @@ get.sa.samples <- function(samples, quantiles) { } # get.sa.samples -##' checks that met2model function exists -##' -##' Checks if `met2model.` exists for a particular model -##' -##' @param model model package name -##' @return logical +#' checks that met2model function exists +#' +#' Checks if `met2model.` exists for a particular model +#' +#' @param model model package name +#' @return logical met2model.exists <- function(model) { load.modelpkg(model) return(exists(paste0("met2model.", model))) diff --git a/base/utils/inst/clear.scratch.sh b/base/utils/inst/clear.scratch.sh index cbc75f2b292..815566596d6 100755 --- a/base/utils/inst/clear.scratch.sh +++ b/base/utils/inst/clear.scratch.sh @@ -1,13 +1,5 @@ #!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- -# + #--------------------------------------------------------------------------------------------------# LOC=/scratch/$USER if [ -d "$LOC" ]; then diff --git a/base/utils/man/PEcAn.Rd b/base/utils/man/PEcAn.Rd index 7b02f3cc42b..4a6752d93c7 100644 --- a/base/utils/man/PEcAn.Rd +++ b/base/utils/man/PEcAn.Rd @@ -10,29 +10,45 @@ \alias{package-pecan} \title{R package to support PEcAn, the Predictive Ecosystem Analyzer} \description{ -Instructions for the use of this package are provided in the project documentation \url{https://pecanproject.github.io/documentation.html}. +Instructions for the use of this package are provided in the project +documentation \url{https://pecanproject.github.io/documentation.html}. } \details{ Project homepage: \url{pecanproject.org} Description of PEcAn -The Predictive Ecosystem 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. PEcAn is an open source utility that encapsulates: +The Predictive Ecosystem 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. PEcAn is an open source utility that encapsulates: \enumerate{ \item acquisition of meteorological inputs -\item synthesis of physiological trait data as the posterior distribution of a Bayesian meta-analysis -\item sampling trait meta-analysis posterior distributions to parameterize ensembles of ED2 and other ecophysiological models +\item synthesis of physiological trait data as the posterior distribution of a +Bayesian meta-analysis +\item sampling trait meta-analysis posterior distributions to parameterize +ensembles of ED2 and other ecophysiological models \item probabilistic forecasts -\item postprocessing to constrain forecasts and model parameters with field, meterological, eddy flux, and spectral data, and +\item postprocessing to constrain forecasts and model parameters with field, +meterological, eddy flux, and spectral data, and \item provenance tracking } -PECAn integrates available data into ecological forecasts by running ensembles of a terrestrial ecosystem model that is parameterized by the posterior distribution from a meta-analysis of available plant trait data. -These trait data are assembled from field research and primary literature, and are stored in a PostgreSQL database. Current development focused on biofuel crops uses BETYdb. -In addition to generating forecasts that reflect available data, PEcAn quantifies the contribution of each parameter to model uncertainty. -This information informs targeted data collection and synthesis efforts that most efficiently reduce forecast uncertainty. +PECAn integrates available data into ecological forecasts by running +ensembles of a terrestrial ecosystem model that is parameterized by the +posterior distribution from a meta-analysis of available plant trait data. +These trait data are assembled from field research and primary literature, +and are stored in a PostgreSQL database. Current development focused on +biofuel crops uses BETYdb. In addition to generating forecasts that reflect +available data, PEcAn quantifies the contribution of each parameter to model +uncertainty. This information informs targeted data collection and synthesis +efforts that most efficiently reduce forecast uncertainty. -Current development is focused on developing PEcAn into a real-time data assimilation and forecasting system. This system will provide a detailed analysis of the past and present ecosystem functioning that seamlessly transitions into forecasts. +Current development is focused on developing PEcAn into a real-time data +assimilation and forecasting system. This system will provide a detailed +analysis of the past and present ecosystem functioning that seamlessly +transitions into forecasts. } \author{ \strong{Maintainer}: Rob Kooper \email{kooper@illinois.edu} diff --git a/base/utils/man/as.sequence.Rd b/base/utils/man/as.sequence.Rd index 43327f14e38..d08c43347fa 100644 --- a/base/utils/man/as.sequence.Rd +++ b/base/utils/man/as.sequence.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{as.sequence} \alias{as.sequence} -\title{as.sequence} +\title{Convert categorical variable into sequential integers} \usage{ as.sequence(x, na.rm = TRUE) } @@ -15,9 +15,6 @@ as.sequence(x, na.rm = TRUE) sequence from 1:length(unique(x)) } \description{ -Convert categorical variable into sequential integers -} -\details{ Turns any categorical variable into a sequential integer. This transformation is required for using data in BUGS/JAGS } diff --git a/base/utils/man/bibtexify.Rd b/base/utils/man/bibtexify.Rd index db981ef1ecc..71c2b0ce360 100644 --- a/base/utils/man/bibtexify.Rd +++ b/base/utils/man/bibtexify.Rd @@ -17,10 +17,7 @@ bibtexify(author, year, title) bibtex citation } \description{ -Convert author, year, title to bibtex citation format -} -\details{ -Converts author year title to author1999abc format +Converts author year title to bibtex \code{author1999abc} format } \author{ unknown diff --git a/base/utils/man/bugs.rdist.Rd b/base/utils/man/bugs.rdist.Rd index 6443e81cc52..13518777c45 100644 --- a/base/utils/man/bugs.rdist.Rd +++ b/base/utils/man/bugs.rdist.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/r2bugs.distributions.R \name{bugs.rdist} \alias{bugs.rdist} -\title{bugs.rdist} +\title{Sample from an R distribution using JAGS} \usage{ bugs.rdist( prior = data.frame(distn = "norm", parama = 0, paramb = 1), @@ -21,9 +21,6 @@ bugs.rdist( vector of samples } \description{ -Sample from an R distribution using JAGS -} -\details{ Takes a distribution with R parameterization, converts it to a BUGS parameterization, and then samples from the distribution using JAGS diff --git a/base/utils/man/clear.scratch.Rd b/base/utils/man/clear.scratch.Rd index 3a8cc6cccc6..1aaeb969887 100644 --- a/base/utils/man/clear.scratch.Rd +++ b/base/utils/man/clear.scratch.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/clear.scratch.R \name{clear.scratch} \alias{clear.scratch} -\title{Clear EBI-CLUSTER worker node local scratch directories of old PEcAn output} +\title{Removes previous model run output from worker node local scratch directories on EBI-CLUSTER} \usage{ clear.scratch(settings) } diff --git a/base/utils/man/convert.expr.Rd b/base/utils/man/convert.expr.Rd index 21cc7a95b78..605a17773c4 100644 --- a/base/utils/man/convert.expr.Rd +++ b/base/utils/man/convert.expr.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{convert.expr} \alias{convert.expr} -\title{convert.expr} +\title{Convert expression to variable names} \usage{ convert.expr(expression) } diff --git a/base/utils/man/distn.table.stats.Rd b/base/utils/man/distn.table.stats.Rd index 34526bd1448..bd77cb13bf6 100644 --- a/base/utils/man/distn.table.stats.Rd +++ b/base/utils/man/distn.table.stats.Rd @@ -2,8 +2,7 @@ % Please edit documentation in R/distn.stats.R \name{distn.table.stats} \alias{distn.table.stats} -\title{return mean and standard deviation of a distribution for each distribution in a table with \code{colnames = c('distn', 'a', 'b')}, -e.g. in a table of priors} +\title{Helper function for computing summary statistics of a parametric distribution} \usage{ distn.table.stats(distns) } @@ -14,7 +13,8 @@ distn.table.stats(distns) named vector of mean and SD } \description{ -a helper function for computing summary statistics of a parametric distribution +return mean and standard deviation of a distribution for each distribution in a table with \code{colnames = c('distn', 'a', 'b')}, +e.g. in a table of priors } \author{ David LeBauer diff --git a/base/utils/man/download.url.Rd b/base/utils/man/download.url.Rd index 476ab869a24..9187d9f72c5 100644 --- a/base/utils/man/download.url.Rd +++ b/base/utils/man/download.url.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/download.url.R \name{download.url} \alias{download.url} -\title{Download file from the url.} +\title{Try and download a file.} \usage{ download.url(url, file, timeout = 600, .opts = list(), retry = TRUE) } @@ -22,9 +22,6 @@ protected site use list(userpwd=userpass, httpauth = 1L)} returns name of file if successful or NA if not. } \description{ -Try and download a file. -} -\details{ This will download a file, if retry is set and 404 is returned it will wait until the file is available. If the file is still not available after timeout tries, it will return NA. If the file is downloaded diff --git a/base/utils/man/download_file.Rd b/base/utils/man/download_file.Rd index d2f3bb302c9..97c660c8a81 100644 --- a/base/utils/man/download_file.Rd +++ b/base/utils/man/download_file.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{download_file} \alias{download_file} -\title{download_file} +\title{Simple function to use ncftpget for FTP downloads behind a firewall.} \usage{ download_file(url, filename, method) } @@ -15,7 +15,6 @@ download_file(url, filename, method) example options(download.ftp.method="ncftpget")} } \description{ -Simple function to use ncftpget for FTP downloads behind a firewall. Requires ncftpget and a properly formatted config file in the users home directory } diff --git a/base/utils/man/full.path.Rd b/base/utils/man/full.path.Rd index 413c0f16435..5fe7d1bf162 100644 --- a/base/utils/man/full.path.Rd +++ b/base/utils/man/full.path.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/full.path.R \name{full.path} \alias{full.path} -\title{Creates an absolute path to a folder} +\title{Creates an absolute path to a folder.} \usage{ full.path(folder) } @@ -13,9 +13,6 @@ full.path(folder) absolute path } \description{ -Creates an absolute path to a folder. -} -\details{ This will take a folder and make it into an absolute folder name. It will normalize the path and prepend it with the current working folder if needed to get an absolute path name. diff --git a/base/utils/man/get.run.id.Rd b/base/utils/man/get.run.id.Rd index 0bbe9eac020..675d762416a 100644 --- a/base/utils/man/get.run.id.Rd +++ b/base/utils/man/get.run.id.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{get.run.id} \alias{get.run.id} -\title{Get Run ID} +\title{returns an id representing a model run} \usage{ get.run.id(run.type, index, trait = NULL, pft.name = NULL, site.id = NULL) } @@ -22,9 +22,6 @@ ensemble or a quantile used to which a trait has been perturbed for sensitivity id representing a model run } \description{ -returns an id representing a model run -} -\details{ Provides a consistent method of naming runs; for use in model input files and indices } \examples{ diff --git a/base/utils/man/get.stats.mcmc.Rd b/base/utils/man/get.stats.mcmc.Rd index 00f6af0a576..f0b71ef60ca 100644 --- a/base/utils/man/get.stats.mcmc.Rd +++ b/base/utils/man/get.stats.mcmc.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{get.stats.mcmc} \alias{get.stats.mcmc} -\title{Get stats for parameters in MCMC output} +\title{Further summarizes output from summary.mcmc} \usage{ get.stats.mcmc(mcmc.summary, sample.size) } diff --git a/base/utils/man/load.modelpkg.Rd b/base/utils/man/load.modelpkg.Rd index 95792b3cf6f..06d4aa6cbf7 100644 --- a/base/utils/man/load.modelpkg.Rd +++ b/base/utils/man/load.modelpkg.Rd @@ -13,7 +13,7 @@ load.modelpkg(model) FALSE if function returns error; else TRUE } \description{ -load model package +Load model package } \examples{ \dontrun{require.modelpkg(BioCro)} diff --git a/base/utils/man/misc.are.convertible.Rd b/base/utils/man/misc.are.convertible.Rd index eebddb8fe66..6364fb8e8c2 100644 --- a/base/utils/man/misc.are.convertible.Rd +++ b/base/utils/man/misc.are.convertible.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{misc.are.convertible} \alias{misc.are.convertible} -\title{misc.are.convertible} +\title{function to check whether units are convertible by misc.convert function} \usage{ misc.are.convertible(u1, u2) } diff --git a/base/utils/man/misc.convert.Rd b/base/utils/man/misc.convert.Rd index 24b9d1e2a74..116bb896f55 100644 --- a/base/utils/man/misc.convert.Rd +++ b/base/utils/man/misc.convert.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{misc.convert} \alias{misc.convert} -\title{misc.convert} +\title{conversion function for the unit conversions that udunits cannot handle but often needed in PEcAn calculations} \usage{ misc.convert(x, u1, u2) } diff --git a/base/utils/man/mstmipvar.Rd b/base/utils/man/mstmipvar.Rd index 111a79d3ee6..592cc971eae 100644 --- a/base/utils/man/mstmipvar.Rd +++ b/base/utils/man/mstmipvar.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{mstmipvar} \alias{mstmipvar} -\title{MstMIP variable} +\title{return MstMIP variable as ncvar} \usage{ mstmipvar( name, @@ -30,9 +30,6 @@ mstmipvar( ncvar based on MstMIP definition } \description{ -return MstMIP variable as ncvar -} -\details{ returns a MstMIP variable as a ncvar based on name and other parameters passed in. } diff --git a/base/utils/man/newxtable.Rd b/base/utils/man/newxtable.Rd index 1d480debd1e..4f679494eb9 100644 --- a/base/utils/man/newxtable.Rd +++ b/base/utils/man/newxtable.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{newxtable} \alias{newxtable} -\title{newxtable} +\title{New xtable} \usage{ newxtable( x, @@ -25,9 +25,6 @@ newxtable( Latex version of table, with percentages properly formatted } \description{ -New xtable -} -\details{ utility to properly escape the '\%' sign for latex } \author{ diff --git a/base/utils/man/pdf.stats.Rd b/base/utils/man/pdf.stats.Rd index ec4d297eaf1..7608980d4a9 100644 --- a/base/utils/man/pdf.stats.Rd +++ b/base/utils/man/pdf.stats.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{pdf.stats} \alias{pdf.stats} -\title{Probability Distirbution Function Statistics} +\title{Probability Distribution Function Statistics} \usage{ pdf.stats(distn, A, B) } diff --git a/base/utils/man/r2bugs.distributions.Rd b/base/utils/man/r2bugs.distributions.Rd index 77d11fc8616..f900f747faa 100644 --- a/base/utils/man/r2bugs.distributions.Rd +++ b/base/utils/man/r2bugs.distributions.Rd @@ -15,9 +15,6 @@ r2bugs.distributions(priors, direction = "r2bugs") priors dataframe using JAGS default parameterizations } \description{ -convert R parameterizations to BUGS paramaterizations -} -\details{ R and BUGS have different parameterizations for some distributions. This function transforms the distributions from R defaults to BUGS defaults. BUGS is an implementation of the BUGS language, and these transformations are expected to work for bugs. } \examples{ diff --git a/base/utils/man/read.output.Rd b/base/utils/man/read.output.Rd index 89602be6a63..29e3dc3ae03 100644 --- a/base/utils/man/read.output.Rd +++ b/base/utils/man/read.output.Rd @@ -73,6 +73,7 @@ Carbon fluxes: GPP, NPP, NEE, TotalResp, AutoResp, HeteroResp, DOC_flux, Fire_flux, and Stem (Stem is specific to the BioCro model) and Water fluxes: Evaporation (Evap), Transpiration (TVeg), surface runoff (Qs), subsurface runoff (Qsb), and rainfall (Rainf). + For more details, see the \href{http://nacp.ornl.gov/MsTMIP_variables.shtml}{MsTMIP variables} documentation. } diff --git a/base/utils/man/retry.func.Rd b/base/utils/man/retry.func.Rd index e5b250e9f1e..7a3ff9216ef 100644 --- a/base/utils/man/retry.func.Rd +++ b/base/utils/man/retry.func.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{retry.func} \alias{retry.func} -\title{retry.func} +\title{Retry function X times before stopping in error} \usage{ retry.func( expr, @@ -28,13 +28,10 @@ retval returns the results of the function call \description{ Retry function X times before stopping in error } -\details{ -Retry function X times before stopping in error -} \examples{ \dontrun{ - file_url <- paste0("https://thredds.daac.ornl.gov/", - "thredds/dodsC/ornldaac/1220", + file_url <- paste0("https://thredds.daac.ornl.gov/", + "thredds/dodsC/ornldaac/1220", "/mstmip_driver_global_hd_climate_lwdown_1999_v1.nc4") dap <- retry.func( ncdf4::nc_open(file_url), diff --git a/base/utils/man/rsync.Rd b/base/utils/man/rsync.Rd index b99d2a6b3fa..2beaa2f940b 100644 --- a/base/utils/man/rsync.Rd +++ b/base/utils/man/rsync.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{rsync} \alias{rsync} -\title{rsync} +\title{R implementation of rsync} \usage{ rsync(args, from, to, pattern = "") } @@ -19,9 +19,6 @@ rsync(args, from, to, pattern = "") nothing, transfers files as a side effect } \description{ -R implementation of rsync -} -\details{ rsync is a file copying tool in bash } \author{ diff --git a/base/utils/man/ssh.Rd b/base/utils/man/ssh.Rd index bacc286f4d9..a7ad6d83503 100644 --- a/base/utils/man/ssh.Rd +++ b/base/utils/man/ssh.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{ssh} \alias{ssh} -\title{SSH} +\title{R implementation of SSH} \usage{ ssh(host, ..., args = "") } diff --git a/base/utils/man/summarize.result.Rd b/base/utils/man/summarize.result.Rd index 28ad6262524..f7cba06d5f1 100644 --- a/base/utils/man/summarize.result.Rd +++ b/base/utils/man/summarize.result.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{summarize.result} \alias{summarize.result} -\title{Summarize Results} +\title{Summarize results of replicate observations in trait data query} \usage{ summarize.result(result) } diff --git a/base/utils/man/temp.settings.Rd b/base/utils/man/temp.settings.Rd index fa5e643ba98..af37b29f347 100644 --- a/base/utils/man/temp.settings.Rd +++ b/base/utils/man/temp.settings.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{temp.settings} \alias{temp.settings} -\title{temp.settings} +\title{Create a temporary settings file} \usage{ temp.settings(settings.txt) } @@ -13,9 +13,6 @@ temp.settings(settings.txt) character vector written to and read from a temporary file } \description{ -Create a temporary settings file -} -\details{ Uses \code{\link{tempfile}} function to provide a valid temporary file (OS independent) Useful for testing functions that depend on settings file Reference: http://stackoverflow.com/a/12940705/199217 diff --git a/base/utils/man/timezone_hour.Rd b/base/utils/man/timezone_hour.Rd index 225ae05ae58..f63c6485c7b 100644 --- a/base/utils/man/timezone_hour.Rd +++ b/base/utils/man/timezone_hour.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/timezone_hour.R \name{timezone_hour} \alias{timezone_hour} -\title{timezone_hour} +\title{Timezone Hour} \usage{ timezone_hour(timezone) } @@ -13,7 +13,7 @@ timezone_hour(timezone) hours offset of the timezone } \description{ -return the number of hours offset to UTC for a timezone. +Returns the number of hours offset to UTC for a timezone. } \examples{ \dontrun{ diff --git a/base/utils/man/tryl.Rd b/base/utils/man/tryl.Rd index 79d0789c5b4..9d011f2e15a 100644 --- a/base/utils/man/tryl.Rd +++ b/base/utils/man/tryl.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{tryl} \alias{tryl} -\title{tryl} +\title{Test if function gives an error} \usage{ tryl(FUN) } @@ -13,9 +13,6 @@ tryl(FUN) FALSE if function returns error; else TRUE } \description{ -Test if function gives an error -} -\details{ adaptation of try that returns a logical value (FALSE if error) } \examples{ diff --git a/base/utils/man/vecpaste.Rd b/base/utils/man/vecpaste.Rd index 23b8e4d92e4..66ff229cdd3 100644 --- a/base/utils/man/vecpaste.Rd +++ b/base/utils/man/vecpaste.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{vecpaste} \alias{vecpaste} -\title{vecpaste} +\title{Convert vector to comma delimited string} \usage{ vecpaste(x) } @@ -13,8 +13,5 @@ vecpaste(x) comma delimited string } \description{ -Convert vector to comma delimited string -} -\details{ vecpaste, turns vector into comma delimited string fit for SQL statements. } diff --git a/base/utils/man/zero.bounded.density.Rd b/base/utils/man/zero.bounded.density.Rd index c2b423e2c17..0a795c7938f 100644 --- a/base/utils/man/zero.bounded.density.Rd +++ b/base/utils/man/zero.bounded.density.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{zero.bounded.density} \alias{zero.bounded.density} -\title{Zero Bounded Density} +\title{Zero bounded density using log density transform} \usage{ zero.bounded.density(x, bw = "SJ", n = 1001) } @@ -17,9 +17,6 @@ zero.bounded.density(x, bw = "SJ", n = 1001) data frame with back-transformed log density estimate } \description{ -Zero bounded density using log density transform -} -\details{ Provides a zero bounded density estimate of a parameter. Kernel Density Estimation used by the \code{\link[stats]{density}} function will cause problems at the left hand end because it will put some weight on negative values. diff --git a/base/utils/scripts/metutils.R b/base/utils/scripts/metutils.R index 79b28047077..0d25fc23506 100644 --- a/base/utils/scripts/metutils.R +++ b/base/utils/scripts/metutils.R @@ -1,11 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- #################################################################################################### #/file # diff --git a/base/utils/scripts/time.constants.R b/base/utils/scripts/time.constants.R index 25387507d69..b6daeb31122 100644 --- a/base/utils/scripts/time.constants.R +++ b/base/utils/scripts/time.constants.R @@ -1,12 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- -#==========================================================================================# #==========================================================================================# # Time conversion units # #------------------------------------------------------------------------------------------# diff --git a/base/utils/tests/Rcheck_reference.log b/base/utils/tests/Rcheck_reference.log index ac9acddcb22..025a87bfa66 100644 --- a/base/utils/tests/Rcheck_reference.log +++ b/base/utils/tests/Rcheck_reference.log @@ -12,38 +12,6 @@ Maintainer: ‘Rob Kooper ’ New submission -License components with restrictions and base license permitting such: - BSD_3_clause + file LICENSE -File 'LICENSE': - University of Illinois/NCSA Open Source License - - Copyright (c) 2012, University of Illinois, NCSA. All rights reserved. - - 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 @@ -57,7 +25,6 @@ Found the following (possibly) invalid URLs: Status: 404 Message: Not Found -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,8 +38,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 @@ -90,11 +56,7 @@ License stub is invalid DCF. * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK -* checking R code for possible problems ... NOTE -mcmc.list2init: no visible binding for global variable ‘nr’ - -Undefined global functions or variables: - nr years yieldarray +* checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK @@ -109,10 +71,7 @@ See chapter ‘Writing R documentation files’ in the ‘Writing R Extensions’ manual. * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK -* checking Rd contents ... WARNING -Argument items with no description in Rd object 'get.sa.sample.list': - ‘env’ - +* checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK * checking data for non-ASCII characters ... OK diff --git a/base/utils/tests/testthat.R b/base/utils/tests/testthat.R index 7c41d64906e..fe77b4f21d0 100644 --- a/base/utils/tests/testthat.R +++ b/base/utils/tests/testthat.R @@ -1,11 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- library(testthat) library(PEcAn.utils) diff --git a/base/utils/tests/testthat/test.trait.dictionary.R b/base/utils/tests/testthat/test.trait.dictionary.R index 39da807c566..4330d518b65 100644 --- a/base/utils/tests/testthat/test.trait.dictionary.R +++ b/base/utils/tests/testthat/test.trait.dictionary.R @@ -1,12 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - test_that("trait dictionary loads and has expected columns",{ rm(list = ls()) data(trait.dictionary, package = "PEcAn.utils") diff --git a/base/utils/tests/testthat/test.utils.R b/base/utils/tests/testthat/test.utils.R index 93337ba0856..37478cba081 100644 --- a/base/utils/tests/testthat/test.utils.R +++ b/base/utils/tests/testthat/test.utils.R @@ -1,11 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- context("Other utilities") test.stats <- data.frame(Y=rep(1,5), diff --git a/models/biocro/LICENSE b/models/biocro/LICENSE index 5a9e44128f1..09ef35a60b4 100644 --- a/models/biocro/LICENSE +++ b/models/biocro/LICENSE @@ -1,34 +1,3 @@ -## 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. - +YEAR: 2024 +COPYRIGHT HOLDER: PEcAn Project +ORGANIZATION: PEcAn Project, authors affiliations diff --git a/models/biocro/NEWS.md b/models/biocro/NEWS.md new file mode 100644 index 00000000000..9947d8a8ac0 --- /dev/null +++ b/models/biocro/NEWS.md @@ -0,0 +1,7 @@ +# PEcAn.BIOCRO 1.7.3.9000 + +## License change +* PEcAn.BIOCRO is now distributed under the BSD three-clause license instead of the NCSA Open Source license. + +## Added +* Added a `NEWS.md` file to track changes to the package. Prior to this point changes are tracked in the main CHANGELOG for the PEcAn repository. diff --git a/models/biocro/R/met2model.BIOCRO.R b/models/biocro/R/met2model.BIOCRO.R index 7cffbd98b62..9e993e59a6b 100644 --- a/models/biocro/R/met2model.BIOCRO.R +++ b/models/biocro/R/met2model.BIOCRO.R @@ -1,29 +1,23 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- .datatable.aware <- TRUE + + ##-------------------------------------------------------------------------------------------------# -##' Converts a met CF file to a model specific met file. The input -##' files are called /.YYYY.cf -##' -##' @name met2model.BIOCRO -##' @title Write BioCro 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 -##' @param lat,lon Site latitude and longitude -##' @param start_date,end_date Date range to convert. Each year will be written to a separate file -##' @param overwrite logical: Write over any existing file of the same name? If FALSE, leaves the existing file untouched and skips to the next year. -##' @param ... other arguments passed from PEcAn, currently ignored -##' @return a dataframe of information about the written file -##' @export -##' @author Rob Kooper, David LeBauer +#' Write BioCro met files +#' +#' Converts a met CF file to a model specific met file. The input +#' files are called /.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 lat,lon Site latitude and longitude +#' @param start_date,end_date Date range to convert. Each year will be written to a separate file +#' @param overwrite logical: Write over any existing file of the same name? If FALSE, leaves the existing file untouched and skips to the next year. +#' @param ... other arguments passed from PEcAn, currently ignored +#' @return a dataframe of information about the written file +#' @export +#' @author Rob Kooper, David LeBauer ##-------------------------------------------------------------------------------------------------# met2model.BIOCRO <- function(in.path, in.prefix, outfolder, overwrite = FALSE, lat, lon, start_date, end_date, ...) { @@ -102,44 +96,42 @@ met2model.BIOCRO <- function(in.path, in.prefix, outfolder, overwrite = FALSE, ##-------------------------------------------------------------------------------------------------# -##' Converts a CF data frame into a BioCro met input -##' -##' @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}} -##' \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 -##' \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 -##' @importFrom data.table := -##' @author David LeBauer +#' Converts a CF data frame into a BioCro met input +#' +#' @param met data.table object with met for a single site; output from \code{\link{load.cfmet}} +#' \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 +#' \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 +#' @importFrom data.table := +#' @author David LeBauer cf2biocro <- function(met, longitude = NULL, zulu2solarnoon = FALSE) { if (!data.table::is.data.table(met)) { diff --git a/models/biocro/R/model2netcdf.BIOCRO.R b/models/biocro/R/model2netcdf.BIOCRO.R index 03c7cab4238..d6fb4dbbff7 100644 --- a/models/biocro/R/model2netcdf.BIOCRO.R +++ b/models/biocro/R/model2netcdf.BIOCRO.R @@ -1,28 +1,16 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- - -##--------------------------------------------------------------------------------------------------# -##' Convert BioCro output to netCDF -##' -##' Converts BioCro output to netCDF. -##' Modified from on model2netcdf.SIPNET and model2netcdf.ED2 by -##' @name model2netcdf.BIOCRO -##' @title Function to convert biocro model output to standard netCDF format -##' @param result a dataframe of model output to be converted -##' @param genus character: What kind of plant was being simulated? -##' Used to correct for some genus-specific differences in model output; -##' Eventually that will be handled inside BioCro and this argument will be removed. -##' @param outdir Location of model output -##' @param lat Latitude of the site -##' @param lon Longitude of the site -##' @export -##' @author David LeBauer, Deepak Jaiswal, Rob Kooper +#' Convert BioCro output to standard netCDF format +#' +#' Modified from on model2netcdf.SIPNET and model2netcdf.ED2 by +#' +#' @param result a dataframe of model output to be converted +#' @param genus character: What kind of plant was being simulated? +#' Used to correct for some genus-specific differences in model output; +#' Eventually that will be handled inside BioCro and this argument will be removed. +#' @param outdir Location of model output +#' @param lat Latitude of the site +#' @param lon Longitude of the site +#' @export +#' @author David LeBauer, Deepak Jaiswal, Rob Kooper model2netcdf.BIOCRO <- function(result, genus = NULL, outdir, lat = -9999, lon = -9999) { if (!("hour" %in% colnames(result))) { diff --git a/models/biocro/R/read.biocro.config.R b/models/biocro/R/read.biocro.config.R index 2a47069be15..e1a58b6b19f 100644 --- a/models/biocro/R/read.biocro.config.R +++ b/models/biocro/R/read.biocro.config.R @@ -1,10 +1,9 @@ -##' Read BioCro config file -##' -##' @title Read BioCro Config -##' @param config.file Path to XML file -##' @return list of run configuration parameters for PEcAn -##' @export -##' @author David LeBauer +#' Read BioCro config file +#' +#' @param config.file Path to XML file +#' @return list of run configuration parameters for PEcAn +#' @export +#' @author David LeBauer read.biocro.config <- function(config.file = "config.xml") { config <- XML::xmlToList(XML::xmlTreeParse(file = config.file, handlers = list(comment = function(x) { NULL }), diff --git a/models/biocro/R/write.configs.BIOCRO.R b/models/biocro/R/write.configs.BIOCRO.R index 6bbca20db36..b7b869376a6 100644 --- a/models/biocro/R/write.configs.BIOCRO.R +++ b/models/biocro/R/write.configs.BIOCRO.R @@ -1,25 +1,16 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the -# University of Illinois/NCSA Open Source License -# which accompanies this distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- PREFIX_XML <- "\n\n" -##' convert parameters from PEcAn database default units to biocro defaults -##' -##' Performs model specific unit conversions on a list of trait values, -##' such as those provided to write.config -##' @name convert.samples.BIOCRO -##' @title Convert samples for biocro -##' @param trait.samples a matrix or dataframe of samples from the trait distribution -##' @param biocro_version numeric, but currently only checks whether version is less than 1.0 -##' @return dataframe with values transformed -##' @export -##' @author David LeBauer +#' convert parameters from PEcAn database default units to biocro defaults +#' +#' Performs model specific unit conversions on a list of trait values, +#' such as those provided to write.config +#' +#' @param trait.samples a matrix or dataframe of samples from the trait distribution +#' @param biocro_version numeric, but currently only checks whether version is less than 1.0 +#' @return dataframe with values transformed +#' @export +#' @author David LeBauer convert.samples.BIOCRO <- function(trait.samples, biocro_version=1.0) { trait.samples <- as.data.frame(trait.samples) @@ -64,19 +55,17 @@ convert.samples.BIOCRO <- function(trait.samples, biocro_version=1.0) { } # convert.samples.BIOCRO -##' Writes a configuration files for the biocro model -##' -##' @name write.config.BIOCRO -##' @title Write configuration files for the biocro model -##' @param defaults named list with default model parameter values -##' @param trait.values named list (or dataframe of trait values) -##' can either be a data.frame or named list of traits, e.g. -##' \code{data.frame(vmax = 1, b0 = 2)} or \code{list(vmax = 1, b0 = 2)} -##' @param settings pecan settings file configured for BioCro -##' @param run.id integer; a unique identifier for the run. -##' @export -##' @return nothing, writes configuration file as side effect -##' @author David LeBauer +#' Writes a configuration files for the biocro model +#' +#' @param defaults named list with default model parameter values +#' @param trait.values named list (or dataframe of trait values) +#' can either be a data.frame or named list of traits, e.g. +#' \code{data.frame(vmax = 1, b0 = 2)} or \code{list(vmax = 1, b0 = 2)} +#' @param settings pecan settings file configured for BioCro +#' @param run.id integer; a unique identifier for the run. +#' @export +#' @return nothing, writes configuration file as side effect +#' @author David LeBauer write.config.BIOCRO <- function(defaults = NULL, trait.values, settings, run.id) { ## find out where to write run/ouput @@ -209,15 +198,13 @@ write.config.BIOCRO <- function(defaults = NULL, trait.values, settings, run.id) } # write.config.BIOCRO -##' Clear out previous config and parameter files. -##' -##' @name remove.config.BIOCRO -##' @title Clear out previous biocro config and parameter files. -##' @param main.outdir Primary PEcAn output directory (will be depreciated) -##' @param settings PEcAn settings file -##' @return nothing, removes config files as side effect -##' @export -##' @author Shawn Serbin, David LeBauer +#' Clear out previous config and parameter files. +#' +#' @param main.outdir Primary PEcAn output directory (will be depreciated) +#' @param settings PEcAn settings file +#' @return nothing, removes config files as side effect +#' @export +#' @author Shawn Serbin, David LeBauer remove.config.BIOCRO <- function(main.outdir, settings) { ## Remove files on localhost diff --git a/models/biocro/man/cf2biocro.Rd b/models/biocro/man/cf2biocro.Rd index 30d359bc3e8..8999385451e 100644 --- a/models/biocro/man/cf2biocro.Rd +++ b/models/biocro/man/cf2biocro.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/met2model.BIOCRO.R \name{cf2biocro} \alias{cf2biocro} -\title{Convert CF-formatted met data to BioCro met} +\title{Converts a CF data frame into a BioCro met input} \usage{ cf2biocro(met, longitude = NULL, zulu2solarnoon = FALSE) } diff --git a/models/biocro/man/convert.samples.BIOCRO.Rd b/models/biocro/man/convert.samples.BIOCRO.Rd index 8964f3284de..28f50af2967 100644 --- a/models/biocro/man/convert.samples.BIOCRO.Rd +++ b/models/biocro/man/convert.samples.BIOCRO.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/write.configs.BIOCRO.R \name{convert.samples.BIOCRO} \alias{convert.samples.BIOCRO} -\title{Convert samples for biocro} +\title{convert parameters from PEcAn database default units to biocro defaults} \usage{ convert.samples.BIOCRO(trait.samples, biocro_version = 1) } @@ -15,9 +15,6 @@ convert.samples.BIOCRO(trait.samples, biocro_version = 1) dataframe with values transformed } \description{ -convert parameters from PEcAn database default units to biocro defaults -} -\details{ Performs model specific unit conversions on a list of trait values, such as those provided to write.config } diff --git a/models/biocro/man/model2netcdf.BIOCRO.Rd b/models/biocro/man/model2netcdf.BIOCRO.Rd index 236fe0879c0..acc489139f0 100644 --- a/models/biocro/man/model2netcdf.BIOCRO.Rd +++ b/models/biocro/man/model2netcdf.BIOCRO.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/model2netcdf.BIOCRO.R \name{model2netcdf.BIOCRO} \alias{model2netcdf.BIOCRO} -\title{Function to convert biocro model output to standard netCDF format} +\title{Convert BioCro output to standard netCDF format} \usage{ model2netcdf.BIOCRO(result, genus = NULL, outdir, lat = -9999, lon = -9999) } @@ -20,10 +20,6 @@ Eventually that will be handled inside BioCro and this argument will be removed. \item{lon}{Longitude of the site} } \description{ -Convert BioCro output to netCDF -} -\details{ -Converts BioCro output to netCDF. Modified from on model2netcdf.SIPNET and model2netcdf.ED2 by } \author{ diff --git a/models/biocro/man/read.biocro.config.Rd b/models/biocro/man/read.biocro.config.Rd index 6240c283018..2b4a5ac910f 100644 --- a/models/biocro/man/read.biocro.config.Rd +++ b/models/biocro/man/read.biocro.config.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/read.biocro.config.R \name{read.biocro.config} \alias{read.biocro.config} -\title{Read BioCro Config} +\title{Read BioCro config file} \usage{ read.biocro.config(config.file = "config.xml") } diff --git a/models/biocro/man/remove.config.BIOCRO.Rd b/models/biocro/man/remove.config.BIOCRO.Rd index 7ceb7aeed94..60b926e7980 100644 --- a/models/biocro/man/remove.config.BIOCRO.Rd +++ b/models/biocro/man/remove.config.BIOCRO.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/write.configs.BIOCRO.R \name{remove.config.BIOCRO} \alias{remove.config.BIOCRO} -\title{Clear out previous biocro config and parameter files.} +\title{Clear out previous config and parameter files.} \usage{ remove.config.BIOCRO(main.outdir, settings) } diff --git a/models/biocro/man/write.config.BIOCRO.Rd b/models/biocro/man/write.config.BIOCRO.Rd index 26505e69d8a..9856d784278 100644 --- a/models/biocro/man/write.config.BIOCRO.Rd +++ b/models/biocro/man/write.config.BIOCRO.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/write.configs.BIOCRO.R \name{write.config.BIOCRO} \alias{write.config.BIOCRO} -\title{Write configuration files for the biocro model} +\title{Writes a configuration files for the biocro model} \usage{ write.config.BIOCRO(defaults = NULL, trait.values, settings, run.id) } diff --git a/models/biocro/tests/Rcheck_reference.log b/models/biocro/tests/Rcheck_reference.log index 98b0a701e11..31fb6ae89ff 100644 --- a/models/biocro/tests/Rcheck_reference.log +++ b/models/biocro/tests/Rcheck_reference.log @@ -12,43 +12,6 @@ Maintainer: ‘David LeBauer ’ 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’ @@ -58,7 +21,6 @@ Strong dependencies not in mainstream repositories: Suggests or Enhances not in mainstream repositories: BioCro, PEcAn.DB -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 @@ -72,8 +34,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 @@ -111,10 +72,7 @@ See section 'Cross-references' 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 -Files in the 'vignettes' directory but no files in 'inst/doc': - ‘C4grass_sa_vd.Rmd’, ‘sa.output.Rdata’, ‘workflow.R’, ‘workflow.Rmd’ -Package has no Sweave vignette sources and no VignetteBuilder field. +* checking files in ‘vignettes’ ... OK * checking examples ... NONE * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED diff --git a/models/biocro/tests/testthat.R b/models/biocro/tests/testthat.R index 31a95f2fe7e..da34f056ebe 100644 --- a/models/biocro/tests/testthat.R +++ b/models/biocro/tests/testthat.R @@ -1,10 +1,3 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2012 University of Illinois, NCSA. All rights reserved. This -# program and the accompanying materials are made available under the terms of -# the University of Illinois/NCSA Open Source License which accompanies this -# distribution, and is available at -# http://opensource.ncsa.illinois.edu/license.html -#------------------------------------------------------------------------------- library(PEcAn.utils) library(PEcAn.settings) library(testthat)