#Converting units from umolCO2/m2/s to gC/m2/30min
realtower$NEE <- (realtower$NEE*1800*12/1000000)
realtower$RECO <- (realtower$RECO*1800*12/1000000)
#Making GPP negative in addition to unit conversion
realtower$GPP <- (realtower$GPP*1800*12/1000000*-1)#NEE daily df
dailyNEE <- aggregate(realtower$NEE, by=list(year=realtower$year, month=realtower$month, day=realtower$day),FUN=sum, na.rm=T)
dailyNEE$date <- paste0(dailyNEE$year, dailyNEE$month, dailyNEE$day)
dailyNEE <- filter(dailyNEE, year!="20")
dailyNEE <- dailyNEE %>% arrange(date)
dailyNEE$x <- ifelse(dailyNEE$year==13,NA,dailyNEE$x)#GPP daily df
dailyGPP <- aggregate(realtower$GPP, by=list(year=realtower$year, month=realtower$month, day=realtower$day),FUN=sum, na.rm=T)
dailyGPP$date <- paste0(dailyGPP$year, dailyGPP$month, dailyGPP$day)
dailyGPP <- filter(dailyGPP, year!="20")
dailyGPP <- dailyGPP %>% arrange(date)
dailyGPP$x <- ifelse(dailyGPP$year==13,NA,dailyGPP$x)#RECO daily df
dailyRECO <- aggregate(realtower$RECO, by=list(year=realtower$year, month=realtower$month, day=realtower$day),FUN=sum, na.rm=T)
dailyRECO$date <- paste0(dailyRECO$year, dailyRECO$month, dailyRECO$day)
dailyRECO <- filter(dailyRECO, year!="20")
dailyRECO <- dailyRECO %>% arrange(date)
dailyRECO$x <- ifelse(dailyRECO$year==13,NA,dailyRECO$x)#NEE Daily sum across entire study period
p <- ggplot(dailyNEE, aes(x=date, y=x)) +geom_point() + labs(caption = "Daily sums of NEE across entire study period, partially missing 2019 data.", title = "NEE daily sums", y= "NEE (g/m2/day)", x="date") + scale_x_discrete(breaks=c("070101","080101","090101","100101","110101","120101","130101","140101","150101","160101","170101","180101","190101"), labels=c("2007","2008", "2009","2010", "2011","2012","2013","2014","2015","2016","2017","2018","2019")) + theme(axis.text.x = element_text(angle=45))
print(p)#Creating monthy NEE sum df's
monthlyNEE <- aggregate(dailyNEE$x, by=list(year=dailyNEE$year, month=dailyNEE$month),na.rm=T, FUN=sum)
monthlyNEE <- monthlyNEE %>% arrange(year, month)
monthlyNEE <- filter(monthlyNEE, year !="13")
monthlyNEE <- filter(monthlyNEE, year !="20")
monthlyNEE <-
monthlyNEE %>%
mutate(
grouping =
case_when(
year == "07" ~ "pre"
, year == "08" ~ "pre"
, year == "09" ~ "pre"
, year == "10" ~ "pre"
, year == "11" ~ "pre"
, year == "12" ~ "pre"
, year == "14" ~ "14"
, year == "15" ~ "15"
, year == "16" ~ "16"
, year == "17" ~ "17"
, year == "18" ~ "18"
, year == "19" ~ "19"
))
monthlyNEE <- aggregate(monthlyNEE$x, by=list(month=monthlyNEE$month, prepost=monthlyNEE$grouping),FUN=mean)
monthlyNEE <- monthlyNEE %>% arrange(month, prepost)
p <-ggplot(monthlyNEE,aes(x=month, y=x, color=prepost, group=prepost)) + geom_point()+ geom_line() + labs( title="Monthly NEE Sum by Pre and Post Fire Years", y="NEE (gco2/m2/month)", x="Month")
print(p)#Creating monthy GPP sum df's
monthlyGPP <- aggregate(dailyGPP$x, by=list(year=dailyGPP$year, month=dailyGPP$month),na.rm=T, FUN=sum)
#Make GPP negative
monthlyGPP <- monthlyGPP %>% arrange(year, month)
monthlyGPP <- filter(monthlyGPP, year !="13")
monthlyGPP <- filter(monthlyGPP, year !="20")
monthlyGPP <-
monthlyGPP %>%
mutate(
grouping =
case_when(
year == "07" ~ "pre"
, year == "08" ~ "pre"
, year == "09" ~ "pre"
, year == "10" ~ "pre"
, year == "11" ~ "pre"
, year == "12" ~ "pre"
, year == "14" ~ "14"
, year == "15" ~ "15"
, year == "16" ~ "16"
, year == "17" ~ "17"
, year == "18" ~ "18"
, year == "19" ~ "19"
))
monthlyGPP <- aggregate(monthlyGPP$x, by=list(month=monthlyGPP$month, prepost=monthlyGPP$grouping),FUN=mean)
monthlyGPP <- monthlyGPP %>% arrange(month, prepost)
p <-ggplot(monthlyGPP,aes(x=month, y=x, color=prepost, group=prepost)) + geom_point()+ geom_line() + labs(title="Monthly GPP Sum by Pre and Post Fire Years", y="GPP (gco2/m2/month)", x="Month")
print(p)#Creating monthy RECO sum df's
monthlyRECO <- aggregate(dailyRECO$x, by=list(year=dailyRECO$year, month=dailyRECO$month),na.rm=T, FUN=sum)
monthlyRECO <- monthlyRECO %>% arrange(year, month)
monthlyRECO <- filter(monthlyRECO, year !="13")
monthlyRECO <- filter(monthlyRECO, year !="20")
monthlyRECO <-
monthlyRECO %>%
mutate(
grouping =
case_when(
year == "07" ~ "pre"
, year == "08" ~ "pre"
, year == "09" ~ "pre"
, year == "10" ~ "pre"
, year == "11" ~ "pre"
, year == "12" ~ "pre"
, year == "14" ~ "14"
, year == "15" ~ "15"
, year == "16" ~ "16"
, year == "17" ~ "17"
, year == "18" ~ "18"
, year == "19" ~ "19"
))
monthlyRECO <- aggregate(monthlyRECO$x, by=list(month=monthlyRECO$month, prepost=monthlyRECO$grouping),FUN=mean)
monthlyRECO <- monthlyRECO %>% arrange(month, prepost)
p <-ggplot(monthlyRECO,aes(x=month, y=x, color=prepost, group=prepost)) + geom_point()+ geom_line() + labs(title="Monthly RECO Sum by Pre and Post Fire Years", y="RECO (gco2/m2/month)", x="Month")
print(p)#Building df for calculating pre fire GPP/month - post fire GPP/month
monthlydiffGPP <- split(monthlyGPP,monthlyGPP$prepost)
monthlydiffGPP <- data.frame(monthlydiffGPP)
monthlydiffGPP <- monthlydiffGPP %>% select(pre.month, pre.x, X14.x,X15.x,X16.x,X17.x,X18.x,X19.x)
monthlydiffGPP$preminus14 <- monthlydiffGPP$pre.x - monthlydiffGPP$X14.x
monthlydiffGPP$preminus15 <- monthlydiffGPP$pre.x - monthlydiffGPP$X15.x
monthlydiffGPP$preminus16 <- monthlydiffGPP$pre.x - monthlydiffGPP$X16.x
monthlydiffGPP$preminus17 <- monthlydiffGPP$pre.x - monthlydiffGPP$X17.x
monthlydiffGPP$preminus18 <- monthlydiffGPP$pre.x - monthlydiffGPP$X18.x
monthlydiffGPP$preminus19 <- monthlydiffGPP$pre.x - monthlydiffGPP$X19.x
monthlydiffGPP <- select(monthlydiffGPP, pre.month, preminus14,preminus15, preminus16, preminus17, preminus18, preminus19)
monthlydiffGPP <- melt(monthlydiffGPP, id=c("pre.month"))
monthlydiffGPP <-
monthlydiffGPP %>%
mutate(
year =
case_when(
variable == "preminus14" ~ "14"
, variable == "preminus15" ~ "15"
, variable == "preminus16" ~ "16"
, variable == "preminus17" ~ "17"
, variable == "preminus18" ~ "18"
, variable == "preminus19" ~ "19"
))
monthlydiffGPP <- monthlydiffGPP %>%
mutate(post_fire_GPP_more_or_less = ifelse(value < 0, "lessGPP", "moreGPP"))#Plotting the differences in monthly GPP
p <- ggplot(monthlydiffGPP,aes(x = pre.month, y= value, group = year)) + geom_point(aes(color = post_fire_GPP_more_or_less)) + geom_line() + labs(title = "Difference in PreFire Monthly GPP and PostFire Monthly GPP", x="Month", y="GPP (gCO2/m2/month)") + facet_wrap(~year)
print(p)Monthly difference between pre-fire GPP and Post fire GPP. Positive values indicate that post fire year had more GPP than prefire year. Calculated as(pre daily GPP sum/month - post fire year GPP sum/month)
#Building df for calculating pre fire RECO/month - post fire RECO/month
monthlydiffRECO <- split(monthlyRECO,monthlyRECO$prepost)
monthlydiffRECO <- data.frame(monthlydiffRECO)
monthlydiffRECO <- monthlydiffRECO %>% select(pre.month, pre.x, X14.x,X15.x,X16.x,X17.x,X18.x,X19.x)
monthlydiffRECO$preminus14 <- monthlydiffRECO$pre.x - monthlydiffRECO$X14.x
monthlydiffRECO$preminus15 <- monthlydiffRECO$pre.x - monthlydiffRECO$X15.x
monthlydiffRECO$preminus16 <- monthlydiffRECO$pre.x - monthlydiffRECO$X16.x
monthlydiffRECO$preminus17 <- monthlydiffRECO$pre.x - monthlydiffRECO$X17.x
monthlydiffRECO$preminus18 <- monthlydiffRECO$pre.x - monthlydiffRECO$X18.x
monthlydiffRECO$preminus19 <- monthlydiffRECO$pre.x - monthlydiffRECO$X19.x
monthlydiffRECO <- select(monthlydiffRECO, pre.month, preminus14,preminus15, preminus16, preminus17, preminus18, preminus19)
monthlydiffRECO <- melt(monthlydiffRECO, id=c("pre.month"))
monthlydiffRECO <-
monthlydiffRECO %>%
mutate(
year =
case_when(
variable == "preminus14" ~ "14"
, variable == "preminus15" ~ "15"
, variable == "preminus16" ~ "16"
, variable == "preminus17" ~ "17"
, variable == "preminus18" ~ "18"
, variable == "preminus19" ~ "19"
))
monthlydiffRECO <- monthlydiffRECO %>%
mutate(post_fire_RECO_more_or_less = ifelse(value < 0, "MoreRECO", "LessRECO"))#Plotting the differences in monthly RECO
p <- ggplot(monthlydiffRECO,aes(x = pre.month, y= value, group = year)) + geom_point(aes(color = post_fire_RECO_more_or_less)) + geom_line() + labs(caption = "", subtitle = "Negative values indicate post fire RECO was greater than pre fire RECO" , title = "Difference in PreFire Monthly RECO and PostFire Monthly RECO", x="Month", y="RECO (gCO2/m2/month)") +ylim(-80, 30)+ facet_wrap(~year)
print(p)Monthly difference between pre-fire RECO and Post fire RECO. Calculated as(Pre Fire Monthly RECO - Post Fire Monthly RECO)
#Combining monthly Difference plots
ggplot(data = NULL, aes(x = pre.month, y= value, group = year)) + geom_point(data=monthlydiffGPP, aes(color = post_fire_GPP_more_or_less)) + geom_point(data=monthlydiffRECO,aes(color = post_fire_RECO_more_or_less)) + facet_wrap(~year)+ geom_line(data=monthlydiffGPP, aes(color = post_fire_GPP_more_or_less))+ geom_line(data=monthlydiffRECO, aes(color = post_fire_RECO_more_or_less)) + labs(title = "Combined plot of how post fire year's GPP and RECO compare to prefire years")Monthly difference between pre-fire RECO and Post fire RECO. Calculated as(Pre Fire Monthly RECO - Post Fire Monthly RECO)
# Creating 5 day smoothing window
fivedayNEEmovingaverage <- ma(realtower$NEE, 240)
fivedayNEEmovingaverage <- as.data.frame(fivedayNEEmovingaverage)
fivedayNEEmovingaverage$rownumber <- seq.int(nrow(fivedayNEEmovingaverage))
colnames(fivedayNEEmovingaverage)[1] <- "fivedayNEEsmooth"
fivedayNEEmovingaverage <- merge(realtower,fivedayNEEmovingaverage, by="rownumber")
fivedayNEEmovingaverage <- filter(fivedayNEEmovingaverage, year!="13")
fivedayNEEmovingaverage <- filter(fivedayNEEmovingaverage, year!="20")
#Creating prefire average of 5 day moving average NEE
prefire5dayNEEsmooth <- filter(fivedayNEEmovingaverage, prepost!="Post")
prefire5dayNEEsmooth <- aggregate(fivedayNEEmovingaverage$fivedayNEEsmooth, by=list(fivedayNEEmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire5dayNEEsmooth <- rename(prefire5dayNEEsmooth, c("Group.1"="onlytime", "x"="prefire5dayNEEsmoothed"))
prefire5dayNEEsmooth$x <- "prefire"
#Creating post fire 5day NEE smooth df
postfire5dayNEEsmooth <- filter(fivedayNEEmovingaverage, prepost!="Pre")#Plotting pre and post 5 day NEE smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire5dayNEEsmooth, aes(y=prefire5dayNEEsmoothed, group=1, color=x)) + geom_line(data=postfire5dayNEEsmooth, aes(y=fivedayNEEsmooth, group=year, color=year)) + labs(title = "NEE 5 day moving average", y= "NEE (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 10 day smoothing window
tendayNEEmovingaverage <- ma(realtower$NEE, 480)
tendayNEEmovingaverage <- as.data.frame(tendayNEEmovingaverage)
tendayNEEmovingaverage$rownumber <- seq.int(nrow(tendayNEEmovingaverage))
colnames(tendayNEEmovingaverage)[1] <- "tendayNEEsmooth"
tendayNEEmovingaverage <- merge(realtower,tendayNEEmovingaverage, by="rownumber")
tendayNEEmovingaverage <- filter(tendayNEEmovingaverage, year!="13")
tendayNEEmovingaverage <- filter(tendayNEEmovingaverage, year!="20")
#Creating prefire average of 10 day moving average NEE
prefire10dayNEEsmooth <- filter(tendayNEEmovingaverage, prepost!="Post")
prefire10dayNEEsmooth <- aggregate(tendayNEEmovingaverage$tendayNEEsmooth, by=list(tendayNEEmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire10dayNEEsmooth <- rename(prefire10dayNEEsmooth, c("Group.1"="onlytime", "x"="prefire10dayNEEsmoothed"))
prefire10dayNEEsmooth$x <- "prefire"
#Creating post fire 10day NEE smooth df
postfire10dayNEEsmooth <- filter(tendayNEEmovingaverage, prepost!="Pre")#Plotting pre and post 10 day NEE smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire10dayNEEsmooth, aes(y=prefire10dayNEEsmoothed, group=1, color=x)) + geom_line(data=postfire10dayNEEsmooth, aes(y=tendayNEEsmooth, group=year, color=year)) + labs(title = "NEE 10 day moving average", y= "NEE (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 15 day smoothing window
fifteendayNEEmovingaverage <- ma(realtower$NEE, 720)
fifteendayNEEmovingaverage <- as.data.frame(fifteendayNEEmovingaverage)
fifteendayNEEmovingaverage$rownumber <- seq.int(nrow(fifteendayNEEmovingaverage))
colnames(fifteendayNEEmovingaverage)[1] <- "fifteendayNEEsmooth"
fifteendayNEEmovingaverage <- merge(realtower,fifteendayNEEmovingaverage, by="rownumber")
fifteendayNEEmovingaverage <- filter(fifteendayNEEmovingaverage, year!="13")
fifteendayNEEmovingaverage <- filter(fifteendayNEEmovingaverage, year!="20")
#Creating prefire average of 15 day moving average NEE
prefire15dayNEEsmooth <- filter(fifteendayNEEmovingaverage, prepost!="Post")
prefire15dayNEEsmooth <- aggregate(fifteendayNEEmovingaverage$fifteendayNEEsmooth, by=list(fifteendayNEEmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire15dayNEEsmooth <- rename(prefire15dayNEEsmooth, c("Group.1"="onlytime", "x"="prefire15dayNEEsmoothed"))
prefire15dayNEEsmooth$x <- "prefire"
#Creating post fire 15day NEE smooth df
postfire15dayNEEsmooth <- filter(fifteendayNEEmovingaverage, prepost!="Pre")#Plotting pre and post 15 day NEE smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire15dayNEEsmooth, aes(y=prefire15dayNEEsmoothed, group=1, color=x)) + geom_line(data=postfire15dayNEEsmooth, aes(y=fifteendayNEEsmooth, group=year, color=year)) + labs(title = "NEE 15 day moving average", y= "NEE (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 20 day smoothing window
fifteendayNEEmovingaverage <- ma(realtower$NEE, 960)
fifteendayNEEmovingaverage <- as.data.frame(fifteendayNEEmovingaverage)
fifteendayNEEmovingaverage$rownumber <- seq.int(nrow(fifteendayNEEmovingaverage))
colnames(fifteendayNEEmovingaverage)[1] <- "fifteendayNEEsmooth"
fifteendayNEEmovingaverage <- merge(realtower,fifteendayNEEmovingaverage, by="rownumber")
fifteendayNEEmovingaverage <- filter(fifteendayNEEmovingaverage, year!="13")
fifteendayNEEmovingaverage <- filter(fifteendayNEEmovingaverage, year!="20")
#Creating prefire average of 20 day moving average NEE
prefire20dayNEEsmooth <- filter(fifteendayNEEmovingaverage, prepost!="Post")
prefire20dayNEEsmooth <- aggregate(fifteendayNEEmovingaverage$fifteendayNEEsmooth, by=list(fifteendayNEEmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire20dayNEEsmooth <- rename(prefire20dayNEEsmooth, c("Group.1"="onlytime", "x"="prefire20dayNEEsmoothed"))
prefire20dayNEEsmooth$x <- "prefire"
#Creating post fire 20day NEE smooth df
postfire20dayNEEsmooth <- filter(fifteendayNEEmovingaverage, prepost!="Pre")#Plotting pre and post 20 day NEE smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire20dayNEEsmooth, aes(y=prefire20dayNEEsmoothed, group=1, color=x)) + geom_line(data=postfire20dayNEEsmooth, aes(y=fifteendayNEEsmooth, group=year, color=year)) + labs(title = "NEE 20 day moving average", y= "NEE (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p##GPP
# Creating 5 day smoothing window
fivedayGPPmovingaverage <- ma(realtower$GPP, 240)
fivedayGPPmovingaverage <- as.data.frame(fivedayGPPmovingaverage)
fivedayGPPmovingaverage$rownumber <- seq.int(nrow(fivedayGPPmovingaverage))
colnames(fivedayGPPmovingaverage)[1] <- "fivedayGPPsmooth"
fivedayGPPmovingaverage <- merge(realtower,fivedayGPPmovingaverage, by="rownumber")
fivedayGPPmovingaverage <- filter(fivedayGPPmovingaverage, year!="13")
fivedayGPPmovingaverage <- filter(fivedayGPPmovingaverage, year!="20")
#Creating prefire average of 5 day moving average GPP
prefire5dayGPPsmooth <- filter(fivedayGPPmovingaverage, prepost!="Post")
prefire5dayGPPsmooth <- aggregate(fivedayGPPmovingaverage$fivedayGPPsmooth, by=list(fivedayGPPmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire5dayGPPsmooth <- rename(prefire5dayGPPsmooth, c("Group.1"="onlytime", "x"="prefire5dayGPPsmoothed"))
prefire5dayGPPsmooth$x <- "prefire"
#Creating post fire 5day GPP smooth df
postfire5dayGPPsmooth <- filter(fivedayGPPmovingaverage, prepost!="Pre")#Plotting pre and post 5 day GPP smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire5dayGPPsmooth, aes(y=prefire5dayGPPsmoothed, group=1, color=x)) + geom_line(data=postfire5dayGPPsmooth, aes(y=fivedayGPPsmooth, group=year, color=year)) + labs(title = "GPP 5 day moving average", y= "GPP (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 10 day smoothing window
tendayGPPmovingaverage <- ma(realtower$GPP, 480)
tendayGPPmovingaverage <- as.data.frame(tendayGPPmovingaverage)
tendayGPPmovingaverage$rownumber <- seq.int(nrow(tendayGPPmovingaverage))
colnames(tendayGPPmovingaverage)[1] <- "tendayGPPsmooth"
tendayGPPmovingaverage <- merge(realtower,tendayGPPmovingaverage, by="rownumber")
tendayGPPmovingaverage <- filter(tendayGPPmovingaverage, year!="13")
tendayGPPmovingaverage <- filter(tendayGPPmovingaverage, year!="20")
#Creating prefire average of 10 day moving average GPP
prefire10dayGPPsmooth <- filter(tendayGPPmovingaverage, prepost!="Post")
prefire10dayGPPsmooth <- aggregate(tendayGPPmovingaverage$tendayGPPsmooth, by=list(tendayGPPmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire10dayGPPsmooth <- rename(prefire10dayGPPsmooth, c("Group.1"="onlytime", "x"="prefire10dayGPPsmoothed"))
prefire10dayGPPsmooth$x <- "prefire"
#Creating post fire 10day GPP smooth df
postfire10dayGPPsmooth <- filter(tendayGPPmovingaverage, prepost!="Pre")#Plotting pre and post 10 day GPP smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire10dayGPPsmooth, aes(y=prefire10dayGPPsmoothed, group=1, color=x)) + geom_line(data=postfire10dayGPPsmooth, aes(y=tendayGPPsmooth, group=year, color=year)) + labs(title = "GPP 10 day moving average", y= "GPP (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 15 day smoothing window
fifteendayGPPmovingaverage <- ma(realtower$GPP, 720)
fifteendayGPPmovingaverage <- as.data.frame(fifteendayGPPmovingaverage)
fifteendayGPPmovingaverage$rownumber <- seq.int(nrow(fifteendayGPPmovingaverage))
colnames(fifteendayGPPmovingaverage)[1] <- "fifteendayGPPsmooth"
fifteendayGPPmovingaverage <- merge(realtower,fifteendayGPPmovingaverage, by="rownumber")
fifteendayGPPmovingaverage <- filter(fifteendayGPPmovingaverage, year!="13")
fifteendayGPPmovingaverage <- filter(fifteendayGPPmovingaverage, year!="20")
#Creating prefire average of 15 day moving average GPP
prefire15dayGPPsmooth <- filter(fifteendayGPPmovingaverage, prepost!="Post")
prefire15dayGPPsmooth <- aggregate(fifteendayGPPmovingaverage$fifteendayGPPsmooth, by=list(fifteendayGPPmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire15dayGPPsmooth <- rename(prefire15dayGPPsmooth, c("Group.1"="onlytime", "x"="prefire15dayGPPsmoothed"))
prefire15dayGPPsmooth$x <- "prefire"
#Creating post fire 15day GPP smooth df
postfire15dayGPPsmooth <- filter(fifteendayGPPmovingaverage, prepost!="Pre")#Plotting pre and post 15 day GPP smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire15dayGPPsmooth, aes(y=prefire15dayGPPsmoothed, group=1, color=x)) + geom_line(data=postfire15dayGPPsmooth, aes(y=fifteendayGPPsmooth, group=year, color=year)) + labs(title = "GPP 15 day moving average", y= "GPP (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 20 day smoothing window
fifteendayGPPmovingaverage <- ma(realtower$GPP, 960)
fifteendayGPPmovingaverage <- as.data.frame(fifteendayGPPmovingaverage)
fifteendayGPPmovingaverage$rownumber <- seq.int(nrow(fifteendayGPPmovingaverage))
colnames(fifteendayGPPmovingaverage)[1] <- "fifteendayGPPsmooth"
fifteendayGPPmovingaverage <- merge(realtower,fifteendayGPPmovingaverage, by="rownumber")
fifteendayGPPmovingaverage <- filter(fifteendayGPPmovingaverage, year!="13")
fifteendayGPPmovingaverage <- filter(fifteendayGPPmovingaverage, year!="20")
#Creating prefire average of 20 day moving average GPP
prefire20dayGPPsmooth <- filter(fifteendayGPPmovingaverage, prepost!="Post")
prefire20dayGPPsmooth <- aggregate(fifteendayGPPmovingaverage$fifteendayGPPsmooth, by=list(fifteendayGPPmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire20dayGPPsmooth <- rename(prefire20dayGPPsmooth, c("Group.1"="onlytime", "x"="prefire20dayGPPsmoothed"))
prefire20dayGPPsmooth$x <- "prefire"
#Creating post fire 20day GPP smooth df
postfire20dayGPPsmooth <- filter(fifteendayGPPmovingaverage, prepost!="Pre")#Plotting pre and post 20 day GPP smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire20dayGPPsmooth, aes(y=prefire20dayGPPsmoothed, group=1, color=x)) + geom_line(data=postfire20dayGPPsmooth, aes(y=fifteendayGPPsmooth, group=year, color=year)) + labs(title = "GPP 20 day moving average", y= "GPP (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p ##RECO
# Creating 5 day smoothing window
fivedayRECOmovingaverage <- ma(realtower$RECO, 240)
fivedayRECOmovingaverage <- as.data.frame(fivedayRECOmovingaverage)
fivedayRECOmovingaverage$rownumber <- seq.int(nrow(fivedayRECOmovingaverage))
colnames(fivedayRECOmovingaverage)[1] <- "fivedayRECOsmooth"
fivedayRECOmovingaverage <- merge(realtower,fivedayRECOmovingaverage, by="rownumber")
fivedayRECOmovingaverage <- filter(fivedayRECOmovingaverage, year!="13")
fivedayRECOmovingaverage <- filter(fivedayRECOmovingaverage, year!="20")
#Creating prefire average of 5 day moving average RECO
prefire5dayRECOsmooth <- filter(fivedayRECOmovingaverage, prepost!="Post")
prefire5dayRECOsmooth <- aggregate(fivedayRECOmovingaverage$fivedayRECOsmooth, by=list(fivedayRECOmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire5dayRECOsmooth <- rename(prefire5dayRECOsmooth, c("Group.1"="onlytime", "x"="prefire5dayRECOsmoothed"))
prefire5dayRECOsmooth$x <- "prefire"
#Creating post fire 5day RECO smooth df
postfire5dayRECOsmooth <- filter(fivedayRECOmovingaverage, prepost!="Pre")#Plotting pre and post 5 day RECO smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire5dayRECOsmooth, aes(y=prefire5dayRECOsmoothed, group=1, color=x)) + geom_line(data=postfire5dayRECOsmooth, aes(y=fivedayRECOsmooth, group=year, color=year)) + labs(title = "RECO 5 day moving average", y= "RECO (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 10 day smoothing window
tendayRECOmovingaverage <- ma(realtower$RECO, 480)
tendayRECOmovingaverage <- as.data.frame(tendayRECOmovingaverage)
tendayRECOmovingaverage$rownumber <- seq.int(nrow(tendayRECOmovingaverage))
colnames(tendayRECOmovingaverage)[1] <- "tendayRECOsmooth"
tendayRECOmovingaverage <- merge(realtower,tendayRECOmovingaverage, by="rownumber")
tendayRECOmovingaverage <- filter(tendayRECOmovingaverage, year!="13")
tendayRECOmovingaverage <- filter(tendayRECOmovingaverage, year!="20")
#Creating prefire average of 10 day moving average RECO
prefire10dayRECOsmooth <- filter(tendayRECOmovingaverage, prepost!="Post")
prefire10dayRECOsmooth <- aggregate(tendayRECOmovingaverage$tendayRECOsmooth, by=list(tendayRECOmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire10dayRECOsmooth <- rename(prefire10dayRECOsmooth, c("Group.1"="onlytime", "x"="prefire10dayRECOsmoothed"))
prefire10dayRECOsmooth$x <- "prefire"
#Creating post fire 10day RECO smooth df
postfire10dayRECOsmooth <- filter(tendayRECOmovingaverage, prepost!="Pre")#Plotting pre and post 10 day RECO smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire10dayRECOsmooth, aes(y=prefire10dayRECOsmoothed, group=1, color=x)) + geom_line(data=postfire10dayRECOsmooth, aes(y=tendayRECOsmooth, group=year, color=year)) + labs(title = "RECO 10 day moving average", y= "RECO (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p###########################################
# Creating 15 day smoothing window
fifteendayRECOmovingaverage <- ma(realtower$RECO, 720)
fifteendayRECOmovingaverage <- as.data.frame(fifteendayRECOmovingaverage)
fifteendayRECOmovingaverage$rownumber <- seq.int(nrow(fifteendayRECOmovingaverage))
colnames(fifteendayRECOmovingaverage)[1] <- "fifteendayRECOsmooth"
fifteendayRECOmovingaverage <- merge(realtower,fifteendayRECOmovingaverage, by="rownumber")
fifteendayRECOmovingaverage <- filter(fifteendayRECOmovingaverage, year!="13")
fifteendayRECOmovingaverage <- filter(fifteendayRECOmovingaverage, year!="20")
#Creating prefire average of 15 day moving average RECO
prefire15dayRECOsmooth <- filter(fifteendayRECOmovingaverage, prepost!="Post")
prefire15dayRECOsmooth <- aggregate(fifteendayRECOmovingaverage$fifteendayRECOsmooth, by=list(fifteendayRECOmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire15dayRECOsmooth <- rename(prefire15dayRECOsmooth, c("Group.1"="onlytime", "x"="prefire15dayRECOsmoothed"))
prefire15dayRECOsmooth$x <- "prefire"
#Creating post fire 15day RECO smooth df
postfire15dayRECOsmooth <- filter(fifteendayRECOmovingaverage, prepost!="Pre")#Plotting pre and post 15 day RECO smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire15dayRECOsmooth, aes(y=prefire15dayRECOsmoothed, group=1, color=x)) + geom_line(data=postfire15dayRECOsmooth, aes(y=fifteendayRECOsmooth, group=year, color=year)) + labs(title = "RECO 15 day moving average", y= "RECO (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p# Creating 20 day smoothing window
fifteendayRECOmovingaverage <- ma(realtower$RECO, 960)
fifteendayRECOmovingaverage <- as.data.frame(fifteendayRECOmovingaverage)
fifteendayRECOmovingaverage$rownumber <- seq.int(nrow(fifteendayRECOmovingaverage))
colnames(fifteendayRECOmovingaverage)[1] <- "fifteendayRECOsmooth"
fifteendayRECOmovingaverage <- merge(realtower,fifteendayRECOmovingaverage, by="rownumber")
fifteendayRECOmovingaverage <- filter(fifteendayRECOmovingaverage, year!="13")
fifteendayRECOmovingaverage <- filter(fifteendayRECOmovingaverage, year!="20")
#Creating prefire average of 20 day moving average RECO
prefire20dayRECOsmooth <- filter(fifteendayRECOmovingaverage, prepost!="Post")
prefire20dayRECOsmooth <- aggregate(fifteendayRECOmovingaverage$fifteendayRECOsmooth, by=list(fifteendayRECOmovingaverage$onlytime), FUN=mean, na.rm =T)
prefire20dayRECOsmooth <- rename(prefire20dayRECOsmooth, c("Group.1"="onlytime", "x"="prefire20dayRECOsmoothed"))
prefire20dayRECOsmooth$x <- "prefire"
#Creating post fire 20day RECO smooth df
postfire20dayRECOsmooth <- filter(fifteendayRECOmovingaverage, prepost!="Pre")#Plotting pre and post 20 day RECO smoothed on single plot
p <- ggplot(data = NULL, aes(x=onlytime)) + geom_line(data = prefire20dayRECOsmooth, aes(y=prefire20dayRECOsmoothed, group=1, color=x)) + geom_line(data=postfire20dayRECOsmooth, aes(y=fifteendayRECOsmooth, group=year, color=year)) + labs(title = "RECO 20 day moving average", y= "RECO (gC/m2/s)" , x="")+ scale_x_discrete(breaks=c("01010000","02010000","03010000","04010000","05010000","06010000","07010000","08010000","09010000","10010000","11010000","12010000"), labels=c("jan","feb", "mar","apr", "may","jun","jul","aug","sep","oct","nov","dec"))
p