Skip to content

Commit

Permalink
add st pete facilities as separate to facilities
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Jan 30, 2024
1 parent 5ad3692 commit a315fdc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(util_dps_checkuni)
export(util_dps_entfacseg)
importFrom(dplyr,"%>%")
importFrom(dplyr,case_when)
importFrom(dplyr,contains)
importFrom(dplyr,filter)
importFrom(dplyr,matches)
importFrom(dplyr,mutate)
Expand Down
33 changes: 18 additions & 15 deletions R/util_dps_entfacseg.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,47 @@
#' Get DPS entity, facility, and bay segment from file name
#'
#' @param pth path to raw entity data
#' @param asdf logical, if \code{TRUE} return as \code{data.frame}
#'
#' @export
#'
#' @details Bay segment is an integer with values of 1, 2, 3, 4, 5, 6, 7, and 55 for Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Boca Ciega Bay, Terra Ceia Bay, Manatee River, and Boca Ciega Bay South, respectively.
#'
#'
#' @importFrom dplyr filter pull
#' @importFrom dplyr filter pull select
#'
#' @return A list with entity, facility, and bay segment
#'
#' @examples
#' pth <- system.file('extdata/ps_dom_hillsco_falkenburg_2019.txt', package = 'tbeploads')
#' util_dps_entfacseg(pth)
util_dps_entfacseg <- function(pth){
util_dps_entfacseg <- function(pth, asdf = FALSE){

# get entity and facility from path
entfac <- basename(pth) %>%
flentfac <- basename(pth) %>%
gsub('\\.txt$', '', .) %>%
strsplit('_') %>%
.[[1]] %>%
.[c(3, 4)]

ent <- facilities %>%
filter(entityshr == entfac[1]) %>%
pull(entity) %>%
entfac <- facilities %>%
filter(entityshr == flentfac[1] & facnameshr == flentfac[2]) %>%
select(-source) %>%
unique()

fac <- facilities %>%
filter(facnameshr == entfac[2]) %>%
pull(facname) %>%
unique()
ent <- entfac %>%
pull(entity)

seg <- facilities %>%
filter(entity == ent & facname == fac) %>%
pull(bayseg) %>%
unique()
fac <- entfac %>%
pull(facname)

seg <- entfac %>%
pull(bayseg)

out <- list(entity = ent, facname = fac, bayseg = seg)

out <- list(ent = ent, fac = fac, seg = seg)
if(asdf)
out <- as.data.frame(out)

return(out)

Expand Down
12 changes: 12 additions & 0 deletions data-raw/facilities.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(haven)
library(dplyr)
library(tibble)

pth <- 'T:/03_BOARDS_COMMITTEES/05_TBNMC/2022_RA_Update/01_FUNDING_OUT/DELIVERABLES/TO-9/datastick_deliverables/2017-2021LUEntityLoads/'

Expand Down Expand Up @@ -128,6 +129,17 @@ dpsfac <- read_sas(paste0(pth, '2017-2021DPSMonthlyEntityBasin/dps1721monthentba
)
)

# add dps st pete facilities
stpete <- tribble(
~bayseg, ~basin, ~entity, ~facname, ~source, ~entityshr, ~facnameshr, ~permit, ~facid,
1, '206-1', 'St. Petersburg', 'City of St. Petersburg Northeast WRF', 'PS - Domestic - REUSE', 'stpete', 'ne', 'FLA128856', 'PC159',
5, '207-5', 'St. Petersburg', 'City of St. Petersburg Northwest WRF', 'PS - Domestic - REUSE', 'stpete', 'nw', 'FLA128821', 'PC156',
55, '207-5', 'St. Petersburg', 'City of St. Petersburg Southwest WRF', 'PS - Domestic - REUSE', 'stpete', 'sw', 'FLA128848', 'PC158'
)

dpsfac <- dpsfac %>%
bind_rows(stpete)

facilities <- bind_rows(ipsfac, dpsfac) %>%
arrange(entity, facname)

Expand Down
Binary file modified data/facilities.rda
Binary file not shown.
4 changes: 3 additions & 1 deletion man/util_dps_entfacseg.Rd

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

0 comments on commit a315fdc

Please sign in to comment.