Skip to content

Commit b51d929

Browse files
committed
Adjust date range. Used most recent start year that allows for all WQ parameters to be assessed.
Turbidity is the limiting parameter. The most recent year turbidity results are available for the the stations of interest and in units of NTU is 2017. -- Updated code to include a warning when parameters are missing from the processed dataframe.
1 parent 50f9597 commit b51d929

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

R/process.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ format_wq <- function(df){
4040
TRUE ~ result_format)) %>%
4141
dplyr::mutate(location_format = gsub("\\s+", "", Location)) %>% # Remove all spaces from location_id
4242
dplyr::mutate(date_format = as.Date(Date, format = "%d %b %Y"),
43-
result_format = as.numeric(result_format)) # Results in warning that NAs introduced by coercion - this is intended result)
43+
result_format = suppressWarnings(as.numeric(result_format))) # Results in warning that NAs introduced by coercion - this is intended result)
4444

4545

4646
return(df)
@@ -90,6 +90,15 @@ process_wq <- function(df, start_date, end_date){
9090
qualifier = qualifier_format
9191
)
9292

93+
# Identify missing parameters
94+
missing_params <- dplyr::setdiff(params, unique(df_processed$parameter))
95+
96+
# Warn the user if any parameters are missing
97+
if (length(missing_params) > 0) {
98+
warning("The following parameters are missing from the filtered dataset: ",
99+
paste(missing_params, collapse = ", "), ". Consider expanding analysis date range.")
100+
}
101+
93102

94103

95104

