Fitting models in batch mode with config files is nice, but sometimes you just want to look at some data and/or run a model manually. In this case you can still leverage config files to specify the data based on what's available on ScienceBase.
library(mda.streams) library(dplyr) library(streamMetabolizer)
First make a config file.
sites <- c("nwis_01649190", "nwis_06478522") config <- stage_metab_config( tag='0.0.13', strategy='initial K600 estimate', date=Sys.time(), model="metab_mle", model_args="list(specs=specs('mle'))", site=sites, start_date="2015-03-15", end_date="2015-04-15", filename=NULL)
Then use config_to_metab
with prep_only=TRUE
to get a list of the input data and arguments rather than a full metabolism model. Set the names of the list in a way that distinguishes meaningfully among the rows in config - that part is up to you to determine.
prep_list <- config_to_metab(config, rows=1:nrow(config), prep_only=TRUE) %>% setNames(sites)
The result is a list as long as nrow(config)
, where each list element is itself a list containing data
, data_daily
, and other arguments for that config row.
names(prep_list[[1]])
You can now inspect the data.
lapply(prep_list, function(prep) range(prep$data$solar.time))
You can still run the model if you like.
mm <- do.call(metab, prep_list[[1]])
The resulting model can now be explored.
plot_DO_preds(predict_DO(mm, "2015-04-10", "2015-04-15"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.