Skip to content

Commit

Permalink
Finished updating NCRO 2022 data.
Browse files Browse the repository at this point in the history
  • Loading branch information
rosehartman committed Aug 8, 2023
1 parent 1cd687c commit 068613f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions data-raw/NCRO.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@ require(stringr)
require(purrr)

# Import data field and laboratory provided by NCRO-WQES
NCRO_all <-
NCRO_allold <-
map(
dir("data-raw/NCRO", pattern = "^WQES.+\\.xlsx", full.names = TRUE),
read_excel
) %>%
list_rbind()

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

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)

# Import Secchi depth and Microcystis data, which were in a different Excel file
NCRO_secchi_mvi <- read_excel("data-raw/NCRO/All WQES Station HAB Obs and Secchi 2017-2021.xlsx")
# It looks like the data file they sent for 2022 included all the older data too.
#NCRO_secchi_mviold <- read_excel("data-raw/NCRO/All WQES Station HAB Obs and Secchi 2017-2021.xlsx")
NCRO_secchi_mvi <- read_excel("data-raw/NCRO/qry_HabObs_StationNameStationCode_DeployEnd.xlsx")

# Import station metadata and coordinates
stations <- read_csv("data-raw/NCRO/Stations.csv")
Expand Down Expand Up @@ -125,12 +140,13 @@ NCRO_all_c1 <- NCRO_all %>%
Datetime = with_tz(mdy_hm(`Collection Date`, tz = "Etc/GMT+8"), tzone = "America/Los_Angeles"),
Date = date(Datetime),
Analyte = AnalyteStd,
Result,
Result = Result,
# add Sign variable which indicates <RL values
Sign = if_else(str_detect(Result, "^<"), "<", "="),
RL = `Rpt Limit`,
Units,
Notes

) %>%
# convert Result to numeric making <RL values equal to their RL
mutate(
Expand All @@ -152,7 +168,7 @@ NCRO_all_c1 <- NCRO_all %>%
# (UserDefined) or (NONE) and substituting them with their proper number.
# We worked with Tyler Salman from NCRO-WQES to determine these.
NCRO_unk_sta <- NCRO_all_c1 %>%
filter(StationNumber %in% c("(UserDefined)", "(NONE)")) %>%
dplyr::filter(StationNumber %in% c("(UserDefined)", "(NONE)")) %>%
mutate(
StationNumber = case_when(
StationName == "Holland Cut at Holland Marina" ~ "B9D75841349",
Expand All @@ -168,7 +184,7 @@ NCRO_unk_sta <- NCRO_all_c1 %>%
)
) %>%
# Remove remaining records with StationNumber as (UserDefined) or (NONE)
filter(!StationNumber %in% c("(UserDefined)", "(NONE)"))
dplyr::filter(!StationNumber %in% c("(UserDefined)", "(NONE)"))

# Add data with corrected station names and numbers back to the main data frame
NCRO_all_c2 <- NCRO_all_c1 %>%
Expand Down Expand Up @@ -368,3 +384,4 @@ NCRO <- NCRO_all_c8_wide %>%
arrange(Datetime)

usethis::use_data(NCRO, overwrite = TRUE)

Binary file modified data-raw/NCRO/WQDiscrete_CentralDelta_CY2022.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DataOwner,DataStatus,LongStationName,ShortStationName,StationNumber,SampleCode,CollectionDate,Analyte,CASReg_Number,Result,RptLimit,Units,Method,Depth,Matrix,SampleType,ParentSample,Description,Notes,ResultRejected
Data Owner,Data Status,Long Station Name,Short Station Name,Station Number,Sample Code,Collection Date,Analyte,CAS Reg Number,Result,Rpt Limit,Units,Method,Depth,Matrix,Sample Type,Parent Sample,Description,Notes,Result Rejected
6301,"3500 - Public, Reviewed and Validated",Frank's Tract Mid Track - D19A,D19A,B9D80281359,CF0522B0613,5/12/2022 12:39,Dissolved Ammonia,7664-41-7,<0.05,0.05,mg/L as N,EPA 350.1 (D) [1]*,1 Meters,"Water, Natural",Normal Sample,0,,,N
6301,"3500 - Public, Reviewed and Validated",Frank's Tract Mid Track - D19A,D19A,B9D80281359,CF0522B0613,5/12/2022 12:39,Chlorophyll a,479-61-8,2.41,0.5,ug/L,Std Method 10200 H [1]*,1 Meters,"Water, Natural",Normal Sample,0,,,N
6301,"3500 - Public, Reviewed and Validated",Frank's Tract Mid Track - D19A,D19A,B9D80281359,CF0522B0613,5/12/2022 12:39,Dissolved Nitrate + Nitrite,NO3+NO2,0.103,0.05,mg/L as N,Std Method 4500-NO3-F [1]*,1 Meters,"Water, Natural",Normal Sample,0,,,N
Expand Down
Binary file modified data-raw/NCRO/WQDiscrete_SouthDelta_CY2022.xlsx
Binary file not shown.
Binary file modified data-raw/NCRO/WQDiscrete_Truckee_CY2022.xlsx
Binary file not shown.
Binary file modified data/NCRO.rda
Binary file not shown.

0 comments on commit 068613f

Please sign in to comment.