R Session Info
sessionInfo()
## R version 3.4.3 (2017-11-30)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.3
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
## [5] tools_3.4.3 htmltools_0.3.6 yaml_2.1.16 Rcpp_0.12.15
## [9] stringi_1.1.6 rmarkdown_1.8 knitr_1.19 stringr_1.2.0
## [13] digest_0.6.15 evaluate_0.10.1
Purpose: The purpose of this document is to visualize and QC the extent of 2015 water temperature data collected as part of the EPSCoR SCTC Aquatic Ecology section.
Hypothesis: Distinct water temperature regimes of biological significance exist among tributaries and the mainstem of the Kenai River watershed.
Note: Not all data is fully continuous due to logger maintenance, failure, or loss.
Data considered here comes from three sources: (See Map: http://arcg.is/1C9Pv)
University of Alaska Fairbanks - HOBO TempPro V2 loggers were installed appx. May - Sept in 2016 at lower, middle, and upper sites in Beaver Creek, Russian River, and Ptarmigan Creek.
Kenai Watershed Forum - Hach Hydrolab multiprobe loggers were installed in adjacent pairs of two in the lower reach of Beaver Creek, Russian River, and Ptarmigan Creek most of the ice-free season.
USGS Gauges - USGS gauges record water temperature on the mainstem Kenai River near the communities of Soldotna and Cooper Landing. Data is imported from the web at nwis.waterdata.usgs.gov .
Do KWF and EPSCoR data correlate; is each representative of the other? If so, combine both datasets for coverage of maximum temporal extent.
How well do lower-reach water temp sites predict data longitudinally throughout each drainage?
How well does logger site predict instantaneous measurements at fish capture sites?
How representative is a “daily mean” water temp of an individual thermal experience? Explore other metrics to quantify caveats for using mean temp in bioenergetics input.
# Verify that sheets are present, create object of sheet with all tabs
BC15 <- gs_title("Beaver_Creek_2015_Water_Temperatures")
RR15 <- gs_title("Russian_River_2015_Water_Temperatures")
PC15 <- gs_title("Ptarmigan_Creek_2015_Water_Temperatures")
Sys.sleep(6)
# Read in data
# Use "Sys.sleep" function because the googlesheets package currently can't handle too many rapid, large data requests.
# read in individual logger data one sheet at a time
### EPSCoR Data ###
#Beaver Creek 2015
LBC2015 <- BC15 %>%
gs_read(ws = "LBC_WL_10324645",col_names=TRUE)
MBC2015 <- BC15 %>%
gs_read(ws = "MBC_WL_10324669",col_names=TRUE)
UBC2015 <- BC15 %>%
gs_read(ws = "UBC_WL_10537880",col_names=TRUE)
Sys.sleep(6)
# Bind UAF Beaver Creek data
BC_UAF15 <- rbind(LBC2015,MBC2015,UBC2015)
#Russian River 2015
LRR2015 <- RR15 %>%
gs_read(ws = "LRR_WL_2004072",col_names=TRUE)
MRR2015 <- RR15 %>%
gs_read(ws = "MRR_WL_10324639",col_names=TRUE)
URR2015 <- RR15 %>%
gs_read(ws = "URR_WL_10324638",col_names=TRUE)
Sys.sleep(6)
# Bind UAF Russian River data
RR_UAF15 <- bind_rows(LRR2015,MRR2015,URR2015)
#Ptarmigan Creek 2015
LPC2015 <- PC15 %>%
gs_read(ws = "LPC_WL_10324640",col_names=TRUE)
MPC2015 <- PC15 %>%
gs_read(ws = "MPC_WL_10324644",col_names=TRUE)
UPC2015 <- PC15 %>%
gs_read(ws = "UPC_WL_10324642",col_names=TRUE)
Sys.sleep(6)
# Bind UAF Ptarmigan creek data
PC_UAF15 <- bind_rows(LPC2015,MPC2015,UPC2015)
### Kenai Watershed Forum Data ###
# Read in KWF 2015 hydrolab water temp data
BC_KWF <- BC15 %>%
gs_read(ws = "KWF_Hydrolab", col_names = TRUE)
RR_KWF <- RR15 %>%
gs_read(ws = "KWF_Hydrolab", col_names = TRUE)
PC_KWF <- PC15 %>%
gs_read(ws = "KWF_Hydrolab", col_names = TRUE)
Sys.sleep(6)
#create total dataset for KWF water temp data
KWF15 <- rbind(PC_KWF,RR_KWF,BC_KWF)
# bind together KWF and UAF data and exculude unneeded columns
watertemps2015 <- bind_rows(BC_UAF15,RR_UAF15,PC_UAF15,KWF15) %>%
select(DateTime,Temp_C,`Stream Name`,`Hydrologic Segment`,`Site ID`,Agency) %>%
rename(Stream_Name = `Stream Name`,
Hydrologic_Segment = `Hydrologic Segment`,
Site_ID = `Site ID`) %>%
transform(DateTime = mdy_hm(DateTime))
# Mainstem Kenai River Data (from USGS)
# read in and join to watertemps2016 dataframe
# Read in online directly from USGS database
# Lower Kenai River
url_lkr15 <- "https://nwis.waterdata.usgs.gov/ak/nwis/uv/?cb_00010=on&format=rdb&site_no=15266300&period=&begin_date=2015-05-10&end_date=2015-10-01"
# remove first row of extraneous characters
LKR15 <- read.csv(url_lkr15,header=T,sep="\t",skip=26)[-1, ] %>%
rename(Temp_C = X1498_00010) %>% # USGS parameter number for water temperature)
select(agency_cd,datetime,Temp_C) %>%
mutate(`Site ID` = "LKR-USGS-2015",
`Site Description` = "Lower Kenai River USGS Gauge, Site no. 15266300",
Latitude = "60.4775",
Longitude = "-151.0794",
`Hydrologic Segment` = "Lower")
Sys.sleep(6)
# Middle Kenai River
url_mkr15 <- "https://nwis.waterdata.usgs.gov/ak/nwis/uv/?cb_00010=on&format=rdb&site_no=15258000&period=&begin_date=2015-05-10&end_date=2015-10-01"
# remove first row of extraneous characters
MKR15 <- read.csv(url_mkr15,header=T,sep="\t",skip=26)[-1, ] %>%
rename(Temp_C = X1478_00010) %>% # USGS parameter number for water temperature)
select(agency_cd,datetime,Temp_C) %>%
mutate(`Site ID` = "MKR-USGS-2015",
`Site Description` = "Middle Kenai River USGS Gauge, Site no. 15258000",
Latitude = "60.49277 ",
Longitude = "-149.80777 ",
`Hydrologic Segment` = "Middle")
Sys.sleep(6)
# Bind lower and middle sites into one dataframe
# exclude unneeded columns
KR15 <- bind_rows(LKR15, MKR15) %>%
rename(Agency = agency_cd,
DateTime = datetime) %>%
select(-Latitude, -Longitude,-`Site Description`) %>%
mutate(`Stream Name` = "Kenai River") %>%
rename(Stream_Name = `Stream Name`,
Hydrologic_Segment = `Hydrologic Segment`,
Site_ID = `Site ID`) %>%
transform(Temp_C = as.numeric(Temp_C),
DateTime = as.POSIXct(DateTime))
# combine USGS data with KWF and UAF data into watertemps2015 dataframe
watertemps2015 <- bind_rows(watertemps2015,KR15) %>%
# add useful columns for plotting & analysis
mutate(Site = paste0(`Hydrologic_Segment`," ",`Stream_Name`," ",
"\n", "(",`Site_ID`,")")) %>%
mutate(Date = date(DateTime)) %>%
mutate(Week = week(DateTime))
Table: All 2015 Water Temperature data
watertemps2015
Figure X- All data, 2016 water temperature.
# All Beaver Creek 2015 water temp data
BC15_all <- watertemps2015 %>%
filter(Stream_Name == "Beaver Creek")
# calculate Daily averages for all Beaver Creek 2015 water temp data
BC15_all_dayavg <- watertemps2015 %>%
filter(Stream_Name == "Beaver Creek") %>%
group_by(Date,Site,Stream_Name) %>%
summarise(avg_temp = mean(Temp_C))
###### i.) Raw data #####
# all together
zz1 <- ggplot(data=BC15_all,aes(x=DateTime,y=Temp_C,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Beaver Creek 2015 Water Temperature ") +
theme(legend.spacing.y = unit(2,"cm")) +
bm_theme
zz1
# save to folder
png(filename="Beaver Creek 2015 Water Temps.png",width=800,height=700,res=72)
plot(zz1)
dev.off()
## quartz_off_screen
## 2
# faceted
zz2 <- zz1 + facet_grid(Site_ID~.)
zz2
# save to folder
png(filename="Beaver Creek 2015 Water Temps faceted.png",width=800,height=700,res=72)
plot(zz2)
dev.off()
## quartz_off_screen
## 2
#### ii.) daily mean temps
# all together
zz3 <- ggplot(data=BC15_all_dayavg,aes(x=Date,y=avg_temp,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Beaver Creek 2015 Daily Mean Water Temperature") +
bm_theme
zz3
# save to folder
png(filename="Beaver Creek 2015 Daily Mean Water Temps.png",width=800,height=700,res=72)
plot(zz3)
dev.off()
## quartz_off_screen
## 2
#faceted
zz4 <- zz3 + facet_grid(Site~.)
zz4
# save to folder
png(filename="Beaver Creek 2015 Daily Mean Water Temps faceted.png",width=800,height=700,res=72)
plot(zz4)
dev.off()
## quartz_off_screen
## 2
Water temperature loggers were installed in relatively close proximity in the lower reach of each of the focus drainages, each with a different temporal extent. Do the datasets correspond closely enough to allow for their combination? E.g., to fill in data gaps as needed?
# a.) Join EPSCoR and KWF data only where data DO overlap temporally.
#### Lower Beaver Creek 2015 ####
# Prep EPSCoR Data
LBC_UAF <- watertemps2015 %>%
filter(Site_ID == "LBC-WL-2015") %>%
select(DateTime,Temp_C) %>%
rename(EPSCoR_Temp = Temp_C)
#select needed columns
LBC_KWF <- watertemps2015 %>%
filter(Site_ID == "LBC-KWF-2015") %>%
select(DateTime,Temp_C) %>%
rename(KWF_Temp = Temp_C)
#join UAF and KWF data in to single dataframe
z <- inner_join(LBC_UAF,LBC_KWF,by=c("DateTime")) %>%
#calculate magnitude of difference between UAF and KWF loggers
mutate(dif=abs(EPSCoR_Temp-KWF_Temp))
#plot UAF vs KWF data
q <- qplot(x=EPSCoR_Temp,y=KWF_Temp,data=z, main = "HOBO vs Hydrolab Water Temperature")
q
#summarize results
summary(z)
## DateTime EPSCoR_Temp KWF_Temp
## Min. :2015-06-07 10:30:00 Min. : 7.419 Min. : 7.26
## 1st Qu.:2015-06-26 23:26:15 1st Qu.:11.492 1st Qu.:11.46
## Median :2015-07-16 12:22:30 Median :12.606 Median :12.53
## Mean :2015-07-16 12:22:30 Mean :12.644 Mean :12.58
## 3rd Qu.:2015-08-05 01:18:45 3rd Qu.:13.786 3rd Qu.:13.74
## Max. :2015-08-24 14:15:00 Max. :17.653 Max. :17.61
## NA's :217
## dif
## Min. :0.00000
## 1st Qu.:0.04300
## Median :0.06700
## Mean :0.09285
## 3rd Qu.:0.15100
## Max. :0.31900
## NA's :217
# If mean difference between two datasets is < 0.2, can combine datasets to
# provide maximum temporal extent.
mean(z$dif)
## [1] NA
Mean difference is 0.0929. Thus KWF and UAF datasets can be combined as needed.
Visual inspection suggests that the best time series to represent lower Beaver Creek water conditions is achieved by combination of LBC-WL-2015 and LBC-KWF-2015 sites.
Decision: Use LBC-WL-2015 data to fill in gaps of LBC-KWF-2015 data.
# unable to find workable code to merge irregular time series in to one column; Lower Beaver Creek 2015 water temperature datasets are combined manually and stored at the following directory:
# /Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015
Plot all 2016 Russian River water temperature data
# Select data
# All Russian River 2015 water temp data
RR15_all <- watertemps2015 %>%
filter(Stream_Name == "Russian River")
# Daily averages for all Russian River 2015 water temp data
RR15_all_dayavg <- watertemps2015 %>%
filter(Stream_Name == "Russian River") %>%
group_by(Date,Site,Stream_Name) %>%
summarise(avg_temp = mean(Temp_C))
###### i.) Raw data #####
# all together
zz1 <- ggplot(data=RR15_all,aes(x=DateTime,y=Temp_C,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Russian River 2015 Water Temperature ") +
theme(legend.spacing.y = unit(10, 'line')) +
bm_theme
zz1
# save to folder
png(filename="Russian River 2015 Water Temps.png",width=800,height=700,res=72)
plot(zz1)
dev.off()
## quartz_off_screen
## 2
# faceted
zz2 <- zz1 + facet_grid(Site_ID~.)
zz2
# save to folder
png(filename="Russian River 2015 Water Temps faceted.png",width=800,height=700,res=72)
plot(zz2)
dev.off()
## quartz_off_screen
## 2
####### ii.) Daily averages ######
# all together
zz3 <- ggplot(data=RR15_all_dayavg,aes(x=Date,y=avg_temp,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Russian River 2015 Daily Mean Water Temperature") +
bm_theme
zz3
# save to folder
png(filename="Russian River 2015 Daily Mean Water Temps.png",width=800,height=700,res=72)
plot(zz3)
dev.off()
## quartz_off_screen
## 2
#faceted
zz4 <- zz3 + facet_grid(Site~.)
zz4
# save to folder
png(filename="Russian River 2015 Daily Mean Water Temps faceted.png",width=800,height=700,res=72)
plot(zz4)
dev.off()
## quartz_off_screen
## 2
# a.) Join EPSCoR and KWF data only where data DO overlap temporally.
#### Lower russian river 2015 ####
# Prep EPSCoR Data
LRR_UAF <- watertemps2015 %>%
filter(Site_ID == "LRR-WL-2015") %>%
select(DateTime,Temp_C) %>%
rename(EPSCoR_Temp = Temp_C)
#select needed columns
LRR_KWF <- watertemps2015 %>%
filter(Site_ID == "LRR-KWF-2015") %>%
select(DateTime,Temp_C) %>%
rename(KWF_Temp = Temp_C)
#join UAF and KWF data in to single dataframe
z <- inner_join(LRR_UAF,LRR_KWF,by=c("DateTime")) %>%
#calculate magnitude of difference between UAF and KWF loggers
mutate(dif=abs(EPSCoR_Temp-KWF_Temp))
#plot UAF vs KWF data
q <- qplot(x=EPSCoR_Temp,y=KWF_Temp,data=z, main = "HOBO vs Hydrolab Water Temperature")
q
#summarize results
summary(z)
## DateTime EPSCoR_Temp KWF_Temp
## Min. :2015-06-22 13:45:00 Min. :10.91 Min. : 9.00
## 1st Qu.:2015-07-08 01:11:15 1st Qu.:13.06 1st Qu.:10.54
## Median :2015-07-23 12:37:30 Median :13.86 Median :11.60
## Mean :2015-07-23 12:37:30 Mean :14.04 Mean :11.62
## 3rd Qu.:2015-08-08 00:03:45 3rd Qu.:14.79 3rd Qu.:12.47
## Max. :2015-08-23 11:30:00 Max. :18.94 Max. :16.07
## NA's :102
## dif
## Min. :0.028
## 1st Qu.:1.898
## Median :2.578
## Mean :2.412
## 3rd Qu.:2.988
## Max. :4.634
## NA's :102
If mean difference between two datasets is <0.2, can combine datasets to provide maximum temporal extent.
Mean difference between is 2.41 C. NOTE: The Lower Russian River area appears to have a distinct thermal regime at the UAF site vs. the KWF site. These datasets should NOT be combined, but rather considered individually. Spatial distance between these sites is at least ~4 km thus results are unsurprising.
Decision: will use KWF data for Lower Reach Russian River modeling purposes, because initial evidence suggests that the UAF site LRR-WL-2015 was NOT suffiently well-mixed enough to be representative of lower russian river reach. Likely that water warms up substantially between the falls and the mouth of the Russian River due to wide, shallow channel.
Finalized data stored at directory “/Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015”.
# KWF russian river 2015 water temperature datasets is stored at the following directory:
setwd("/Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015")
rr15_fnl <- watertemps2015 %>%
filter(Site_ID == "LRR-KWF-2015") %>%
mutate(Date = date(DateTime)) %>%
select(Site,DateTime,Date,Temp_C,Agency) %>%
rename(Source = Agency)
# write.csv(rr15_fnl, "2015_LRR_H2OTemp_Final.csv")
Plot all 2015 Ptarmigan Creek water temperature data.
# All Ptarmigan Creek 2015 water temp data
PC15_all <- watertemps2015 %>%
filter(Stream_Name == "Ptarmigan Creek")
# Daily averages for all Ptarmigan Creek 2015 water temp data
PC15_all_dayavg <- watertemps2015 %>%
filter(Stream_Name == "Ptarmigan Creek") %>%
group_by(Date,Site,Stream_Name) %>%
summarise(avg_temp = mean(Temp_C))
###### i.) Raw data #####
# all together
zz1 <- ggplot(data=PC15_all,aes(x=DateTime,y=Temp_C,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Ptarmigan Creek 2015 Water Temperature ") +
theme(legend.spacing.y = unit(10, 'line')) +
bm_theme
zz1
# save to folder
png(filename="Ptarmigan Creek 2015 Water Temps.png",width=800,height=700,res=72)
plot(zz1)
dev.off()
## quartz_off_screen
## 2
# faceted
zz2 <- zz1 + facet_grid(Site_ID~.)
zz2
# save to folder
png(filename="Ptarmigan Creek 2015 Water Temps faceted.png",width=800,height=1000,res=72)
plot(zz2)
dev.off()
## quartz_off_screen
## 2
####### ii.) Daily averages ######
# all together
zz3 <- ggplot(data=PC15_all_dayavg,aes(x=Date,y=avg_temp,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Ptarmigan Creek 2015 Daily Mean Water Temperature") +
bm_theme
zz3
# save to folder
png(filename="Ptarmigan Creek 2015 Daily Mean Water Temps.png",width=800,height=700,res=72)
plot(zz3)
dev.off()
## quartz_off_screen
## 2
#faceted
zz4 <- zz3 + facet_grid(Site~.)
zz4
# save to folder
png(filename="Ptarmigan Creek 2016 Daily Mean Water Temps faceted.png",width=800,height=700,res=72)
plot(zz4)
dev.off()
## quartz_off_screen
## 2
Water temperature loggers were installed in relatively close proximity in the lower reach of each of the focus drainages, each with a different temporal extent. Do the datasets correspond closely enough to allow for their combination? E.g., to fill in data gaps as needed?
#### Lower Ptarmigan Creek 2015 ####
# Prep EPSCoR Data
LPC_UAF <- watertemps2015 %>%
filter(Site_ID == "LPC-WL-2015") %>%
select(DateTime,Temp_C) %>%
rename(EPSCoR_Temp = Temp_C)
#select needed columns
LPC_KWF <- watertemps2015 %>%
filter(Site_ID == "LPC-KWF-2015") %>%
select(DateTime,Temp_C) %>%
rename(KWF_Temp = Temp_C)
#join UAF and KWF data in to single dataframe
z <- inner_join(LPC_UAF,LPC_KWF,by=c("DateTime")) %>%
#calculate magnitude of difference between UAF and KWF loggers
mutate(dif=abs(EPSCoR_Temp-KWF_Temp))
#plot UAF vs KWF data
q <- qplot(x=EPSCoR_Temp,y=KWF_Temp,data=z)
q
#summarize results
summary(z)
## DateTime EPSCoR_Temp KWF_Temp
## Min. :2015-05-31 20:00:00 Min. : 7.494 Min. : 7.38
## 1st Qu.:2015-06-22 07:18:45 1st Qu.:11.053 1st Qu.:10.95
## Median :2015-07-13 18:52:30 Median :12.292 Median :12.21
## Mean :2015-07-13 18:48:31 Mean :12.228 Mean :12.12
## 3rd Qu.:2015-08-04 06:11:15 3rd Qu.:13.257 3rd Qu.:13.16
## Max. :2015-08-25 17:30:00 Max. :16.487 Max. :16.39
## NA's :305
## dif
## Min. :0.0000
## 1st Qu.:0.0610
## Median :0.1080
## Mean :0.1406
## 3rd Qu.:0.1860
## Max. :0.8930
## NA's :305
If mean difference between two datasets is <0.2, thus can combine datasets to fill in gaps and provide maximum temporal extent. Mean difference between sites in 2016 is 0.141 C; within tolerance margin.
Decision: water temperature data from KWF site is of much longer time series and correlates well with UAF site. Will use KWF site temps for modeling purposes in lower Ptarmigan creek.
Lower Ptarmigan Creek 2015 data is combined manually and saved at “/Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data”.
Plot all 2015 Kenai River water temperature data
# All Kenai River 2015 water temp data
KR15_all <- watertemps2015 %>%
filter(Stream_Name == "Kenai River")
# Daily averages for all Kenai River 2015 water temp data
KR15_all_dayavg <- watertemps2015 %>%
filter(Stream_Name == "Kenai River") %>%
group_by(Date,Site,Stream_Name) %>%
summarise(avg_temp = mean(Temp_C))
###### i.) Raw data #####
# all together
zz1 <- ggplot(data=KR15_all,aes(x=DateTime,y=Temp_C,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Kenai River 2015 Water Temperature ") +
theme(legend.spacing.y = unit(10, 'line')) +
bm_theme
zz1
# save to folder
png(filename="Kenai River 2015 Water Temps.png",width=800,height=700,res=72)
plot(zz1)
dev.off()
## quartz_off_screen
## 2
# faceted
zz2 <- zz1 + facet_grid(Site_ID~.)
zz2
# save to folder
png(filename="Kenai River 2015 Water Temps faceted.png",width=800,height=700,res=72)
plot(zz2)
dev.off()
## quartz_off_screen
## 2
####### ii.) Daily averages ######
# all together
zz3 <- ggplot(data=KR15_all_dayavg,aes(x=Date,y=avg_temp,color=Site)) +
geom_line() +
xlab("Date") +
ylab("Temperature (C)") +
ggtitle("Kenai River 2015 Daily Mean Water Temperature") +
bm_theme
zz3
# save to folder
png(filename="Kenai River 2015 Daily Mean Water Temps.png",width=800,height=700,res=72)
plot(zz3)
dev.off()
## quartz_off_screen
## 2
#faceted
zz4 <- zz3 + facet_grid(Site~.)
zz4
# save to folder
png(filename="Kenai River 2015 Daily Mean Water Temps faceted.png",width=800,height=700,res=72)
plot(zz4)
dev.off()
## quartz_off_screen
## 2
Inspection of the above charts suggest the lower and middle Kenai River USGS gauge sites have distinct thermal regimes.
Question: On average, how much do the sites differ in termperature throughuot the study period?
# Prep USGS Data Lower Kenai
LKR_USGS <- watertemps2015 %>%
filter(Site_ID == "LKR-USGS-2015") %>%
select(DateTime,Temp_C) %>%
rename(LKR_Temp = Temp_C)
# Prep USGS Data Middle Kenai
MKR_USGS <- watertemps2015 %>%
filter(Site_ID == "MKR-USGS-2015") %>%
select(DateTime,Temp_C) %>%
rename(MKR_Temp = Temp_C)
#join UAF and KWF data in to single dataframe
z <- inner_join(LKR_USGS,MKR_USGS,by=c("DateTime")) %>%
#calculate magnitude of difference between UAF and KWF loggers
mutate(dif=abs(MKR_Temp - LKR_Temp))
#plot UAF vs KWF data
q <- qplot(x=LKR_Temp,y=MKR_Temp,data=z)
q
#summarize results
summary(z)
## DateTime LKR_Temp MKR_Temp
## Min. :2015-05-10 08:00:00 Min. : 5.50 Min. : 4.900
## 1st Qu.:2015-06-15 13:56:15 1st Qu.: 8.70 1st Qu.: 6.800
## Median :2015-07-21 19:52:30 Median :10.50 Median : 8.700
## Mean :2015-07-21 19:52:30 Mean :10.68 Mean : 8.764
## 3rd Qu.:2015-08-27 01:48:45 3rd Qu.:12.50 3rd Qu.:10.400
## Max. :2015-10-02 07:45:00 Max. :16.90 Max. :15.200
## dif
## Min. : 0.000
## 1st Qu.: 0.700
## Median : 1.700
## Mean : 2.078
## 3rd Qu.: 3.100
## Max. :10.400
# Prep for export
# Lower Kenai
setwd("/Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015")
LKR_USGS <- watertemps2015 %>%
filter(Site_ID == "LKR-USGS-2015")
# write file
# write.csv(LKR_USGS, file = "2015_LKR_H2OTemp_Final.csv")
# Lower Kenai River 2015 data is saved at
# /Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015
# Middle Kenai
setwd("/Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015")
MKR_USGS <- watertemps2015 %>%
filter(Site_ID == "MKR-USGS-2015")
# write file
# write.csv(MKR_USGS, file = "2015_MKR_H2OTemp_Final.csv")
# Lower Kenai River 2015 data is saved at
# /Users/bmeyer/Google Drive/Thesis/R Analysis/Temperature Data/Final Temperature Data/2015
If mean difference between two datasets is <0.2, can combine datasets to provide maximum temporal extent. NOTE: The Lower and Middle Kenai USGS gauge sites have distinct thermal regimes throughout the study period (mean dif = 2.08 C).
Decision: Treat lower and middle Kenai as seperate regimes/sites for modeling purposes…
Uses finalized data from previous step. This data will be used as inputs for initial bioenegetic modeling.
#### Boxplots ###
#Create boxplot with of weekly temperatures
bp <- ggplot(fnl_temps,aes(factor(Week),Temp_C))
zz <- bp + geom_boxplot() +
facet_grid(Site~.) +
theme_bw() +
xlab("Week") +
ylab("Temperature (C)") +
ggtitle("2015 Weekly Water Temperature")
zz
# save to folder
png(filename="2015 Boxplot Water Temps.png",width=800,height=1000,res=72)
plot(zz)
dev.off()
## quartz_off_screen
## 2
### Lower Sites TimeSeries ###
# Plot final 2015 data from LBC, LRR, LPC, MKR, and LKR together; how do temperature regimes compare?
# Total time series 2015
lower_sites <- ggplot(fnl_temps,aes(DateTime,Temp_C, color = Site))
zz1 <- lower_sites + geom_line()
zz1
# save to folder
png(filename="2015 All Lower Sites Water Temps.png",width=800,height=700,res=72)
plot(zz1)
dev.off()
## quartz_off_screen
## 2
# Weekly averages 2015
lower_sites_watertemp_2015_dayavg <- fnl_temps %>%
group_by(Site,Date) %>%
summarise(daily_avg = mean(Temp_C))
# plot
lower_sites_dayavg <- ggplot(lower_sites_watertemp_2015_dayavg,aes(Date,daily_avg, color = Site))
zz2 <- lower_sites_dayavg + geom_line()
zz2
# save to folder
png(filename="2015 Daily Means - All Lower Sites Water Temps.png",width=800,height=700,res=72)
plot(zz2)
dev.off()
## quartz_off_screen
## 2
# Color-heat scatterplot for temperature time series
# For daily mean temperatures with loess smooth curve
# (from https://www.r-bloggers.com/part-3a-plotting-with-ggplot2/)
# plot all final data
zz3 <- ggplot(lower_sites_watertemp_2015_dayavg,aes(x = Date,y = daily_avg)) +
facet_grid(Site~.) +
ggtitle ("2015 Daily Mean Water Temperature") +
geom_point(aes(colour = daily_avg),size=5) +
scale_colour_gradient2(name = "Logger\nTemperature",
low = "blue",
mid = "green",
high = "red",
midpoint = 12) +
geom_smooth(span=0.3,color = "red",size = 1) +
scale_y_continuous(limits = c(5,18), breaks = seq(5,18,5)) +
xlab("Date") +
ylab ("Temperature (ºC)") +
theme_bw() +
bm_theme
# Plot temperature logger time series
zz3
# save to folder
png(filename="2015 Daily Means - Loess - All Lower Sites Water Temps.png",width=800,height=700,res=72)
plot(zz3)
dev.off()
## quartz_off_screen
## 2
Some sites use a combination of data from more than one nearby logger in order to achieve the longest continuous time series (e.g. nearby UAF and KWF loggers). In these cases, what is the percent contribution from each source?
pct_tbl <- fnl_temps %>%
group_by(Site, Agency) %>%
summarise(n = n()) %>%
mutate(freq = n / sum(n)) %>%
select(-n) %>%
spread(Agency, freq)
pct_tbl[is.na(pct_tbl)] <- 0
datatable(pct_tbl) %>%
formatPercentage(c("KWF","UAF","USGS"), 2)