Skip to contents

Get 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 TRUE updated posteriors will be written to BETYdb. Defaults to FALSE.

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.Rdata

Contains 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.Rdata

Contains a single object prior.distns: a data frame with one row per trait and columns distn, parama, paramb, and n. Row names are trait variable names. Traits listed in pft$constants are excluded.

trait.data.csv

CSV export of trait.data (all traits row-bound).

prior.distns.csv

CSV export of prior.distns.

species.csv or cultivars.csv

PFT 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.

Author

David LeBauer, Shawn Serbin, Rob Kooper