output/all_scores.csv

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"","sci_subshed","Trash","Dumpsites","Effective Impervious Area","Temperature, water","pH","Dissolved oxygen (DO)","Escherichia coli","Turbidity","Conductivity","Nitrogen","Phosphorus, Total (as P)","Connectivity","Fish","Habitat","Macroinvertebrates"
2-
"1","Battery Kemble Creek",8.375,10,6,10,10,10,7.17122657287291,10,1.32946707229891,1.1722461961956,10,10,3,4,7
3-
"2","Broad Branch",8.64516129032258,7,2,10,9.49484604605374,10,3.96201632162848,10,1.39551171022171,2.53189561427939,10,10,2,4,6
4-
"3","Dalecarlia Tributary",9.25,10,4,9.49281310022025,9.49429215204554,10,2.26543812278347,7.88130147148155,1.57723215112077,1.64140564675688,1.50035060003774,1,2,3,6
5-
"4","Dumbarton Oaks",7.75,10,4,10,10,10,8.54782802837774,10,1.70833294620897,1.32807710704536,2.8679579947462,10,3,5,7
6-
"5","Fenwick Branch",7.42857142857143,10,3,9.49476657878656,10,10,6.8791964501452,10,1.75285115573104,2.32427732195356,10,10,2,3,6
7-
"6","Fort Chaplin Tributary",2.5,10,2,10,10,9.44055926057385,3.66863632512962,8.77121712686461,2.01955422326341,1.09628813677057,10,1,1,4,3
8-
"7","Fort Davis Tributary",7.27272727272727,1,2,10,10,10,4.56378937695466,3.40381314529514,1.28521704525446,0.950005376536892,1.78543632558786,1,1,5,5
9-
"8","Fort Dupont Tributary",7.51063829787234,2,8,10,10,8.19644566724721,4.39637929649141,3.667361623274,2.99612324159937,0.749069894299005,10,1,3,4,6
10-
"9","Fort Stanton Tributary",6.57142857142857,4,1,9.49458887028815,10,10,3.49306972579195,8.24161710963122,2.14961627380251,0.950005376536892,10,1,1,3,7
11-
"10","Foundry Branch",8.91803278688525,10,2,10,10,10,5.43588122762784,4.44089503244838,2.9615349603606,2.05698424129608,10,1,1,4,NA
12-
"11","Hickey Run",8.03846153846154,10,9,9.32570696570447,10,9.31006357105735,1.71733915151806,7.52739827502453,1.92353016456839,0.749069894299005,2.7927191991411,10,6,2,4
13-
"12","Klingle Valley Run",7.4,10,2,10,10,10,6.5392010054142,10,2.16336911176854,1.52948677601239,10,10,2,3,6
14-
"13","Luzon Branch",5.2,10,1,10,10,10,2.74149789121648,5.16856938057974,1.68139016788936,2.13654818496565,2.91985046082419,10,2,3,6
15-
"14","Nash Run",7.6,10,3,8.97058038494947,9.49162145959481,10,2.85130675778872,8.98648127446675,3.13741218623777,1.09628813677057,10,10,6,5,4
16-
"15","Normanstone Creek",7.35294117647059,4,1,10,8.9888961180284,10,4.46891175504634,10,1.49230558316491,2.58568816872641,10,10,3,3,6
17-
"16","Oxon Run",5.8,8,1,9.49482509665549,10,10,4.08034192298863,7.26446748330366,2.73668115439965,0.677223449104501,0.963293817107756,10,4,4,4
18-
"17","Pinehurst Branch",8.57142857142857,7,6,10,9.45561327204199,10,6.86529198320573,10,1.64381726305677,2.53189561427939,10,10,2,4,5
19-
"18","Piney Branch",8,10,1,10,10,10,6.24485935433058,10,1.37920467622303,2.43350524767764,10,10,3,2,4
20-
"19","Pope Branch",8,10,3,10,10,10,6.70307871860358,4.63848137391428,2.04750999680075,0.950005376536892,10,1,4,6,8
21-
"20","Portal Branch",7,10,3,10,8.98692894850945,10,4.24400479220216,6.90674993457207,1.02448007263146,2.74453544775747,10,10,1,3,6
22-
"21","Reservation 630",9.34782608695652,10,3,9.49484222518253,10,10,4.89875662885154,6.54810880322023,1.95694969141548,2.32427732195356,10,10,4,7,7
23-
"22","Rock Creek",8.19158878504673,7,1,9.03991429859265,9.63931584712039,10,4.75298766520739,8.85351874858907,3.01758638876789,2.35646823207748,10,10,5,4,5
24-
"23","Soapstone Creek",8.3,10,1,10,8.98764540312439,10,6.80566463860387,10,1.91408087817814,2.53189561427939,2.88434296861746,10,2,3,6
25-
"24","Texas Avenue Tributary",7,10,3,10,10,10,3.54658539291944,7.3375495518317,1.74050116850977,0.837784090876652,10,1,1,5,3
26-
"25","Watts Branch",3.71428571428571,5,1,9.32024027311975,9.03799489304956,9.94283156569335,3.52383649640539,8.10990235278729,2.71307679688268,0.80598894736693,4.92721388547487,10,4,3,6
2+
"1","Battery Kemble Creek",8.375,10,6,10,10,10,6.32062005095886,10,1.29231798230656,1.1722461961956,10,10,3,4,7
3+
"2","Broad Branch",8.64516129032258,7,2,10,9.11598058121053,10,3.46549967300485,10,1.40786928664922,2.53189561427939,10,10,2,4,6
4+
"3","Dalecarlia Tributary",9.25,10,4,10,9.11501612829956,10,1.79924220701643,5.39181210894379,1.54095748278918,1.64140564675688,1.50035060003774,1,2,3,6
5+
"4","Dumbarton Oaks",7.75,10,4,10,10,10,8.69454411312198,10,1.7182364203714,1.32807710704536,2.8679579947462,10,3,5,7
6+
"5","Fenwick Branch",7.42857142857143,10,3,9.11584178377435,10,10,7.91414335091951,10,1.67080476066,2.32427732195356,10,10,2,3,6
7+
"6","Fort Chaplin Tributary",2.5,10,2,10,10,10,3.14328341096651,6.7504762638985,2.34331228746609,1.09628813677057,10,1,1,4,3
8+
"7","Fort Davis Tributary",7.27272727272727,1,2,10,10,10,4.22286031198727,4.18921125717516,1.35529464548602,0.950005376536892,1.78543632558786,1,1,5,5
9+
"8","Fort Dupont Tributary",7.51063829787234,2,8,10,10,6.96284375057502,3.64726473466637,2.43327471561426,3.40901285108323,0.749069894299005,10,1,3,4,6
10+
"9","Fort Stanton Tributary",6.57142857142857,4,1,10,10,10,3.29121342861143,10,2.20279397836273,0.950005376536892,10,1,1,3,7
11+
"10","Foundry Branch",8.91803278688525,10,2,10,10,10,5.66456777163845,3.2907745424067,3.74323286480178,2.05698424129608,10,1,1,4,NA
12+
"11","Hickey Run",8.03846153846154,10,9,9.41009036527631,10,9.40152724571608,1.4726563880943,8.13425471258536,1.83124163066893,0.749069894299005,2.7927191991411,10,6,2,4
13+
"12","Klingle Valley Run",7.4,10,2,10,10,10,6.77483210090502,10,2.59915902790879,1.52948677601239,10,10,2,3,6
14+
"13","Luzon Branch",5.2,10,1,10,10,10,2.78813266445486,2.9961918649383,2.02783283938377,2.13654818496565,2.91985046082419,10,2,3,6
15+
"14","Nash Run",7.6,10,3,9.11248888034847,10,10,2.71471677210064,10,3.30455432114584,1.09628813677057,10,10,6,5,4
16+
"15","Normanstone Creek",7.35294117647059,4,1,10,9.1135271129832,10,3.89478721657816,10,1.52837904138215,2.58568816872641,10,10,3,3,6
17+
"16","Oxon Run",5.8,8,1,10,10,10,4.0747186744388,10,2.27679630352316,0.677223449104501,0.963293817107756,10,4,4,4
18+
"17","Pinehurst Branch",8.57142857142857,7,6,10,10,10,6.16093987885743,10,1.31319413147893,2.53189561427939,10,10,2,4,5
19+
"18","Piney Branch",8,10,1,10,10,10,6.0165044795982,10,1.4437683502385,2.43350524767764,10,10,3,2,4
20+
"19","Pope Branch",8,10,3,10,10,10,6.71945403858055,10,2.05640672559587,0.950005376536892,10,1,4,6,8
21+
"20","Portal Branch",7,10,3,10,9.10792604923647,10,4.31380455155285,4.85620423789826,1.02900740067405,2.74453544775747,10,10,1,3,6
22+
"21","Reservation 630",9.34782608695652,10,3,10,10,10,5.10335745387789,4.89901716957291,2.34406341759797,2.32427732195356,10,10,4,7,7
23+
"22","Rock Creek",8.19158878504673,7,1,8.96387389248844,9.73928966893275,10,4.47912349705504,9.55547144639708,3.31713855234648,2.35646823207748,10,10,5,4,5
24+
"23","Soapstone Creek",8.3,10,1,10,9.11382163130491,10,6.3737125830251,10,2.22860207640777,2.53189561427939,2.88434296861746,10,2,3,6
25+
"24","Texas Avenue Tributary",7,10,3,10,10,10,3.32974708185848,6.39509486095813,1.73143114170272,0.837784090876652,10,1,1,5,3
26+
"25","Watts Branch",3.71428571428571,5,1,9.50858726011676,9.21408928798276,10,3.29401925724737,7.87140978534999,2.76165269687594,0.80598894736693,4.92721388547487,10,4,3,6

workflow.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ devtools::load_all(".")
88
# Input Variables ---------------------------------------------------------
99

1010
# Excel spreadsheet with Ambient Water Quality Data
11-
df_wq <- readxl::read_excel("data/ARII_Xtab_AmbWQ_SCI_downloaded_20250102.xlsx")
11+
df_wq <- readxl::read_excel("data/ARII_Xtab_AmbWQ_SCI_downloaded_20250102.xlsx",
12+
col_types = c("text","text","date","text","text","date", "text","text","text","text"))
1213

1314
# Excel spreadsheet with Rapid Stream Assessment (RSA) reach and point data
1415
df_reach <- readxl::read_excel("data/StreamReaches_20241105.xlsx")
1516
df_point <- readxl::read_excel("data/StreamPoints_20241105_INT.xlsx")
1617

1718
# Date ranges used for filtering water quality data
18-
start_date <- "2015-07-01"
19-
end_date <- "2020-06-30"
19+
start_date <- "2017-01-01"
20+
end_date <- "2024-12-31"
2021

2122
# Field name prefixes for RSA dataset
2223
# Prefixes change depending on layer and table names pulled from geodatabase

0 commit comments

Comments
 (0)