Package 'SampleSplitting'

Title: Assists users in loading site data and preparing splitting volumes for the lab
Description: Uses USGS NWISWeb web services to fetch data for the user's desired USGS NWIS stations; calculates sample bottle volumes for provided storm events; and returns this data in a text output file.
Authors: Laura Hubbard [aut], Jessica Thompson [aut], Laura DeCicco [cre]
Maintainer: Laura DeCicco <[email protected]>
License: CC0
Version: 1.0.6
Built: 2024-11-16 04:04:48 UTC
Source: https://github.com/USGS-R/SampleSplitting

Help Index


Function to return adaps_data_all df from NWISWeb or previously retrieved RDB files

Description

This function accepts an NWIS gage site id, an NWIS precip site id, a StartDate, an EndDate, a timezone and file names as needed

Usage

getADAPSData(siteNo, StartDt, EndDt, precipSite, dataFile = "", tzCode = "")

Arguments

siteNo

NWIS gaging station id

StartDt

a date to start data pulls

EndDt

a date to end data pulls

precipSite

NWIS precipitation station id

dataFile

string of data file path and name

tzCode

a timezone specification for the data

Value

adaps_data_all data frame containing merged ADAPS data for the requested site and date range

Examples

## Not run: 
siteNo <- "424421077495301"
StartDt <- '2016-02-03'
EndDt <- '2016-02-03'
precipSite <- "424421077495301"
tzCode <- "America/Jamaica"
adaps_data_all <- getADAPSData(siteNo,StartDt,EndDt,precipSite,tzCode=tzCode)

## End(Not run)

Function to return hydrographInteractive html to create interactive hydrograph plot through googleVis

Description

This function accepts a merged data frame of ADAPS data for a site/storm event

Usage

hydrographInteractive(adaps_data_all)

Arguments

adaps_data_all

data frame containing merged ADAPS data for the requested storm event

Value

hydrographInteractive html object containing code to create googleVis plot

Examples

rdbExample<-rdbExample
hydrographInteractive(rdbExample)

Function to generate and save pdf version of the hydrograph plot

Description

This function accepts a merged data frame of ADAPS data for a site/storm event

Usage

hydrographPDF(adaps_data_all, siteNo, dateInt, tzCode = "America/Chicago")

Arguments

adaps_data_all

data frame containing merged ADAPS data for the requested storm event

siteNo

string containing USGS gage number

dateInt

number containing number of hours difference between x-axis tick marks

tzCode

character a timezone specification for the data #' @export


Function to csv file of all intermediate volumes used for calculations

Description

This function accepts a siteNo, StartDt, EndDt and tableOut list of data for a given storm event

Usage

intermediateVolTable(siteNo, StartDt, EndDt, tableOut)

Arguments

siteNo

USGS station id

StartDt

start of storm event

EndDt

end of storm event

tableOut

list of data frames of event data


Function to return adaps_lab_samples df derived from previously merged data

Description

This function accepts a data frame of data for a site/storm event, storm start dates, storm end dates, storm names, maximum volume in one sample bottle, and maximum volume for an entire storm sample

Usage

labDataOut(
  adaps_data_all,
  StormStart,
  StormEnd,
  StormName,
  maxBottleVol,
  maxSampVol,
  removeDate = NA,
  subNum = -9,
  tzCode = "America/Chicago"
)

Arguments

adaps_data_all

data frame containing merged ADAPS data for the requested site and date range

StormStart

vector of datetimes for storm starts

StormEnd

vector of datetime for storm ends

StormName

vector of storm names

maxBottleVol

vector of maximum volumes in one subsample bottle

maxSampVol

vector of maximum volumes of one total sample

removeDate

vector of datetimes to be removed from the calculation, in the same timezone as adaps_data_all$datetime

subNum

vector of starting numbers for first bottle of each storm event

tzCode

character a timezone specification for the data

Value

tableOut list of a table for each storm event of bottle volumes

Examples

rdbExample <- rdbExample
tzCode <- "America/Chicago"
maxBottleVol <- c(400,600,600,600,600,600,600,400,600,800)
maxSampVol <- c(3900,3900,3900,3900,3900,3900,3900,3900,3900,3900)
StormStart <- c("2008-05-30 02:51","2008-06-05 04:39","2008-06-06 04:22",
                "2008-06-07 22:52","2008-06-08 08:41","2008-06-08 19:03",
                "2008-06-12 09:03","2008-06-12 21:40","2008-06-14 16:52",
                "2008-06-15 04:07")
StormEnd <- c("2008-05-30 08:49","2008-06-05 07:21","2008-06-06 05:28",
              "2008-06-08 01:14","2008-06-08 11:39","2008-06-08 21:31",
              "2008-06-12 10:22","2008-06-13 01:36","2008-06-14 18:05",
              "2008-06-15 09:22")
StormName <- c("S2-066","S2-067","S2-068","S2-069","S2-070","S2-071",
               "S2-072","S2-073","S2-074","S2-075")
subNum <- c(1,1,1,1,16,1,1,5,1,7)
dataOut <- labDataOut(rdbExample,
                      StormStart,StormEnd,
                      StormName,maxBottleVol,maxSampVol)
