Skip to content

Commit ad9e897

Browse files
committed
doc update for get.trait.data.pft.R
1 parent 983f754 commit ad9e897

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

base/db/DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ Copyright: Authors
8080
LazyLoad: yes
8181
LazyData: FALSE
8282
Encoding: UTF-8
83+
Roxygen: list(markdown = TRUE)
8384
RoxygenNote: 7.3.3
8485
X-schema.org-keywords: PEcAn, database

base/db/R/get.trait.data.pft.R

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
11
##' Get trait data from the database for a single PFT
22
##'
3-
##' @details `pft` should be a list containing at least `name` and `outdir`, and optionally `posteriorid` and `constants`. BEWARE: All existing files in `outir` will be deleted!
4-
##' @param pft list of settings for the pft whose traits to retrieve. See details
5-
##' @param modeltype type of model that is used, this is used to distinguish between different pfts with the same name.
3+
##' Queries BETYdb for trait observations and prior distributions for a single
4+
##' plant functional type (PFT). Results are saved to `.RData` and `.csv` files
5+
##' in the PFT output directory (`pft$outdir`), and also registered in the
6+
##' database as posterior records when `write = TRUE`.
7+
##'
8+
##' @details
9+
##' `pft` should be a list containing at least `name` and `outdir`, and
10+
##' optionally `posteriorid` and `constants`.
11+
##' **BEWARE:** All existing files in `pft$outdir` will be deleted on entry.
12+
##'
13+
##' **File-based side effects (saved to `pft$outdir`):**
14+
##' \describe{
15+
##' \item{`trait.data.Rdata`}{Contains a single object `trait.data`: a named
16+
##' list of data frames, one per trait. Each data frame has columns from
17+
##' BETYdb's traits/yields views (e.g., `mean`, `stat`, `n`, `site_id`,
18+
##' `treatment_id`). Names correspond to trait variable names
19+
##' (e.g., `"SLA"`, `"Vcmax"`).}
20+
##' \item{`prior.distns.Rdata`}{Contains a single object `prior.distns`: a
21+
##' data frame with one row per trait and columns `distn`, `parama`,
22+
##' `paramb`, and `n`. Row names are trait variable names. Traits listed
23+
##' in `pft$constants` are excluded.}
24+
##' \item{`trait.data.csv`}{CSV export of `trait.data` (all traits
25+
##' row-bound).}
26+
##' \item{`prior.distns.csv`}{CSV export of `prior.distns`.}
27+
##' \item{`species.csv` or `cultivars.csv`}{PFT membership list used to
28+
##' detect changes between runs.}
29+
##' }
30+
##'
31+
##' **Downstream contract:** The files `trait.data.Rdata` and
32+
##' `prior.distns.Rdata` are expected by [run.meta.analysis.pft()], which
33+
##' loads them from `pft$outdir`. This implicit file-based coupling means
34+
##' the two functions must agree on directory path and object names. A future
35+
##' refactoring goal is to pass these objects directly via function arguments
36+
##' instead.
37+
##'
38+
##' @param pft list of settings for the pft whose traits to retrieve. See details.
39+
##' @param modeltype type of model that is used, this is used to distinguish
40+
##' between different pfts with the same name.
641
##' @param dbfiles location where previous results are found
742
##' @param dbcon database connection
8-
##' @param forceupdate set this to true to force an update, auto will check to see if an update is needed.
43+
##' @param forceupdate set this to true to force an update, auto will check to
44+
##' see if an update is needed.
945
##' @param write (Logical) If `TRUE` updated posteriors will be written to
10-
##' BETYdb. Defaults to FALSE.
46+
##' BETYdb. Defaults to `FALSE`.
1147
##' @param trait.names list of trait names to retrieve
12-
##' @return updated pft with posteriorid
48+
##' @return The `pft` input list, updated with `pft$posteriorid` set to the
49+
##' ID of the (possibly new) posterior record in BETYdb. Note: the function's
50+
##' primary outputs (`trait.data`, `prior.distns`) are currently communicated
51+
##' only through files saved in `pft$outdir`, not through the return value.
1352
##' @author David LeBauer, Shawn Serbin, Rob Kooper
1453
##' @export
1554
get.trait.data.pft <-

0 commit comments

Comments
 (0)