Skip to content
Snippets Groups Projects

Ngwmn cleanups

Merged Laura A DeCicco requested to merge ldecicco-USGS:ngwmn into master

Merge request reports

Merged by avatar (Jan 9, 2025 5:21am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • I took out reference to "_wml2" in the names. I think that's not super important to the user. I also tested the timeseries parser on the USGS services. It gets the values and dates, so I think we can just make that our general "base" WaterML2 parser. We should in the future try to get the "default" behavior back in there, and see if we can make it smart enough to handle some comments that are bundled with the TVPs.

  • Created by: coveralls

    Coverage Status

    Coverage increased (+0.3%) to 88.655% when pulling 152ecda9 on ldecicco-USGS:ngwmn into 7cb2d1df on USGS-R:master.

  • Yeah, it would be nice to just abstract getting any additional fields within the TVP, if there are additional ones that I didn't code in.

  • David Watkins
    David Watkins @wwatkins started a thread on commit 152ecda9
7 7 #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character
8 8 #' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the
9 9 #' datetimes to UTC (properly accounting for daylight savings times based on the data's provided time zone offset).
10 #' Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
10 #' Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
  • David Watkins
    David Watkins @wwatkins started a thread on commit 152ecda9
  • 123 131 #' @importFrom lubridate parse_date_time
    124 132 #' @export
    125 parseWaterML2Timeseries <- function(input, asDateTime, tz) {
    126 gmlID <- xml_attr(input,"id") #TODO: make this an attribute
    127 TVP <- xml_find_all(input, ".//wml2:MeasurementTVP")#time-value pairs
    133 #' @examples
    134 #' baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
    135 #' URL <- paste(baseURL, "sites=01646500",
    136 #' "startDT=2014-09-01",
    137 #' "endDT=2014-09-08",
    138 #' "statCd=00003",
    139 #' "parameterCd=00060",sep="&")
    140 #' \dontrun{
    141 #' timesereies <- importWaterML2(URL, asDateTime=TRUE, tz="UTC")
    142 #' }
    143 importWaterML2 <- function(input, asDateTime=FALSE, tz="UTC") {
    • Do want a default tz this far down? I was going to only include that at the user-interaction level. And if so, should there be a match.arg for it? It is currently above in importNGWMN.

  • Laura A DeCicco
    Laura A DeCicco @ldecicco started a thread on commit 152ecda9
  • 7 7 #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character
    8 8 #' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the
    9 9 #' datetimes to UTC (properly accounting for daylight savings times based on the data's provided time zone offset).
    10 #' Possible values to provide are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
    10 #' Possible values are "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles",
    • It is...but in the documentation, I want to emphasize that these are the timezones that the US will almost most certainly have. That's why I changed it from "to provide" to "are".

  • Laura A DeCicco
    Laura A DeCicco @ldecicco started a thread on commit 152ecda9
  • 123 131 #' @importFrom lubridate parse_date_time
    124 132 #' @export
    125 parseWaterML2Timeseries <- function(input, asDateTime, tz) {
    126 gmlID <- xml_attr(input,"id") #TODO: make this an attribute
    127 TVP <- xml_find_all(input, ".//wml2:MeasurementTVP")#time-value pairs
    133 #' @examples
    134 #' baseURL <- "https://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
    135 #' URL <- paste(baseURL, "sites=01646500",
    136 #' "startDT=2014-09-01",
    137 #' "endDT=2014-09-08",
    138 #' "statCd=00003",
    139 #' "parameterCd=00060",sep="&")
    140 #' \dontrun{
    141 #' timesereies <- importWaterML2(URL, asDateTime=TRUE, tz="UTC")
    142 #' }
    143 importWaterML2 <- function(input, asDateTime=FALSE, tz="UTC") {
    • I left it to be consistent with the other "import" functions. It is possible people use this function as a standalone (the certainly use the other import functions for local files. As WaterML2 becomes even more popular, this function could be used on local files too).

    Please register or sign in to reply
    Loading