removeDate <- as.POSIXct("2008-06-15 05:44:00")
dataOut2 <- labDataOut(rdbExample,
                       StormStart, StormEnd,
                       StormName,maxBottleVol,maxSampVol,
                        removeDate, tzCode = tzCode)

Function to return adaps_lab_samples df derived from previously merged data

Description

This function accepts a data frame of data for a site/storm event, storm start dates, storm end dates, storm names, maximum volume in one sample bottle, and maximum volume for an entire storm sample

Usage

labDataOutMI(
  adaps_data_all,
  StormStart,
  StormEnd,
  StormName,
  maxBottleVol,
  maxSampVol,
  removeDate = NA,
  subNum = -9
)

Arguments

adaps_data_all

data frame containing merged ADAPS data for the requested site and date range

StormStart

vector of datetimes for storm starts

StormEnd

vector of datetime for storm ends

StormName

vector of storm names

maxBottleVol

vector of maximum volumes in one subsample bottle

maxSampVol

vector of maximum volumes of one total sample

removeDate

vector of datetimes to be removed from the calculation

subNum

vector of starting numbers for first bottle of each storm event

Value

tableOut list of a table for each storm event of bottle volumes

Examples

rdbExample <- rdbExample
maxBottleVol <- c(400,600,600,600,600,600,600,400,600,800)
maxSampVol <- c(3900,3900,3900,3900,3900,3900,3900,3900,3900,3900)
StormStart <- c("2008-05-30 02:51","2008-06-05 04:39","2008-06-06 04:22",
                "2008-06-07 22:52","2008-06-08 08:41","2008-06-08 19:03",
                "2008-06-12 09:03","2008-06-12 21:40","2008-06-14 16:52",
                "2008-06-15 04:07")
StormEnd <- c("2008-05-30 08:49","2008-06-05 07:21","2008-06-06 05:28",
              "2008-06-08 01:14","2008-06-08 11:39","2008-06-08 21:31",
              "2008-06-12 10:22","2008-06-13 01:36","2008-06-14 18:05",
              "2008-06-15 09:22")
StormName <- c("S2-066","S2-067","S2-068","S2-069","S2-070","S2-071",
               "S2-072","S2-073","S2-074","S2-075")
subNum <- c(1,1,1,1,16,1,1,5,1,7)
labDataOut(rdbExample,StormStart,StormEnd,StormName,
           maxBottleVol,maxSampVol)

Function to generate clean text file of sample amounts for lab

Description

This function accepts a vector of storm names, vector of storm start and end datetimes and list of dataframes containing event data

Usage

labVolumesTable(
  StormName,
  StormStart,
  StormEnd,
  tableOut,
  bottlePickup,
  tzCode = "America/Chicago"
)

Arguments

StormName

vector of storm name(s)

StormStart

vector of storm start dates

StormEnd

vector of storm end dates

tableOut

list of data frames containing event data

bottlePickup

dates bottles were retrieved

tzCode

character a timezone specification for the data


Function to generate clean text file of sample amounts for lab

Description

This function accepts a vector of storm names, vector of storm start and end datetimes and list of dataframes containing event data

Usage

labVolumesTableMI(StormName, StormStart, StormEnd, tableOut, bottlePickup)

Arguments

StormName

vector of storm name(s)

StormStart

vector of storm start dates

StormEnd

vector of storm end dates

tableOut

list of data frames containing event data

bottlePickup

dates bottles were retrieved


Function to save merged data for station/storm event, saved as file, eg 434425090462401data.txt

Description

This function accepts a siteNo, StartDt and EndDt and merged data data frame for a storm event, and generates a data file

Usage

mergedDataTable(siteNo, StartDt, EndDt, adaps_data_all)

Arguments

siteNo

USGS station id

StartDt

start of storm event

EndDt

end of storm event

adaps_data_all

data frame of event data


Function to return data availability, internal or public, from NWISWeb

Description

This function accepts an NWIS gage site id

Usage

paramAvailability(siteNo)

Arguments

siteNo

NWIS gaging station id

Value

SiteFile data frame of data available for a given site from NWISWeb

Examples

## Not run: 
siteNo <- "441520088045002"
StartDt <- '2014-03-10'
EndDt <- '2014-03-17'
paramAvailability(siteNo)

## End(Not run)

Example data

Description

Example data


Function to generate text file with storm event sample bottle volume table(s) and extra info

Description

This function accepts a vector of storm names, vector of storm start and end datetimes, vector of comments (optional) and list of dataframes containing event data

Usage

stormEventsTable(
  StormName,
  StormStart,
  StormEnd,
  tableOut,
  maxBottleVol,
  bottlePickup,
  removeComment = "",
  tzCode = "America/Chicago"
)

Arguments

StormName

vector of storm name(s)

StormStart

vector of storm start dates

StormEnd

vector of storm end dates

tableOut

list of data frames containing event data

maxBottleVol

maximum bottle volume

bottlePickup

date bottles were retrieved

removeComment

vector of comments

tzCode

character a timezone specification for the data