Skip to content

Commit

Permalink
Added DOP water quality data
Browse files Browse the repository at this point in the history
  • Loading branch information
rosehartman committed Feb 27, 2024
1 parent 6ff0e3a commit 2be0229
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 13 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# discretewq (development version)

# discretewq 2.4.1

* Added DOP water quality data.


# discretewq 2.4.0

* Added temperature and conductivity to `USGS_CAWSC`
Expand Down
37 changes: 37 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,43 @@
"YBFMP"



# DOP -------------------------------------------------------------------

#' Directed Outflow Project water quality data
#'
#' Water quality data from the ICF/USBR Directed Outflow Project.
#'
#' @encoding UTF-8
#' @format a tibble with 5491 rows and 18 variables
#' \describe{
#' \item{Source}{Name of the source dataset.}
#' \item{Station}{Station where sample was collected.}
#' \item{Latitude}{Latitude at start of zooplankton tow in decimal degrees.}
#' \item{Longitude}{Longitude at start of zooplankton tow in decimal degrees.}
#' \item{Field_coords}{Flag indicating GPS coordinates were taken in the field, rather than at pre-determined stations.}
#' \item{Date}{Date sample was collected.}
#' \item{Datetime}{Date and time sample was collected.}
#' \item{Depth}{Depth at start of trawl (m)}
#' \item{Salinity}{Salinity at depth of trawl in PSU}
#' \item{Secchi}{Secchi depth (cm).}
#' \item{Turbidity}{Turbidity at depth of tow in FNU}
#' \item{Temperature}{Temperature (°C) at depth of tow.}
#' \item{Conductivity}{Specific conductance (\eqn{\mu}S \ifelse{html}{\out{cm<sup>-1</sup>}}{\eqn{cm^{-1}}}) at depth of tow.}
#' \item{DissolvedOxygen}{Dissolved oxygen (mg/L) at depth of two.}
#' \item{pH}{pH (dimensionless) at depth of tow.}
#' \item{DOC}{Dissolved Organic Carbon (mg/L)}
#' \item{Chlorophyll}{Chlorophyll-a concentration (\eqn{\mu}g \ifelse{html}{\out{L<sup>-1</sup>}}{\eqn{L^{-1}}})}
#' \item{DissNitrateNitrite}{Dissolved Nitrate and Nitrite (mg/L).}
#' \item{DissAmmonia}{Dissolved Ammonia (mg/L).}
#' \item{DissOrthophos}{Dissolved Ortho-phosphate (mg/L).}
#' }
#'
#' @details More metadata and information on methods are available \href{https://portal.edirepository.org/nis/metadataviewer?packageid=edi.494.2}{here} and \href{https://portal.edirepository.org/nis/metadataviewer?packageid=edi.233.3}{here}.
#' @seealso \code{\link{wq}}
"DOP"


# Internal Documentation --------------------------------------------------

