Skip to content

Commit

Permalink
Merge pull request #75 from aappling-usgs/master
Browse files Browse the repository at this point in the history
updates for sM & mda.streams changes
  • Loading branch information
aappling-usgs committed Sep 18, 2015
2 parents f6cdce1 + 4f8b580 commit b7139aa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: powstreams
Type: Package
Title: powstreams
Version: 0.7.13
Date: 2015-09-08
Version: 0.7.14
Date: 2015-09-17
Author: Jordan S Read, Luke A Winslow, Alison Appling
Maintainer: Jordan S Read <jread@usgs.gov>
Description: tools for working Powell Center working group on stream metabolism.
Expand All @@ -16,6 +16,7 @@ Depends:
R (>= 3.0)
Imports:
mda.streams (>= 0.7.21),
streamMetabolizer,
sbtools,
shiny,
unitted,
Expand All @@ -26,6 +27,6 @@ Imports:
gsplot (>= 0.2.2),
leaflet
Suggests:
testthat
testthat
LazyLoad: yes
LazyData: yes
5 changes: 4 additions & 1 deletion R/get_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#' ts-getting.
#'
#' @usage get_ts(var_src, site_name, method = "approx", approx_tol =
#' as.difftime(3, units = "hours"), on_local_exists = "skip")
#' as.difftime(3, units = "hours"), on_local_exists = "skip", on_invalid =
#' "stop")
#' @param var_src a valid variable name for timeseries data (see
#' \code{dplyr::select(dplyr::filter(var_src_codes, data_type=='ts'),
#' var_src)})
Expand All @@ -18,6 +19,8 @@
#' 2nd:nth data argument to combine_ts (relative to the first argument)
#' @param on_local_exists character indicating what to do if the folder already
#' contains a file with the intended download name
#' @param on_invalid character in \code{c("stop","warn")} indicating how to
#' handle invalid timeseries
#'
#' @importFrom mda.streams get_ts
#' @name get_ts
Expand Down
9 changes: 5 additions & 4 deletions inst/shiny/model/server.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library(dygraphs)
library(datasets)
library(DT)
library(streamMetabolizer)
library(powstreams)

noneselected = "-- no variable selected --"
Expand Down Expand Up @@ -28,8 +29,8 @@ shinyServer(function(input, output) {
if (is.null(names(models)) || !names(models) %in% r.chr){
file = download_metab_model(metab_models[row, ]$model_name, on_local_exists = 'skip')
if (file.size(file) > 0){
load(file) # site-specific, run-specific model object
models[[r.chr]] <- mm
varname <- load(file) # site-specific, run-specific model object
models[[r.chr]] <- mda.streams::modernize_metab_model(get(varname))
} else {
models[[r.chr]] <- list() # empty model
}
Expand All @@ -50,8 +51,8 @@ shinyServer(function(input, output) {
} else {
ts.out <- null.xts
for (nm in names(models)){
df <- data.frame(xts::xts(models[[nm]]@fit[[var]], order.by=models[[nm]]@fit[['date']])) %>%
setNames(paste(var,models[[nm]]@info$site, models[[nm]]@info$strategy, models[[nm]]@info$tag, sep='.'))
df <- data.frame(xts::xts(get_fit(models[[nm]])[[var]], order.by=get_fit(models[[nm]])[['local.date']])) %>%
setNames(paste(var,get_info(models[[nm]])$config$site, get_info(models[[nm]])$config$strategy, get_info(models[[nm]])$config$tag, sep='.'))
ts.out <- merge(ts.out, df)
}
return(ts.out)
Expand Down
5 changes: 4 additions & 1 deletion man/get_ts.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ over which an approximation will be used to fill in data gaps in the
2nd:nth data argument to combine_ts (relative to the first argument)}

\item{on_local_exists}{character indicating what to do if the folder already
contains a file with the intended download name}
contains a file with the intended download name}

\item{on_invalid}{character in \code{c("stop","warn")} indicating how to
handle invalid timeseries}
}
\description{
Downloads the file from SB if either (1) the file has not yet been downloaded
Expand Down

0 comments on commit b7139aa

Please sign in to comment.