knitr::opts_knit$set(root.dir = "//Users//abbey//Desktop//thesis//data//REPORT//weather//csv//compiled_weather")
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(ggplot2)
for preliminary data organization and viewing: load in and format february CC data, change class from character (initial) to date (final as “POSIXct” “POSIXt” )
#setwd("//Users//abbey//Desktop//thesis//data//REPORT//weather//csv//compiled_weather")
feb_CC <-read.csv("feb_cc_compiled.csv", stringsAsFactors = FALSE)
class(feb_CC$date)
## [1] "character"
head(feb_CC$time)
## [1] "14:00:00" "15:00:00" "16:00:00" "17:00:00" "18:00:00" "19:00:00"
# merging date and time columns
feb_CC$datetime <- paste(feb_CC$date, feb_CC$time)
class(feb_CC$datetime)
## [1] "character"
feb_CC$datetime2 <- mdy_hms(feb_CC$datetime)
class(feb_CC$datetime2)
## [1] "POSIXct" "POSIXt"
plot(feb_CC$datetime2,feb_CC$temp_C)
load in and format february SC data, change class from character (initial) to date (final as “POSIXct” “POSIXt” )
setwd("//Users//abbey//Desktop//thesis//data//REPORT//weather//csv//compiled_weather")
feb_SC <-read.csv("feb_sc_compiled.csv", stringsAsFactors = FALSE)
class(feb_SC$date)
## [1] "character"
head(feb_SC$time)
## [1] "13:00:00" "14:00:00" "15:00:00" "16:00:00" "17:00:00" "18:00:00"
# merging date and time columns
feb_SC$datetime <- paste(feb_SC$date, feb_SC$time)
class(feb_SC$datetime)
## [1] "character"
feb_SC$datetime2 <- mdy_hms(feb_SC$datetime)
class(feb_SC$datetime2)
## [1] "POSIXct" "POSIXt"
plot(feb_SC$datetime2,feb_SC$temp_C)
note that deployment took place at jan 10 at 2pm for january samples ONLY and then on jan 14 midday. the logger stopped collecting for some reason before it was placed out, unfortunately. data collection started back up after the first harvest
load in and format jun CC data, change class from character (initial) to date (final as “POSIXct” “POSIXt” )
setwd("//Users//abbey//Desktop//thesis//data//REPORT//weather//csv//compiled_weather")
jun_CC <-read.csv("jun_cc_compiled.csv", stringsAsFactors = FALSE)
# merging date and time columns
jun_CC$datetime <- paste(jun_CC$date, jun_CC$time)
jun_CC$datetime2 <- mdy_hms(jun_CC$datetime)
plot(jun_CC$datetime2,jun_CC$temp_C)
this temperature logger must have been one of those out in the field testing since late December
load in and format jun SC data, change class from character (initial) to date (final as “POSIXct” “POSIXt” )
setwd("//Users//abbey//Desktop//thesis//data//REPORT//weather//csv//compiled_weather")
jun_SC <-read.csv("jun_SC_compiled.csv", stringsAsFactors = FALSE)
# merging date and time columns
jun_SC$datetime <- paste(jun_SC$date, jun_SC$time)
jun_SC$datetime2 <- mdy_hms(jun_SC$datetime)
plot(jun_SC$datetime2,jun_SC$temp_C)
to begin, compare the weather data between two HOBOS both under current conditions (CC).
#merging two datafarmes
feb_CC$temp_C_feb<-feb_CC$temp_C
jun_CC$temp_C_jun<-jun_CC$temp_C
CC=cbind(feb_CC,jun_CC)
CC <- CC[, !duplicated(colnames(CC))]
CC_final<- CC[,c(6,7,8)]
#graphing in ggplot
ggplot(CC_final, aes(x=datetime2))+
geom_line(aes(y = temp_C_feb, colour = "temperature C feb site")) +
geom_line(aes(y = temp_C_jun, colour = "temperature C jun site"))+
theme(legend.position = "bottom")+
ggtitle("current conditions temperature trends")
notice temperature differentials throughout jan 10 - jan 14 (ish). this is due to the fact that the january plot was placed out on jan 10th (~2pm), and then the subsequent plots feb thru june were set out on january 14. therefore, the first 4 days of the ‘green’ line represents most like room temperature, while the orange is recording the actual room temperature. cool!
now, compare this ‘current condition’ data to that of the snow cover conditions (SC). since one out of the two HOBO loggers for this treatment did not successfully record data, there will only be one additional data set added to the graph.
next, compare the weather data between two HOBOS both under snow conditions (SC).
#merging two datafarmes
feb_SC$temp_C_feb_SC<-feb_SC$temp_C
jun_SC$temp_C_jun_SC<-jun_SC$temp_C
SC<-merge(feb_SC, jun_SC, by="datetime2", all = T)
SC_final<- SC[,c(1,7,13)]
#graphing in ggplot
ggplot(SC_final, aes(x=datetime2))+
geom_line(aes(y = temp_C_feb_SC, colour = "temperature C feb site")) +
geom_line(aes(y = temp_C_jun_SC, colour = "temperature C jun site"))+
theme(legend.position = "bottom")+
ggtitle("snow cover temperature trends")
## Warning: Removed 887 rows containing missing values (geom_path).
note: feb site SC temp monitor is not the best at keeping a consistent data record…
merging the data for 2 logs of current conditions and 1 log of snow cover conditions:
both_sites<-merge(SC_final, CC_final, by="datetime2", all = T)
plotting these results:
ggplot(both_sites, aes(x=datetime2))+
geom_line(aes(y = temp_C_feb, colour = "temperature C feb site")) +
geom_line(aes(y = temp_C_jun, colour = "temperature C jun site"))+
geom_line(aes(y = temp_C_jun_SC, colour = "temperature C jun site, snow cover"))+
geom_line(aes(y = temp_C_feb_SC, colour = "temperature C feb site, snow cover"))+
scale_color_manual(values=c("#FF3300", "#99FF33", "#0000CC", "#000000"))+
theme(legend.position = "bottom")
## Warning: Removed 887 rows containing missing values (geom_path).
we want all data from jan 14 onward, therefore subset data from ‘both_sites’ to only include measurements after 2pm on the 14th (time in which samples were in place)
both_sites_final <- subset(both_sites, datetime2 > "2020-01-14 09:00:00")
trying out this graph while creating a mean current conditions between the two data sets feb_CC and jun_CC. new column titled ‘mean_CC’ has averaged the two temperature records for CC
both_sites_final$mean_CC = (both_sites_final$temp_C_feb + both_sites_final$temp_C_jun) / 2
both_sites_final$mean_SC <- rowMeans(both_sites_final[c('temp_C_feb_SC', 'temp_C_jun_SC')], na.rm=TRUE)
ggplot(both_sites_final, aes(x=datetime2))+
geom_line(aes(y = mean_CC, colour = "current conditions mean temperature")) +
geom_line(aes(y = mean_SC, colour = "snow cover mean temperature"))+
scale_color_manual(values=c("#FF6633", "#000000"))+
theme(legend.position = "bottom")+
labs(title="localized temperature through time relative to experimental treatment",
x ="date", y = "temperature (°C)")
note: interesting temperature spikes in the snow cover mean temp (black line) between mar 01 and mar 15 - most likely in high melt events that allowed for temperatures to spike above 0°C
the above graph is the ~final product~ in which we are tracking temperature through time, comparing between experimental treatments (snow cover and no snow cover)
TO DO
resume here.