Title: | Create BC Groundwater Level Reports |
---|---|
Description: | Fetch data, calculate historical percentiles and create reports of BC groundwater levels for set dates. |
Authors: | Steffi LaZerte [aut, cre] , Jon Goetz [aut] |
Maintainer: | Steffi LaZerte <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.0.0.9000 |
Built: | 2024-11-05 04:59:21 UTC |
Source: | https://github.com/bcgov/bcgwlreports |
Create reproducible reports of current groundwater statuses.
Removes data cache
clean_cache()
clean_cache()
# clean_cache()
# clean_cache()
Get a list of all wells from a natural resource region or area.
get_obs_in_area( nr_area = c("North Natural Resource Area", "South Coast Region", "South Natural Resource Area", "West Coast Region"), rm_well = NA )
get_obs_in_area( nr_area = c("North Natural Resource Area", "South Coast Region", "South Natural Resource Area", "West Coast Region"), rm_well = NA )
nr_area |
List one or multiple of c("North Natural Resource Area", "South Coast Region", "South Natural Resource Area", "West Coast Region") |
rm_well |
Exclude specific wells. |
Create both percentiles and historical plot with selected observation wells
gw_both_plots(data, ows = NA, water_year_start = 10)
gw_both_plots(data, ows = NA, water_year_start = 10)
data |
Data object created from |
ows |
List a specific well to plot from original listed wells (exports just this well) |
Create a percentiles map with selected observation wells
gw_conditions( ows = NA, report_dates = Sys.Date(), n_days = 14, years_min = 5, cache_age = 7 )
gw_conditions( ows = NA, report_dates = Sys.Date(), n_days = 14, years_min = 5, cache_age = 7 )
ows |
Character vector. Observation well numbers (e.g, "OW000"). Set to NA for all wells (default). |
report_dates |
Character vector. Only one date for this function. Default Sys.Date(). |
n_days |
Numeric. If there is no data on the report date chosen, this is the range of days over which to look for alternative dates with data. Defaults to 2 weeks, meaning 2 weeks before and 2 weeks after a given report date, for a total window of 4 weeks. |
years_min |
Numeric. Minimum number of years required to to calculate a percentiles |
cache_age |
Logical. Maximum age in days of cached datasets (not obs well data, but metadata related to regional maps, aquifer and wells). |
Create a percentiles map with selected observation wells
gw_conditions_save( ows = NA, report_dates = Sys.Date(), n_days = 14, years_min = 5, cache_age = 7, save_plots = FALSE, csv_dir = "", plots_dir = "" )
gw_conditions_save( ows = NA, report_dates = Sys.Date(), n_days = 14, years_min = 5, cache_age = 7, save_plots = FALSE, csv_dir = "", plots_dir = "" )
ows |
Character vector. Observation well numbers (e.g, "OW000"). Set to NA for all wells (default). |
report_dates |
Character vector. Only one date for this function. Default Sys.Date(). |
n_days |
Numeric. If there is no data on the report date chosen, this is the range of days over which to look for alternative dates with data. Defaults to 2 weeks, meaning 2 weeks before and 2 weeks after a given report date, for a total window of 4 weeks. |
years_min |
Numeric. Minimum number of years required to to calculate a percentiles |
cache_age |
Logical. Maximum age in days of cached datasets (not obs well data, but metadata related to regional maps, aquifer and wells). |
Prepare well data for creating table and plots
gw_data_prep( ows, report_dates = Sys.Date(), remarks = NULL, n_days = 14, years_min = 5, cache_age = 7, water_year_start = 10 )
gw_data_prep( ows, report_dates = Sys.Date(), remarks = NULL, n_days = 14, years_min = 5, cache_age = 7, water_year_start = 10 )
ows |
Character vector. Observation well numbers (e.g, "OW000") |
report_dates |
Character vector. Two current dates to explore. By default a date 2 week ago and 4 weeks before that are used. |
remarks |
Character / data frame. Path to file OR data frame containing remarks on specific observation wells to be included in the main summary table (see Details). |
n_days |
Numeric. If there is no data on the report date chosen, this is the range of days over which to look for alternative dates with data. Defaults to 2 weeks, meaning 2 weeks before and 2 weeks after a given report date, for a total window of 4 weeks. |
years_min |
Numeric. Minimum number of years required to to calculate a percentiles |
cache_age |
Logical. Maximum age in days of cached datasets (not obs well data, but metadata related to regional maps, aquifer and wells). |
remarks
can be a file path to a TSV (tab-separated) text file or
Excel file contain columns 'ow' and 'remarks', or it can be a
data.frame()
/tibble()
(see examples) containing the same. Note that CSV
is not permitted as ',' is used for separating variables which can make it
difficult to write out complete, complex remarks.
## Not run: wells <- c('OW400') gw_data <- gw_data_prep(ows = wells) ## End(Not run)
## Not run: wells <- c('OW400') gw_data <- gw_data_prep(ows = wells) ## End(Not run)
Create historical data plot with selected observation wells
gw_historic_data_plot(data, ows = NA)
gw_historic_data_plot(data, ows = NA)
data |
Data object created from |
ows |
List a specific well to plot from original listed wells (exports just this well) |
Create a percentiles class table with selected observation wells
gw_percentile_class_table(data, gt = TRUE)
gw_percentile_class_table(data, gt = TRUE)
data |
Data object created from |
gt |
Make the table gt format (TRUE) or a regular data.frame (FALSE) |
Create a percentiles map with selected observation wells
gw_percentile_map(data)
gw_percentile_map(data)
data |
Data object created from |
Create a wells percentiles details with selected observation wells
gw_percentiles_details_table(data, gt = TRUE)
gw_percentiles_details_table(data, gt = TRUE)
data |
Data object created from |
gt |
Make the table gt format (TRUE) or a regular data.frame (FALSE) |
Create an annual hydrograph with percentiles plot with selected observation wells
gw_percentiles_plot(data, ows = NA)
gw_percentiles_plot(data, ows = NA)
data |
Data object created from |
ows |
List a specific well to plot from original listed wells (exports just this well) |
Create a wells below normal table with selected observation wells
gw_wells_below_normal_table( data, which = c("totals", "hydraulic_connectivity", "type")[1], gt = TRUE )
gw_wells_below_normal_table( data, which = c("totals", "hydraulic_connectivity", "type")[1], gt = TRUE )
data |
Data object created from |
which |
Which group to filter by: "totals" for all, 'hydraulic_connectivity' or 'type' for aquifer type. |
gt |
Make the table gt format (TRUE) or a regular data.frame (FALSE) |
Compile report
well_report( ows, name = "report", report_dates = c(Sys.Date() - lubridate::weeks(2), Sys.Date() - lubridate::weeks(4)), title = NULL, description = NULL, remarks = NULL, n_days = 13, years_min = 5, out_dir = ".", cache_age = 7, water_year_start = 10 )
well_report( ows, name = "report", report_dates = c(Sys.Date() - lubridate::weeks(2), Sys.Date() - lubridate::weeks(4)), title = NULL, description = NULL, remarks = NULL, n_days = 13, years_min = 5, out_dir = ".", cache_age = 7, water_year_start = 10 )
ows |
Character vector. Observation well numbers (e.g, "OW000") |
name |
Character string. Short text to name the file. Will become
|
report_dates |
Character vector. Two current dates to explore. By default a date 2 week ago and 4 weeks before that are used. |
title |
Character. Title of the report. |
description |
Character. Descriptive paragraph to place at the start. |
remarks |
Character / data frame. Path to file OR data frame containing remarks on specific observation wells to be included in the main summary table (see Details). |
n_days |
Numeric. If there is no data on the report date chosen, this is the range of days over which to look for alternative dates with data. Defaults to 2 weeks, meaning 2 weeks before and 2 weeks after a given report date, for a total window of 4 weeks. |
years_min |
Numeric. Minimum number of years required to to calculate a percentiles |
out_dir |
Character. Location of output report. Defaults to working directory. |
cache_age |
Logical. Maximum age in days of cached datasets (not obs well data, but metadata related to regional maps, aquifer and wells). |
remarks
can be a file path to a TSV (tab-separated) text file or
Excel file contain columns 'ow' and 'remarks', or it can be a
data.frame()
/tibble()
(see examples) containing the same. Note that CSV
is not permitted as ',' is used for separating variables which can make it
difficult to write out complete, complex remarks.
## Not run: well_report(ows = c("OW008", "OW217", "OW377", "OW197")) # If short, easiest to add remarks in script: library(dplyr) remarks <- tribble(~ow, ~remarks, "OW377", "Construction in the area disrupting measurements", "OW008", "No problems") well_report(ows = c("OW008", "OW217", "OW377", "OW197"), remarks = remarks) # Or load from a file library(readr) write_tsv(remarks, "remarks.txt") check_remarks(remarks = "remarks.txt") ## End(Not run)
## Not run: well_report(ows = c("OW008", "OW217", "OW377", "OW197")) # If short, easiest to add remarks in script: library(dplyr) remarks <- tribble(~ow, ~remarks, "OW377", "Construction in the area disrupting measurements", "OW008", "No problems") well_report(ows = c("OW008", "OW217", "OW377", "OW197"), remarks = remarks) # Or load from a file library(readr) write_tsv(remarks, "remarks.txt") check_remarks(remarks = "remarks.txt") ## End(Not run)