Repository navigation
V1 #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
V1 #926
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2f1308d
Switch to v1
ldecicco-USGS a7f4492
Add news
ldecicco-USGS f4cc62a
Fix tests
ldecicco-USGS d8888ba
Fix tests
ldecicco-USGS e531b62
Merge branch 'main' of github.com:DOI-USGS/dataRetrieval into v1
ldecicco-USGS 73306da
Update monitoring_location to convert dates if convertType
ldecicco-USGS 69c83ac
the pcode_to_name doesn't work anymore
ldecicco-USGS 91dbdd8
ugg
ldecicco-USGS b3145f5
fix tests
ldecicco-USGS 0252a4a
take out WQP tests until things are stabilized
ldecicco-USGS ff0284d
regenerate readme
ldecicco-USGS 25dd2c7
Fix any sketchy URLs
ldecicco-USGS a3fda31
upstream
ldecicco-USGS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,24 @@ | ||
| #' Parameter code to characteristic name | ||
| #' | ||
| #' This function is useful to fine what characteristic name, result sample | ||
| #' fraction, unit code, and other parameters are mapped with USGS parameter | ||
| #' codes. This information is useful for converting workflows from a more | ||
| #' traditional NWIS water quality retrieval to a Water Quality Portal retrieval. | ||
| #' This function no longer works because the underlying service | ||
| #' has been removed. Similar functionality can be found with | ||
| #' `check_waterdata_sample_params`. | ||
| #' | ||
| #' @export | ||
| #' @param parameterCd character that contains the code for a character vector | ||
| #' of 5-digit parameter codes. Default is "all" which will return a complete | ||
| #' list of parameter codes that have been mapped to a characteristic name. | ||
| #' @return a data frame with columns "parm_cd", "description", | ||
| #' "characteristicname", "measureunitcode", "resultsamplefraction", | ||
| #' "resulttemperaturebasis", "resultstatisticalbasis", "resulttimebasis", | ||
| #' "resultweightbasis", "resultparticlesizebasis", "last_rev_dt" | ||
| #' of 5-digit parameter codes. | ||
| #' @examples | ||
| #' pcodes <- c("00070", "00075", "00430", "52642") | ||
| #' \donttest{ | ||
| #' | ||
| #' all <- pcode_to_name() | ||
| #' some <- pcode_to_name(pcodes) | ||
| #' all_new <- read_waterdata_parameter_codes(parameter_code = pcodes) | ||
| #' ref_list <- check_waterdata_sample_params("reference-list") | ||
| #' ref_list_sm <- ref_list[ref_list$parm_cd %in% pcodes, ] | ||
| #' | ||
| #' } | ||
| pcode_to_name <- function(parameterCd = "all") { | ||
| parameterCd.orig <- parameterCd | ||
| parameterCd <- parameterCd[!is.na(parameterCd)] | ||
|
|
||
| url_all <- "https://www.waterqualitydata.us/Codes/public_srsnames/?mimeType=json" | ||
| doc <- get_nldi_sources(url_all) | ||
| retval <- doc[["pcodes"]] | ||
|
|
||
| if (all(tolower(parameterCd) != "all")) { | ||
| retval <- retval[retval$parm_cd %in% parameterCd, ] | ||
| } | ||
|
|
||
| attr(retval, "url") <- url_all | ||
|
|
||
| if (any(parameterCd != "all")) { | ||
| if (nrow(retval) != length(unique(parameterCd))) { | ||
| badPcode <- parameterCd[!(parameterCd %in% retval$parm_cd)] | ||
| warning( | ||
| "The following pCodes seem mistyped, and no information was returned: ", | ||
| paste(badPcode, collapse = ", ") | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| if (nrow(retval) != sum(is.na(parameterCd.orig))) { | ||
| na.params <- data.frame(matrix( | ||
| ncol = ncol(retval), | ||
| nrow = sum(is.na(parameterCd.orig)) | ||
| )) | ||
| names(na.params) <- names(retval) | ||
| retval <- rbind(retval, na.params) | ||
| } | ||
|
|
||
| # order by parameterCd.orig | ||
| if (!isTRUE(parameterCd.orig == "all")) { | ||
| retval <- retval[match(parameterCd.orig, retval$parm_cd), ] | ||
| retval$parm_cd <- parameterCd.orig | ||
| } | ||
|
|
||
| return(retval) | ||
| .Deprecated( | ||
| new = "check_waterdata_sample_params", | ||
| package = "dataRetrieval", | ||
| msg = "Convert to check_waterdata_sample_params('reference-list')." | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a planned date for when they'll be removed entirely? If we have a date, might be handy to put here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~June, but I'm trying to thread the needle of not freaking people out about V0 (which is mostly a non-event) before WaterServices is decommissioned (which is a much bigger event) -- so we haven't announced more specifics than that yet. (I also haven't thought about it a ton yet, either)