Skip to content

Commit

Permalink
updated description; updated readme; added to globalVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
swmpkim committed Jul 10, 2024
1 parent 886049e commit d30e5b6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 31 deletions.
11 changes: 8 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tbeptools
Title: Data and Indicators for the Tampa Bay Estuary Program
Version: 2.0.1.9024
Date: 2024-06-10
Version: 2.0.1.9025
Date: 2024-07-11
Authors@R: c(
person(given = "Marcus",
family = "Beck",
Expand Down Expand Up @@ -43,7 +43,12 @@ Authors@R: c(
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2686-0784")
)
),
person(given = "Kim",
family = "Cressman",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-8083-2434"))
)
Description: Several functions are provided for working with Tampa Bay Estuary
Program data and indicators, including the water quality report card, tidal creek
Expand Down
6 changes: 3 additions & 3 deletions R/anlz_fibwetdry.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ anlz_fibwetdry <- function(fibdata,

# now calculate
prcp_calcd <- precipdata %>%
dplyr::group_by(.data$station) %>%
dplyr::group_by(station) %>%
dplyr::mutate(rain_total = eval(formula_obj)) %>%
dplyr::rename(rain_sampleDay = .data$rain) %>%
dplyr::rename(rain_sampleDay = rain) %>%
dplyr::ungroup()


# left join, fibdata = left, prcipdata = right; on station and date
# use threshold to show wet or dry
out <- dplyr::left_join(fibdata, prcp_calcd,
by = c("station", "date")) %>%
dplyr::mutate(wet_sample = .data$rain_total >= wet_threshold)
dplyr::mutate(wet_sample = rain_total >= wet_threshold)

return(out)
}
6 changes: 5 additions & 1 deletion R/globalVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ globalVariables(c("Chlorophyll_aQ", "Latitude", "Longitude", "SampleTime", "Samp
"sumgt400", "yearfac", "nyrs", "ActivityDepthHeightMeasure.MeasureUnitCode",
"ActivityDepthHeightMeasure.MeasureValue", "chla_target", "chla_val",
"la_target", "la_val", "MonitoringLocationTypeName", "loadest", "out1",
"v", "z"))
"v", "z", "ActivityLocation.LatitudeMeasure", "ActivityLocation.LongitudeMeasure",
"ActivityStartTime.TimeZoneCode", "DetectionQuantitationLimitMeasure.MeasureValue",
"MeasureQualifierCode", "ResultLaboratoryCommentText", "V1", "V2", "V3", "Var3",
"ecocci_censored", "rain", "rain_total", "sumgt", "wet_sample")
)

#' @importFrom grDevices rgb
NULL
Expand Down
39 changes: 19 additions & 20 deletions R/read_importentero.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

read_importentero <- function(args){
# args should be a list of sites, characteristic names, and start/end dates
# should probably figure out how to make that flexible, e.g. no end date

# generate the parts
# a weakness here is building the '&' into everything but siteid -
Expand Down Expand Up @@ -63,27 +62,27 @@ read_importentero <- function(args){

# select columns
dat2 <- dat %>%
dplyr::select(station = .data$MonitoringLocationIdentifier,
Latitude = .data$ActivityLocation.LatitudeMeasure,
Longitude = .data$ActivityLocation.LongitudeMeasure,
ecocci = .data$ResultMeasureValue, # - the result (has characters in here too - 'Not Reported')
ecocci_units = .data$ResultMeasure.MeasureUnitCode,
qualifier = .data$MeasureQualifierCode,
date = .data$ActivityStartDate,
time = .data$ActivityStartTime.Time, # local time
time_zone = .data$ActivityStartTime.TimeZoneCode,
MDL = .data$DetectionQuantitationLimitMeasure.MeasureValue,
LabComments = .data$ResultLaboratoryCommentText) %>%
dplyr::select(station = MonitoringLocationIdentifier,
Latitude = ActivityLocation.LatitudeMeasure,
Longitude = ActivityLocation.LongitudeMeasure,
ecocci = ResultMeasureValue, # - the result (has characters in here too - 'Not Reported')
ecocci_units = ResultMeasure.MeasureUnitCode,
qualifier = MeasureQualifierCode,
date = ActivityStartDate,
time = ActivityStartTime.Time, # local time
time_zone = ActivityStartTime.TimeZoneCode,
MDL = DetectionQuantitationLimitMeasure.MeasureValue,
LabComments = ResultLaboratoryCommentText) %>%
dplyr::filter(ecocci != 'Not Reported') %>%
dplyr::mutate(ecocci = as.numeric(.data$ecocci),
ecocci_censored = dplyr::case_when(.data$ecocci <= .data$MDL ~ TRUE,
dplyr::mutate(ecocci = as.numeric(ecocci),
ecocci_censored = dplyr::case_when(ecocci <= MDL ~ TRUE,
.default = FALSE),
date = as.Date(.data$date),
yr = lubridate::year(.data$date),
mo = lubridate::month(.data$date)) %>%
dplyr::relocate(.data$date, .data$station, .data$ecocci) %>%
dplyr::relocate(.data$ecocci_censored, .after = ecocci) %>%
dplyr::arrange(.data$station, .data$date)
date = as.Date(date),
yr = lubridate::year(date),
mo = lubridate::month(date)) %>%
dplyr::relocate(date, station, ecocci) %>%
dplyr::relocate(ecocci_censored, .after = ecocci) %>%
dplyr::arrange(station, date)

return(dat2)
}
6 changes: 3 additions & 3 deletions R/read_importrain.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ read_importrain <- function(curyr, catch_pixels, mos = 1:12, quiet = T){
# import from the zipped file
datall <- utils::read.table(unz(tmp1, txtflnm),
sep = ',', header = F) %>%
dplyr::rename(pixel = .data$V1, date = .data$V2, rain = .data$V3)
dplyr::rename(pixel = V1, date = V2, rain = V3)

unlink(tmp1, recursive = T)


# join with grd cells, average by date, station
dat <- dplyr::left_join(catch_pixels, datall, by = 'pixel',
relationship = 'many-to-many') %>%
dplyr::group_by(.data$station, .data$date) %>%
dplyr::group_by(station, date) %>%
dplyr::summarise(
rain = mean(.data$rain, na.rm = T)
rain = mean(rain, na.rm = T)
) %>%
dplyr::ungroup()

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ Suffix descriptions:

* `attain`: Analyze functions that summarize data relative to attainment categories specific to bay segments
* `ave`, `med`: Analyze functions that summarize data into averages or medians
* `benthic`: Applies to benthic monitoring data used for the Tampa Bay Benthic Index
* `benthic`: Applies to benthic monitoring data used for the Tampa Bay Benthic Index
* `entero`: Applies to Enterococcus, a specific type of Fecal Indicator Bacteria, when `fib` functions are not applicable
* `fib`: Applies generally to Fecal Indicator Bacteria
* `fim`: Applies to data from the Fisheries Independent Monitoring program used for the Tampa Bay Nekton Index
* `form`: An intermediate function for formatting imported data for downstream analysis
* `hmp`: Functions that work with Habitat Master Plan data
Expand Down

0 comments on commit d30e5b6

Please sign in to comment.