Skip to content

Commit

Permalink
Merge pull request #301 from aappling-usgs/develop
Browse files Browse the repository at this point in the history
updates in support of htcondor mle & bayes runs
  • Loading branch information
aappling-usgs committed Feb 13, 2017
2 parents 95ec1d9 + 7cf3fd4 commit 837c0f0
Show file tree
Hide file tree
Showing 167 changed files with 59 additions and 221 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: mda.streams
Type: Package
Title: Data Preparation, Access, and Analysis Functions for the Powell Center
Continental Stream Metabolism Project
Version: 0.9.15
Date: 2017-01-19
Version: 0.9.19
Date: 2017-02-11
Author: Alison P Appling, Luke A Winslow, Jordan S Read, Lindsay Carr
Maintainer: Alison Appling <aappling@usgs.gov>
Description: Back end tools for powstreams.
Expand All @@ -20,7 +20,7 @@ Imports:
geoknife (>= 1.5.2),
sbtools (>= 1.0.2),
streamMetabolizer (>= 0.9.18),
unitted (>= 0.2.7),
unitted (>= 0.2.8),
dplyr (>= 0.5.0),
tibble (>= 1.2.0),
foreign,
Expand All @@ -39,4 +39,4 @@ Suggests:
yaml
LazyLoad: yes
LazyData: yes
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ importFrom(tools,write_PACKAGES)
importFrom(unitted,deunitted)
importFrom(unitted,get_units)
importFrom(unitted,is.unitted)
importFrom(unitted,rbind.unitted)
importFrom(unitted,read_unitted)
importFrom(unitted,u)
importFrom(unitted,v)
Expand Down
2 changes: 1 addition & 1 deletion R/archive_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @param filename character. the filename[s] to archive
#' @param verbose logical. give status messages?
#' @import sbtools
archive_ts <- function(var_src, site_name, version=c('tsv','rds'), ts_id, filename, verbose=TRUE) {
archive_ts <- function(var_src, site_name, version=c('rds','tsv'), ts_id, filename, verbose=TRUE) {

# check session
sb_require_login("stop")
Expand Down
2 changes: 2 additions & 0 deletions R/config_to_metab.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ config_to_metab <- function(config, rows, verbose=TRUE, prep_only=FALSE) {
error=function(e) {
out <- "error in model run"
attr(out, "errors") <- as.character(e$message)
attr(out, "error_object") <- e
attr(out, "inputs") <- list(specs=metab_args$specs, data=metab_data, data_daily=metab_data_daily, info=metab_args$info)
out
})

Expand Down
2 changes: 1 addition & 1 deletion R/download_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' \code{get_var_src_codes(data_type=='ts')$var_src})
#' @param folder string for a folder location
#' @param version character string indicating whether you want to download the
#' ts as a .tsv or .rds
#' ts as an .rds or .tsv
#' @param on_remote_missing character indicating what to do if the remote file
#' is missing
#' @param on_local_exists character indicating what to do if the folder already
Expand Down
17 changes: 12 additions & 5 deletions R/login_sb.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Log into ScienceBase with your myUSGS credentials
#'
#' BE CAREFUL NOT TO POST OR SHARE YOUR PASSWORD! Even better, set up your
#' ~/.R/stream_metab.yaml with fields for sb_user and sb_password so you never
#' ~/.R/stream_metab.yaml with fields for sb_user and sb_password so you never
#' again have to bring your password into the R global environment. If that file
#' exists and you call \code{login_sb()} with no arguments, the file contents
#' will be used to log you in.
Expand All @@ -11,17 +11,24 @@
#' \code{sbtools::\link[sbtools]{authenticate_sb}} but easier to type.
#'
#' @param username Your ScienceBase/myUSGS username, usually an email address
#' @param filename The file path to a yaml file where fields for sb_user and
#' sb_password can be found. This file will be ignored if \code{username} is
#' given.
#' @import sbtools
#' @export
login_sb <- function(username) {
login_sb <- function(username, filename='~/.R/stream_metab.yaml') {
# if username is provided, assume the user wants to log in manually
if(!missing(username)) {
return(authenticate_sb(username))
}

# next possibility is that yaml pkg is available and a profile exists
filename <- file.path(Sys.getenv("HOME"), ".R", "stream_metab.yaml")
if(requireNamespace('yaml', quietly=TRUE) && file.exists(filename)) {
# next possibility is that yaml pkg is available and a profile exists. putting
# the yaml in ~/.R is preferred. putting the yaml in the current working
# directory is also an option (useful for cluster runs) but not widely
# advertised because it increases the risk of accidentally committing a
# password file to a versioning system
if(file.exists(filename)) {
if(!requireNamespace('yaml', quietly=TRUE)) stop("need the yaml package to log in by file")
profile <- yaml::yaml.load_file(filename)
if(exists('sb_user', profile) && exists('sb_password', profile)) {
return(authenticate_sb(profile$sb_user, profile$sb_password))
Expand Down
2 changes: 1 addition & 1 deletion R/mda_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ parse_metab_model_path <- function(file_path, out=c("dir_name","file_name","mode
dir_name <- sapply(file_path, dirname, USE.NAMES=FALSE)
file_name <- sapply(file_path, basename, USE.NAMES=FALSE)

version <- if(substring(file_name, 1, 3) == "mmm") "modern" else "original"
version <- ifelse(substring(file_name, 1, 3) == "mmm", "modern", "original")
parsed <- data.frame(
dir_name = dir_name,
file_name = file_name,
Expand Down
4 changes: 2 additions & 2 deletions R/stage_meta_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param verbose logical. print status messages?
#' @import dplyr
#' @import tibble
#' @importFrom unitted u v get_units
#' @importFrom unitted u v is.unitted get_units write_unitted
#' @export
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -78,7 +78,7 @@ stage_meta_basic <- function(sites=list_sites(), on_exists=c('replace','add_rows
}

# add truly new rows
new_meta <- rbind.unitted(old_meta, sites_meta)
new_meta <- rbind(old_meta, sites_meta)
} else {
new_meta <- sites_meta
}
Expand Down
4 changes: 2 additions & 2 deletions R/stage_meta_indy.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' function is called (except that this copying is currently only implemented
#' for the 'basic' metadata table).
#' @inheritParams stage_meta_styx
#' @importFrom unitted u is.unitted get_units
#' @importFrom unitted u v is.unitted get_units write_unitted
#' @export
stage_meta_indy <- function(
rows=u(data.frame(
Expand Down Expand Up @@ -41,7 +41,7 @@ stage_meta_indy <- function(
}

# add truly new rows
new_meta <- rbind.unitted(old_meta, rows)
new_meta <- rbind(old_meta, rows)
} else {
new_meta <- rows
}
Expand Down
4 changes: 2 additions & 2 deletions R/stage_meta_styx.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' by the new rows.
#' @param folder where to store the staged file
#' @param verbose logical. give status messages?
#' @importFrom unitted u write_unitted is.unitted rbind.unitted
#' @importFrom unitted u write_unitted is.unitted
#' @import dplyr
#' @export
stage_meta_styx <- function(rows, on_exists=c("stop","replace"), folder = tempdir(), verbose = FALSE) {
Expand Down Expand Up @@ -38,7 +38,7 @@ stage_meta_styx <- function(rows, on_exists=c("stop","replace"), folder = tempdi
}

# add truly new rows
new_meta <- rbind.unitted(old_meta, rows)
new_meta <- rbind(old_meta, rows)
} else {
new_meta <- rows
}
Expand Down
2 changes: 1 addition & 1 deletion R/stage_nwis_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param folder a folder to place the file outputs in (defaults to temp
#' directory)
#' @param version character string indicating whether you want to stage the
#' \code{ts} as a .tsv or .rds
#' \code{ts} as an .rds or .tsv
#' @param verbose provide verbose output (currently not implemented)
#' @return a character vector of file handles
#' @importFrom dataRetrieval readNWISuv
Expand Down
2 changes: 1 addition & 1 deletion R/ts_has_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' file meeting the criteria
#'
#' @param ts_items a list of timeseries sbitems
#' @param with_ts_version one or more of \code{c('tsv','rds')} to limit the
#' @param with_ts_version one or more of \code{c('rds','tsv')} to limit the
#' dataset extension to anything in with_ts_version (if the dataset is a ts)
#' @param with_ts_archived one or more of \code{c(TRUE,FALSE)} to limit the list
#' to sites that have a ts that's archived, not archived, or either
Expand Down
2 changes: 1 addition & 1 deletion R/write_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param var the variable name of the output, e.g., 'doobs'
#' @param src the source of the data, e.g., 'nwis' or 'nldas'
#' @param folder the folder to write the file in
#' @param version the output version for the file (tsv, rds)
#' @param version the output version for the file (rds, tsv)
#' @keywords internal
#' @importFrom lubridate tz
#' @importFrom unitted u
Expand Down
3 changes: 1 addition & 2 deletions man/archive_ts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/build_calc_ts_needs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/build_sysdata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_depth_calcDischHarvey.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_depth_calcDischRaymond.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_doinit_calcDStart.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_dopsat_calcObsSat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_dosat_calcGG.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_par_calcLat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_par_calcLatSw.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_par_calcSw.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_simCopy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_simNew.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_sitedate_calcLon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_sitetime_calcLon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_suntime_calcLon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_veloc_calcDischHarvey.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_veloc_calcDischRaymond.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/calc_ts_with_input_check.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/choose_data_source.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/cluster_bundle_packages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/combine_dplyr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/combine_tables.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/combine_ts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/condense_by_ply.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/condense_by_stat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_preds_to_data_column.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_to_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_to_data_column.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_to_metab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_to_metab_clusterfun.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/config_to_metab_repeat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/define_pkg_env.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/delete_item.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/delete_meta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/delete_metab_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/delete_metab_run.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/delete_sb_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 837c0f0

Please sign in to comment.