This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KAWN_Statistics_Plotting.Rmd
1473 lines (1362 loc) · 61.7 KB
/
KAWN_Statistics_Plotting.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Figure File"
author: "Michelle Catherine Kelly"
output: html_notebook
editor_options:
chunk_output_type: console
---
Copyright (c) 2019 Michelle Catherine Kelly
License: MIT License
```{r Setup}
library(lubridate)
library(ggplot2)
library(dplyr)
library(ggmap) # Mapping libraries
library(maps)
library(mapdata)
library(ggpubr)
library(gridExtra)
library(StreamPULSE)
```
```{r Load data}
# Site location data ---------------------------------------------------------
coords <- read.csv("./Data/GPScoordinates_12Nov18.csv",
stringsAsFactors = FALSE)
# Rename site names
coords$SiteNickname[coords$SiteNickname == "Bowersock"] <- "S0"
coords$SiteNickname[coords$SiteNickname == "Eric"] <- "S1"
coords$SiteNickname[coords$SiteNickname == "Steve"] <- "S2"
coords$SiteNickname[coords$SiteNickname == "Desoto"] <- "S3"
# Sensor data ----------------------------------------------------------------
# Request from streampulse
vars <- c('DO_mgL', 'DOsat_pct','satDO_mgL','WaterPres_kPa', 'WaterTemp_C',
'Light_PAR','AirPres_kPa','Discharge_m3s', 'Depth_m', 'Nitrate_mgL')
eric <- StreamPULSE::request_data("KS_KANSASREASTLAWRENCE", variables = vars)
steve <- StreamPULSE::request_data("KS_KANSASRFALLLEAF", variables = vars)
desoto <- StreamPULSE::request_data("KS_KANSASR", variables = vars)
sensor_eric <- eric$data
sensor_steve <- steve$data
sensor_desoto <- desoto$data
# Count total percent of "Bad Data" points out of all data points
sum(sensor_eric$flagtype %in% c("Bad Data"))/nrow(sensor_eric)*100 +
sum(sensor_steve$flagtype %in% c("Bad Data"))/nrow(sensor_steve)*100 +
sum(sensor_desoto$flagtype %in% c("Bad Data"))/nrow(sensor_desoto)*100
# summarize sensor data: take daily averages & merge w/ metabolism
dailyavg <- function(sensor_data, avgs){
# if sensor data has a "bad data" flag, set value to NA
sensor_data$value[sensor_data$flagtype %in% c("Bad Data")] <- NA
# reshape sensor data from long format to wide format
sensor_data <- tidyr::spread(sensor_data, key = variable, value = value)
# reformat datetime
sensor_data$DateTime_UTC <- lubridate::ymd_hms(sensor_data$DateTime_UTC)
# change time zone from UTC to central
sensor_data$dateTime <- lubridate::with_tz(sensor_data$DateTime_UTC,
tzone = "America/Chicago")
if (avgs) {
# sort data file and find daily averages
sensor_data <- sensor_data %>%
dplyr::group_by(date = lubridate::date(dateTime)) %>%
dplyr::summarise(Nitrate_mgL = mean(Nitrate_mgL, na.rm = TRUE),
Discharge_m3s = mean(Discharge_m3s, na.rm = TRUE),
DO_mgL = mean(DO_mgL, na.rm = TRUE),
Light_PAR = mean(Light_PAR, na.rm = TRUE),
WaterTemp_C = mean(WaterTemp_C, na.rm = TRUE),
Depth_m = mean(Depth_m, na.rm = TRUE))
}
# Factorize release status
sensor_data$ReleaseStatus <- NA
sensor_data$ReleaseStatus[sensor_data$date < ymd("2018-04-01")] <- "During"
sensor_data$ReleaseStatus[sensor_data$date >= ymd("2018-04-01")] <- "After"
sensor_data$ReleaseStatus <- factor(sensor_data$ReleaseStatus,
levels = c("During", "After"))
return(sensor_data)
}
diel_eric <- dailyavg(sensor_eric, avgs = FALSE)
diel_steve <- dailyavg(sensor_steve, avgs = FALSE)
diel_desoto <- dailyavg(sensor_desoto, avgs = FALSE)
sensor_eric <- dailyavg(sensor_eric, avgs = TRUE)
sensor_steve <- dailyavg(sensor_steve, avgs = TRUE)
sensor_desoto <- dailyavg(sensor_desoto, avgs = TRUE)
# Mass balance data ----------------------------------------------------------
massbal <- readRDS("./Outputs/NMassBalance.rds")
# Steve nitrate sensor burial
massbal$Nitrate.steve_mgNL[massbal$date >= ymd("2018-03-10") &
massbal$date <= ymd("2018-03-26")] <- NA
# Metabolism results ---------------------------------------------------------
metab_S1S2 <- readRDS("./Outputs/MetabResults_TwoStation.RData")
metab_desoto <- readRDS("./Outputs/MetabResults_Desoto.RData")
metab_desoto <- metab_desoto@fit[["daily"]]
# Create date sequence of everyday during sampling period, this is so that
# geom_ribbon will correctly plot NA dates in Figure 3
dates <- data.frame(date = seq(as.Date("2018-02-01"), as.Date("2018-05-01"),
by = "days"))
metab_desoto <- full_join(metab_desoto, dates)
rm(dates)
metab_desoto <- metab_desoto[c("date", "GPP_50pct", "GPP_2.5pct", "GPP_97.5pct",
"ER_50pct", "ER_2.5pct", "ER_97.5pct",
"K600_daily_50pct", "K600_daily_2.5pct",
"K600_daily_97.5pct")]
metab_desoto <- metab_desoto %>%
dplyr::rename("GPP" = "GPP_50pct", "GPP.lower" = "GPP_2.5pct",
"GPP.upper" = "GPP_97.5pct", "ER" = "ER_50pct",
"ER.lower" = "ER_2.5pct", "ER.upper" = "ER_97.5pct",
"K" = "K600_daily_50pct", "K.lower" = "K600_daily_2.5pct",
"K.upper" = "K600_daily_97.5pct")
# Two station model: For days when ER is modeled as positive, remove day from
# dataframe - this is the approach used in Hall et al 2016
sum(metab_S1S2$ER > 0) # Count of days when ER is positive
metab_S1S2$date[metab_S1S2$ER > 0]
sum(metab_S1S2$ER > 0) / length(metab_S1S2$ER) * 100 # Percentage of data removed
metab_S1S2 <- metab_S1S2 %>% filter(metab_S1S2$ER < 0) # Filter data
# Merge into one dataframe and filter by time of interest
metab <- dplyr::full_join(metab_S1S2, metab_desoto, by = "date",
suffix = c(".S1S2", ".S3")) %>%
filter(date >= as.Date("2018-02-01") & date < as.Date("2018-05-01"))
metab <- metab[order(metab$date),]
metab$s <- NULL
metab$s.lower <- NULL
metab$s.upper <- NULL
metab$accept <- NULL
rm(metab_S1S2)
rm(metab_desoto)
# Reshape metabolism dataframe -----------------------------------------------
# Factorize release status
metab$ReleaseStatus <- NA
metab$ReleaseStatus[metab$date < ymd("2018-04-01")] <- "During"
metab$ReleaseStatus[metab$date >= ymd("2018-04-01")] <- "After"
metab$ReleaseStatus <- factor(metab$ReleaseStatus,
levels = c("During", "After"))
# Adjust from wide to long format
metab.long <- tidyr::gather(metab %>% select(date, ReleaseStatus, GPP.S1S2,
ER.S1S2, GPP.S3, ER.S3),
key = site, value = value, GPP.S1S2:ER.S3)
# Factorize site and change labels
metab.long$site <- factor(metab.long$site)
# Initialize column to store metab model type (GPP or ER)
metab.long$model <- metab.long$site
# Rename factor levels
levels(metab.long$model)[levels(metab.long$site)=="GPP.S1S2"] <- "GPP"
levels(metab.long$site)[levels(metab.long$site)=="GPP.S1S2"] <- "S1S2"
levels(metab.long$model)[levels(metab.long$site)=="GPP.S3"] <- "GPP"
levels(metab.long$site)[levels(metab.long$site)=="GPP.S3"] <- "S3"
levels(metab.long$model)[levels(metab.long$site)=="ER.S1S2"] <- "ER"
levels(metab.long$site)[levels(metab.long$site)=="ER.S1S2"] <- "S1S2"
levels(metab.long$model)[levels(metab.long$site)=="ER.S3"] <- "ER"
levels(metab.long$site)[levels(metab.long$site)=="ER.S3"] <- "S3"
metab.long$model <- factor(metab.long$model, levels = c("GPP", "ER")) # Reorder
metab.long$site <- factor(metab.long$site, levels = c("S1S2", "S3"))
metab$PR.S1S2 <- metab$GPP.S1S2/abs(metab$ER.S1S2)
metab$PR.S3 <- metab$GPP.S3/abs(metab$ER.S3)
#### Stoichiometric scaling ##################################################
# Predict areal N uptake rate based on metabolism
# Assumptions: (Hall & Tank 2003)
# 1. C production will drive autotrophic & heterotrophic demand for N (AKA,
# assume a respiratory quotient = 1)
# 2. Molar C:N scaling ratio = 20 [g C / g N] (Hall & Tank 2003) OR
# Molar C:N scaling ratio = 12 [g C / g N] (Covino et al 2018, citing
# steltzer & lamberti 2001) OR
# Molar C:N scaling ratio = 16 [g C / g N] average of algae in the Little
# MO River, from E. Arsenault unpublished data
# 3. Net autotrophic production is 0.5*GPP (Odum 1957, Webster & Myer 1997)
# 4. Heterotrophic respiration can be estimated from ecosystem respiration
# using the equation HR = ER - ra*GPP where HR is herotrophic respiration,
# and ra is a growth efficiency term. Hall & Tank select a moderate growth
# efficiency = 0.2 and low growth efficiency = 0.05 to bound their estimate
# 5. Heterotrophic N assimilation can be calculated assuming a respiratory
# quotient of 1 and a C:N scaling ratio of 20:1 (both Hall & Tank 2003 and
# Covino et al 2018 use 20 as ratio)
# Equations -----------------------------------------------------------------
# Autotrophic N assimilation = GPP [gO2/m2d] * Respiratory quotient [g C/g O2]
# * Autotrophic respiration coefficient
# * C:N scaling ratio [g N / g C]
# Ua [g N / m2 day ] = GPP * 1 * 0.5 * 1/20 or 1/12
# Heterotrophic respiration = ER - ra * GPP
# HR [g O2 / m2 day] = ER - 0.5 * GPP
# Heterotrophic N assimilation = HR [g O2 / m2 day]
# * Respiratory quotient [g C / g O2]
# * C:N scaling ratio [g N / g C]
# Heterotrophic N assimilation = (HR*0.2) / (1 - 0.2) * 1/20
# Assumed constants ----------------------------------------------------------
RespQuot <- 1
AutoRespCoeff <- 0.5
CNscaleAut <- 20
CNscaleHet <- 20
ra.med <- 0.5
ra.low <- 0.2
# Run calculation ------------------------------------------------------------
stoich20 <-
metab %>%
mutate(# S1S2
ER.S1S2 = abs(ER.S1S2),
Uaut_gNm2day.S1S2 = GPP.S1S2 * RespQuot * AutoRespCoeff / CNscaleAut,
HR = ER.S1S2 - 0.5 * GPP.S1S2,
Uhet_gNm2day.S1S2 = ((0.2*HR) / (1-0.2)) / CNscaleHet,
Upred_gNm2day.S1S2 = Uaut_gNm2day.S1S2 + Uhet_gNm2day.S1S2,
# S3
ER.S3 = abs(ER.S3),
Uaut_gNm2day.S3 = GPP.S3 * RespQuot * AutoRespCoeff / CNscaleAut,
HR = ER.S3 - 0.5 * GPP.S3,
Uhet_gNm2day.S3 = ((0.2*HR) / (1-0.2)) / CNscaleHet,
Upred_gNm2day.S3 = Uaut_gNm2day.S3 + Uhet_gNm2day.S3)
# Nitrate uptake results -----------------------------------------------------
uptake <- readRDS("./Outputs/NitrateUptakeResults_Eqn1_twostation.rds")
uptake$UaNO3_gNm2day.steve[uptake$Date == "2018-03-01"] <- NA # affected by
# rapid discharge change, U calculation overestimate
uptake$UaNO3_gNm2day.steve[uptake$Date == "2018-03-09"] <- NA # affected by
# sensor burial that started around 03-10
# Section date
uptake <- uptake[uptake$Date >= ymd("2018-02-01") &
uptake$Date < ymd("2018-05-01"),]
## Calculate uptake velocity ###################################################
# vf = U [g-N / m2 day] / NO3 [mg-N / L] * 1000 [mg-N / g-N] / 1000 [m3 / L]
# = vf [m / day] / 1440 [day / min] * 1000 [mm/m] = vf [mm/min]
uptake$vf_mmmin.eric <-
uptake$UaNO3_gNm2day.eric / uptake$Mean.Nitrate_mgL.eric / 1440 * 1000
uptake$vf_mmmin.steve <-
uptake$UaNO3_gNm2day.steve / uptake$Mean.Nitrate_mgL.steve / 1440 * 1000
uptake$vf_mmmin.desoto <-
uptake$UaNO3_gNm2day.desoto / uptake$Mean.Nitrate_mgL.desoto / 1440 * 1000
# Adjust data frame structure
vf <- tidyr::gather(uptake[c("Date", "vf_mmmin.eric", "vf_mmmin.steve", "vf_mmmin.desoto")],
key = site, value = vf_mmmin,
vf_mmmin.eric:vf_mmmin.desoto)
vf$site <- factor(vf$site, levels = c("vf_mmmin.eric", "vf_mmmin.steve",
"vf_mmmin.desoto"))
levels(vf$site)[levels(vf$site)=="vf_mmmin.eric"] <- "S1"
levels(vf$site)[levels(vf$site)=="vf_mmmin.steve"] <- "S2"
levels(vf$site)[levels(vf$site)=="vf_mmmin.desoto"] <- "S3"
vf <- subset(vf, Date < "2018-05-01")
vf$Month <- lubridate::month(vf$Date, label = TRUE, abbr = TRUE)
# Adjust from wide to long format
uptake.long <-
uptake %>%
tidyr::gather(site, UaNO3_gNm2day, UaNO3_gNm2day.eric, UaNO3_gNm2day.steve,
UaNO3_gNm2day.desoto) %>%
select(Date, site, UaNO3_gNm2day)
# Rename site names
uptake.long$site[uptake.long$site == "UaNO3_gNm2day.eric"] <- "S1"
uptake.long$site[uptake.long$site == "UaNO3_gNm2day.steve"] <- "S2"
uptake.long$site[uptake.long$site == "UaNO3_gNm2day.desoto"] <- "S3"
# Factorize site name
uptake.long$site <- factor(uptake.long$site)
# Merge stoich with uptake
stoich20 <- uptake %>%
dplyr::full_join(stoich20, by = c("Date" = "date", "ReleaseStatus"))
# DOC data -------------------------------------------------------------------
DOC <- read.csv("./Data/KAW_RAPID_DOC.csv", header = TRUE,
stringsAsFactors = FALSE)
DOC$SamplingDate <- lubridate::mdy(DOC$SamplingDate)
# Meta analysis data ---------------------------------------------------------
# Tank et al 2008 uptake meta-analysis
tank <- read.csv("./Data/Meta-analysis/Tank_2008_uptakedata.csv",
header = TRUE)
tank$NO3_Cb_mgNL <- tank$NO3_Cb_ugNL/1000
# Rode et al 2016
rode.hensley <- read.csv("./Data/Meta-analysis/Rode_Hensley_SensorUptake.csv")
# Hall et al 2016 metabolism meta-analysis
hall <- read.csv("./Data/Meta-analysis/Hall_2016_metabolismdata.csv",
header = TRUE)
hall$q_m3s <- hall$q_Ls/1000
```
```{r Stats}
## Metabolism ##################################################################
# Test whether GPP was different between S1-S2 and S3
# Need to compare the means of paired samples: Paired sample T-test
t.test(metab$GPP.S1S2, metab$GPP.S3, paired = TRUE, alternative = "two.sided")
# Test whether ER was different between S1-S2 and S3
mean(metab$ER.S1S2,na.rm = T) # Mean of ER at S1S2
mean(metab[na.omit(metab$ER.S1S2),]$ER.S3, na.rm = T) # Mean of ER at S3 during S1S2 data
mean(metab$ER.S3, na.rm = T)
t.test(abs(metab$ER.S1S2), abs(metab$ER.S3), paired = TRUE, alternative = "two.sided")
## Uptake ######################################################################
# Test whether mean U was different between sites
mean(uptake$UaNO3_gNm2day.eric, na.rm = T) # Mean of Udiel at S1
uptake.long %>%
filter(site == "S1") %>%
summarise(mean(UaNO3_gNm2day, na.rm = T)) # Just double checking
mean(uptake$UaNO3_gNm2day.steve, na.rm = T) # Mean of Udiel at S2
mean(uptake$UaNO3_gNm2day.desoto, na.rm = T) # Mean of Udiel at S3
# One-way ANOVA to assess differences between sites
# ANOVA for only days where we have data for all 3 sites
UANOVA_data <- na.omit(uptake %>% select(Date, UaNO3_gNm2day.eric,
UaNO3_gNm2day.steve,
UaNO3_gNm2day.desoto)) %>%
tidyr::pivot_longer(cols = 2:4, names_to = "site",
values_to = "UaNO3_gNm2day")
UANOVA <- aov(UaNO3_gNm2day ~ site, data = UANOVA_data)
summary(UANOVA)
# Posthoc testing
TukeyHSD(UANOVA)
### Figure 4 ######################
# Linear model
forecast::tslm(UaNO3_gNm2day.eric ~ Date, data = uptake) # We can use regular lm even though this is time series data because the data does not have seasonality
cor.test(x = zoo::as.zoo(uptake$Date), y = uptake$UaNO3_gNm2day.eric,
method = "pearson", use = "complete.obs")
lmmodel <- lm(uptake$UaNO3_gNm2day.eric ~ zoo::as.zoo(uptake$Date)) # S1
summary(lmmodel) # S1
lmmodel <- lm(uptake$UaNO3_gNm2day.steve ~ zoo::as.zoo(uptake$Date)) # S2
summary(lmmodel) # S2
lmmodel <- lm(uptake$UaNO3_gNm2day.desoto ~ zoo::as.zoo(uptake$Date)) # S3
summary(lmmodel) # S3
## Uptake velocity #############################################################
# Test whether mean Vf was different between sites
mean(uptake$vf_mmmin.eric, na.rm = T) # S1
vf %>%
filter(site == "S1") %>%
summarise(mean(vf_mmmin, na.rm = T)) # Just double checking
mean(uptake$vf_mmmin.steve, na.rm = T) # S2
mean(uptake$vf_mmmin.desoto, na.rm = T) # S3
# One-way ANOVA to assess differences between sites
# ANOVA for only days where we have data for all 3 sites
VfANOVA_data <- na.omit(uptake %>% select(Date, vf_mmmin.eric,
vf_mmmin.steve,
vf_mmmin.desoto)) %>%
tidyr::pivot_longer(cols = 2:4, names_to = "site",
values_to = "vf_mmmin")
VfANOVA <- aov(vf_mmmin ~ site, data = VfANOVA_data)
summary(VfANOVA)
# Posthoc testing
TukeyHSD(VfANOVA)
# Linear model
forecast::tslm(vf_mmmin.eric ~ Date, data = uptake) # We can use regular lm even though this is time series data because the data does not have seasonality
cor.test(x = zoo::as.zoo(uptake$Date), y = uptake$vf_mmmin.eric,
method = "pearson", use = "complete.obs")
lmmodel <- lm(uptake$vf_mmmin.eric ~ zoo::as.zoo(uptake$Date)) # S1
summary(lmmodel) # S1
lmmodel <- lm(uptake$vf_mmmin.steve ~ zoo::as.zoo(uptake$Date)) # S2
summary(lmmodel) # S2
lmmodel <- lm(uptake$vf_mmmin.desoto ~ zoo::as.zoo(uptake$Date)) # S3
summary(lmmodel) # S3
## Udiel vs Upred ############################################################
# Means
mean(stoich20$Upred_gNm2day.S1S2, na.rm = T) # S1-S2 U pred
mean(stoich20[-which(is.na(stoich20$Upred_gNm2day.S1S2)),]$UaNO3_gNm2day.steve,
na.rm = T) # U diel mean at S2 during S1S2 data
mean(stoich20$Upred_gNm2day.S3, na.rm = T) # S3 U pred
mean(stoich20[-which(is.na(stoich20$Upred_gNm2day.S3)),]$UaNO3_gNm2day.desoto,
na.rm = T) # U diel mean at S3 during S3 data
## Compare during release vs after at S3
stoich20 %>%
filter(ReleaseStatus == "During",
!is.na(Upred_gNm2day.S3)) %>%
summarise(mean(UaNO3_gNm2day.desoto, na.rm = T),
mean(Upred_gNm2day.S3, na.rm = T))
stoich20 %>%
filter(ReleaseStatus == "After",
!is.na(Upred_gNm2day.S3)) %>%
summarise(mean(UaNO3_gNm2day.desoto, na.rm = T),
mean(Upred_gNm2day.S3, na.rm = T))
###### Figure 5 ########################
# Linear model
lmmodel <- lm(stoich20$Upred_gNm2day.S1S2 ~ stoich20$UaNO3_gNm2day.eric) # S1S2 vs S1
summary(lmmodel) # S1S2 vs S1
lmmodel <- lm(stoich20$Upred_gNm2day.S1S2 ~ stoich20$UaNO3_gNm2day.steve) # S1S2 vs S2
summary(lmmodel) # S1S2 vs S2
lmmodel <- lm(stoich20$Upred_gNm2day.S3 ~ stoich20$UaNO3_gNm2day.desoto) # S3
summary(lmmodel) # S3
mean(subset(stoich20, ReleaseStatus == "During")$UaNO3_gNm2day.desoto, na.rm = T)
mean(subset(stoich20, ReleaseStatus == "During")$Upred_gNm2day.S3, na.rm = T)
mean(subset(stoich20, ReleaseStatus == "After")$UaNO3_gNm2day.desoto, na.rm = T)
mean(subset(stoich20, ReleaseStatus == "After")$Upred_gNm2day.S3, na.rm = T)
# During waste release
lmmodel <- lm(Upred_gNm2day.S3 ~ UaNO3_gNm2day.desoto,
data = subset(stoich20, ReleaseStatus == "During")) # S3
summary(lmmodel) # S3
lmmodel <- lm(Upred_gNm2day.S3 ~ UaNO3_gNm2day.desoto,
data = subset(stoich20, ReleaseStatus == "After")) # S3
summary(lmmodel) # S3
## Udiel & Vf vs GPP ################################################
#### Figure 6 ########################
# Linear model
# Udiel
lmmodel <- lm(UaNO3_gNm2day.steve ~ GPP.S1S2, data = stoich20) # S1S2
summary(lmmodel) # S1S2
lmmodel <- lm(UaNO3_gNm2day.desoto ~ GPP.S3, data = stoich20) # S3
summary(lmmodel) # S3
##### Supplemental figure ############
# Vf
lmmodel <- lm(vf_mmmin.steve ~ GPP.S1S2, data = stoich20) # S1S2
summary(lmmodel) # S1S2
lmmodel <- lm(vf_mmmin.desoto ~ GPP.S3, data = stoich20) # S3
summary(lmmodel) # S3
# During waste release
lmmodel <- lm(UaNO3_gNm2day.desoto ~ GPP.S3,
data = subset(stoich20, ReleaseStatus == "During")) # S3
summary(lmmodel) # S3
lmmodel <- lm(UaNO3_gNm2day.desoto ~ GPP.S3,
data = subset(stoich, ReleaseStatus == "After")) # S3
summary(lmmodel) # S3
cor.test(x = subset(stoich, ReleaseStatus == "During")$UaNO3_gNm2day.desoto,
y = subset(stoich, ReleaseStatus == "During")$GPP.S3)
cor.test(x = subset(stoich, ReleaseStatus == "After")$UaNO3_gNm2day.desoto,
y = subset(stoich, ReleaseStatus == "After")$GPP.S3)
cor.test(x = stoich$UaNO3_gNm2day.desoto,
y = stoich$GPP.S3)
## Udiel & Vf vs ER ################################################
##### Figure 6 #######################
# Linear model
# Udiel
lmmodel <- lm(UaNO3_gNm2day.steve ~ ER.S1S2, data = stoich20) # S1S2
summary(lmmodel) # S1S2
lmmodel <- lm(UaNO3_gNm2day.desoto ~ ER.S3, data = stoich20) # S3
summary(lmmodel) # S3
# Vf
lmmodel <- lm(vf_mmmin.steve ~ ER.S1S2, data = stoich20) # S1S2
summary(lmmodel) # S1S2
lmmodel <- lm(vf_mmmin.desoto ~ ER.S3, data = stoich20) # S3
summary(lmmodel) # S3
# Udiel vs PR
lmmodel <- lm(UaNO3_gNm2day.steve ~ GPP.S1S2/ER.S1S2, data = stoich) # S1S2
summary(lmmodel) # S1S2
lmmodel <- lm(UaNO3_gNm2day.desoto ~ GPP.S3/ER.S3, data = stoich) # S3
summary(lmmodel) # S3
lmmodel <- lm(vf_mmmin.desoto ~ GPP.S3/ER.S3, data = stoich) # S3
summary(lmmodel) # S3
```
```{r Table 1}
##### Discharge ########################################
# S0
mean(massbal$Q.lawrence_Ls[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)/1000
sd(massbal$Q.lawrence_Ls[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)/1000
# S1
mean(sensor_eric$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
sd(sensor_eric$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
# S2
mean(sensor_steve$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
sd(sensor_steve$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
# S3
mean(sensor_desoto$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
sd(sensor_desoto$Discharge_m3s[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
## Depth
mean(sensor_eric$[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
## Velocity
##### Ammonium ########################################
## S0
mean(massbal$Ammonium.bowersock_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
sd(massbal$Ammonium.bowersock_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
## S1
mean(massbal$Ammonium.eric_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
sd(massbal$Ammonium.eric_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
## S2
mean(massbal$Ammonium.steve_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
sd(massbal$Ammonium.steve_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
## S3
mean(massbal$Ammonium.desoto_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
sd(massbal$Ammonium.desoto_mgNL[massbal$date >= "2018-02-01" &
massbal$date <= "2018-05-01"],
na.rm = TRUE)
##### Nitrate, Discharge ########################################
sensorData <- full_join(sensor_eric, sensor_steve, by = "date",
suffix =c(".S1", ".S2")) %>%
full_join(., sensor_desoto, by = "date") %>%
filter(date >= "2018-02-01" & date < "2018-05-01")
sensorMeans <-
sensorData %>%
summarise_if(is.numeric, mean, na.rm = T)
sensorSD <-
sensorData %>%
summarise_if(is.numeric, sd, na.rm = T)
## Calculating mean nitrate when only all observations are present
a <- sensorData %>%
tidyr::drop_na() %>%
summarise_if(is.numeric, mean, na.rm = T)
##### DOC ########################################
DOC %>%
filter(SamplingDate >= "2018-02-01" & SamplingDate <= "2018-05-01") %>%
arrange(SamplingDate) %>%
group_by(Site) %>%
filter(Site == "Dam" | Site == "Disch" | Site == "Steve" | Site == "Desoto") %>%
summarise(mean_NPOC_mgL = mean(Result_NPOC_mg.L), sd = sd(Result_NPOC_mg.L),
n = length(Result_NPOC_mg.L))
##### Nitrate uptake ########################################
## S1
mean(uptake$UaNO3_gNm2day.eric[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
sd(uptake$UaNO3_gNm2day.eric[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
## S2
mean(uptake$UaNO3_gNm2day.steve[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
sd(uptake$UaNO3_gNm2day.steve[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
## S3
mean(uptake$UaNO3_gNm2day.desoto[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
sd(uptake$UaNO3_gNm2day.desoto[uptake$Date >= "2018-02-01" &
uptake$Date < "2018-05-01"], na.rm = TRUE)
##### Uptake velocity ########################################
## S1
mean(vf$vf_mmmin[vf$site == "S1"], na.rm = TRUE)
sd(vf$vf_mmmin[vf$site == "S1"], na.rm = TRUE)
## S2
mean(vf$vf_mmmin[vf$site == "S2"], na.rm = TRUE)
sd(vf$vf_mmmin[vf$site == "S2"], na.rm = TRUE)
## S3
mean(vf$vf_mmmin[vf$site == "S3"], na.rm = TRUE)
sd(vf$vf_mmmin[vf$site == "S3"], na.rm = TRUE)
##### Temp ########################################
mean(sensor_desoto$WaterTemp_C[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
max(sensor_desoto$WaterTemp_C[sensor_desoto$date >= "2018-02-01" &
sensor_desoto$date <= "2018-05-01"], na.rm = TRUE)
```
```{r Table 2}
###### GPP ###############################################
## S1S2
mean(metab$GPP.S1S2, na.rm = TRUE)
sd(metab$GPP.S1S2, na.rm = TRUE)
## S3
mean(metab$GPP.S3, na.rm = TRUE)
sd(metab$GPP.S3, na.rm = TRUE)
### Mean values during the duration of S1S2 data
mean(metab[!is.na(metab$GPP.S1S2),]$GPP.S3, na.rm = TRUE)
###### |ER| ###############################################
## S1S2
mean(stoich20$ER.S1S2, na.rm = TRUE) #check
mean(metab$ER.S1S2, na.rm = TRUE) #check
sd(metab$ER.S1S2, na.rm = TRUE)
## S3
mean(metab$ER.S3, na.rm = TRUE)
sd(metab$ER.S3, na.rm = TRUE)
### Mean values during the duration of S1S2 data
mean(metab[!is.na(metab$ER.S1S2),]$ER.S3, na.rm = TRUE)
###### P/R ###############################################
## S1S2
mean(metab$PR.S1S2, na.rm = TRUE)
sd(metab$PR.S1S2, na.rm = TRUE)
## S3
mean(metab$PR.S3, na.rm = TRUE)
sd(metab$PR.S3, na.rm = TRUE)
### Mean values during the duration of S1S2 data
mean(metab[!is.na(metab$PR.S1S2),]$PR.S3, na.rm = TRUE)
###### K ###############################################
## S1S2
mean(metab$K.S1S2, na.rm = TRUE)
sd(metab$K.S1S2, na.rm = TRUE)
## S3
mean(metab$K.S3, na.rm = TRUE)
sd(metab$K.S3, na.rm = TRUE)
```
```{r Fig 1. Map}
# Pull country, state, county map data
state.map <- map_data("state")
kansas.map <- subset(state.map, region == "kansas")
counties.map <- subset(map_data("county"), region == "kansas")
# Pull rivers map data:
# Data provided by Esri, National Atlas of the United States and the United
# States Geological Survey, accessed 26-Jan-19, ArcGIS "USA Rivers and Streams"
# dataset www.arcgis.com
load(url("https://vrzkj25a871bpq7t1ugcgmn9-wpengine.netdna-ssl.com/wp-content/datasets/usa_rivers.RData"))
lines.rivers2 <- subset(lines.rivers, STATE %in% c("KS") &
NAME %in% c("Kansas River", "Republican River", "Little Blue River",
"Big Blue River", "West Fork Big Blue River",
"North Branch West Fork Big Blue River",
"Big Blue Creek", "North Fork Smoky Hill River",
"Smoky Hill River", "Saline River",
"Saline Branch", "North Fork Saline River",
"South Fork Saline River", "Solomon River",
"North Fork Solomon River", "South Fork Solomon River"))
ks_rivers <- fortify(lines.rivers2)
ks_rivers.all <- fortify(subset(lines.rivers, STATE %in% c("KS")))
unique(lines.rivers$NAME[grep("Kansas", lines.rivers$NAME)])
unique(lines.rivers$NAME[grep("Blue", lines.rivers$NAME)])
unique(lines.rivers$NAME[grep("Smoky", lines.rivers$NAME)])
unique(lines.rivers$NAME[grep("Saline", lines.rivers$NAME)])
unique(lines.rivers$NAME[grep("Solomon", lines.rivers$NAME)])
# USA map
#a <-
ggplot() +
theme_nothing() +
geom_polygon(data = state.map,
aes(x = long, y = lat, group = group),
color = "black", size = 0.2, fill = NA) +
coord_fixed(1.3) +
guides(fill = FALSE)
ggsave("./Plots/Fig1_a_Map_USA.jpg", height = 40, width = 50, units = "mm", dpi = 600)
# State map
#b <-
ggplot() +
theme_nothing() +
# County border
geom_polygon(data = counties.map, aes(x = long, y = lat, group = group),
fill = NA, color = "grey", size = 0.2) +
# Rivers
geom_path(data = ks_rivers, aes(x = long, y = lat, group = group),
col = "#23baaf", size = 0.2) +
# State border
geom_polygon(data = kansas.map, aes(x = long, y = lat, group = group),
fill = NA, color = "black", size = 0.2) +
# Location marker
geom_point(data = coords, mapping = aes(x = long[5], y = lat[5]),
shape = 0, size = 4, stroke = 0.5, col = "black") +
coord_fixed(1.3) +
guides(fill = FALSE)
ggsave("./Plots/Fig1_b_Map_KS.jpg", height = 40, width = 50, units = "mm", dpi = 600)
#c <-
ggplot() +
#theme_nothing() +
# County border
geom_polygon(data = counties.map, aes(x = long, y = lat, group = group),
fill = NA, color = "grey", size = 0.2) +
# Rivers
geom_path(data = ks_rivers.all, aes(x = long, y = lat, group = group, col = "S2")) +
geom_path(data = ks_rivers, aes(x = long, y = lat, group = group, col = "S2"),
size = 1.5) +
# Site location bubbles
geom_point(data = coords, mapping = aes(x = long[1], y = lat[1], col = "S0"),
shape = 1, size = 5, stroke = 2) +
geom_point(data = coords, mapping = aes(x = long[5], y = lat[5], col = "S1"),
shape = 1, size = 5, stroke = 2) +
geom_point(data = coords, mapping = aes(x = long[8], y = lat[8], col = "S2"),
shape = 1, size = 5, stroke = 2) +
geom_point(data = coords, mapping = aes(x = long[15], y = lat[15], col = "S3"),
shape = 1, size = 5, stroke = 2) +
# Lawrence
geom_point(data = NULL, mapping = aes(y = 38.94, x = -95.28, col = "S0"),
shape = 2, size = 5) +
# Release point
geom_point(data = NULL, mapping = aes(y = 38.969, x = -95.21, col = "S0"),
shape = 4, size = 5) +
# Site names
geom_text(data = coords, aes(x = long, y = lat, label = SiteNickname),
nudge_y = -0.017, size = 5) +
scale_color_manual(values = c("S0" = "#000000", "S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S0", "S1", "S2", "S3")) +
coord_fixed(1.3) +
coord_quickmap(xlim = c(-95.3, -94.9), ylim = c(38.83, 39.1)) +
theme(panel.border = element_rect(color = "black", fill = NA),
legend.position = "none", axis.title = element_blank(),
text = element_text(size = 8))
ggsave("./Plots/Fig1_c_Map_local.jpg", height = 80, width = 80, units = "mm",
dpi = 600)
grob <- grid.arrange(a, b, nrow = 2)
grob <- grid.arrange(grob, c, ncol = 2)
```
```{r Fig 2. N concentration}
# N concentration plot
a <-
ggplot(data = massbal, aes(x = date)) +
# Add vertical line at release stop date
geom_vline(xintercept = ymd("2018-04-01"), linetype = 2) +
# S0
geom_point(data = massbal[massbal$date < as.Date("2018-02-26"),],
aes(x = date, y = Nitrate.bowersock_mgNL, fill = "S0"),
size = 2, shape = 21) +
# S0 BDL
geom_segment(aes(x = as.Date("2018-02-26"), xend = as.Date("2018-05-01"),
y = 0.01, yend = 0.01), linetype = 1) +
# S1
geom_point(aes(y = Nitrate.eric_mgNL, fill = "S1"), size = 2, shape = 21) +
# S2
geom_point(aes(y = Nitrate.steve_mgNL, fill = "S2"), size = 2, shape = 21) +
# S3
geom_point(aes(y = Nitrate.desoto_mgNL, fill = "S3"), size = 2, shape = 21) +
# axis and color scales
scale_x_date(limits = c(as_date("2018-02-01"), as_date("2018-05-01")),
date_breaks = "2 weeks", date_labels = "%b %e" ) +
scale_y_log10()+
scale_fill_manual(values = c("S0" = "#ffffff", "S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S0", "S1", "S2", "S3")) +
# axis labels
labs(tag = "a", fill = "Site") +
xlab(NULL) +
ylab(expression(NO[3]^{"-"} ~~ "(mg-N" ~~ L^{-1} * ")"))+
# plot theme
theme_classic() +
theme(legend.position = c(0.15,0.13), #legend.title = element_blank(),
legend.box.background = element_rect(color = "black"),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8)) +
guides(fill = guide_legend(keyheight = 0.5, ncol = 2))
ggsave("./Plots/Fig2_a_Nitrate_time.png", a, height = 77, width = 120,
units = "mm", dpi = 600)
# Temperature and discharge
b <-
# Water temperature and discharge from the Desoto site
ggplot(data = sensor_desoto, aes(x = date)) +
# Add vertical line at release stop date
geom_vline(xintercept = ymd("2018-04-01"), linetype = 2) +
# Add data
geom_line(aes(y = WaterTemp_C), color = "black") +
geom_line(aes(y = Discharge_m3s/2), color = "grey") +
# axis and color scales
scale_x_date(limits = c(as_date("2018-02-01"), as_date("2018-05-01")),
date_breaks = "2 weeks", date_labels = "%b %e" ) +
scale_y_continuous(limits = c(0,50),
sec.axis = sec_axis(~.*2,
name = expression("Q ("*m^3 ~ s^{-1} *")"))) +
# axis labels
labs(tag = "b") +
xlab(NULL) +
ylab(expression("T ("*{degree}*C * ")"))+
# plot theme
theme_classic() +
theme(panel.border = element_rect(color = "black", fill = NA),
legend.position = "none", legend.title = element_blank(),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
ggsave("./Plots/Fig2_b_T.Q_time.png", b,height = 1.75, width = 4.8)
# Diel zoom-in
c <-
ggplot(data = diel_eric, aes(x = dateTime)) +
# Add grey bars for local nighttime
geom_rect(aes(xmin = ymd_hms("2018-03-23 00:00:00"),
xmax = ymd_hms("2018-03-23 06:00:00"),
ymin = 0, ymax = 11), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-23 20:00:00"),
xmax = ymd_hms("2018-03-24 06:00:00"),
ymin = 0, ymax = 11), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-24 20:00:00"),
xmax = ymd_hms("2018-03-25 06:00:00"),
ymin = 0, ymax = 11), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-25 20:00:00"),
xmax = ymd_hms("2018-03-26 00:00:00"),
ymin = 0, ymax = 11), fill = "lightgrey") +
# Plot S1 data on top
geom_point(aes(y = Nitrate_mgL, fill = "S1"), size = 2, shape = 21) +
# axis and color scales
scale_x_datetime(limits = c(ymd_hms("2018-03-23 00:00:00"),
ymd_hms("2018-03-26 00:00:00")),
date_breaks = "1 day", date_labels = "%b %e" ) +
scale_y_continuous(limits = c(0, 11))+
scale_fill_manual(values = c("S0" = "#000000", "S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S0", "S1", "S2", "S3")) +
# axis labels
labs(tag = "c") +
xlab(NULL) +
ylab(expression(NO[3]^{"-"} ~~ "(mg-N" ~~ L^{-1} * ")"))+
# plot theme
theme_classic() +
theme(legend.position = "none", legend.title = element_blank(),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
d <-
ggplot(data = diel_steve, aes(x = dateTime)) +
# Add grey bars for local nighttime
geom_rect(aes(xmin = ymd_hms("2018-03-28 00:00:00"),
xmax = ymd_hms("2018-03-28 06:00:00"),
ymin = 0, ymax = 0.6), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-28 20:00:00"),
xmax = ymd_hms("2018-03-29 06:00:00"),
ymin = 0, ymax = 0.6), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-29 20:00:00"),
xmax = ymd_hms("2018-03-30 06:00:00"),
ymin = 0, ymax = 0.6), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-30 20:00:00"),
xmax = ymd_hms("2018-03-31 00:00:00"),
ymin = 0, ymax = 0.6), fill = "lightgrey") +
# S2
geom_point(aes(y = Nitrate_mgL, fill = "S2"), size = 2, shape = 21) +
# axis and color scales
scale_x_datetime(limits = c(ymd_hms("2018-03-28 00:00:00"),
ymd_hms("2018-03-31 00:00:00")),
date_breaks = "1 days", date_labels = "%b %e" ) +
#scale_y_log10()+
scale_fill_manual(values = c("S0" = "#000000", "S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S0", "S1", "S2", "S3")) +
scale_y_continuous(limits = c(0, 0.6)) +
# axis labels
labs(tag = "d") +
xlab(NULL) +
ylab(expression(NO[3]^{"-"} ~~ "(mg-N" ~~ L^{-1} * ")"))+
# plot theme
theme_classic() +
theme(legend.position = "none", legend.title = element_blank(),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
e <-
ggplot(data = diel_desoto, aes(x = dateTime)) +
# Add grey bars for local nighttime
geom_rect(aes(xmin = ymd_hms("2018-03-24 00:00:00"),
xmax = ymd_hms("2018-03-24 06:00:00"),
ymin = 0, ymax = 0.75), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-24 20:00:00"),
xmax = ymd_hms("2018-03-25 06:00:00"),
ymin = 0, ymax = 0.75), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-25 20:00:00"),
xmax = ymd_hms("2018-03-26 06:00:00"),
ymin = 0, ymax = 0.75), fill = "lightgrey") +
geom_rect(aes(xmin = ymd_hms("2018-03-26 20:00:00"),
xmax = ymd_hms("2018-03-27 00:00:00"),
ymin = 0, ymax = 0.75), fill = "lightgrey") +
# S3
geom_point(aes(y = Nitrate_mgL, fill = "S3"), size = 2, shape = 21) +
# axis and color scales
scale_x_datetime(limits = c(ymd_hms("2018-03-24 00:00:00"),
ymd_hms("2018-03-27 00:00:00")),
date_breaks = "1 days", date_labels = "%b %e" ) +
scale_y_continuous(limits = c(0, 0.75)) +
scale_fill_manual(values = c("S0" = "#000000", "S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S0", "S1", "S2", "S3")) +
# axis labels
labs(tag = "e") +
xlab(NULL) +
ylab(expression(NO[3]^{"-"} ~~ "(mg-N" ~~ L^{-1} * ")"))+
# plot theme
theme_classic() +
theme(legend.position = "none", legend.title = element_blank(),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
grob2 <- gridExtra::grid.arrange(c, d, e, ncol = 1)
ggsave("./Plots/Fig2_cde_DielN.png", grob2, height = 115, width = 63,
units = "mm", dpi = 600)
```
```{r Fig 3. Metabolism}
# S1S2
a <-
ggplot(data = metab, aes(x = date)) +
# Horizontal line at Y = 0
geom_hline(yintercept = 0) +
# Vertical line at release stop date
geom_vline(xintercept = ymd("2018-04-01"), linetype = 2) +
# Plot GPP
geom_ribbon(aes(ymin = GPP.lower.S1S2, ymax = GPP.upper.S1S2),
fill = "lightgrey", alpha = 0.7) +
geom_pointrange(aes(y = GPP.S1S2, ymin = GPP.lower.S1S2, ymax = GPP.upper.S1S2),
color = "lightgrey") +
geom_point(aes(y = GPP.S1S2, fill = "S2"), size = 1.8, shape = 21) +
# Plot ER
geom_ribbon(aes(ymin = ER.lower.S1S2, ymax = ER.upper.S1S2),
fill = "lightgrey", alpha = 0.7) +
geom_pointrange(aes(y = ER.S1S2, ymin = ER.lower.S1S2, ymax = ER.upper.S1S2),
color = "lightgrey") +
geom_point(aes(y = ER.S1S2), size = 1.8, shape = 21, fill = "white") +
# y-axis limits
scale_y_continuous(limits = c(-8, 10), breaks = c(-10, -5, 0, 5, 10, 15)) +
# Axis labels
labs(x = NULL, tag = "a",
y = bquote("GPP or ER (g" ~~ O[2] ~ m^-2 ~ d^-1 ~ ")")) +
# Theme adjustments
theme_classic() +
scale_fill_manual(values = c("S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S1", "S2", "S3")) +
theme(legend.position = "none", legend.title = element_blank(),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
# DeSoto (S3)
b <-
ggplot(data = metab, aes(x = date)) +
# Horizontal line at Y = 0
geom_hline(yintercept = 0) +
# Vertical line at release stop date
geom_vline(xintercept = ymd("2018-04-01"), linetype = 2) +
# ER
geom_ribbon(aes(ymin = ER.lower.S3, ymax = ER.upper.S3),
fill = "lightgrey", alpha = 0.7) +
geom_pointrange(aes(y = ER.S3, ymin = ER.lower.S3, ymax = ER.upper.S3),
color = "lightgrey") +
geom_point(aes(y = ER.S3), size = 1.8, shape = 21, fill = "white") +
# GPP
geom_ribbon(aes(ymin = GPP.lower.S3, ymax = GPP.upper.S3),
fill = "lightgrey", alpha = 0.7) +
geom_pointrange(aes(y = GPP.S3, ymin = GPP.lower.S3, ymax = GPP.upper.S3),
color = "lightgrey") +
geom_point(aes(y = GPP.S3, fill = "S3"), size = 1.8, shape = 21) +
# y-axis limits
scale_y_continuous(limits = c(-8, 10), breaks = c(-10, -5, 0, 5, 10, 15)) +
# Axis labels
labs(x = NULL, tag = "b",
y = bquote("GPP or ER (g" ~~ O[2] ~ m^-2 ~ d^-1 ~ ")")) +
# Theme adjustments
theme_classic() +
scale_fill_manual(values = c("S1" = "#FF0000",
"S2" = "#23baaf", "S3" = "#F2AD00"),
breaks = c("S1", "S2", "S3")) +
theme(legend.position = "none", legend.title = element_blank(),
panel.border = element_rect(fill = NA),
axis.text = element_text(color = "black"),
text = element_text(size = 8))
grob <- grid.arrange(a,b, ncol = 1)
ggsave("./Plots/Fig3_MetabPlot.png", grob, height = 95, width = 115, units = "mm",
dpi = 600)
```
```{r Fig 4: Uptake and Vf}
# U ############################################################################
a <-
ggplot(data = uptake.long, aes(x = Date, y = UaNO3_gNm2day, fill = site)) +
facet_wrap(~site, nrow = 1) +