Commit 9e8b5300 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Merge pull request #148 from ldecicco-USGS/master

Make a consistent naming convention when dealing with reported columns.
parents 4047fb88 3886c7d2
......@@ -173,8 +173,10 @@ importRDB1 <- function(obs_url, asDateTime=FALSE, qw=FALSE, convertType = TRUE,
if(any(is.na(data[,regexpr('d$', dataType) > 0]))){
data[,paste(names(data)[regexpr('d$', dataType) > 0],"date",sep = "_")] <- as.Date(substr(rawDateTimes,1,10))
data[,paste(names(data)[regexpr('d$', dataType) > 0],"tm",sep = "_")] <- substr(rawDateTimes,12,nchar(rawDateTimes))
base.name <- names(data)[regexpr('d$', dataType) > 0]
base.name <- gsub("_dt","",base.name)
data[,paste(base.name,"date","reported",sep = "_")] <- as.Date(substr(rawDateTimes,1,10))
data[,paste(base.name,"tm","reported",sep = "_")] <- substr(rawDateTimes,12,nchar(rawDateTimes))
}
data[,regexpr('d$', dataType) > 0] <- data[,regexpr('d$', dataType) > 0] + offset*60*60
......
......@@ -101,10 +101,10 @@ readNWISuv <- function (siteNumbers,parameterCd,startDate="",endDate="", tz=""){
#' peak_cd \tab character \tab Peak Discharge-Qualification codes (see \code{comment} for more information) \cr
#' gage_ht \tab numeric \tab Gage height for the associated peak streamflow in feet \cr
#' gage_ht_cd \tab character \tab Gage height qualification codes \cr
#' year_last_pk \tab character \tab Peak streamflow reported is the highest since this year \cr
#' ag_dt \tab character \tab Date of maximum gage-height for water year (if not concurrent with peak) \cr
#' year_last_pk \tab numeric \tab Peak streamflow reported is the highest since this year \cr
#' ag_dt \tab Date \tab Date of maximum gage-height for water year (if not concurrent with peak) \cr
#' ag_tm \tab character \tab Time of maximum gage-height for water year (if not concurrent with peak) \cr
#' ag_gage_ht \tab character \tab maximum Gage height for water year in feet (if not concurrent with peak) \cr
#' ag_gage_ht \tab numeric \tab maximum Gage height for water year in feet (if not concurrent with peak) \cr
#' ag_gage_ht_cd \tab character \tab maximum Gage height code \cr
#' }
#'
......@@ -141,9 +141,12 @@ readNWISpeak <- function (siteNumbers,startDate="",endDate="", asDateTime=TRUE){
warning(length(badDates), " rows were thrown out due to incomplete dates")
}
}
data$peak_dt <- as.Date(data$peak_dt)
if("peak_dt" %in% names(data)) data$peak_dt <- as.Date(data$peak_dt, format="%Y-%m-%d")
if("ag_dt" %in% names(data)) data$ag_dt <- as.Date(data$ag_dt, format="%Y-%m-%d")
}
data$gage_ht <- as.numeric(data$gage_ht)
data$ag_gage_ht <- as.numeric(data$ag_gage_ht)
data$year_last_pk <- as.numeric(data$year_last_pk)
siteInfo <- readNWISsite(siteNumbers)
siteInfo <- left_join(unique(data[,c("agency_cd","site_no")]),siteInfo, by=c("agency_cd","site_no"))
......
......@@ -30,10 +30,10 @@ peak_va \tab numeric \tab Annual peak streamflow value in cfs \cr
peak_cd \tab character \tab Peak Discharge-Qualification codes (see \code{comment} for more information) \cr
gage_ht \tab numeric \tab Gage height for the associated peak streamflow in feet \cr
gage_ht_cd \tab character \tab Gage height qualification codes \cr
year_last_pk \tab character \tab Peak streamflow reported is the highest since this year \cr
ag_dt \tab character \tab Date of maximum gage-height for water year (if not concurrent with peak) \cr
year_last_pk \tab numeric \tab Peak streamflow reported is the highest since this year \cr
ag_dt \tab Date \tab Date of maximum gage-height for water year (if not concurrent with peak) \cr
ag_tm \tab character \tab Time of maximum gage-height for water year (if not concurrent with peak) \cr
ag_gage_ht \tab character \tab maximum Gage height for water year in feet (if not concurrent with peak) \cr
ag_gage_ht \tab numeric \tab maximum Gage height for water year in feet (if not concurrent with peak) \cr
ag_gage_ht_cd \tab character \tab maximum Gage height code \cr
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment