diff --git a/DESCRIPTION b/DESCRIPTION index d02adb0a7f84b8a9822724e1c9fdf6800d81b26d..30925fcbb8a41824dbd0c09758037f9d16116c8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dataRetrieval Type: Package Title: Retrieval functions for hydrologic data -Version: 1.3.2 +Version: 1.3.3 Date: 2014-08-04 Author: Robert M. Hirsch, Laura De Cicco Maintainer: Laura De Cicco <ldecicco@usgs.gov> diff --git a/R/getGeneralWQPData.R b/R/getGeneralWQPData.R index 9c178aa5053265c115d6813905b53684a25ee198..f163f623a7bdd04b8d148b918c04013b14f662de 100644 --- a/R/getGeneralWQPData.R +++ b/R/getGeneralWQPData.R @@ -9,9 +9,8 @@ #' (subsequent qualifier/value columns could follow depending on requested parameter codes) #' @export #' @examples -#' setInternet2(use=NA) -#' options(timeout=120) -#' pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName="pH") +#' nameToUse <- "pH" +#' pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName=nameToUse) getGeneralWQPData <- function(...){ matchReturn <- match.call() @@ -22,7 +21,7 @@ getGeneralWQPData <- function(...){ if(!all(names(matchReturn[-1]) %in% options)) warning(matchReturn[!(names(matchReturn[-1]) %in% options)],"is not a valid query parameter to the Water Quality Portal") - values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep="")))) + values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep="")))) urlCall <- paste(paste(names(values),values,sep="="),collapse="&") diff --git a/R/getNWISSites.R b/R/getNWISSites.R index 78172d2c8e72bb81f7efe3da58cc0f3405b5bd54..1b720c3806bff87ab94c41b16830d5f6d2138f92 100644 --- a/R/getNWISSites.R +++ b/R/getNWISSites.R @@ -13,7 +13,7 @@ getNWISSites <- function(...){ matchReturn <- match.call() - values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep="")))) + values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep="")))) urlCall <- paste(paste(names(values),values,sep="="),collapse="&") diff --git a/R/getWQPSites.R b/R/getWQPSites.R index 73c9e7d75a79796a1593f5511441b1ff9d0b32dc..2cf54c6d36cdf403759ba12d655086152d7d4d09 100644 --- a/R/getWQPSites.R +++ b/R/getWQPSites.R @@ -9,13 +9,10 @@ #' (subsequent qualifier/value columns could follow depending on requested parameter codes) #' @export #' @examples -#' setInternet2(use=NA) -#' options(timeout=120) -#' \dontrun{sitesList <- getWQPSites(within=10,lat=43.06932,long=-89.4444,characteristicName="pH") -#' siteListPH <- getWQPSites(characteristicName="pH")} +#' siteListPH <- getWQPSites(characteristicName="pH", statecode="US:55") getWQPSites <- function(...){ - matchReturn <- match.call() + matchReturn <- match.call(expand.dots = TRUE) options <- c("bBox","lat","long","within","countrycode","statecode","countycode","siteType","organization", "siteid","huc","sampleMedia","characteristicType","characteristicName","pCode","activityId", @@ -23,7 +20,7 @@ getWQPSites <- function(...){ if(!all(names(matchReturn[-1]) %in% options)) warning(matchReturn[!(names(matchReturn[-1]) %in% options)],"is not a valid query parameter to the Water Quality Portal") - values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep="")))) + values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep="")))) urlCall <- paste(paste(names(values),values,sep="="),collapse="&") diff --git a/R/populateDateColumns.r b/R/populateDateColumns.r index 99ac1d3ce67ba1dea9e875a01f4c6c2166a8526a..b6a5cc7d2bb97949c06836d0183b7507e5fb6682 100644 --- a/R/populateDateColumns.r +++ b/R/populateDateColumns.r @@ -6,7 +6,7 @@ #' @return DateFrame dataframe #' @export #' @examples -#' dateTime <- c('1984-01-01', '1985-01-02', '1986-01-03') +#' dateTime <- c('1984-02-28 13:56', '1984-03-01', '1986-03-01') #' expandedDateDF <- populateDateColumns(dateTime) populateDateColumns <- function(rawData){ # rawData is a vector of dates DateFrame <- as.data.frame(matrix(ncol=1,nrow=length(rawData))) @@ -17,12 +17,25 @@ populateDateColumns <- function(rawData){ # rawData is a vector of dates DateFrame$Month <- dateTime$mon + 1 DateFrame$Day <- dateTime$yday + 1 year <- dateTime$year + 1900 + hour <- dateTime$hour + minute <- dateTime$min + + if (sum(hour) == 0 & sum(minute) == 0){ + dateTime$hour <- rep(12,length(dateTime)) + } leapOffset <- ifelse((year%%4 == 0) & ((year%%100 != 0) | (year%%400 == 0)), 0,1) DateFrame$Day[DateFrame$Day > 59] <- DateFrame$Day[DateFrame$Day > 59] + leapOffset[DateFrame$Day > 59] - DateFrame$DecYear <- year + (DateFrame$Day -0.5)/366 +# DateFrame$DecYear <- year + (DateFrame$Day -0.5)/366 + + jan1 <- as.POSIXlt(paste(year,"-01-01",sep=""),format="%Y-%m-%d") + jan1NextYear <- as.POSIXlt(paste(year+1,"-01-01",sep=""),format="%Y-%m-%d") + decimal <- as.numeric(difftime(dateTime, jan1, units = "secs")) + decimal <- decimal/as.numeric(difftime(jan1NextYear, jan1, units = "secs")) + + DateFrame$DecYear <- year + decimal DateFrame$MonthSeq <- ((year-1850)*12)+DateFrame$Month return (DateFrame) diff --git a/man/getGeneralWQPData.Rd b/man/getGeneralWQPData.Rd index 6c9f32562544856b47b22eda04b99bef5e473cfd..f191f404ab752483e3ce5d370dbe97700d63f174 100644 --- a/man/getGeneralWQPData.Rd +++ b/man/getGeneralWQPData.Rd @@ -17,9 +17,8 @@ Imports data from Water Quality Portal web service. This function gets the data because it allows for other agencies rather than the USGS. } \examples{ -setInternet2(use=NA) -options(timeout=120) -pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName="pH") +nameToUse <- "pH" +pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName=nameToUse) } \keyword{WQP} \keyword{data} diff --git a/man/getWQPSites.Rd b/man/getWQPSites.Rd index 357c1f731bac22c2f15e9fe32909edef2c6430fb..4462ad23a1cb9021515e4427a58dcf5b297e8cdb 100644 --- a/man/getWQPSites.Rd +++ b/man/getWQPSites.Rd @@ -17,10 +17,7 @@ Returns a list of sites from the Water Quality Portal web service. This function Arguments to the function should be based on \url{www.waterqualitydata.us/webservices_documentation.jsp} } \examples{ -setInternet2(use=NA) -options(timeout=120) -\dontrun{sitesList <- getWQPSites(within=10,lat=43.06932,long=-89.4444,characteristicName="pH") -siteListPH <- getWQPSites(characteristicName="pH")} +siteListPH <- getWQPSites(characteristicName="pH", statecode="US:55") } \keyword{WQP} \keyword{data} diff --git a/man/populateDateColumns.Rd b/man/populateDateColumns.Rd index 8d8f3a447b686c670d31f6f938aaf03d9301dce7..9b5a10f8b0a9865476c2c7b8c342f36ab897a57d 100644 --- a/man/populateDateColumns.Rd +++ b/man/populateDateColumns.Rd @@ -15,7 +15,7 @@ DateFrame dataframe Creates various date columns for WRTDS study. } \examples{ -dateTime <- c('1984-01-01', '1985-01-02', '1986-01-03') +dateTime <- c('1984-02-28 13:56', '1984-03-01', '1986-03-01') expandedDateDF <- populateDateColumns(dateTime) } diff --git a/vignettes/dataRetrieval.log b/vignettes/dataRetrieval.log index bfdd710bbf7a8d624264c341f44edb1c31ab07c8..105be2591df3c3c3f049d5333ab8169dc829f64f 100644 --- a/vignettes/dataRetrieval.log +++ b/vignettes/dataRetrieval.log @@ -1,4 +1,4 @@ -This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9) (preloaded format=pdflatex 2014.8.7) 8 AUG 2014 15:39 +This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9) (preloaded format=pdflatex 2014.8.7) 13 AUG 2014 13:08 entering extended mode **dataRetrieval.tex (D:\LADData\RCode\dataRetrieval\vignettes\dataRetrieval.tex @@ -1022,7 +1022,7 @@ les (x86)/MiKTeX 2.9/fonts/type1/urw/courier/ucrb8a.pfb><C:/Program Files (x86) rw/helvetic/uhvr8a.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/urw/times /utmr8a.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/urw/times/utmri8a.pf b> -Output written on dataRetrieval.pdf (33 pages, 335873 bytes). +Output written on dataRetrieval.pdf (33 pages, 335831 bytes). PDF statistics: 484 PDF objects out of 1000 (max. 8388607) 84 named destinations out of 1000 (max. 500000) diff --git a/vignettes/dataRetrieval.pdf b/vignettes/dataRetrieval.pdf index f62020ecfa6e09995d9db1351c3b6d48346e33b7..ab32ac0ac6810c3430e3bd671e6b9ad7b6106028 100644 Binary files a/vignettes/dataRetrieval.pdf and b/vignettes/dataRetrieval.pdf differ diff --git a/vignettes/dataRetrieval.synctex.gz b/vignettes/dataRetrieval.synctex.gz index 0efeab0b128c449044f46dcc6562e90a11ae750f..f2742fffb97ddfdbbbc4a0d8fbf026ef220bb2ae 100644 Binary files a/vignettes/dataRetrieval.synctex.gz and b/vignettes/dataRetrieval.synctex.gz differ diff --git a/vignettes/dataRetrieval.tex b/vignettes/dataRetrieval.tex index 8b083b15c8674991b1e26c71ced91d24735c6d89..d4710d610fcb823dc5445e34f6257333b9d53bd8 100644 --- a/vignettes/dataRetrieval.tex +++ b/vignettes/dataRetrieval.tex @@ -267,7 +267,7 @@ Not every station will measure all parameters. A short list of commonly measured % latex table generated in R 3.1.1 by xtable 1.7-3 package -% Fri Aug 08 15:39:28 2014 +% Wed Aug 13 13:07:49 2014 \begin{table}[ht] \caption{Common USGS Parameter Codes} \label{tab:params} @@ -330,7 +330,7 @@ For unit values data (sensor data measured at regular time intervals such as 15 Some common codes are shown in Table \ref{tab:stat}. % latex table generated in R 3.1.1 by xtable 1.7-3 package -% Fri Aug 08 15:39:30 2014 +% Wed Aug 13 13:07:50 2014 \begin{table}[ht] \caption{Commonly used USGS Stat Codes} \label{tab:stat} @@ -411,7 +411,7 @@ To discover what data is available for a particular USGS site, including measure % latex table generated in R 3.1.1 by xtable 1.7-3 package -% Fri Aug 08 15:39:30 2014 +% Wed Aug 13 13:07:50 2014 \begin{table}[ht] \caption{Daily mean data availabile at the Choptank River near Greensboro, MD. [Some columns deleted for space considerations]} \label{tab:gda} @@ -423,7 +423,7 @@ To discover what data is available for a particular USGS site, including measure & Temperature, water & 1988-10-01 & 2012-05-09 & 894 & deg C \\ [5pt] & Temperature, water & 2010-10-01 & 2012-05-09 & 529 & deg C \\ [5pt] & Temperature, water & 2010-10-01 & 2012-05-09 & 529 & deg C \\ - [5pt] & Stream flow, mean. daily & 1948-01-01 & 2014-08-07 & 24326 & ft$^3$/s \\ + [5pt] & Stream flow, mean. daily & 1948-01-01 & 2014-08-12 & 24331 & ft$^3$/s \\ [5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\ [5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\ [5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\ @@ -789,7 +789,7 @@ There are 4750 data points, and 4750 days. % latex table generated in R 3.1.1 by xtable 1.7-3 package -% Fri Aug 08 15:39:49 2014 +% Wed Aug 13 13:08:05 2014 \begin{table}[ht] \caption{Daily dataframe} \label{tab:DailyDF1} @@ -910,7 +910,7 @@ To illustrate how the dataRetrieval package handles a more complex censoring pro % latex table generated in R 3.1.1 by xtable 1.7-3 package -% Fri Aug 08 15:39:50 2014 +% Wed Aug 13 13:08:06 2014 \begin{table}[ht] \caption{Example data} \label{tab:exampleComplexQW} @@ -955,12 +955,12 @@ For the more complex example case, let us say dp is reported as \verb@<@0.01 and 5 2005-05-30 NA 0.050 0 0.0250 56762 5 6 2005-10-30 NA 0.020 0 0.0100 56915 10 Day DecYear MonthSeq SinDY CosDY -1 46 2003 1838 0.70407 0.7101 -2 182 2003 1842 0.02575 -0.9997 -3 259 2005 1857 -0.96251 -0.2712 -4 30 2005 1861 0.48506 0.8745 -5 151 2005 1865 0.52943 -0.8484 -6 304 2006 1870 -0.87861 0.4775 +1 46 2003 1838 0.70253 0.7117 +2 182 2003 1842 0.03872 -0.9993 +3 259 2005 1857 -0.96134 -0.2754 +4 30 2005 1861 0.48251 0.8759 +5 151 2005 1865 0.54163 -0.8406 +6 304 2006 1870 -0.88205 0.4712 \end{verbatim} \end{kframe} \end{knitrout} @@ -1122,12 +1122,12 @@ There are 4750 data points, and 4750 days. 5 2000-03-23 56.917 4.0416 0.52 0.52 1 0.52 6 2000-06-05 1.812 0.5946 1.11 1.11 1 1.11 Julian Month Day DecYear MonthSeq SinDY CosDY -1 54789 1 4 2000 1801 0.06005 0.9982 -2 54819 2 34 2000 1802 0.54392 0.8391 -3 54831 2 46 2000 1802 0.70407 0.7101 -4 54835 2 50 2000 1802 0.75113 0.6602 -5 54868 3 83 2000 1803 0.98809 0.1539 -6 54942 6 157 2000 1806 0.43940 -0.8983 +1 54789 1 4 2000 1801 0.05576 0.9984 +2 54819 2 34 2000 1802 0.54031 0.8415 +3 54831 2 46 2000 1802 0.70101 0.7132 +4 54835 2 50 2000 1802 0.74829 0.6634 +5 54868 3 83 2000 1803 0.98742 0.1581 +6 54942 6 157 2000 1806 0.44325 -0.8964 \end{verbatim} \end{kframe} \end{knitrout} @@ -1351,7 +1351,7 @@ There are a few steps that are required in order to create a table in a Microsof 5 Suspended sediment discharge 1980-10-01 End Count Units 1 2012-05-09 529 deg C -2 2014-08-07 24326 ft3/s +2 2014-08-12 24331 ft3/s 3 2012-05-09 527 uS/cm @25C 4 1991-09-30 3651 mg/l 5 1991-09-30 3652 tons/day diff --git a/vignettes/figure/egretEx.pdf b/vignettes/figure/egretEx.pdf index 87cadec1ad3a1be69335e470820ad297f6615779..b19a3ca6a90f6f2c1038bf101bb85066cf226e3c 100644 Binary files a/vignettes/figure/egretEx.pdf and b/vignettes/figure/egretEx.pdf differ diff --git a/vignettes/figure/getNWIStemperaturePlot.pdf b/vignettes/figure/getNWIStemperaturePlot.pdf index 11f6561a856572a7bb74beb0de5ec46354895305..cdb9a4617bcf0656f994f4604bf05b3b7790144c 100644 Binary files a/vignettes/figure/getNWIStemperaturePlot.pdf and b/vignettes/figure/getNWIStemperaturePlot.pdf differ diff --git a/vignettes/figure/getQWtemperaturePlot.pdf b/vignettes/figure/getQWtemperaturePlot.pdf index 566673982144aab433d72e83444eb92dc9bf15f5..27d6cf946d2b0340c1d7bf9b198fb1a9c2ba7a1c 100644 Binary files a/vignettes/figure/getQWtemperaturePlot.pdf and b/vignettes/figure/getQWtemperaturePlot.pdf differ