Skip to content

Commit

Permalink
update mancofibdata and associated fib functions for simpler area sel…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
fawda123 committed Oct 15, 2024
1 parent f77959f commit 7c3b769
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 52 deletions.
63 changes: 32 additions & 31 deletions R/anlz_fibmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' All valid options for \code{areasel} for \code{fibdata} include \code{"Alafia River"}, \code{"Hillsborough River"}, \code{"Big Bend"}, \code{"Cockroach Bay"}, \code{"East Lake Outfall"}, \code{"Hillsborough Bay"}, \code{"Little Manatee"}, \code{"Lower Tampa Bay"}, \code{"McKay Bay"}, \code{"Middle Tampa Bay"}, \code{"Old Tampa Bay"}, \code{"Palm River"}, \code{"Tampa Bypass Canal"}, or \code{"Valrico Lake"}. One to any of the options can be used.
#'
#' Valid entries for \code{areasel} for \code{mancofibdata} include 'Big Slough', 'Bowlees Creek', 'Braden River', 'Bud Slough', 'Cedar Creek', 'Clay Gully', 'Cooper Creek', 'Curiosity Creek', 'Frog Creek', 'Gamble Creek', 'Gap Creek', 'Gates Creek', 'Gilley Creek', 'Hickory Hammock Creek', 'Lake Manatee', 'Little Manatee River', 'Lower Manatee River', 'Lower Tampa Bay', 'Manatee River Estuary', 'Mcmullen Creek', 'Mill Creek', 'Mud Lake Slough', 'Myakka River', 'Nonsense Creek', 'Palma Sola Bay', 'Piney Point Creek', 'Rattlesnake Slough', 'Sugarhouse Creek', 'Upper Manatee River', 'Ward Lake', or 'Williams Creek'. One to any of the options can be used.
#' Valid entries for \code{areasel} for \code{mancofibdata} include \code{"Big Slough"}, \code{"Bowlees Creek"}, \code{"Braden River"}, \code{"Bud Slough"}, \code{"Clay Gully"}, \code{"Frog Creek"}, \code{"Gap Creek"}, \code{"Little Manatee River"}, \code{"Lower Tampa Bay"}, \code{"Manatee River"}, \code{"Mcmullen Creek"}, \code{"Mud Lake Slough"}, \code{"Myakka River"}, \code{"Palma Sola Bay"}, or \code{"Piney Point Creek"}. One to any of the options can be used.
#'
#' @return A \code{data.frame} if similar to \code{fibdata} or \code{mancofibdata} if \code{assf = FALSE} with additional columns describing station categories and optionally filtered by arguments passed to the function. A \code{sf} object if \code{assf = TRUE} with additional columns for \code{\link{show_fibmap}}.
#'
Expand Down Expand Up @@ -97,40 +97,41 @@ anlz_fibmap <- function(fibdata, yrsel = NULL, mosel = NULL, areasel = NULL, ass
dplyr::filter(mo %in% mosel)
}

