before starting the assignment the following libraries were loaded, graphics were turned off, and the work directory was set.
library(ncdf4);
library(ncdf4.helpers);
## Warning: package 'ncdf4.helpers' was built under R version 3.5.2
library(maps);
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 3.5.2
library(lattice)
library(latticeExtra)
setwd("/Users/Kennf/Documents/GY671assignement")
graphics.off()
rm(list=ls())
Once that was completed the NGTN data was loaded using the read.csv function.
ross = read.csv(file.path(getwd(),'rossaveel_monthly.csv'),skip = 1,header=TRUE)
ring = read.csv(file.path(getwd(),'ringaskiddy_monthly.csv'),skip = 1,header=TRUE)
port = read.csv(file.path(getwd(),'port_oriel_monthly.csv'),skip = 1,header=TRUE)
malin = read.csv(file.path(getwd(),'malin_monthly.csv'),skip = 1,header=TRUE)
howth = read.csv(file.path(getwd(),'howth_monthly.csv'),skip = 1,header=TRUE)
galway = read.csv(file.path(getwd(),'galway_monthly.csv'),skip = 1,header=TRUE)
fenit = read.csv(file.path(getwd(),'fenit_monthly.csv'),skip = 1,header=TRUE)
dunmore = read.csv(file.path(getwd(),'dunmore_east_monthly.csv'),skip = 1,header=TRUE)
dub = read.csv(file.path(getwd(),'dublin_monthly.csv'),skip = 1,header=TRUE)
cast = read.csv(file.path(getwd(),'castletownbere_monthly.csv'),skip = 1,header=TRUE)
ballyg = read.csv(file.path(getwd(),'ballyglass_monthly.csv'),skip = 1,header=TRUE)
ballycotton = read.csv(file.path(getwd(),'ballycotton_monthly.csv'),skip = 1,header=TRUE)
arklow = read.csv(file.path(getwd(),'arklow_monthly.csv'),skip = 1,header=TRUE)
The following code was then inputted to make the files easier to use.
names(ross)<-c("Month","Year","h","Time")
names(malin)<-c("Month","Year","h","Time")
names(howth)<-c("Month","Year","h","Time")
names(arklow)<-c("Month","Year","h","Time")
names(ballycotton)<-c("Month","Year","h","Time")
names(ballyg)<-c("Month","Year","h","Time")
names(cast)<-c("Month","Year","h","Time")
names(dub)<-c("Month","Year","h","Time")
names(fenit)<-c("Month","Year","h","Time")
names(port)<-c("Month","Year","h","Time")
names(ring)<-c("Month","Year","h","Time")
names(galway)<-c("Month","Year","h","Time")
names(dunmore)<-c("Month","Year","h","Time")
Task 1 asked for a map of the NTGN. For that to be completed the following cordinates were collected from the NTGN website. These were needed to plot the map of the tide gauges.
ross.lon = -9.56206
ross.lat = 53.26693
malin.lon = -7.3344
malin.lat = 55.3717
howth.lon = -6.0683
howth.lat = 53.3915
galway.lon = -9.048
galway.lat = 53.269
dunmore.lon = -6.99188
dunmore.lat = 52.14767
arklow.lon = -6.145231
arklow.lat = 52.792046
ballycotton.lon = -8.0007
ballycotton.lat = 51.8278
ballyg.lon = -9.8928
ballyg.lat = 54.2536
cast.lon = -9.9034
cast.lat = 51.6496
dub.lon = -6.2217
dub.lat = 53.3457
fenit.lon = -9.8635645
fenit.lat = 52.270702
port.lon = -6.221441
port.lat = 53.798042
ring.lon = -8.305566
ring.lat = 51.83496
map("world",c("ireland","uk"),fill=FALSE,xlim=c(-12,-4),ylim=c(51,56))
map.axes(cex.axis=1)
title(main="Location of Irish Tide Gauges",xlab="Longitude",ylab="Latitude")
points(ross.lon,ross.lat,pch=21,col="gray",bg="blue")
text(ross.lon-.5,ross.lat,"Ross.",col="black")
points(malin.lon,malin.lat,pch=21,col="gray",bg="blue")
text(malin.lon-.5,malin.lat,"Malin.",col="black")
points(howth.lon,howth.lat,pch=21,col="gray",bg="blue")
text(howth.lon-.7,howth.lat,"Howth.",col="black")
points(galway.lon,galway.lat,pch=21,col="gray",bg="blue")
text(galway.lon,galway.lat,"Gal.",col="black")
points(dunmore.lon,dunmore.lat,pch=21,col="gray",bg="blue")
text(dunmore.lon-.5,dunmore.lat,"Dunmore.",col="black")
points(arklow.lon,arklow.lat,pch=21,col="gray",bg="blue")
text(arklow.lon-.5,arklow.lat,"Arklow.",col="black")
points(ballycotton.lon,ballycotton.lat,pch=21,col="gray",bg="blue")
text(ballycotton.lon-.9,ballycotton.lat,"BallyC.",col="black")
points(ballyg.lon,ballyg.lat,pch=21,col="gray",bg="blue")
text(ballyg.lon-.5,ballyg.lat,"BallG.",col="black")
points(cast.lon,cast.lat,pch=21,col="gray",bg="blue")
text(cast.lon-.5,cast.lat,"CastleTown.",col="black")
points(dub.lon,dub.lat,pch=21,col="gray",bg="blue")
text(dub.lon +0.5,dub.lat,"Dublin.",col="black")
points(fenit.lon,fenit.lat,pch=21,col="gray",bg="blue")
text(fenit.lon-.05,fenit.lat,"Fenit.",col="black")
points(port.lon,port.lat,pch=21,col="gray",bg="blue")
text(port.lon-.05,port.lat,"Port.",col="black")
points(ring.lon,ring.lat,pch=21,col="gray",bg="blue")
text(ring.lon +1.2,ring.lat,"Ringask.",col="black")
The second part of task 1 was to plot the trends. However, there was a hiccup with the code so the data did not appear. However here is the code, the trends were aggregated to smoothen out the time seires. The data didn’t need to be offset considering using a varied colour scheme they did not needed to be completely seprated.
dub_year <- aggregate(dub$h, by = list( dub$Year), FUN = mean, na.rm = TRUE)
arklow_year <- aggregate(arklow$h, by = list( arklow$Year), FUN = mean, na.rm = TRUE)
ballycotton_year <- aggregate(ballycotton$h, by = list( ballycotton$Year), FUN = mean, na.rm = TRUE)
ballyg_year <- aggregate(ballyg$h, by = list( ballyg$Year), FUN = mean, na.rm = TRUE)
cast_year <- aggregate(cast$h, by = list( cast$Year), FUN = mean, na.rm = TRUE)
dunmore_year <- aggregate(dunmore$h, by = list( dunmore$Year), FUN = mean, na.rm = TRUE)
fenit_year <- aggregate(fenit$h, by = list( fenit$Year), FUN = mean, na.rm = TRUE)
galway_year <- aggregate(galway$h, by = list( galway$Year), FUN = mean, na.rm = TRUE)
howth_year <- aggregate(howth$h, by = list( howth$Year), FUN = mean, na.rm = TRUE)
malin_year <- aggregate(malin$h, by = list( malin$Year), FUN = mean, na.rm = TRUE)
port_year <- aggregate(port$h, by = list( port$Year), FUN = mean, na.rm = TRUE)
ring_year <- aggregate(ring$h, by = list( ring$Year), FUN = mean, na.rm = TRUE)
ross_year <- aggregate(ross$h, by = list( ross$Year), FUN = mean, na.rm = TRUE)
colnames(dub_year) <- c("year", "Flow")
colnames(arklow_year) <- c("year", "Flow")
colnames(ballycotton_year) <- c("year", "Flow")
colnames(ballyg_year) <- c("year", "Flow")
colnames(cast_year) <- c("year", "Flow")
colnames(dunmore_year) <- c("year", "Flow")
colnames(fenit_year) <- c("year", "Flow")
colnames(galway_year) <- c("year", "Flow")
colnames(howth_year) <- c("year", "Flow")
colnames(malin_year) <- c("year", "Flow")
colnames(port_year) <- c("year", "Flow")
colnames(ring_year) <- c("year", "Flow")
colnames(ross_year) <- c("year", "Flow")
plot(dub_year$year, dub_year$Flow, type= "l", col = "blue", main="Sea level vs Year",xlab="Year",ylab="Sea Level",xlim=c(2000,2019),ylim=c(-0.5,0.3))
lines(arklow_year$year, arklow_year$Flow, type = "l", col = "chartreuse")
lines(ballycotton_year$year, ballycotton_year$Flow, type = "l", col = "black")
lines(ballyg_year$year, ballyg_year$Flow, type = "l", col = "blueviolet")
lines(cast_year$year, cast_year$Flow, type = "l", col = "lightcoral")
lines(dunmore_year$year, dunmore_year$Flow, type = "l", col = "lightpink")
lines(fenit_year$year, fenit_year$Flow, type = "l", col = "navy")
lines(galway_year$year, galway_year$Flow, type = "l", col = "peachpuff")
lines(howth_year$year, howth_year$Flow, type = "l", col = "mistyrose")
lines(malin_year$year, malin_year$Flow, type = "l", col = "seagreen")
lines(port_year$year, port_year$Flow, type = "l", col = "chocolate4")
lines(ring_year$year, ring_year$Flow, type = "l", col = "peru")
lines(ross_year$year, ross_year$Flow, type = "l", col = "yellow")
legend("bottomleft", legend=c("Arklow Year", "Dublin Year", "BallyC Year", "BallyG Year","CastleT Year","Dunmore Year",
"Fenit Year", "Galway Year","Howth Year","Malin Year","Port Year","Ring Year", "Ross Year"),
col=c("blue","chartreuse","black","blueviolet","lightcoral", "lightpink","navy","peachpuff","mistyrose",
"seagreen", "chocolate4","peru","yellow"),lty=1:1, cex=0.5)
The data was downloaded was editied so no negative or empty values would not appear and tamper with the data.Following this the PSMSL files for conveince were made into .csv files due to difficulites trying to read these files as .txt files.
The following PSMSL files that were downloaded were “Portrush”, “Belfast”, “Dublin”.“Bangor” and “Malin head” The data is 7000mm below the mean sea level. These files were read and the data was plotted into map and a time series as was done with the NTGN.
par(mfrow=c(1,1))
PSMSL_MAL = read.csv(file.path(getwd(),'PSMSL_MAL.csv'),skip = 1,header=TRUE)
PSMSL_BAN = read.csv(file.path(getwd(),'PSMSL_BAN.csv'),skip = 1,header=TRUE)
PSMSL_BEL = read.csv(file.path(getwd(),'PSMSL_BELFAST.csv'),skip = 1,header=TRUE)
PSMSL_PRUSH = read.csv(file.path(getwd(),'PSMSL_PORTRUSH.csv'),skip = 1,header=TRUE)
PSMSL_DUB = read.csv(file.path(getwd(),'PSMSL_DUB2.csv'),skip = 1,header=TRUE)
Dub.lon = -6.2217
Dub.lat = 53.3457
Bel.lon = -5.9167
Bel.lat = 54.6
Ban.lon = -5.6695
Ban.lat = 54.6648
Prush.lon = -6.6568
Prush.lat = 55.2068
Malin.lon = -7.3344
Malin.lat = 55.3717
names(PSMSL_DUB)<-c("Year","Month","h")
names(PSMSL_BEL)<-c("Year","Month","h")
names(PSMSL_BAN)<-c("Year","Month","h")
names(PSMSL_PRUSH)<-c("Year","Month","h")
names(PSMSL_MAL)<-c("Year","Month","h")
map("world",c("ireland","uk"),fill=FALSE,xlim=c(-12,-4),ylim=c(51,56))
map.axes(cex.axis=1)
title(main="Location of PSMSL Irish Tide Gauges",xlab="Longitude",ylab="Latitude")
points(Dub.lon,Dub.lat,pch=21,col="gray",bg="blue")
text(Dub.lon-.5,Dub.lat,"Dublin.",col="black")
points(Malin.lon,Malin.lat,pch=21,col="gray",bg="blue")
text(Malin.lon-.5,Malin.lat,"Malin.",col="black")
points(Bel.lon,Bel.lat,pch=21,col="gray",bg="blue")
text(Bel.lon-.7,Bel.lat,"Belfast.",col="black")
points(Ban.lon,Ban.lat,pch=21,col="gray",bg="blue")
text(Ban.lon+.7,Ban.lat,"Bangor.",col="black")
points(Prush.lon,Prush.lat,pch=21,col="gray",bg="blue")
text(Prush.lon+.7,Prush.lat,"Port rush.",col="black")
PSMSL_Dub_year <- aggregate(PSMSL_DUB$h, by = list( PSMSL_DUB$Year), FUN = mean, na.rm = TRUE)
PSMSL_Bel_year <- aggregate(PSMSL_BEL$h, by = list( PSMSL_BEL$Year), FUN = mean, na.rm = TRUE)
PSMSL_Ban_year <- aggregate(PSMSL_BAN$h, by = list( PSMSL_BAN$Year), FUN = mean, na.rm = TRUE)
PSMSL_Prush_year <- aggregate(PSMSL_PRUSH$h, by = list( PSMSL_PRUSH$Year), FUN = mean, na.rm = TRUE)
PSMSL_Mal_year <- aggregate(PSMSL_MAL$h, by = list( PSMSL_MAL$Year), FUN = mean, na.rm = TRUE)
colnames(PSMSL_Dub_year) <- c("year", "Flow")
colnames(PSMSL_Bel_year) <- c("year", "Flow")
colnames(PSMSL_Ban_year) <- c("year", "Flow")
colnames(PSMSL_Prush_year) <- c("year", "Flow")
colnames(PSMSL_Mal_year) <- c("year", "Flow")
plot(PSMSL_Dub_year$year, PSMSL_Dub_year$Flow, type= "l", col = "aquamarine", main="PSMSL Data",xlab="Year",ylab="Sea Level",xlim=c(1850,2019),ylim=c(6800,7200))
lines(PSMSL_Bel_year$year, PSMSL_Bel_year$Flow, type = "l", col = "brown")
lines(PSMSL_Ban_year$year, PSMSL_Ban_year$Flow, type = "l", col = "green")
lines(PSMSL_Prush_year$year, PSMSL_Prush_year$Flow, type = "l", col = "coral")
lines(PSMSL_Mal_year$year, PSMSL_Mal_year$Flow, type = "l", col = "black")
legend("topleft", legend=c("PSMSL Dublin", "PSMSL Belfast", "PSMSL Bangor", "PSMSL Port rush","PSMSL Malin"),
col=c("aquamarine","brown","green","coral","black"),lty=1:1, cex=0.5)
Once that was done. The PSMSL files of Malin head and Dublin were converted to be compared among the NTGN. However due to the hiccup of the data, the code will be presented but the data isn’t shown visibily.
P_Mal_Fix = cbind(PSMSL_MAL$Year,PSMSL_MAL$Month, (PSMSL_MAL$h - 7000)*10e-4)
P_Dub_Fix = cbind(PSMSL_DUB$Year, PSMSL_DUB$Month, (PSMSL_DUB$h - 7000)*10e-4)
write.csv(P_Mal_Fix,'PSMSL_MAL_FIXED.csv')
write.csv(P_Dub_Fix,'PSMSL_DUB_FIXED.csv')
Mal_fix = read.csv(file.path(getwd(),'PSMSL_MAL_FIXED.csv'),skip = 1,header=TRUE)
Dub_fix = read.csv(file.path(getwd(),'PSMSL_DUB_FIXED.csv'),skip = 1,header=TRUE)
names(Dub_fix)<-c("index","Year","Month","h")
names(Mal_fix)<-c("index","Year","Month","h")
Pfix_Dub_year <- aggregate(Dub_fix$h, by = list( Dub_fix$Year), FUN = mean, na.rm = TRUE)
Pfix_Mal_year <- aggregate(Mal_fix$h, by = list( Mal_fix$Year), FUN = mean, na.rm = TRUE)
colnames(Pfix_Dub_year) <- c("year", "Flow")
colnames(Pfix_Mal_year) <- c("year", "Flow")
plot(Pfix_Dub_year$year, Pfix_Dub_year$Flow, type= "l", col = "red", main="PSMSL Data",xlab="Year",ylab="Sea Level",xlim=c(1938,2019))
lines(Pfix_Mal_year$year, Pfix_Mal_year$Flow, type = "l", col = "green")
legend("topleft", legend=c("PSMSL Dublin fix", "PSMSL Malin fix"),
col=c("red","green"),lty=1:1, cex=0.8)
P_Prush_Fix = cbind(PSMSL_PRUSH$Year, PSMSL_PRUSH$Month, (PSMSL_PRUSH$h - 7000)*10e-4)
write.csv(P_Prush_Fix,'PSMSL_PRUSH_FIXED.csv')
Prush_fix = read.csv(file.path(getwd(),'PSMSL_PRUSH_FIXED.csv'),skip = 1,header=TRUE)
names(Prush_fix)<-c("index","Year","Month","h")
Pfix_Prush_year <- aggregate(Prush_fix$h, by = list( Prush_fix$Year), FUN = mean, na.rm = TRUE)
colnames(Pfix_Prush_year) <- c("year", "Flow")
plot(Pfix_Mal_year$year, Pfix_Mal_year$Flow, type= "l", col = "red", main="Malin and Port Rush",xlab="Year",ylab="Sea Level",xlim=c(1900,2019))
lines(Pfix_Prush_year$year, Pfix_Prush_year$Flow, type = "l", col = "yellow")
legend("bottomleft", legend=c("PSMSL Malin", "NTGN Malin", "PSMSL Port Rush"),
col=c("red", "blue", "yellow"),lty=1:1, cex=0.8)
Data showing the attempt to merge the data togther using the PSMSL of portrush. Being that they were of similar trends it made most sense to use these particular trends.
To calculatr the trends linear models were used to create a map that could be accurately plotted.
In the following map, the red arrows indicate a positive trend and blue being negative.
dub_year <- aggregate(dub$h, by = list( dub$Year), FUN = mean, na.rm = TRUE)
arklow_year <- aggregate(arklow$h, by = list( arklow$Year), FUN = mean, na.rm = TRUE)
ballycotton_year <- aggregate(ballycotton$h, by = list( ballycotton$Year), FUN = mean, na.rm = TRUE)
ballyg_year <- aggregate(ballyg$h, by = list( ballyg$Year), FUN = mean, na.rm = TRUE)
cast_year <- aggregate(cast$h, by = list( cast$Year), FUN = mean, na.rm = TRUE)
dunmore_year <- aggregate(dunmore$h, by = list( dunmore$Year), FUN = mean, na.rm = TRUE)
fenit_year <- aggregate(fenit$h, by = list( fenit$Year), FUN = mean, na.rm = TRUE)
galway_year <- aggregate(galway$h, by = list( galway$Year), FUN = mean, na.rm = TRUE)
howth_year <- aggregate(howth$h, by = list( howth$Year), FUN = mean, na.rm = TRUE)
malin_year <- aggregate(malin$h, by = list( malin$Year), FUN = mean, na.rm = TRUE)
port_year <- aggregate(port$h, by = list( port$Year), FUN = mean, na.rm = TRUE)
ring_year <- aggregate(ring$h, by = list( ring$Year), FUN = mean, na.rm = TRUE)
ross_year <- aggregate(ross$h, by = list( ross$Year), FUN = mean, na.rm = TRUE)
arklow_year.lm <- lm(arklow_year[1:17,2]~arklow_year[1:17,1])
dub_year.lm <- lm(dub_year[1:13,2]~dub_year[1:13,1])
ballycotton_year.lm <- lm(ballycotton_year[1:10,2]~ballycotton_year[1:10,1])
ballyg_year.lm <- lm(ballyg_year[1:12,2]~ballyg_year[1:12,1])
cast_year.lm <- lm(cast_year[1:12,2]~cast_year[1:12,1])
dunmore_year.lm <- lm(dunmore_year[1:8,2]~dunmore_year[1:8,1])
fenit_year.lm <- lm(fenit_year[1:8,2]~fenit_year[1:8,1])
galway_year.lm <- lm(galway_year[1:13,2]~galway_year[1:13,1])
howth_year.lm <- lm(howth_year[1:14,2]~howth_year[1:14,1])
malin_year.lm <- lm(malin_year[1:11,2]~malin_year[1:11,1])
port_year.lm <- lm(port_year[1:12,2]~port_year[1:12,1])
ring_year.lm <- lm(ring_year[1:8,2]~ring_year[1:8,1])
ross_year.lm <- lm(ross_year[1:10,2]~ross_year[1:10,1])
arklow_slope = -0.001029
dub_slope = 0.005430249
ballycotton_slope = -0.00606
ballyg_slope = 0.00256
cast_slope = 0.005127
dunmore_slope = 0.002619
fenit_slope = -0.01406
galway_slope = 0.0004726
howth_slope = -0.003942
malin_slope = -0.001005
port_slope = -0.005927
ring_slope = -0.002755
ross_slope = -0.01122
map("world",c("ireland","uk"),fill=FALSE,xlim=c(-12,-4),ylim=c(51,56))
map.axes(cex.axis=1)
points(ross.lon,ross.lat,pch=25,col="gray",bg="blue", cex = ross_slope*-400, lwd = 0.4)
text(ross.lon-.7,ross.lat,"Ross.",col="blue")
points(malin.lon,malin.lat,pch=25,col="gray",bg="blue", cex = malin_slope*-400, lwd = 0.4)
text(malin.lon-.5,malin.lat,"Malin.",col="blue")
points(howth.lon,howth.lat,pch=25,col="gray",bg="blue", cex = howth_slope*-400, lwd = 0.4)
text(howth.lon+0.7,howth.lat,"Howth.",col="blue")
points(galway.lon,galway.lat,pch=24,col="gray",bg="red", cex = galway_slope*400, lwd = 0.4)
text(galway.lon+0.4,galway.lat,"Gal.",col="red")
points(dunmore.lon,dunmore.lat,pch=24,col="gray",bg="red", cex = dunmore_slope*400, lwd = 0.4)
text(dunmore.lon-.7,dunmore.lat,"Dunmore.",col="red")
points(arklow.lon,arklow.lat,pch=25,col="gray",bg="blue",cex = arklow_slope*-400, lwd = 0.4)
text(arklow.lon-.5,arklow.lat,"Arklow.",col="blue")
points(ballycotton.lon,ballycotton.lat,pch=25,col="gray",bg="blue", cex = ballycotton_slope*-400, lwd = 0.4)
text(ballycotton.lon-.9,ballycotton.lat,"ballycotton.",col="blue")
points(ballyg.lon,ballyg.lat,pch=24,col="gray",bg="red", cex = ballyg_slope*400, lwd = 0.4)
text(ballyg.lon-.5,ballyg.lat,"BallyGlass.",col="red")
points(cast.lon,cast.lat,pch=24,col="gray",bg="red", cex = cast_slope*400, lwd = 0.4)
text(cast.lon-1,cast.lat,"CastleTown.",col="red")
points(dub.lon,dub.lat,pch=24,col="gray",bg="red", cex = dub_slope*400, lwd = 0.4)
text(dub.lon -.7,dub.lat,"Dublin.",col="red")
points(fenit.lon,fenit.lat,pch=25,col="gray",bg=("blue"), cex = fenit_slope*-400, lwd = 0.4)
text(fenit.lon-.8,fenit.lat,"Fenit.",col="blue")
points(port.lon,port.lat,pch=25,col="gray",bg="blue", cex = port_slope*-400, lwd = 0.4)
text(port.lon-.5,port.lat,"Portoriel.",col="blue")
points(ring.lon,ring.lat,pch=25,col="gray",bg="blue", cex = ring_slope*-400, lwd = 0.4)
text(ring.lon +1.2,ring.lat,"Ringask.",col="blue")
Dangendorf, S., Marcos, M., Wöppelmann, G., Conrad, C. P., Frederikse, T., & Riva, R. (2017). Reassessment of 20th century global mean sea level rise. Proceedings of the NationalAcademy of Sciences
evrejeva, S., Moore, J. C., Grinsted, A., & Woodworth, P. L. (2008). Recent global sea level acceleration started over 200 years ago?. Geophysical Research Letters