DOI-USGS / streamMetabolizer

streamMetabolizer uses inverse modeling to estimate aquatic metabolism (photosynthesis and respiration) from time series data on dissolved oxygen, water temperature, depth, and light.
http://usgs-r.github.io/streamMetabolizer/
Other
36 stars 22 forks source link

predict_metab could offer instantaneous preds #222

Open aappling-usgs opened 8 years ago

aappling-usgs commented 8 years ago

someday would be neat to offer predictions of GPP, ER, and D at each timestep, offer plotting, etc.

aappling-usgs commented 7 years ago

cool trick: can already extract inst GPP, ER, and DO_mod from bayesian models if you ask for them ahead of time. below, plot_DO_preds() uses calc_dDOdt rather than mcmc output to compute the brown line, but the black line from bayesian model nonetheless plots right on top, as it should.

mm1 <- metab(revise(specs("b_np_oi_tr_plrckm.stan"), params_out=c(params_out, 'GPP', 'ER', 'DO_mod')), dat)
plot_DO_preds(mm1, y_var='conc') + geom_line(data=get_fit(mm1)$inst, aes(x=solar.time, y=DO_mod_50pct), size=1.5, linetype='dashed')

image

and here are the instantaneous GPP & ER

ggplot(get_fit(mm1)$inst, aes(x=solar.time)) + geom_line(aes(y=GPP_50pct), color='forestgreen') + geom_line(aes(y=ER_50pct), color='brown') + theme_bw() + ylab("GPP (green) and ER (brown) (gO2 m^-2 d^-1)")

image