# filter by area, epchc
if(!is.null(areasel) & isepchc){
areasls <- list(
`Alafia River` = c('Alafia River', 'Alafia River Tributary'),
`Hillsborough River` = c('Hillsborough River', 'Hillsborough River Tributary', 'Lake Thonotosassa',
'Lake Thonotosassa Tributary', 'Lake Roberta'),
`Big Bend` = 'Big Bend',
`Cockroach Bay` = c('Cockroach Bay', 'Cockroach Bay Tributary'),
`East Lake Outfall` = 'East Lake Outfall',
`Hillsborough Bay` = c('Hillsborough Bay', 'Hillsborough Bay Tributary'),
`Little Manatee River` = c('Little Manatee River', 'Little Manatee River Tributary'),
`Lower Tampa Bay` = 'Lower Tampa Bay',
`McKay Bay` = c('McKay Bay', 'McKay Bay Tributary'),
`Middle Tampa Bay` = c('Middle Tampa Bay', 'Middle Tampa Bay Tributary'),
`Old Tampa Bay` = c('Old Tampa Bay', 'Old Tampa Bay Tributary'),
`Palm River` = c('Palm River', 'Palm River Tributary'),
`Tampa Bypass Canal` = c('Tampa Bypass Canal', 'Tampa Bypass Canal Tributary'),
`Valrico Lake` = 'Valrico Lake'
)
areasel <- match.arg(areasel, names(areasls), several.ok = TRUE)

out <- out %>%
dplyr::filter(area %in% unlist(areasls[areasel]))

}
# filter by area, epchc or manco
if(!is.null(areasel)){

if(isepchc)
areasls <- list(
`Alafia River` = c('Alafia River', 'Alafia River Tributary'),
`Hillsborough River` = c('Hillsborough River', 'Hillsborough River Tributary', 'Lake Thonotosassa',
'Lake Thonotosassa Tributary', 'Lake Roberta'),
`Big Bend` = 'Big Bend',
`Cockroach Bay` = c('Cockroach Bay', 'Cockroach Bay Tributary'),
`East Lake Outfall` = 'East Lake Outfall',
`Hillsborough Bay` = c('Hillsborough Bay', 'Hillsborough Bay Tributary'),
`Little Manatee River` = c('Little Manatee River', 'Little Manatee River Tributary'),
`Lower Tampa Bay` = 'Lower Tampa Bay',
`McKay Bay` = c('McKay Bay', 'McKay Bay Tributary'),
`Middle Tampa Bay` = c('Middle Tampa Bay', 'Middle Tampa Bay Tributary'),
`Old Tampa Bay` = c('Old Tampa Bay', 'Old Tampa Bay Tributary'),
`Palm River` = c('Palm River', 'Palm River Tributary'),
`Tampa Bypass Canal` = c('Tampa Bypass Canal', 'Tampa Bypass Canal Tributary'),
`Valrico Lake` = 'Valrico Lake'
)

# filter by area, manatee county
if(!is.null(areasel) & ismanco){
areas <- sort(unique(mancofibdata$area))
if(ismanco){
areasls <- c("Big Slough", "Bowlees Creek", "Braden River", "Bud Slough",
"Clay Gully", "Frog Creek", "Gap Creek", "Little Manatee River",
"Lower Tampa Bay", "Manatee River", "Mcmullen Creek", "Mud Lake Slough",
"Myakka River", "Palma Sola Bay", "Piney Point Creek")
names(areasls) <- areasls
areasls <- as.list(areasls)
}

areasel <- match.arg(areasel, areas, several.ok = TRUE)
areasel <- match.arg(areasel, names(areasls), several.ok = TRUE)

out <- out %>%
dplyr::filter(area %in% areasel)
dplyr::filter(area %in% unlist(areasls[areasel]))

}

Expand Down
36 changes: 26 additions & 10 deletions R/read_formwqp.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @return A data frame containing formatted water quality and station metadata
#'
#' @details This function is used by \code{\link{read_importwqp}} to combine, format, and process data (\code{res}) and station metadata (\code{sta}) obtained from the Water Quality Portal for the selected county and data type. The resulting data frame includes the date, time, station identifier, latitude, longitude, variable name, value, unit, and quality flag. Manatee County FIB data (21FLMANA_WQX) will also include an \code{area} column indicating the waterbody name as used by the USF Water Atlas.
#' @details This function is used by \code{\link{read_importwqp}} to combine, format, and process data (\code{res}) and station metadata (\code{sta}) obtained from the Water Quality Portal for the selected county and data type. The resulting data frame includes the date, time, station identifier, latitude, longitude, variable name, value, unit, and quality flag. Manatee County FIB data (21FLMANA_WQX) will also include an \code{area} column indicating the waterbody name as used by the USF Water Atlas, with some area aggregations.
#'
#' @concept read
#'
Expand Down Expand Up @@ -194,13 +194,13 @@ read_formwqp <- function(res, sta, org, type, trace = F){
if(type == 'fib' & org == '21FLMANA_WQX'){

tomtch <- data.frame(
station = c("396", "BC1", "BC2", "BC41",
"BL01", "BL201", "BR1", "BR2", "BR3", "BU01A", "CC1", "CH1",
"D1", "D3", "ER1", "ER2", "FC1", "GA1", "GC1", "GC2", "GP", "LL1",
"LM3", "LM4", "LM5", "LM6", "MC1", "MC2", "MM", "MR1", "MR2",
"MS01", "MS02", "MY01", "MY02A", "MY04", "PP1", "SC1", "TS1",
"TS2", "TS3", "TS4", "TS5", "TS6", "TS7", "UM1", "UM2", "UM3",
"UM4", "WC1"),
station = c("396", "BC1", "BC2", "BC41", "BL01",
"BL201", "BR1", "BR2", "BR3", "BU01A", "CC1", "CH1", "D1", "D3",
"ER1", "ER2", "FC1", "GA1", "GC1", "GC2", "GP", "LL1", "LM3",
"LM4", "LM5", "LM6", "MC1", "MC2", "MM", "MR1", "MR2", "MS01",
"MS02", "MY01", "MY02A", "MY04", "PP1", "SC1", "TS1", "TS2",
"TS3", "TS4", "TS5", "TS6", "TS7", "UM1", "UM2", "UM3", "UM4",
"WC1"),
area = c("Lower Tampa Bay", "Bowlees Creek", "Bowlees Creek",
"Bowlees Creek", "Big Slough", "Big Slough", "Braden River",
"Braden River", "Braden River", "Bud Slough", "Curiosity Creek",
Expand All @@ -213,10 +213,26 @@ read_formwqp <- function(res, sta, org, type, trace = F){
"Myakka River", "Piney Point Creek", "Sugarhouse Creek", "Rattlesnake Slough",
"Cedar Creek", "Cooper Creek", "Cooper Creek", "Hickory Hammock Creek",
"Braden River", "Nonsense Creek", "Lower Manatee River", "Lake Manatee",
"Gilley Creek", "Upper Manatee River", "Williams Creek")
"Gilley Creek", "Upper Manatee River", "Williams Creek"),
areacmb = c("Lower Tampa Bay",
"Bowlees Creek", "Bowlees Creek", "Bowlees Creek", "Big Slough",
"Big Slough", "Braden River", "Braden River", "Braden River",
"Bud Slough", "Little Manatee River", "Palma Sola Bay", "Little Manatee River",
"Little Manatee River", "Braden River", "Braden River", "Frog Creek",
"Manatee River", "Manatee River", "Manatee River", "Gap Creek",
"Braden River", "Braden River", "Manatee River", "Manatee River",
"Manatee River", "Manatee River", "Manatee River", "Mcmullen Creek",
"Clay Gully", "Myakka River", "Mud Lake Slough", "Mud Lake Slough",
"Myakka River", "Myakka River", "Myakka River", "Piney Point Creek",
"Braden River", "Braden River", "Braden River", "Braden River",
"Braden River", "Braden River", "Braden River", "Braden River",
"Manatee River", "Manatee River", "Manatee River", "Manatee River",
"Braden River")
)

out <- dplyr::left_join(out, tomtch, by = 'station', relationship = 'many-to-one')
out <- dplyr::left_join(out, tomtch, by = 'station', relationship = 'many-to-one') %>%
dplyr::select(-area) %>%
dplyr::rename(area = areacmb)

}

Expand Down
12 changes: 4 additions & 8 deletions R/show_fibmatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#'
#' If the input to \code{fibdata} is from EPCHC (from \code{\link{read_importfib}}), valid entries for \code{areasel} include 'Alafia River', 'Hillsborough River', 'Big Bend', 'Cockroach Bay', 'East Lake Outfall', 'Hillsborough Bay', 'Little Manatee River', 'Lower Tampa Bay', 'McKay Bay', 'Middle Tampa Bay', 'Old Tampa Bay', 'Palm River', 'Tampa Bypass Canal', and 'Valrico Lake'. If the input data is not from EPCHC (from \code{\link{read_importentero}}), valid entries for \code{areasel} include 'OTB', 'HB', 'MTB', 'LTB', 'BCB', and 'MR'.
#'
#' Input from \code{\link{read_importwqp}} for Manatee County (21FLMANA_WQX) FIB data can also be used. The function has not been tested for other organizations. Valid entries for \code{areasel} include 'Big Slough', 'Bowlees Creek', 'Braden River', 'Bud Slough', 'Cedar Creek', 'Clay Gully', 'Cooper Creek', 'Curiosity Creek', 'Frog Creek', 'Gamble Creek', 'Gap Creek', 'Gates Creek', 'Gilley Creek', 'Hickory Hammock Creek', 'Lake Manatee', 'Little Manatee River', 'Lower Manatee River', 'Lower Tampa Bay', 'Manatee River Estuary', 'Mcmullen Creek', 'Mill Creek', 'Mud Lake Slough', 'Myakka River', 'Nonsense Creek', 'Palma Sola Bay', 'Piney Point Creek', 'Rattlesnake Slough', 'Sugarhouse Creek', 'Upper Manatee River', 'Ward Lake', or 'Williams Creek'
#' Input from \code{\link{read_importwqp}} for Manatee County (21FLMANA_WQX) FIB data can also be used. The function has not been tested for other organizations. Valid entries for \code{areasel} include \code{"Big Slough"}, \code{"Bowlees Creek"}, \code{"Braden River"}, \code{"Bud Slough"}, \code{"Clay Gully"}, \code{"Frog Creek"}, \code{"Gap Creek"}, \code{"Little Manatee River"}, \code{"Lower Tampa Bay"}, \code{"Manatee River"}, \code{"Mcmullen Creek"}, \code{"Mud Lake Slough"}, \code{"Myakka River"}, \code{"Palma Sola Bay"}, or \code{"Piney Point Creek"}.
#'
#' Bay segment matrix categories can be shown if input data are from \code{\link{read_importentero}}). Stations for these data were chosen specifically as downstream endpoints for each bay segment, whereas the other datasets are not appropriate for estimating bay segment outcomes.
#'
Expand Down Expand Up @@ -116,13 +116,9 @@ show_fibmatmap <- function(fibdata, yrsel, areasel, indic, threshold = NULL,

# check areas
areas <- c("Big Slough", "Bowlees Creek", "Braden River", "Bud Slough",
"Cedar Creek", "Clay Gully", "Cooper Creek", "Curiosity Creek",
"Frog Creek", "Gamble Creek", "Gap Creek", "Gates Creek", "Gilley Creek",
"Hickory Hammock Creek", "Lake Manatee", "Little Manatee River",
"Lower Manatee River", "Lower Tampa Bay", "Manatee River Estuary",
"Mcmullen Creek", "Mill Creek", "Mud Lake Slough", "Myakka River",
"Nonsense Creek", "Palma Sola Bay", "Piney Point Creek", "Rattlesnake Slough",
"Sugarhouse Creek", "Upper Manatee River", "Ward Lake", "Williams Creek")
"Clay Gully", "Frog Creek", "Gap Creek", "Little Manatee River",
"Lower Tampa Bay", "Manatee River", "Mcmullen Creek", "Mud Lake Slough",
"Myakka River", "Palma Sola Bay", "Piney Point Creek")

chk <- !areasel %in% areas
if(any(chk)){
Expand Down
Binary file modified data/mancofibdata.RData
Binary file not shown.
2 changes: 1 addition & 1 deletion man/anlz_fibmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/read_formwqp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/show_fibmatmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7c3b769

Please sign in to comment.