choose_data_source: Select the specific data source to use for a given variable...

View source: R/choose_data_source.R

choose_data_sourceR Documentation

Select the specific data source to use for a given variable and site

Description

Var and site are always required fields. logic is required by has a default value that may be used without explict specification. For every element of logic that equals one of the default options, the specified chosing algorithm will be used to supply values for type and src. If logic is unrecognized, then type and src are also required and the row will be constructed from the manually specified elements of site, type, src, and logic.

Usage

choose_data_source(var, site, logic = c("priority local", "unused var"),
  type = c(NA, "ts", "meta", "ts_file", "const", "pred", "pred_file", "none"),
  src = NA, with_ts_version = "rds", with_ts_archived = FALSE,
  with_ts_uploaded_after = "2015-01-01")

Arguments

var

character. A single variable name as in unique(get_var_src_codes(out="var")).

site

character. The site code or codes for which to choose data.

logic

character specifying the algorithm to use, or the manual logic that was used by the user, to choose the type and src. if an element of logic is not one of the options given in the argument definition, then the corresponding elements of type and src must be specified.

type

character in c("ts","meta","file","const").

src

character indicating a src to be interpreted in the context of type

with_ts_version

one or more of c('rds','tsv') to limit the dataset extension to anything in with_ts_version (if the dataset is a ts)

with_ts_archived

one or more of c(TRUE,FALSE) to limit the list to sites that have a ts that's archived, not archived, or either

with_ts_uploaded_after

POSIXct, or convertible to POSIXct, giving date after which a ts must have been uploaded to count

Value

a 4-column data.frame component of a config file

Examples

## Not run: 
choose_data_source(var="baro", site="nwis_03067510", logic='priority local')
# expect warnings:
choose_data_source(var="baro", site=c("nwis_08062500","nwis_03067510"), 
  logic='my made-up data', type="ts_file", src=c("myfile1.txt","myfile2.txt"))
choose_data_source(var="dosat", site="nwis_03067510", logic='priority local')

# as in default to stage_metab_config
site=list_sites(c("doobs_nwis","disch_nwis","wtr_nwis"))[40:49]
sitetime=choose_data_source("sitetime", site)
doobs=choose_data_source("doobs", site)
dosat=choose_data_source("dosat", site)
depth=choose_data_source("depth", site)
wtr=choose_data_source("wtr", site)
par=choose_data_source("par", site)

# as in verify_config
choose_data_source(var="doobs", site="dummy_site", logic="manual", type="ts", src="simCopy")

# for K
K600=choose_data_source("K600", "nwis_08062500")
login_sb()
K600=choose_data_source(var="K600", site="nwis_08062500", logic="nighttime reg", 
  type="pred", src="0.0.6")
K600=choose_data_source(var="K600", site="nwis_08062500", logic="nighttime reg", 
  type="pred", src="nwis_08062500-307-150730 0.0.6 nighttime_k_plus_data")

## End(Not run)

USGS-R/mda.streams documentation built on June 3, 2023, 8:43 a.m.