Skip to content

Commit 64cdc07

Browse files
authored
Merge pull request #28 from bcgov/formats
Formats
2 parents c68d1a3 + 16c50ff commit 64cdc07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+462
-527
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ language: R
44
sudo: false
55
cache: packages
66

7-
r_build_args: "--no-build-vignettes --no-tests"
8-
r_check_args: "--no-build-vignettes --as-cran --no-tests --no-examples"
7+
r_build_args: "--no-build-vignettes"
8+
r_check_args: "--no-build-vignettes --as-cran --no-examples"

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
Package: tidyhydat
2-
Title: Extract tidy hydrometric data
3-
Version: 0.2.6
2+
Title: Extract Tidy Canadian Hydrometric Data
3+
Version: 0.2.7
4+
Date: 2017-09-12
45
Authors@R: c(person("Sam", "Albers", email = "sam.albers@gov.bc.ca", role = c("aut", "cre"),
56
), person("Dave", "Hutchinson", email = "david.hutchinson@canada.ca", role = "ctb"))
6-
Description: tidyhydat provides functions to extract river data from Water Survey of Canada sources and make it tidy.
7+
Description: tidyhydat provides functions to extract river data from Water Survey of Canada sources (http://dd.weather.gc.ca/hydrometric/csv/ and http://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www/) and make it tidy.
78
Depends: R (>= 3.4.0)
89
License: Apache License (== 2.0) | file LICENSE
10+
URL: https://github.com/bcgov/tidyhydat
11+
BugReports: https://github.com/bcgov/tidyhydat/issues
912
Encoding: UTF-8
1013
Imports:
1114
dplyr,

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# tidyhydat 0.2.7
2+
* Updated documentation
3+
* Updated README
4+
* Created a small database so that unit testing occurs remotely (#1)
5+
* Fixed `STN_DATA_RANGE` bug (#26)
6+
17
# tidyhydat 0.2.6
28
* using `styler` package to format code to tidyverse style guide
39
* added `PROV_TERR_STATE_LOC` to `allstations`

R/MONTHLY_FLOWS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param end_date Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive.
2222
#'
2323
#' @return A tibble of monthly flows. This includes a \code{Date_occured} column which indicates the date of the \code{Sum_stat}. For MEAN and
24-
#' TOTAL this is not presented as those aren't daily values.
24+
#' TOTAL this is not presented as those are not daily values.
2525
#'
2626
#' @examples
2727
#' \donttest{

R/MONTHLY_LEVELS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param end_date Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive.
2222
#'
2323
#' @return A tibble of monthly levels. This includes a \code{Date_occured} column which indicates the date of the \code{Sum_stat}. For MEAN and
24-
#' TOTAL this is not presented as those aren't daily values.
24+
#' TOTAL this is not presented as those are not daily values.
2525
#'
2626
#' @examples
2727
#' \donttest{

R/SED_MONTHLY_LOADS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param end_date Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive.
2222
#'
2323
#' @return A tibble of monthly sediment loads. This includes a \code{Date_occured} column which indicates the date of the \code{Sum_stat}. For MEAN and
24-
#' TOTAL this is not presented as those aren't daily values.
24+
#' TOTAL this is not presented as those are not daily values.
2525
#'
2626
#' @examples
2727
#' \donttest{

R/SED_MONTHLY_SUSCON.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param end_date Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive.
2222
#'
2323
#' @return A tibble of monthly suspended sediment concentrations. This includes a \code{Date_occured} column which indicates the date of the \code{Sum_stat}. For MEAN and
24-
#' TOTAL this is not presented as those aren't daily values.
24+
#' TOTAL this is not presented as those are not daily values.
2525
#'
2626
#' @examples
2727
#' \donttest{

R/STN_.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ STN_REMARKS <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STATE_
3232
stn_remarks
3333
}
3434

35-
#' STN_DATUM_CONVERTION function
35+
#' STN_DATUM_CONVERSION function
3636
#'
37-
#' STN_DATUM_CONVERTION look-up Table
37+
#' STN_DATUM_CONVERSION look-up Table
3838
#' @inheritParams STATIONS
3939
#'
40-
#' @return A tibble of STN_DATUM_CONVERTION
40+
#' @return A tibble of STN_DATUM_CONVERSION
4141
#'
4242
#' @export
4343
#'
@@ -88,12 +88,14 @@ STN_DATA_RANGE <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STA
8888
}
8989
}
9090

