Friday, October 3, 2014

10 3 2014 How to Convert and Plot HoboLogger Temp Data

TempDataConcatScript.R
#Temp concat
library(plyr)
library(ggplot2)
library(scales)
oysaugfeb<-read.table('OysAugtoFeb.csv', row.names=1)
#read in data, first change column names and remove data name in excel to make it work
head(oysaugfeb)
##          V2    V3    V4
## 1 8/17/2013 12:42 23.77
## 2 8/17/2013 12:57 23.20
## 3 8/17/2013 13:12 23.20
## 4 8/17/2013 13:27 23.39
## 5 8/17/2013 13:42 23.58
## 6 8/17/2013 13:57 23.77
oysaugfeb<-rename(oysaugfeb, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
oysaugfeb$Date<-as.Date(oysaugfeb$Date, "%m/%d/%Y")
#tell R that these are dates
tmptst<-ddply(oysaugfeb,.(Date),summarise, mean_temp=mean(Temp,na.rm=T))
#creates mean temperature per date using summary statistics and ddply
plot(mean_temp~Date,data=tmptst)

plot of chunk unnamed-chunk-1

#plot using native plotting function to view temp graph, fix later with ggplot2 graph
oysfebmay<-read.table('Oyster_BayFebtoMay2014.csv', row.names=1)
oysmayjun<-read.table('OysterBayMaytoJune14.csv', row.names=1)
oysjun<-read.table('OysterBayJune14.csv',row.names=1)
oysjunjul<-read.table('Oyster_BayJuntoJul14.csv',row.names=1)
oysjunsep<-read.table('OysterBayJuntoSept.csv',row.names=1)
oysjulaug<-read.table('Oyster_BayJultoAug.csv',row.names=1)
oysaugsep<-read.table('Oyster_BayAug14toSep.csv',row.names=1)
#reads in as tables the other 4 temp data sets
oysfebmay<-rename(oysfebmay, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysmayjun<-rename(oysmayjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjun<-rename(oysjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjunjul<-rename(oysjunjul, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjunsep<-rename(oysjunsep, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjulaug<-rename(oysjulaug, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysaugsep<-rename(oysaugsep, c("V2"="Date",'V3'='Time','V4'='Temp'))
#renames the columns of the other 4 data sets
oysfebmay$Date<-as.Date(oysfebmay$Date, "%m/%d/%Y")
oysmayjun$Date<-as.Date(oysmayjun$Date, "%m/%d/%Y")
oysjun$Date<-as.Date(oysjun$Date, "%m/%d/%Y")
oysjunjul$Date<-as.Date(oysjunjul$Date, "%m/%d/%Y")
oysjunsep$Date<-as.Date(oysjunsep$Date, "%m/%d/%Y")
oysjulaug$Date<-as.Date(oysjulaug$Date, "%m/%d/%Y")
oysaugsep$Date<-as.Date(oysaugsep$Date, "%m/%d/%Y")
#tells R that all the date columns are dates
oysaugmay<-merge(oysaugfeb,oysfebmay,by = c("Date","Time","Temp"),all=T)
#merges oysaugfeb to oysfebmay into one continuous data file
oysy1<-rbind(oysaugfeb,oysfebmay,oysmayjun,oysjun,oysjunjul,oysjunsep,oysjulaug,oysaugsep)
#merges all temp files into a single table
oysmeantemp<-ddply(oysy1,.(Date),summarise,mean_temp=mean(Temp,na.rm=T))
#creates mean temp file
oysmintemp<-ddply(oysy1,.(Date),summarise,min_temp=min(Temp,na.rm=T))
#creates min temp file
oysmaxtemp<-ddply(oysy1,.(Date),summarise,max_temp=max(Temp,na.rm=T))
#creates max temp file
oysmedtemp<-ddply(oysy1,.(Date),summarise,med_temp=median(Temp,na.rm=T))
#creates median temp file
ggplot(data=oysmedtemp, aes(Date, med_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#generates plot of median temps
ggplot(data=oysmeantemp, aes(Date, mean_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#creates plot of mean temp data with 12.5 C line
ggplot(data=oysmintemp, aes(Date, min_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#creates plot of min temp data with 12.5 C line
ggplot(data=oysmaxtemp, aes(Date, max_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#creates plot of max temps with 12.5 C line
ggplot()+geom_line(data=oysmeantemp, aes(Date,mean_temp, group=1), color="orange",size=1)+geom_line(data=oysmintemp, aes(Date,min_temp,group=1),color="blue",size=1)+geom_line(data=oysmaxtemp,aes(Date,max_temp,group=1),color="red",size=1)+geom_abline(intercept=12.5, slope=0,color="red", size=0.5)+labs(x="Date",y="Min|Max|Mean Temperatures(C)")+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#generates plot containing min,max, and mean temp color coordinated as well as 12.5 C line. 
meanmax<-merge(oysmeantemp,oysmaxtemp,by="Date",all=T)
#merges mean and max frames
medmin<-merge(oysmedtemp,oysmintemp,by="Date",all=T)
#merges median and min frames
oystmpstat<-merge(meanmax,medmin,by="Date",all=T)
#merges meanmax and medmin frames together
oysy1stat<-merge(oysy1,oystmpstat,by="Date",all=T)
#merges year 1 temp info with stats for each date
write.csv(oysy1stat, file="oysY1stats.csv",row.names=F)
#creates CSV file with all temp and stat info

Friday, September 19, 2014

9 19 2014 oyster bay fall maintenance

Kamilche wa

High 60s low 70s cloudy to mostly sunny

Participants: Sean Bennett,  Jonathan Allen,  and Jake heare.

Took live dead counts for all remaining trays. Then moved remaining oysters from trays to new hexagonal hanging cages. Then tied the cages together and hung them off the same hanging ropes. Very high survival in all trays, less than 2% mortality. Food growth in all trays. Some oysters look market size now. Mussel incursion was much better than expected with very little in most trays. More red rock crabs than I expected but seemed to have little effect on survival. Also lots of oyster spat in all trays. Collected spat for DNA workup if desired.

Numbers as follow

1S9-12
Live.           3
Dead.         3
Sampled     3

1H13-16
Live.           12
Dead.          2
Sample.      12

1N1-4
Live.           72
Dead.         0
Sample.      20

1H5-8
Live.          49
Dead.         7
Sample.      13

1S1-4
Live.          80
Dead.         4
Sample.      24

1S13-16
Live.          71
Dead.          2
Sample.      23

1N5-8
Live.          51
Dead.         0
Sample.      10

1H9-12.     
Live.          80
Dead.         3
Sample.      15

1H1-4
Live.         67
Dead.        3
Sample.     10

1N9-12
Live.          77
Dead.         1
Sample.      20

Pics below. 1S1-4 tray with 3 live on it is actually 1S9-12.