Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions R/available-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ print_station_coverage <- function(x) {
#' @param ... ignored
#'
#' @return A tibble with columns:
#' \itemize{
#' \item STATION_NUMBER
#' \item final_start, final_end - date range for validated data
#' \item provisional_start, provisional_end - date range for provisional data
#' \item final_n, provisional_n - record counts
#' }
#' - STATION_NUMBER
#' - final_start, final_end - date range for validated data
#' - provisional_start, provisional_end - date range for provisional data
#' - final_n, provisional_n - record counts
#'
#' @method summary available
#' @export
Expand Down
32 changes: 14 additions & 18 deletions R/available.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#' ## Data Approval Status
#'
#' The `Approval` column uses ECCC's terminology
#' (see \url{https://wateroffice.ec.gc.ca/contactus/faq_e.html}):
#' (see <https://wateroffice.ec.gc.ca/contactus/faq_e.html>):
#'
#' - **"final"**: Historical data from HYDAT or web service that has been approved by ECCC.
#'
Expand All @@ -60,14 +60,12 @@
#' sources and query metadata.
#'
#' @format A tibble with 6 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{Date}{Observation date. Formatted as a Date class.}
#' \item{Parameter}{Parameter being measured. Value is "Flow"}
#' \item{Value}{Discharge value. The units are m^3/s.}
#' \item{Symbol}{Measurement/river conditions}
#' \item{Approval}{Approval status: "final" (approved) or "provisional" (subject to revision)}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **Date**: Observation date. Formatted as a Date class.
#' - **Parameter**: Parameter being measured. Value is "Flow"
#' - **Value**: Discharge value. The units are m^3/s.
#' - **Symbol**: Measurement/river conditions
#' - **Approval**: Approval status: "final" (approved) or "provisional" (subject to revision)
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -141,7 +139,7 @@ available_flows <- function(
#' ## Data Approval Status
#'
#' The `Approval` column uses ECCC's terminology
#' (see \url{https://wateroffice.ec.gc.ca/contactus/faq_e.html}):
#' (see <https://wateroffice.ec.gc.ca/contactus/faq_e.html>):
#'
#' - **"final"**: Historical data from HYDAT or web service that has been approved by ECCC.
#'
Expand All @@ -154,14 +152,12 @@ available_flows <- function(
#' sources and query metadata.
#'
#' @format A tibble with 6 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{Date}{Observation date. Formatted as a Date class.}
#' \item{Parameter}{Parameter being measured. Value is "Level"}
#' \item{Value}{Level value. The units are metres.}
#' \item{Symbol}{Measurement/river conditions}
#' \item{Approval}{Approval status: "final" (approved) or "provisional" (subject to revision)}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **Date**: Observation date. Formatted as a Date class.
#' - **Parameter**: Parameter being measured. Value is "Level"
#' - **Value**: Level value. The units are metres.
#' - **Symbol**: Measurement/river conditions
#' - **Approval**: Approval status: "final" (approved) or "provisional" (subject to revision)
#'
#' @examples
#' \dontrun{
Expand Down
54 changes: 23 additions & 31 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
#'
#'
#' @format A tibble with 5 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{STATION_NAME}{Official name for station identification}
#' \item{PROV_TERR_STATE_LOC}{The province, territory or state in which the station is located}
#' \item{HYD_STATUS}{Current status of discharge or level monitoring in the hydrometric network}
#' \item{REAL_TIME}{Logical. Indicates if a station has the capacity to deliver data in
#' real-time or near real-time}
#' \item{LATITUDE}{North-South Coordinates of the gauging station in decimal degrees}
#' \item{LONGITUDE}{East-West Coordinates of the gauging station in decimal degrees}
#' \item{station_tz}{Timezone of station calculated using the lutz package based on LAT/LONG of stations}
#' \item{standard_offset}{Offset from UTC of local standard time}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **STATION_NAME**: Official name for station identification
#' - **PROV_TERR_STATE_LOC**: The province, territory or state in which the station is located
#' - **HYD_STATUS**: Current status of discharge or level monitoring in the hydrometric network
#' - **REAL_TIME**: Logical. Indicates if a station has the capacity to deliver data in
#' real-time or near real-time
#' - **LATITUDE**: North-South Coordinates of the gauging station in decimal degrees
#' - **LONGITUDE**: East-West Coordinates of the gauging station in decimal degrees
#' - **station_tz**: Timezone of station calculated using the lutz package based on LAT/LONG of stations
#' - **standard_offset**: Offset from UTC of local standard time
#'
#' @source HYDAT, Meteorological Service of Canada datamart
"allstations"
Expand All @@ -38,11 +36,9 @@
#' A look table for data symbols
#'
#' @format A tibble with 5 rows and 3 variables:
#' \describe{
#' \item{SYMBOL_ID}{Symbol code}
#' \item{SYMBOL_EN}{Description of Symbol (English)}
#' \item{SYMBOL_FR}{Description of Symbol (French)}
#' }
#' - **SYMBOL_ID**: Symbol code
#' - **SYMBOL_EN**: Description of Symbol (English)
#' - **SYMBOL_FR**: Description of Symbol (French)
#' @family HYDAT functions
#' @source HYDAT
"hy_data_symbols"
Expand All @@ -52,28 +48,24 @@
#' A look table for data types
#'
#' @format A tibble with 5 rows and 3 variables:
#' \describe{
#' \item{DATA_TYPE}{Data type code}
#' \item{DATA_TYPE_EN}{Descriptive data type (English)}
#' \item{DATA_TYPE_FR}{Descriptive data type (French)}
#' }
#' - **DATA_TYPE**: Data type code
#' - **DATA_TYPE_EN**: Descriptive data type (English)
#' - **DATA_TYPE_FR**: Descriptive data type (French)
#' @family HYDAT functions
#'
#' @source HYDAT
"hy_data_types"

#' @title Parameter ID
#' Parameter ID
#'
#' @description A tibble of parameter id codes and their corresponding explanation/description specific to the ECCC webservice
#' A tibble of parameter id codes and their corresponding explanation/description specific to the ECCC webservice
#'
#' @format A tibble with 8 rows and 7 variables:
#' \describe{
#' \item{Parameter}{Numeric parameter code}
#' \item{Code}{Letter parameter code}
#' \item{Name_En}{Code name in English}
#' \item{Name_En}{Code name in French}
#' \item{Unit}{Parameter units}
#' }
#' - **Parameter**: Numeric parameter code
#' - **Code**: Letter parameter code
#' - **Name_En**: Code name in English
#' - **Name_En**: Code name in French
#' - **Unit**: Parameter units
#'
#'
#'
Expand Down
2 changes: 1 addition & 1 deletion R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @param dl_hydat_here Directory to the HYDAT database. The path is chosen by the `rappdirs` package and is OS specific and can be view by [hy_dir()].
#' This path is also supplied automatically to any function that uses the HYDAT database. A user specified path can be set though this is not the advised approach.
#' It also downloads the database to a directory specified by [hy_dir()].
#' @param ask Whether to ask (as \code{TRUE}/\code{FALSE}) if HYDAT should be downloaded. If \code{FALSE} the keypress question is skipped.
#' @param ask Whether to ask (as `TRUE`/`FALSE`) if HYDAT should be downloaded. If `FALSE` the keypress question is skipped.
#' @export
#'
#' @examples \dontrun{
Expand Down
86 changes: 37 additions & 49 deletions R/hy.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
#' @return A tibble of hy_stn_remarks
#'
#' @format A tibble with 4 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{REMARK_TYPE}{Type of Remark}
#' \item{Year}{Year of the remark}
#' \item{REMARK}{Remark}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **REMARK_TYPE**: Type of Remark
#' - **Year**: Year of the remark
#' - **REMARK**: Remark
#'
#' @export
#'
Expand Down Expand Up @@ -69,13 +67,11 @@ hy_stn_remarks <- function(
#' @return A tibble of hy_stn_datum_conv
#'
#' @format A tibble with 4 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{DATUM_FROM}{Identifying a datum from which water level is being converted}
#' \item{DATUM_TO}{Identifying a datum to which water level is being converted}
#' \item{CONVERSTION_FACTOR}{The conversion factor applied to water levels referred to
#' one datum to obtain water levels referred to another datum}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **DATUM_FROM**: Identifying a datum from which water level is being converted
#' - **DATUM_TO**: Identifying a datum to which water level is being converted
#' - **CONVERSTION_FACTOR**: The conversion factor applied to water levels referred to
#' one datum to obtain water levels referred to another datum
#'
#'
#' @export
Expand Down Expand Up @@ -149,12 +145,10 @@ hy_stn_datum_conv <- function(
#' @return A tibble of hy_stn_datum_unrelated
#'
#' @format A tibble with 4 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{DATUM_ID}{Unique code identifying a datum}
#' \item{Year_from}{First year of use}
#' \item{Year_to}{Last year of use}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **DATUM_ID**: Unique code identifying a datum
#' - **Year_from**: First year of use
#' - **Year_to**: Last year of use
#'
#' @export
#' @examples
Expand Down Expand Up @@ -214,14 +208,12 @@ hy_stn_datum_unrelated <- function(
#' @return A tibble of hy_stn_data_range
#'
#' @format A tibble with 6 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{DATA_TYPE}{Code for the type of data}
#' \item{SED_DATA_TYPE}{Code for the type of instantaneous sediment data}
#' \item{Year_from}{First year of use}
#' \item{Year_to}{Last year of use}
#' \item{RECORD_LENGTH}{Number of years of data available in the HYDAT database}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **DATA_TYPE**: Code for the type of data
#' - **SED_DATA_TYPE**: Code for the type of instantaneous sediment data
#' - **Year_from**: First year of use
#' - **Year_to**: Last year of use
#' - **RECORD_LENGTH**: Number of years of data available in the HYDAT database
#'
#' @family HYDAT functions
#' @source HYDAT
Expand Down Expand Up @@ -281,16 +273,14 @@ hy_stn_data_range <- function(
#' @return A tibble of hy_stn_data_coll
#'
#' @format A tibble with 6 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{DATA_TYPE}{The type of data}
#' \item{Year_from}{First year of use}
#' \item{Year_to}{Last year of use}
#' \item{MEASUREMENT}{The sampling method used in the collection of
#' sediment data or the type of the gauge used in the collection of the hydrometric data}
#' \item{OPERATION}{The schedule of station operation
#' for the collection of sediment or hydrometric data}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **DATA_TYPE**: The type of data
#' - **Year_from**: First year of use
#' - **Year_to**: Last year of use
#' - **MEASUREMENT**: The sampling method used in the collection of
#' sediment data or the type of the gauge used in the collection of the hydrometric data
#' - **OPERATION**: The schedule of station operation
#' for the collection of sediment or hydrometric data
#'
#' @family HYDAT functions
#' @source HYDAT
Expand Down Expand Up @@ -363,13 +353,11 @@ hy_stn_data_coll <- function(
#' @return A tibble of hy_stn_op_schedule
#'
#' @format A tibble with 6 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{DATA_TYPE}{The type of data}
#' \item{Year}{Year of operation schedule}
#' \item{Month_from}{First month of use}
#' \item{Month_to}{Last month of use}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **DATA_TYPE**: The type of data
#' - **Year**: Year of operation schedule
#' - **Month_from**: First month of use
#' - **Month_to**: Last month of use
#'
#' @family HYDAT functions
#' @source HYDAT
Expand Down Expand Up @@ -424,11 +412,11 @@ hy_stn_op_schedule <- function(
as.hy(stn_operation_schedule)
}

#' @title Output OS-independent path to the HYDAT sqlite database
#' Output OS-independent path to the HYDAT sqlite database
#'
#' @description Provides the download location for \link{download_hydat} in an OS independent manner.
#' Provides the download location for [download_hydat] in an OS independent manner.
#'
#' @param ... arguments potentially passed to \code{rappdirs::user_data_dir}
#' @param ... arguments potentially passed to `rappdirs::user_data_dir`
#'
#' @examples \dontrun{
#' hy_dir()
Expand All @@ -448,8 +436,8 @@ hy_dir <- function(...) {
#' AGENCY look-up Table
#'
#' @param hydat_path The path to the hydat database or NULL to use the default location
#' used by \link{download_hydat}. It is also possible to pass in an existing
#' \link[dplyr]{src_sqlite} such that the database only needs to be opened once per
#' used by [download_hydat]. It is also possible to pass in an existing
#' [src_sqlite][dplyr::src_sqlite] such that the database only needs to be opened once per
#' user-level call.
#'
#' @return A tibble of agencies
Expand Down
20 changes: 9 additions & 11 deletions R/hy_annual_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
#' @return A tibble of hy_annual_stats.
#'
#' @format A tibble with 8 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{Parameter}{Parameter being measured. Only possible values are FLOW and LEVEL}
#' \item{Year}{Year of record.}
#' \item{Sum_stat}{Summary statistic being used.}
#' \item{Value}{Value of the measurement. If Parameter equals FLOW the units are m^3/s. If Parameter equals LEVEL the
#' units are metres.}
#' \item{Date}{Observation date. Formatted as a Date class. MEAN is a annual summary
#' and therefore has an NA value for Date.}
#' \item{Symbol}{Measurement/river conditions}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **Parameter**: Parameter being measured. Only possible values are FLOW and LEVEL
#' - **Year**: Year of record.
#' - **Sum_stat**: Summary statistic being used.
#' - **Value**: Value of the measurement. If Parameter equals FLOW the units are m^3/s. If Parameter equals LEVEL the
#' units are metres.
#' - **Date**: Observation date. Formatted as a Date class. MEAN is a annual summary
#' and therefore has an NA value for Date.
#' - **Symbol**: Measurement/river conditions
#'
#' @examples
#' \dontrun{
Expand Down
12 changes: 5 additions & 7 deletions R/hy_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
#' @return A tibble of daily flows and levels
#'
#' @format A tibble with 5 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{Date}{Observation date. Formatted as a Date class.}
#' \item{Parameter}{Parameter being measured.}
#' \item{Value}{Discharge value. The units are m^3/s.}
#' \item{Symbol}{Measurement/river conditions}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **Date**: Observation date. Formatted as a Date class.
#' - **Parameter**: Parameter being measured.
#' - **Value**: Discharge value. The units are m^3/s.
#' - **Symbol**: Measurement/river conditions
#'
#' @export
#' @family HYDAT functions
Expand Down
16 changes: 7 additions & 9 deletions R/hy_daily_flows.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.

#' @title Extract daily flows information from HYDAT database or web service
#' Extract daily flows information from HYDAT database or web service
#'
#' @description Provides wrapper to turn the DLY_FLOWS table in HYDAT (or historical web service)
#' Provides wrapper to turn the DLY_FLOWS table in HYDAT (or historical web service)
#' into a tidy data frame of daily flows. `station_number` and `prov_terr_state_loc` can both be
#' supplied. If both are omitted all values from the `hy_stations` table are returned.
#' That is a large tibble for `hy_daily_flows`.
Expand All @@ -32,13 +32,11 @@
#' @return A tibble of daily flows
#'
#' @format A tibble with 5 variables:
#' \describe{
#' \item{STATION_NUMBER}{Unique 7 digit Water Survey of Canada station number}
#' \item{Date}{Observation date. Formatted as a Date class.}
#' \item{Parameter}{Parameter being measured. Only possible value is Flow}
#' \item{Value}{Discharge value. The units are m^3/s.}
#' \item{Symbol}{Measurement/river conditions}
#' }
#' - **STATION_NUMBER**: Unique 7 digit Water Survey of Canada station number
#' - **Date**: Observation date. Formatted as a Date class.
#' - **Parameter**: Parameter being measured. Only possible value is Flow
#' - **Value**: Discharge value. The units are m^3/s.
#' - **Symbol**: Measurement/river conditions
#'
#' @examples
#' \dontrun{
Expand Down
Loading