91-
## Determine which stations we are querying
92-
stns <- station_choice(hydat_con, STATION_NUMBER, PROV_TERR_STATE_LOC)
91+
9392

9493
## Read on database
9594
hydat_con <- DBI::dbConnect(RSQLite::SQLite(), hydat_path)
9695

96+
## Determine which stations we are querying
97+
stns <- station_choice(hydat_con, STATION_NUMBER, PROV_TERR_STATE_LOC)
98+
9799
on.exit(DBI::dbDisconnect(hydat_con))
98100

99101
stn_data_range <- dplyr::tbl(hydat_con, "STN_DATA_RANGE") %>%
@@ -122,12 +124,12 @@ STN_DATA_RANGE <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STA
122124
}
123125
}
124126

125-
## Determine which stations we are querying
126-
stns <- station_choice(hydat_con, STATION_NUMBER, PROV_TERR_STATE_LOC)
127-
128127
## Read on database
129128
hydat_con <- DBI::dbConnect(RSQLite::SQLite(), hydat_path)
130129

130+
## Determine which stations we are querying
131+
stns <- station_choice(hydat_con, STATION_NUMBER, PROV_TERR_STATE_LOC)
132+
131133
on.exit(DBI::dbDisconnect(hydat_con))
132134

133135
stn_data_range <- dplyr::tbl(hydat_con, "STN_DATA_COLLECTION") %>%

R/data.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,32 @@
2828
# select(STATION_NUMBER, STATION_NAME) %>%
2929
# bind_rows(bcstations)
3030

31-
#' @title A tibble of BC stations and their names
31+
#' A tibble of BC stations and their names
3232
#'
33-
#' @description A shorthand to avoid having always call \code{STATIONS}. Only up to date as of 2017-07-18.
33+
#' A shorthand to avoid having always call \code{STATIONS}. Only up to date as of 2017-07-18.
3434
#'
3535
#' @source HYDAT
3636
"bcstations"
3737

3838

39-
#' @title A tibble of all Canadian Stations stations and their names.
39+
#' A tibble of all Canadian Stations stations and their names.
4040
#'
41-
#' @description A shorthand to avoid having always call \code{STATIONS}. Only up to date as of 2017-07-18.
41+
#' A shorthand to avoid having always call \code{STATIONS}. Only up to date as of 2017-07-18.
4242
#'
4343
#' @source HYDAT
4444
"allstations"
4545

4646

47-
#' @title DATA_SYMBOLS – DATA SYMBOLS look-up table
47+
#' DATA SYMBOLS look-up table
4848
#'
49-
#' @description A look table for data symbols
49+
#' A look table for data symbols
5050
#'
5151
#' @source HYDAT
5252
"DATA_SYMBOLS"
5353

54-
#' @title DATA_TYPES – DATA TYPES look-up table
54+
#' DATA TYPES look-up table
5555
#'
56-
#' @description A look table for data types
56+
#' A look table for data types
5757
#'
5858
#' @source HYDAT
5959
"DATA_TYPES"