#' @title Sign Variables
Expand Down
11 changes: 9 additions & 2 deletions R/wq.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#' "Suisun" (Suisun Marsh Fish Study, \code{\link{suisun}}),
#' "USBR" (United States Bureau of Reclamation Sacramento Deepwater Ship Channel data, \code{\link{USBR}}),
#' "USGS_CAWSC" (USGS California Water Science Center monitoring data, \code{\link{USGS_CAWSC}}),
#' "USGS_SFBS" (USGS San Francisco Bay Surveys, \code{\link{USGS_SFBS}}), and
#' "YBFMP" (Yolo Bypass Fish Monitoring Program, \code{\link{YBFMP}}).
#' "USGS_SFBS" (USGS San Francisco Bay Surveys, \code{\link{USGS_SFBS}})
#' "YBFMP" (Yolo Bypass Fish Monitoring Program, \code{\link{YBFMP}}), and
#' "DOP" (Directed Outflow Proejct \code{\link{DOP}})).
#' @param Start_year Earliest year you would like included in the dataset. Must be an integer. Defaults to year \code{0}.
#' @param End_year Latest year you would like included in the dataset. Must be an integer. Defaults to the current year.
#' @importFrom magrittr %>%
Expand All @@ -29,6 +30,7 @@
#' "20mm",
#' "Baystudy",
#' "DJFMP",
#' "DOP",
#' "EDSM",
#' "EMP",
#' "FMWT",
Expand Down Expand Up @@ -60,6 +62,7 @@ wq <- function(Sources = NULL,
"20mm",
"Baystudy",
"DJFMP",
"DOP",
"EDSM",
"EMP",
"FMWT",
Expand Down Expand Up @@ -109,6 +112,10 @@ wq <- function(Sources = NULL,
WQ_list[["EDSM"]] <- discretewq::EDSM
}

if ("DOP" %in% Sources) {
WQ_list[["DOP"]] <- discretewq::DOP
}

if ("EMP" %in% Sources) {
WQ_list[["EMP"]] <- discretewq::EMP
}
Expand Down
3 changes: 3 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Data <- wq(
"20mm",
"Baystudy",
"DJFMP",
"DOP",
"EDSM",
"EMP",
"FMWT",
Expand Down Expand Up @@ -103,6 +104,8 @@ O’Rear, T., J. Durand, and P. Moyle. 2022. Suisun Marsh Fish Study. [https://w

Schraga, T. S., E. S. Nejad, C. A. Martin, and J. E. Cloern. 2020. USGS measurements of water quality in San Francisco Bay (CA), beginning in 2016 (ver. 3.0, March 2020). U. S. Geological Survey data release. [doi:https://doi.org/10.5066/F7D21WGF](https://doi.org/10.5066/F7D21WGF)

Schultz, A.A. and A.J. Kalmbach. 2023. Directed Outflow Project Lower Trophic Study ver 4. Environmental Data Initiative. [https://doi.org/10.6073/pasta/86a01140eb3bb756ee9f7f8dab8aefc4](https://doi.org/10.6073/pasta/86a01140eb3bb756ee9f7f8dab8aefc4).

United States Fish and Wildlife Service, T. Senegal, R. Mckenzie, J. Speegle, B. Perales, D. Bridgman, K. Erly, S. Staiger, A. Arrambide, and M. Gilbert. 2022. Interagency Ecological Program and US Fish and Wildlife Service: San Francisco Estuary Enhanced Delta Smelt Monitoring Program data, 2016-2021 ver 8. Environmental Data Initiative. [doi:10.6073/pasta/e1a540c161b7be56b941df50fd7b44c5](https://portal.edirepository.org/nis/metadataviewer?packageid=edi.415.8)

U.S. Geological Survey. 2022. USGS water data for the Nation: U.S. Geological Survey National Water Information System database, accessed October 21, 2022, at
Expand Down
41 changes: 41 additions & 0 deletions data-raw/DOP.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Code to prepare DOP data goes here
library(lubridate)
library(tidyverse)

#read in dataset
DOPx = read_csv("https://portal.edirepository.org/nis/dataviewer?packageid=edi.1187.4&entityid=0dbed7163901c12df414da0762d28a86",
col_types=cols_only(Date="c", Latitude="d", Longitude="d",
Station_Code="c", Conductivity="d",
Temperature="d", Secchi="d", Start_Time="c",
NO3 = "d", NH4 = "d",pH = "d",
Chl_a = "d", PO4 = "d", Start_Depth = "d",
Salinity = "d", Turbidity = "d", DOC = "d",
DO="d"))

DOP= DOPx %>%
#standardize colom names
rename(Depth = Start_Depth,
Station = Station_Code,
Chlorophyll = Chl_a,
DissolvedOxygen = DO,
DissNitrateNitrite = NO3,
DissAmmonia = NH4,
DissOrthophos = PO4) %>%
#make a date-time column, convert feet to meters
mutate( Date=parse_date_time(Date, c("%Y-%m-%d", "%m/%d/%Y"), tz="America/Los_Angeles"),
Datetime = parse_date_time(if_else(is.na(Start_Time), NA_character_, paste(Date, Start_Time)), "%Y-%m-%d %H:%M:%S", tz="America/Los_Angeles"),

Field_coords = TRUE, Source = "DOP", Depth = Depth*0.3048) %>%

#select relevent columns
#note - i'm not including microcystis because they use a different method
select(Source, Station, Latitude, Longitude,
Field_coords, Date, Datetime,
Depth, Salinity,
Temperature, Turbidity, Conductivity,
pH, Chlorophyll, DissolvedOxygen, Secchi,
DOC, DissNitrateNitrite, DissAmmonia, DissOrthophos)


usethis::use_data(DOP, overwrite = TRUE)

12 changes: 5 additions & 7 deletions data-raw/NCRO.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ NCRO_allold <-
) %>%
list_rbind()

NCRO_all2022 <-
map(
dir("data-raw/NCRO", pattern = "^WQES.+\\.xlsx", full.names = TRUE),
read_excel
) %>%
list_rbind()

south = read_excel("data-raw/NCRO/WQDiscrete_SouthDelta_CY2022.xlsx") %>%
mutate(`Collection Date` = as.character(format(`Collection Date`, "%m/%d/%Y %H:%M")))
central = read_excel("data-raw/NCRO/WQDiscrete_CentralDelta_CY2022.xlsx")
trukee = read_excel("data-raw/NCRO/WQDiscrete_Truckee_CY2022.xlsx")
northdelta = read_csv("data-raw/NCRO/WQDiscrete_NorthDelta_RockSlough_FranksTract_YoloBypass_CY2022.csv")%>%
mutate(`Parent Sample` = as.character(`Parent Sample`))%>%
mutate(`Rpt Limit` = as.character(`Rpt Limit`))

NCRO_all = bind_rows(NCRO_allold,NCRO_all2022, northdelta)
NCRO_all = bind_rows(NCRO_allold,south, central, trukee, northdelta)



Expand Down
Binary file added data/DOP.rda
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/testthat/test-Data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ require(dplyr)
require(lubridate)

All_rows<-sum(map_dbl(list(baystudy, DJFMP, EDSM, EMP, FMWT, SDO, SKT, NCRO,
SLS, STN, suisun, twentymm, USBR, USGS_SFBS, YBFMP, USGS_CAWSC), nrow))
tzs<-map_chr(list(baystudy, DJFMP, EDSM, EMP, FMWT, SDO, SKT, SLS, STN, suisun, twentymm, USBR, USGS_SFBS, YBFMP, USGS_CAWSC, NCRO), ~tz(.x$Datetime))
SLS, STN, suisun, twentymm, USBR, USGS_SFBS, YBFMP, USGS_CAWSC, DOP), nrow))
tzs<-map_chr(list(baystudy, DJFMP, EDSM, EMP, FMWT, SDO, SKT, SLS, STN, suisun, twentymm, USBR, USGS_SFBS, YBFMP, USGS_CAWSC, NCRO, DOP), ~tz(.x$Datetime))
Data<-wq(Sources=c("EMP", "STN", "FMWT", "EDSM", "DJFMP", "SDO", "SKT", "SLS", "NCRO",
"20mm", "Suisun", "Baystudy", "USBR", "USGS_SFBS", "YBFMP", "USGS_CAWSC"))%>%
"20mm", "Suisun", "Baystudy", "USBR", "USGS_SFBS", "YBFMP", "USGS_CAWSC", "DOP"))%>%
mutate(ID=paste(Source, Station, Date, Datetime, Latitude, Longitude))


Expand Down Expand Up @@ -35,6 +35,6 @@ test_that("No zeros in environmental variables that shouldn't have them", {

test_that("Errors work correctly", {
expect_error(wq(Sources="USGS"), 'The "USGS" data source has been renamed to "USGS_SFBS" because of the inclusion of an additional USGS dataset, "USGS_CAWSC".', fixed=TRUE)
expect_error(wq(Sources="SFBS"), 'You must specify the data sources you wish to include. Choices include:\n 20mm, Baystudy, DJFMP, EDSM, EMP, FMWT, NCRO, SDO, SKT, SLS, STN, Suisun, USBR, USGS_CAWSC, USGS_SFBS, YBFMP', fixed=TRUE)
expect_error(wq(Sources="SFBS"), 'You must specify the data sources you wish to include. Choices include:\n 20mm, Baystudy, DJFMP, DOP, EDSM, EMP, FMWT, NCRO, SDO, SKT, SLS, STN, Suisun, USBR, USGS_CAWSC, USGS_SFBS, YBFMP', fixed=TRUE)
})

0 comments on commit 2be0229

Please sign in to comment.