metab_sim | R Documentation |
Takes input data in the form of a sub-daily time series (data
) of
DO.sat, depth, temperature, and light, and a daily time series
(data_daily
) of GPP, ER, and K600 values, and turns these into
simulated DO.obs. Either data
or data_daily
should specify a
starting DO.obs value for each day; if in data
, this takes the form of
a DO.obs column with values on at least the first time point of each day (all
other values are ignored), or if in data_daily
, this takes the form of
a DO.mod.1 column with one starting DO value per day.
metab_sim(
specs = specs(mm_name("sim")),
data = mm_data(solar.time, DO.obs, DO.sat, depth, temp.water, light, optional =
"DO.obs"),
data_daily = mm_data(date, discharge.daily, DO.mod.1, K600.daily, GPP.daily, Pmax,
alpha, ER.daily, ER20, err.obs.sigma, err.obs.phi, err.proc.sigma, err.proc.phi,
optional = "all"),
info = NULL
)
specs |
a list of model specifications and parameters for a model.
Although this may be specified manually (it's just a list), it is easier
and safer to use |
data |
data.frame (not a tbl_df) of input data at the temporal
resolution of raw observations (unit-value). Columns must have the same
names, units, and format as the default. The solar.time column must also
have a timezone code ('tzone' attribute) of 'UTC'. See the
'Formatting |
data_daily |
data.frame containing inputs with a daily timestep. See the
'Formatting |
info |
any information, in any format, that you would like to store within the metab_model object |
A metab_sim object containing the fitted model. This object can be
inspected with the functions in the metab_model_interface
.
Other metab_model:
metab_Kmodel
,
metab_bayes
,
metab_mle
,
metab_night
## simulations with variation all at sub-daily scale
# prepare input data (DO used only to pick first DO of each day)
dat <- data_metab('3', res='15')
dat_daily <- data.frame(date=as.Date(paste0("2012-09-", 18:20)),
GPP.daily=2, ER.daily=-3, K600.daily=21, stringsAsFactors=FALSE)
# define simulation parameters
mm <- metab_sim(
specs(mm_name('sim'), err_obs_sigma=0.1, err_proc_sigma=2,
GPP_daily=NULL, ER_daily=NULL, K600_daily=NULL),
data=dat, data_daily=dat_daily)
# actual simulation happens during prediction - different each time
get_params(mm)
predict_metab(mm)
predict_DO(mm)[seq(1,50,by=10),]
predict_DO(mm)[seq(1,50,by=10),]
# or same each time if seed is set
mm@specs$sim_seed <- 236
predict_DO(mm)$DO.obs[seq(1,50,by=10)]
predict_DO(mm)$DO.obs[seq(1,50,by=10)]
# fancy GPP equation
dat_daily <- data.frame(date=as.Date(paste0("2012-09-", 18:20)),
Pmax=8, alpha=0.01, ER.daily=-3, K600.daily=21, stringsAsFactors=FALSE)
mm <- metab_sim(
specs(mm_name('sim', GPP_fun='satlight'), err_obs_sigma=0.1, err_proc_sigma=2,
Pmax=NULL, alpha=NULL, ER_daily=NULL, K600_daily=NULL),
data=dat, data_daily=dat_daily)
get_params(mm)
predict_metab(mm) # metab estimates are for data without errors
predict_DO(mm)[seq(1,50,by=10),]
## simulations with variation at both sub-daily and multi-day scales
sp <- specs(mm_name('sim', pool_K600='none'),
K600_daily = function(n, ...) pmax(0, rnorm(n, 10, 3))) # n is available within sim models
mm <- metab(sp, dat)
get_params(mm)
predict_metab(mm)
## K~Q model
dat <- data_metab('10','15')
sp <- specs(mm_name('sim', pool_K600='binned'))
mm <- metab(sp, dat)
pars <- get_params(mm)
attr(pars, 'K600_eqn')
## Not run:
plot_DO_preds(predict_DO(mm))
plot_DO_preds(mm)
library(ggplot2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.