R/download.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ download_realtime_dd <- function(STATION_NUMBER = NULL, PROV_TERR_STATE_LOC) {
170170

171171
#' download a tibble of active realtime stations
172172
#'
173-
#' An up to date dataframe of all stations in the Realtime Water Survey of Canada hydrometric network operated by Environment and Cliamte Change Canada
173+
#' An up to date dataframe of all stations in the Realtime Water Survey of Canada
174+
#' hydrometric network operated by Environment and Climate Change Canada
174175
#'
175-
#' @param PROV_TERR_STATE_LOC Province/State/Territory or Location. See examples for list of available options. realtime_network_meta() for all stations.
176+
#' @param PROV_TERR_STATE_LOC Province/State/Territory or Location. See examples for list of available options.
177+
#' realtime_network_meta() for all stations.
176178
#'
177179
#' @family realtime functions
178180
#' @export
@@ -215,7 +217,7 @@ realtime_network_meta <- function(PROV_TERR_STATE_LOC = NULL) {
215217
#' Request a token from the Environment and Climate Change Canada
216218
#' @param username Supplied by ECCC
217219
#' @param password Supplied by ECCC
218-
#' Request a token from the ECCC webservice using the POST method. This token expires after 10 minutes.
220+
#' Request a token from the ECCC web service using the POST method. This token expires after 10 minutes.
219221
#' You can only have 5 tokens out at once.
220222
#'
221223
#' @details The \code{username} and \code{password} should be treated carefully and should never be entered directly into an r script or console.
@@ -238,13 +240,13 @@ get_ws_token <- function(username, password) {
238240
r <- httr::POST("https://wateroffice.ec.gc.ca/services/auth", body = login)
239241

240242
## If the POST request was not a successful, print out why.
241-
## Possibly could provide errors as per Webservice guidelines
243+
## Possibly could provide errors as per web service guidelines
242244
if (httr::status_code(r) == 422) {
243245
stop("422 Unprocessable Entity: Username and/or password are missing or are formatted incorrectly.")
244246
}
245247

246248
if (httr::status_code(r) == 403) {
247-
stop("403 Forbidden: the webservice is denying your request. Try any of the following options: ensure you are not currently using all 5 tokens,
249+
stop("403 Forbidden: the web service is denying your request. Try any of the following options: ensure you are not currently using all 5 tokens,
248250
wait a few minutes and try again or copy the get_ws_token code and paste it directly into the console.")
249251
}
250252

@@ -260,7 +262,7 @@ get_ws_token <- function(username, password) {
260262
}
261263

262264
#' Download realtime data from the ECCC web service
263-
#' Function to actually retrieve data from ECCC webservice. Before using this function,
265+
#' Function to actually retrieve data from ECCC web service. Before using this function,
264266
#' a token from \code{get_ws_token()} is needed.
265267
#' @param STATION_NUMBER Water Survey of Canada station number.
266268
#' @param parameters parameter ID. Can take multiple entries. Parameter is a numeric code. See \code{param_id} for options. Defaults to all parameters.
@@ -330,7 +332,7 @@ download_realtime_ws <- function(STATION_NUMBER, parameters = c(46, 16, 52, 47,
330332
get_ws <- httr::GET(url_for_GET)
331333

332334
if (httr::status_code(get_ws) == 403) {
333-
stop("403 Forbidden: the webservice is denying your request. Try any of the following options: wait a few minutes and try
335+
stop("403 Forbidden: the web service is denying your request. Try any of the following options: wait a few minutes and try
334336
again or copy the get_ws_token code and paste it directly into the console.")
335337
}
336338

R/tidyhydat.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@
4141
#' \item tidy data vignette: \url{https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html}
4242
#' }
4343
#'
44-
#' To download the latest version of hydat please follow this link:
44+
#' To download the latest version of hydat please either:
4545
#' \itemize{
46-
#' \item \url{http://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www/}
46+
#' \item Follow this link \url{http://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www/} or;
47+
#' \item use the \code{download_hydat()} function.
4748
#' }
4849
#'
4950
#'

R/utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ search_number <- function(search_term) {
4040

4141
#' AGENCY_LIST function
4242
#'
43-
#' AGENCY_LIST – AGENCY look-up Table
43+
#' AGENCY look-up Table
4444
#' @param hydat_path Directory to the hydat database. Can be set as "Hydat.sqlite3" which will look for Hydat in the working directory.
4545
#' The hydat path can also be set in the \code{.Renviron} file so that it doesn't have to specified every function call. The path should
4646
#' set as the variable \code{hydat}. Open the \code{.Renviron} file using this command: \code{file.edit("~/.Renviron")}.
@@ -74,7 +74,7 @@ AGENCY_LIST <- function(hydat_path=NULL) {
7474

7575
#' REGIONAL_OFFICE_LIST function
7676
#'
77-
#' REGIONAL_OFFICE_LIST – OFFICE look-up Table
77+
#' OFFICE look-up Table
7878
#' @inheritParams AGENCY_LIST
7979
#' @return A tibble of offices
8080
#'
@@ -106,7 +106,7 @@ REGIONAL_OFFICE_LIST <- function(hydat_path=NULL) {
106106

107107
#' DATUM_LIST function
108108
#'
109-
#' DATUM_LIST – DATUM look-up Table
109+
#' DATUM look-up Table
110110
#' @inheritParams AGENCY_LIST
111111
#'
112112
#' @return A tibble of DATUMS

0 commit comments

Comments
 (0)