@ -19,30 +19,39 @@ setwd("C:/Users/z5025317/OneDrive - UNSW/WRL_Postdoc_Manual_Backup/WRL_Postdoc/P
#Set inputs
#Set inputs
######################
######################
Case.Study <- " CASESTUDY2"
Case.Study <- " CASESTUDY2"
Estuary <- " RICHMOND "
Estuary <- " HUNTER "
Riv.Gauge.loc <- " OAKLANDROAD " #GRETA
Riv.Gauge.loc <- " GRETA " #GRETA
Est.Gauge.loc <- " CORAKI" #"RAYMONDTERRACE" # "HEXHAMBRIDGE"
Est.Gauge.loc <- " RAYMONDTERRACE" #" CORAKI" #"RAYMONDTERRACE" # "HEXHAMBRIDGE"
logtransformFlow <- TRUE
logtransformFlow <- TRUE
ggplotGAM.k <- 15
ggplotGAM.k <- 15
rivTempGAM.k <- 20
rivTempGAM.k <- 20
Version <- ' V2'
Version <- ' V3'
Fontsize <- 12
######################
######################
######################
######################
Output.Directory <- paste ( ' ./Output/ ', Case.Study , ' /', Estuary , ' /Recent_Trends /Riv_', Riv.Gauge.loc , ' _Est_' , Est.Gauge.loc , ' _GAMk' , ggplotGAM.k , ' /', sep = " " )
Output.Directory <- paste ( ' ./Output/ CASESTUDY2_V4 /', Estuary , ' /Recent_Trends /', sep = " " )
if ( file.exists ( Output.Directory ) ) {
if ( file.exists ( Output.Directory ) ) {
print ( ' output folder already existed and was not created again' )
print ( ' output folder already existed and was not created again' )
} else {
} else {
dir.create ( file.path ( Output.Directory ) )
dir.create ( file.path ( Output.Directory ) )
print ( ' output folder did not exist and was created' )
print ( ' output folder did not exist and was created' )
}
}
Output.Directory <- paste ( ' ./Output/CASESTUDY2_V4/' , Estuary , ' /Recent_Trends/Riv_' , Riv.Gauge.loc , ' _Est_' , Est.Gauge.loc , ' _GAMk' , ggplotGAM.k , ' b/' , sep = " " )
if ( file.exists ( Output.Directory ) ) {
print ( ' output folder already existed and was not created again' )
} else {
dir.create ( file.path ( Output.Directory ) )
print ( ' output folder did not exist and was created' )
}
######################
######################
######################
######################
#Set input file paths
#Set input file paths
######################
######################
pattern = paste ( ' SILO_climdata_' , Estuary , ' *' , sep = " " )
pattern = paste ( ' SILO_climdata_' , Estuary , ' _Catchment *', sep = " " )
AirT_CSV_Path <- list.files ( paste ( " ./Data/SILO/" , Case.Study , ' /' , sep = " " ) , pattern , full.names = T , recursive = T )
AirT_CSV_Path <- list.files ( paste ( " ./Data/SILO/" , Case.Study , ' /' , sep = " " ) , pattern , full.names = T , recursive = T )
pattern = paste ( Estuary , ' @' , Riv.Gauge.loc , ' .*.ALL.csv' , sep = " " )
pattern = paste ( Estuary , ' @' , Riv.Gauge.loc , ' .*.ALL.csv' , sep = " " )
@ -114,6 +123,12 @@ RivT.full.pvalNCV_ECall <- summary(linear.trend.model_EC_all )$coefficients[2,4]
RivT.full.lintrend <- summary ( linear.trend.model_EC_all ) $ coefficients [2 , 1 ] * 356
RivT.full.lintrend <- summary ( linear.trend.model_EC_all ) $ coefficients [2 , 1 ] * 356
############River temp
############River temp
#export interpolated data as csv
#csv.name <- "C:/Users/z5025317/OneDrive - UNSW/CC_Estuaries_CASESTUDY2/Data/River_Gauge_Data/HUNTER@Greta_210064_Temp_interpolated.csv"
#write.csv(RivT.df, csv.name)
############River flow
############River flow
#Load a daily (no gaps) time series as a time serie baseline for other time series used here
#Load a daily (no gaps) time series as a time serie baseline for other time series used here
#Here we use the raw DPI CSV format that comes with a bunch of metadata
#Here we use the raw DPI CSV format that comes with a bunch of metadata
@ -128,7 +143,8 @@ rm(dat,char.df)
#RivQ.full.TS <- zoo(log10((as.numeric(as.character(RivQ.df$Flow))) +1) , order.by= as.Date(RivQ.df[,"Date"], format = "%d/%m/%Y")) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
#RivQ.full.TS <- zoo(log10((as.numeric(as.character(RivQ.df$Flow))) +1) , order.by= as.Date(RivQ.df[,"Date"], format = "%d/%m/%Y")) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
RivQ.full.TS <- zoo ( as.numeric ( as.character ( RivQ.df $ Flow ) ) , order.by = as.Date ( RivQ.df [ , " Date" ] , format = " %d/%m/%Y" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
RivQ.full.TS <- zoo ( as.numeric ( as.character ( RivQ.df $ Flow ) ) , order.by = as.Date ( RivQ.df [ , " Date" ] , format = " %d/%m/%Y" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
RivQ.TS <- window ( RivQ.full.TS , start = as.Date ( " 1990-01-01" ) , end = as.Date ( " 2018-01-01" ) )
#RivQ.TS <- window(RivQ.full.TS, start=as.Date("1990-01-01"), end=as.Date("2018-01-01"))
RivQ.full.TS <- window ( RivQ.full.TS , start = as.Date ( " 2013-06-01" ) , end = as.Date ( " 2018-06-01" ) )
RivQ.full.df <- data.frame ( RivQ.full.TS ) ### This is only done because
RivQ.full.df <- data.frame ( RivQ.full.TS ) ### This is only done because
RivQ.df <- data.frame ( RivQ.TS )
RivQ.df <- data.frame ( RivQ.TS )
colnames ( RivQ.df ) <- ' RivQmean'
colnames ( RivQ.df ) <- ' RivQmean'
@ -149,7 +165,10 @@ RivQ.full.lintrend <- summary(linear.trend.model_EC_all )$coefficients[2,1] * 35
#Load a daily (no gaps) time series as a time serie baseline for other time series used here
#Load a daily (no gaps) time series as a time serie baseline for other time series used here
SST.df <- data.frame ( read.csv ( SST_CSV_Path ) )
SST.df <- data.frame ( read.csv ( SST_CSV_Path ) )
SST.full.TS <- zoo ( SST.df $ NNRP_R1_1950 -273.15 , order.by = as.Date ( SST.df [ , " X" ] , format = " %Y-%m-%d" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
SST.full.TS <- zoo ( SST.df $ NNRP_R1_1950 -273.15 , order.by = as.Date ( SST.df [ , " X" ] , format = " %Y-%m-%d" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
SST.TS <- window ( SST.full.TS , start = as.Date ( " 1990-01-01" ) , end = as.Date ( " 2018-01-01" ) )
#SST.TS <- window(SST.full.TS, start=as.Date("1990-01-01"), end=as.Date("2018-01-01"))
SST.full.TS <- window ( SST.full.TS , start = as.Date ( " 2013-06-01" ) , end = as.Date ( " 2018-06-01" ) )
SST.full.df <- data.frame ( SST.full.TS )
SST.full.df <- data.frame ( SST.full.TS )
SST.df <- data.frame ( SST.TS )
SST.df <- data.frame ( SST.TS )
str ( SST.df )
str ( SST.df )
@ -185,8 +204,7 @@ rm(dat,char.df)
#replace negative values with NA
#replace negative values with NA
EstT.df $ Temp <- replace ( EstT.df $ Temp , which ( as.numeric ( as.character ( EstT.df $ Temp ) ) < 11 ) , NA )
EstT.df $ Temp <- replace ( EstT.df $ Temp , which ( as.numeric ( as.character ( EstT.df $ Temp ) ) < 11 ) , NA )
EstT.full.TS <- zoo ( as.numeric ( as.character ( EstT.df $ Temp ) ) , order.by = as.Date ( EstT.df [ , " Date" ] , format = " %d/%m/%Y" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
EstT.full.TS <- zoo ( as.numeric ( as.character ( EstT.df $ Temp ) ) , order.by = as.Date ( EstT.df [ , " Date" ] , format = " %d/%m/%Y" ) ) #=daily time series of rainfall for creation of clean, daily TS of ET and Q
plot ( EstT.full.TS )
EstT.TS <- window ( EstT.full.TS , start = as.Date ( " 2013-06-01" ) , end = as.Date ( " 2018-06-01" ) )
EstT.TS <- window ( EstT.full.TS , start = as.Date ( " 2013-06-01" ) , end = as.Date ( " 2018-01-01" ) )
EstT.full.TS <- EstT.TS
EstT.full.TS <- EstT.TS
EstT.full.df <- data.frame ( EstT.TS ) ### This is only done because of poor data at beginning
EstT.full.df <- data.frame ( EstT.TS ) ### This is only done because of poor data at beginning
EstT.df <- data.frame ( EstT.TS )
EstT.df <- data.frame ( EstT.TS )
@ -211,7 +229,7 @@ EstT.full.lintrend <- summary(linear.trend.model_EC_all )$coefficients[2,1] * 35
##################################### Full Time Period
##################################### Full Time Period
#Air temp Full period
#Air temp Full period
p1air <- ggplot ( AirT.full.df , aes ( y = tasmean , x = index ( AirT.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p1air <- ggplot ( AirT.full.df , aes ( y = tasmean , x = index ( AirT.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , " Catchment Centroid - Linear and smooth trend in catchment airT (SILO) lin trend was ",
ggtitle ( paste ( Estuary , " Catchment Centroid - Linear and smooth trend s in catchment airT (SILO) lin trend was ",
round ( AirT.full.lintrend , 3 ) , ' C°/year with p=' , round ( AirT.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
round ( AirT.full.lintrend , 3 ) , ' C°/year with p=' , round ( AirT.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
@ -219,12 +237,14 @@ p1air <- ggplot(AirT.full.df, aes(y=tasmean, x=index(AirT.full.TS))) + geom_line
ylab ( " Air Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Air Temperature [C°]" ) + xlab ( " Time" )
p1riv <- ggplot ( RivT.full.df , aes ( y = rivTmean , x = index ( RivT.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p1riv <- ggplot ( RivT.full.df , aes ( y = rivTmean , x = index ( RivT.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , ' @' , Riv.Gauge.loc , " - Linear and smooth trend in river temperature (GAUGE) lin trend was ",
ggtitle ( paste ( Estuary , " - Linear and smooth trends in gauged river temperature (@" , Riv.Gauge.loc , " ) - Linear trend was ",
round ( RivT.full.lintrend , 3 ) , ' C°/year with p=', round( RivT.full.pvalNCV_ECall , 10 ) , sep = " ") ) +
round ( RivT.full.lintrend , 3 ) , ' C°/year with p=', sprintf( " %.5f" , round( RivT.full.pvalNCV_ECall , 10 ) ) , sep = " ") ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " River Temperature [C°]" ) + xlab ( " Time" )
ylab ( " River Temperature [C°]" ) + xlab ( " Time" ) + xlab ( NULL ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
if ( logtransformFlow == TRUE ) {
if ( logtransformFlow == TRUE ) {
@ -234,7 +254,9 @@ p1rivQ <- ggplot(RivQ.full.df, aes(y=log10(RivQmean+2), x=index(RivQ.full.TS)))
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( expression ( paste ( " log10(River Flow [ML/day] + 2)" , sep = " " ) ) ) + xlab ( " Time" )
ylab ( expression ( paste ( " log10(River Flow [ML/day] + 2)" , sep = " " ) ) ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
} else {
} else {
p1rivQ <- ggplot ( RivQ.full.df , aes ( y = RivQmean , x = index ( RivQ.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p1rivQ <- ggplot ( RivQ.full.df , aes ( y = RivQmean , x = index ( RivQ.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , ' @' , Riv.Gauge.loc , " - Linear and smooth trend in river flow (GAUGE) lin trend was " ,
ggtitle ( paste ( Estuary , ' @' , Riv.Gauge.loc , " - Linear and smooth trend in river flow (GAUGE) lin trend was " ,
@ -242,28 +264,54 @@ p1rivQ <- ggplot(RivQ.full.df, aes(y=log10(RivQmean+2), x=index(RivQ.full.TS)))
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( expression ( paste ( " River Flow [ML/day]" , sep = " " ) ) ) + xlab ( " Time" )
ylab ( expression ( paste ( " River Flow [ML/day]" , sep = " " ) ) ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
}
}
#Sea temp Full period
#Sea temp Full period
p1sst <- ggplot ( SST.full.df , aes ( y = SSTmean , x = index ( SST.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p1sst <- ggplot ( SST.full.df , aes ( y = SSTmean , x = index ( SST.full.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , " NNRP (NARCLIM reanalysis) - Linear and smooth trend in sea surface temperature (NNRP) lin trend was ",
ggtitle ( paste ( Estuary , " offsho re - Linear and smooth trends in sea surface temperature (NNRP NARCLIM reanalysis ) linear trend was ",
round ( SST.full.lintrend , 3 ) , ' C°/year with p=', round( SST.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
round ( SST.full.lintrend , 3 ) , ' C°/year with p=', sprintf( " %.5f" , round( SST.full.pvalNCV_ECall , 10 ) ) , sep = " " ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " Sea Surface Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Sea Surface Temperature [C°]" ) + xlab ( " Time" ) + xlab ( NULL ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
p1Est <- ggplot ( EstT.full.df , aes ( y = EstTmean , x = index ( EstT.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p1Est <- ggplot ( EstT.full.df , aes ( y = EstTmean , x = index ( EstT.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , ' @' , Est.Gauge.loc , " - Linear and smooth trend in Estuary temperature (GAUGE) lin trend was " ,
ggtitle ( paste ( Estuary , ' @' , Est.Gauge.loc , " - Linear and smooth trend in Estuary temperature (GAUGE) lin trend was " ,
round ( EstT.full.lintrend , 3 ) , ' C°/year with p=', round ( EstT.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
round ( EstT.full.lintrend , 3 ) , ' C°/year with p=', round ( EstT.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " Estuary Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Estuary Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
p1Est2 <- ggplot ( EstT.full.df , aes ( y = EstTmean , x = index ( EstT.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , ' @' , Est.Gauge.loc , " - Linear and smooth trend in Estuary temperature (GAUGE) lin trend was " ,
round ( EstT.full.lintrend , 3 ) , ' C°/year with p=' , round ( EstT.full.pvalNCV_ECall , 10 ) , sep = " " ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
#stat_smooth(method=gam, formula=y~s(x, k=ggplotGAM.k), se=T, size=0.5) +
binomial_smooth ( formula = y ~ splines :: ns ( x , 2 ) ) +
ylab ( " Estuary Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
png.name <- paste ( Output.Directory , Estuary , ' @' , Est.Gauge.loc , ' _Trends_estTmean_full_period_' , Sys.Date ( ) , " nosmoothb3.png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 4 , units = ' in' , res = 500 )
grid.arrange ( p1Est2 , ncol = 1 )
dev.off ( )
gA1 <- ggplotGrob ( p1riv )
gA2 <- ggplotGrob ( p1sst )
gA1 $ widths <- gA2 $ widths
#export to png
#export to png
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_tasmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_tasmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
@ -271,7 +319,11 @@ grid.arrange(p1air,ncol=1)
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_rivTmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_rivTmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
grid.arrange ( p1riv , ncol = 1 )
grid.arrange ( p1riv , p1riv , ncol = 1 )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_rivTmean_SSTmean_full_period4_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
grid.arrange ( gA1 , gA2 , ncol = 1 )
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_RivQmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_RivQmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
@ -279,12 +331,18 @@ grid.arrange(p1rivQ,ncol=1)
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_SSTmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_SSTmean_full_period_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
grid.arrange ( p1sst , ncol= 1 )
grid.arrange ( p1sst , p1sst, ncol= 1 )
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Est.Gauge.loc , ' _Trends_estTmean_full_period_' , Sys.Date ( ) , " .png", sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Est.Gauge.loc , ' _Trends_estTmean_full_period_' , Sys.Date ( ) , " b .png", sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 4 , units = ' in' , res = 500 )
grid.arrange ( p1Est , ncol = 1 )
grid.arrange ( p1Est , ncol = 1 )
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Est.Gauge.loc , ' _Trends_estTmean_full_period_' , Sys.Date ( ) , " nosmoothb.png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 4 , units = ' in' , res = 500 )
grid.arrange ( p1Est2 , ncol = 1 )
dev.off ( )
##################################### Full Time Period
##################################### Full Time Period
@ -300,7 +358,9 @@ p2air <- ggplot(combined.df, aes(y=tasmean, x=index(combined.TS))) + geom_line(a
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " Air Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Air Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
#Riv temp
#Riv temp
p2riv <- ggplot ( combined.df , aes ( y = rivTmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p2riv <- ggplot ( combined.df , aes ( y = rivTmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
@ -309,7 +369,9 @@ p2riv <- ggplot(combined.df, aes(y=rivTmean, x=index(combined.TS))) + geom_line(
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " River Temperature [C°]" ) + xlab ( " Time" )
ylab ( " River Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
#Riv flow
#Riv flow
if ( logtransformFlow == TRUE ) {
if ( logtransformFlow == TRUE ) {
@ -319,7 +381,9 @@ if(logtransformFlow ==TRUE){
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( expression ( paste ( " log10(River Flow [ML/day] + 2)" , sep = " " ) ) ) + xlab ( " Time" )
ylab ( expression ( paste ( " log10(River Flow [ML/day] + 2)" , sep = " " ) ) ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
} else {
} else {
p2rivQ <- ggplot ( combined.df , aes ( y = rivQmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p2rivQ <- ggplot ( combined.df , aes ( y = rivQmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
ggtitle ( paste ( Estuary , ' @' , Riv.Gauge.loc , " - Linear and smooth trend in river flow (GAUGE) lin trend was " ,
ggtitle ( paste ( Estuary , ' @' , Riv.Gauge.loc , " - Linear and smooth trend in river flow (GAUGE) lin trend was " ,
@ -327,7 +391,9 @@ if(logtransformFlow ==TRUE){
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( expression ( paste ( " River Flow [ML/day]" , sep = " " ) ) ) + xlab ( " Time" )
ylab ( expression ( paste ( " River Flow [ML/day]" , sep = " " ) ) ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
}
}
#Sea temp
#Sea temp
@ -337,7 +403,9 @@ p2sst <- ggplot(combined.df, aes(y=SSTmean, x=index(combined.TS))) + geom_line(a
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
stat_smooth ( method = gam , formula = y ~ s ( x , k = ggplotGAM.k ) , se = T , size = 0.5 ) +
ylab ( " Sea Surface Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Sea Surface Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
#sst temp
#sst temp
p2Est <- ggplot ( combined.df , aes ( y = EstTmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
p2Est <- ggplot ( combined.df , aes ( y = EstTmean , x = index ( combined.TS ) ) ) + geom_line ( alpha = 0.5 ) +
@ -346,7 +414,9 @@ p2Est <- ggplot(combined.df, aes(y=EstTmean, x=index(combined.TS))) + geom_line(
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
theme ( plot.title = element_text ( face = " bold" , size = 9 ) ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
geom_smooth ( method = ' lm' , fill = " green" , formula = y ~ x , colour = " darkgreen" , size = 0.5 ) +
#stat_smooth(method=gam, formula=y~s(x, k=ggplotGAM.k), se=T, size=0.5) +
#stat_smooth(method=gam, formula=y~s(x, k=ggplotGAM.k), se=T, size=0.5) +
ylab ( " Estuary Temperature [C°]" ) + xlab ( " Time" )
ylab ( " Estuary Temperature [C°]" ) + xlab ( " Time" ) +
theme ( axis.text = element_text ( size = Fontsize ) ) +
theme ( panel.grid.major.x = element_blank ( ) , panel.grid.minor.x = element_blank ( ) , panel.grid.major.y = element_line ( size = .1 , color = " white" ) )
#export to png
#export to png
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_tasmean_1990-present_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_tasmean_1990-present_' , Sys.Date ( ) , " .png" , sep = " " )
@ -382,6 +452,11 @@ png(file = png.name, width = 10.5, height = 7, units='in', res=500)
grid.arrange ( gA , gB , gC , ncol = 1 )
grid.arrange ( gA , gB , gC , ncol = 1 )
dev.off ( )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_SST_RivT_1990-present_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
grid.arrange ( gB , gC , ncol = 1 )
dev.off ( )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_SST_RivT_EstT_1990-present_' , Sys.Date ( ) , " .png" , sep = " " )
png.name <- paste ( Output.Directory , Estuary , ' @' , Riv.Gauge.loc , ' _Trends_SST_RivT_EstT_1990-present_' , Sys.Date ( ) , " .png" , sep = " " )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
png ( file = png.name , width = 10.5 , height = 7 , units = ' in' , res = 500 )
grid.arrange ( gB , gD , gC , ncol = 1 )
grid.arrange ( gB , gD , gC , ncol = 1 )
@ -413,3 +488,4 @@ dev.off()