Get trait data from the database for a single PFT
Source:R/get.trait.data.pft.R
get.trait.data.pft.RdGet trait data from the database for a single PFT
Usage
get.trait.data.pft(
pft,
modeltype,
dbfiles,
dbcon,
trait.names,
forceupdate = FALSE,
write = FALSE
)Arguments
- pft
list of settings for the pft whose traits to retrieve. See details.
- modeltype
type of model that is used, this is used to distinguish between different pfts with the same name.
- dbfiles
location where previous results are found
- dbcon
database connection
- trait.names
list of trait names to retrieve
- forceupdate
set this to true to force an update, auto will check to see if an update is needed.
- write
(Logical) If
TRUEupdated posteriors will be written to BETYdb. Defaults toFALSE.
Value
The pft input list, updated with pft$posteriorid set to the
ID of the (possibly new) posterior record in BETYdb. The posterior ID can
be used to locate the output files (trait.data.Rdata, prior.distns.Rdata,
etc.) via BETYdb's dbfiles table.
Details
pft should be a list containing at least name and outdir, and
optionally posteriorid and constants.
File-based side effects (saved to pft$outdir):
trait.data.RdataContains a single object
trait.data: a named list of data frames, one per trait. Each data frame has columns from BETYdb's traits/yields views (e.g.,mean,stat,n,site_id,treatment_id). Names correspond to trait variable names (e.g.,"SLA","Vcmax").prior.distns.RdataContains a single object
prior.distns: a data frame with one row per trait and columnsdistn,parama,paramb, andn. Row names are trait variable names. Traits listed inpft$constantsare excluded.trait.data.csvCSV export of
trait.data(all traits row-bound).prior.distns.csvCSV export of
prior.distns.species.csvorcultivars.csvPFT membership list used to detect changes between runs.
Downstream contract: The files trait.data.Rdata and
prior.distns.Rdata are expected by run.meta.analysis.pft, which
loads them from pft$outdir. This implicit file-based coupling means
the two functions must agree on directory path and object names. A future
refactoring goal is to pass these objects directly via function arguments
instead.