Skip to content

Commit

Permalink
Merge pull request #376 from aappling-usgs/err-proc-day
Browse files Browse the repository at this point in the history
implement daytime process error bayesian models (err_proc_dayiid=T)
  • Loading branch information
aappling-usgs authored Feb 2, 2019
2 parents b530bc2 + 8c10b6e commit 3540d23
Show file tree
Hide file tree
Showing 442 changed files with 31,319 additions and 3,776 deletions.
24 changes: 22 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@

language: r
sudo: required
dist: trusty
warnings_are_errors: true

matrix:
include:
- os: linux
dist: trusty
r: release
r_binary_packages:
- devtools
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"

before_install:
- eval "${MATRIX_EVAL}"
- mkdir -p ~/.R/
- echo "CXX14 = g++-7 -fPIC" >> ~/.R/Makevars
- echo "CXX14FLAGS = -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-attributes -O3" >> ~/.R/Makevars

env:
global:
- R_BUILD_ARGS="--no-build-vignettes --no-manual"
Expand All @@ -23,7 +44,6 @@ before_script:
- Rscript -e "install.packages('rmarkdown')"

r_packages:
- modeest
- deSolve
- rstan

Expand Down
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: streamMetabolizer
Type: Package
Title: Models for Estimating Aquatic Photosynthesis and Respiration
Version: 0.11.0
Date: 2018-10-10
Author: Alison P. Appling, Robert O. Hall, Maite Arroita, and Charles B.
Version: 0.11.3
Date: 2019-02-02
Author: Alison P. Appling, Robert O. Hall, Jr., Maite Arroita, and Charles B.
Yackulic
Authors@R: c(
person("Alison P.", "Appling", , "[email protected]", c("aut", "cre")),
Expand Down Expand Up @@ -124,5 +124,5 @@ Collate:
'streamMetabolizer-deprecated.R'
'streamMetabolizer.R'
'zz_build_docs.R'
RoxygenNote: 6.1.0
Encoding: UTF-8
RoxygenNote: 6.1.1
Encoding: UTF-8
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 0.11.2

* changed `err_proc_dayiid` to `err_proc_GPP` and switched to a more GPP-oriented
process error for those models

# 0.11.1

* added `err_proc_dayiid` option for Bayesian models

# 0.11.0

* added `GPP_fun='satlight'` option for Bayesian models
Expand Down
18 changes: 11 additions & 7 deletions R/metab_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ prepdata_bayes <- function(
switch(
features$GPP_fun,
linlight = list(
frac_GPP = {
# X_mult_Y syntax: X = process reflected by multiplier, Y = quantity
# modified by multiplier
light_mult_GPP = {
mat_light <- time_by_date_matrix(data$light)
# normalize light by the sum of light in the first 24 hours of the time window
in_solar_day <- apply(obs_times, MARGIN=2, FUN=function(timevec) {timevec - timevec[1] <= 1} )
Expand All @@ -551,8 +553,9 @@ prepdata_bayes <- function(
),

list(
frac_ER = time_by_date_matrix(1),
frac_D = time_by_date_matrix(timestep_days), # the yackulic shortcut models rely on this being constant over time
# X_mult_Y syntax: X = process reflected by multiplier, Y = quantity
# modified by multiplier
const_mult_ER = time_by_date_matrix(1),
KO2_conv = {
KO2_conv_vec <- suppressWarnings(convert_k600_to_kGAS(k600=1, temperature=data$temp.water, gas="O2"))
if(any(is.nan(KO2_conv_vec))) {
Expand Down Expand Up @@ -783,15 +786,16 @@ format_mcmc_mat_nosplit <- function(mcmc_mat, data_list_d, data_list_n, model_na
'lnK600_lnQ_nodes'),
daily = c(
'GPP', 'ER',
'GPP_daily', 'Pmax', 'alpha', 'ER_daily', 'K600_daily',
if(features$pool_K600_type %in% c('linear','binned')) 'K600_daily_predlog'),
'GPP_daily', 'Pmax', 'alpha', 'ER_daily', 'K600_daily', 'DO_R2',
if(features$pool_K600_type %in% c('linear','binned')) 'K600_daily_predlog',
if(features$err_proc_GPP) 'GPP_pseudo_R2'),
inst = c(
'DO_mod', 'DO_mod_partial', # d*n
'DO_mod_partial_sigma', # d*n
'GPP_inst', 'ER_inst', 'KO2_inst', # d*n
'GPP_inst_partial', 'err_proc_GPP', # d*n for GPP process error
'err_proc_acor_inc', 'err_proc_acor', # can be d*n (trapezoid) or d*(n-1) (euler), same timestamp indexing as GPP_inst
'err_obs_iid', 'err_proc_iid', # d*(n-1), timestamp[i+1] relates to var[i:i+1]
'coef_GPP'
'err_obs_iid', 'err_proc_iid' # d*(n-1), timestamp[i+1] relates to var[i:i+1]
)
)

Expand Down
Loading

0 comments on commit 3540d23

Please sign in to comment.