Loading the required data

To begin, the working directory was set and a path to navigate to the data was created.

setwd("C:/MSc_CC/GerardAssignment")

path <- file.path(getwd(),"data")

The required data was then downloaded. The National Tide Gauge (NTG) data was readily available online from Moodle. There were 13 datasets available. These datasets were saved into the chosen working directory. These datasets were saved as .csv files. The Permanent Service for Mean Sea Level (PSMSL) data could be found online at the PSMSL website (https://www.psmsl.org/). There were 5 datasets required to download. These datasets were saved into the folder the file.path() was directed to within the working directory. These datasets were saved as RLRData files, which could be opened in Excel and saved as a .txt file.

The data from the National Tide Gauge records was then loaded.

Arklow <- read.csv ("arklow_monthly.csv")
Ballycotton <- read.csv("ballycotton_monthly.csv")
Ballyglass <- read.csv("ballyglass_monthly.csv")
Castletownbere <- read.csv("castletownbere_monthly.csv")
Dublin2 <- read.csv("dublin_monthly.csv")
Dunmore_east <- read.csv("dunmore_east_monthly.csv")
Fenit <- read.csv("fenit_monthly.csv")
Galway <-read.csv("galway_monthly.csv")
Howth <- read.csv("howth_monthly.csv")
Malin <- read.csv("malin_monthly.csv")
Port_oriel <- read.csv("port_oriel_monthly.csv")
Ringaskiddy <- read.csv("ringaskiddy_monthly.csv") 
Rossaveel <- read.csv("rossaveel_monthly.csv")

The datasets were briefly explored by use of the head() function to indicate what was in each column.

head(Arklow)
head(Ballyglass)
head(Galway)
head(Howth)

Each had an ‘x’ column which contained a simple list of numbers for each observation, a ‘year’ column, and a ‘month’ column. Next, there was an ‘h’ column containing the sea surface height data in meters. Finally, a ‘time’ column was present. The ‘time’ column was a date in the format of ‘d/m/y/’. The ‘time’ columns in each dataset were not in a format R can easily read, and so this column in each was formatted to be more easily read by R, as well as ensuring all the datasets had the same time format to work with.

Arklow$time <- as.Date(Arklow$time, format = "%d/%m/%Y")
Ballycotton$time <- as.Date(Ballycotton$time, format = "%d/%m/%Y")
Ballyglass$time <- as.Date(Ballyglass$time, format = "%d/%m/%Y")
Castletownbere$time <- as.Date (Castletownbere$time, format = "%d/%m/%Y")
Dublin2$time <- as.Date (Dublin2$time, format = "%d/%m/%Y")
Dunmore_east$time <- as.Date (Dunmore_east$time, format = "%d/%m/%Y")
Fenit$time <- as.Date (Fenit$time, format = "%d/%m/%Y")
Galway$time <- as.Date (Galway$time, format = "%d/%m/%Y")
Howth$time <- as.Date (Howth$time, format = "%d/%m/%Y")
Malin$time <- as.Date (Malin$time, format = "%d/%m/%Y")
Port_oriel$time <- as.Date (Port_oriel$time, format = "%d/%m/%Y")
Ringaskiddy$time <- as.Date (Ringaskiddy$time, format = "%d/%m/%Y")
Rossaveel$time <- as.Date (Rossaveel$time, format = "%d/%m/%Y")

Next, the datasets for the 5 PSMSL records were loaded.

BelfastPS <- read.table(file.path(path,"belfast_monthly.txt"), header = TRUE)
DublinPS <- read.table(file.path(path,"dublin_monthly.txt"), header = TRUE)
MalinheadPS <- read.table(file.path(path,"malin_monthly.txt"), header = TRUE)
PortrushPS <- read.table(file.path(path,"portrush_monthly.txt"), header = TRUE)
BangorPS <- read.table(file.path(path,"bangor_monthly.txt"), header = TRUE)
head(BelfastPS)
head(BangorPS)

Again brief exploration was undertaken with use of the head() function and the tail() function. There was a column present which clearly contained year in a conventional format. There was a column which contained larger numbers which denoted months, such as 417 meaning January and 1250 meaning February. The next column contained the sea surface height data. The units were in mm in this case. The two final columns contained ‘flag’ and ‘missing days’, which was explained on the PSMSL website. These datasets were reopened in Excel to manipulate. Firstly, column headings were added - “Year”, “Month” and “Rlr”. To format the ‘month’ column into a more readable format in R, each dataset was edited simply in Excel. The ‘Find and Replace’ function was used to change the larger numbers into months (1-12). For example, in each year, the 417 in the month column was replaced with 1 (January), 1250 was replaced with 2 (February), and so on. Any missing data was also easily dealt with as -9999, which denotes a missing value, was replaced with ‘NA’, again by using the ‘Find and Replace’ function. Finally, the ‘flag’ and ‘missing days’ columns were removed as they would not be required in this study. The datasets were then saved to overwrite the previous .txt files. These edited .txt files were then reread in over the existed using the same code shown previously.

Mapping tide gauge locations

A map plotting all the locations of the tide gauges from both the NTG and the PSMSL datasets was created. The latitudes and longitudes of each tide gauge were found online (from the NTG and the PSMSL websites) and noted. Opening each file in Excel, a latitude (lat) and longitude (lon) column was added. The latitude and longitude values were then added and extended down all the rows for both of these new columns. The NTG datasets were saved over the previous again as.csv files. These were then reloaded using the previous code. A brief exploration using the head() function ensures the new latitude and longitude columns were added. The PSMSL datasets were also saved over the previous again as .txt files. These were then reloaded using the previous code. A brief exploration using the head() function ensures the new latitude and longitude columns were added. (NOTE: lat and lon were not yet added at this stage).

NTG:

head(Arklow)
head(Galway)
##   X month year           h       time  lat lon
## 1 1     4 2007 -0.17201932 2007-04-15 53.3  -9
## 2 2     5 2007 -0.05556248 2007-05-15 53.3  -9
## 3 3     6 2007 -0.01711444 2007-06-15 53.3  -9
## 4 4     7 2007 -0.01641613 2007-07-15 53.3  -9
## 5 5     8 2007 -0.09717110 2007-08-15 53.3  -9
## 6 6     9 2007 -0.08603322 2007-09-15 53.3  -9

PSMSL:

head(BangorPS)
head(BelfastPS)
##   Year Month  Rlr  lat  lon
## 1 1957     1 7064 54.6 -5.9
## 2 1957     2 7167 54.6 -5.9
## 3 1957     3 7093 54.6 -5.9
## 4 1957     4 6900 54.6 -5.9
## 5 1957     5 6915 54.6 -5.9
## 6 1957     6 6925 54.6 -5.9

The map could then be plotted with the new latitude and longitude included. The required packages for this stage were also loaded.

library(VulnToolkit)
library(maps)
map("world",c("ireland", "uk"),fill= FALSE,xlim=c(-12,-4),ylim=c(51,56))
map.axes(cex.axis=1)
title(main="Location of Tide Gauges",xlab="Longitude",ylab="Latitude")

points(Arklow$lon,Arklow$lat,pch=21,col="gray",bg="red")
text(Arklow$lon, y = Arklow$lat, "Arklow", pos = 4, cex= 0.6)
points(Ballycotton$lon,Ballycotton$lat,pch=21,col="gray",bg="red")
text(Ballycotton$lon, y = Ballycotton$lat, "Ballycotton", pos = 4, cex= 0.6)
points(Ballyglass$lon,Ballyglass$lat, pch=21, col="gray", bg= "red")
text(Ballyglass$lon, y = Ballyglass$lat, "Ballyglass", pos = 3, cex = 0.6)
points(Castletownbere$lon,Castletownbere$lat,pch=21,col="gray",bg="red")
text(Castletownbere$lon, y = Castletownbere$lat, "Castletownbere", pos = 1, cex= 0.6)
points(Dublin2$lon,Dublin2$lat,pch=21,col="gray",bg="red")
text(Dublin2$lon, y = Dublin2$lat, "Dublin", pos = 2, cex= 0.6)
points(Dunmore_east$lon,Dunmore_east$lat,pch=21,col="gray",bg="red")
text(Dunmore_east$lon, y = Dunmore_east$lat, "Dunmore", pos = 4, cex= 0.6)
points(Fenit$lon,Fenit$lat,pch=21,col="gray",bg="red")
text(Fenit$lon, y = Fenit$lat, "Fenit", pos = 4, cex= 0.6)
points(Galway$lon,Galway$lat,pch=21,col="gray",bg="red")
text(Galway$lon, y = Galway$lat, "Galway", pos = 3, cex= 0.6)
points(Howth$lon,Howth$lat,pch=21,col="gray",bg="red")
text(Howth$lon, y = Howth$lat, "Howth", pos = 4, cex= 0.6)
points(Malin$lon,Malin$lat,pch=21,col="gray",bg="red")
text(Malin$lon, y = Malin$lat, "MalinHead", pos = 2, cex= 0.6)
points(Port_oriel$lon,Port_oriel$lat,pch=21,col="gray",bg="red")
text(Port_oriel$lon, y = Port_oriel$lat, "PortOriel", pos = 4, cex= 0.6)
points(Ringaskiddy$lon,Ringaskiddy$lat,pch=21,col="gray",bg="red")
text(Ringaskiddy$lon, y = Ringaskiddy$lat, "Ringaskiddy", pos = "1", cex= 0.6)
points(Rossaveel$lon,Rossaveel$lat,pch=21,col="gray",bg="red")
text(Rossaveel$lon, y = Rossaveel$lat, "Rossaveel", pos = "2", cex= 0.6)
points(BelfastPS$lon,BelfastPS$lat,pch=21, col="gray",bg="red")
text(BelfastPS$lon, y = BelfastPS$lat, "Belfast", pos = "2", cex = 0.6)
points(BangorPS$lon,BangorPS$lat,pch=21, col="gray",bg="red")
text(BangorPS$lon, y = BangorPS$lat, "Bangor", pos = "4", cex = 0.6)
points(PortrushPS$lon,PortrushPS$lat,pch=21, col="gray",bg="red")
text(PortrushPS$lon, y = PortrushPS$lat, "Portrush", pos = "3", cex = 0.6)

Overall, the tide gauge locations are reasonably well spread around the coastline of the island of Ireland. However as there are only 15 tide gauges in this study, naturally there could be a better representation if there were more tide gauges. There could potentially be one or two more gauges located along the coastline of the northwest and the west of Ireland.

Plotting the NTG time series

To create a plot of each time series for the NTG datasets and the PSMSL datasets, the following packages were loaded.

library(ggplot2)
library(readr)    
library(tidyverse) 
library(lubridate)
library(purrr)  
library(stringr)   
library(dplyr)
library(magrittr)
library(dygraphs)
library(reshape2)
library(leaflet)
library(ggvis)

Firstly, the 13 NTG datasets were plotted. These were chosen to be plotted using the ‘time’ column. It must be noted the ‘Ballyglass’ dataset did not have a time column and so was not plotted on the following graph. This multiple timeseries was plot was chosen to be created using the ggplot package. This required the dataset to be all moved into one data frame- here named ‘datasets’. This could be done by selecting the files from the working directory which were .csv files. Next, the names of the files where changed to a more appropriate and readable format by removing the unnecessary parts of the .csv file names. For example, ‘arklow_monthly’ was changed to ‘Arklow’. This created the value ‘locations’.

files <- dir(pattern='*.csv')
locations <- str_remove(files,"_mon.*") %>% 
  str_replace("_"," ") %>% 
  str_to_title()

Next, the each dataset in the complete ‘datasets’ data frame was renamed based on the ‘locations’ value. Each dataset was then bound using rbind() to create one long continuous data frame with each dataset stacked on top of the next. A column containing was in this data frame, which was formatted by using the mutate () function. This ensured all the dates were in the same format to plot, i.e. ‘dmy’. A column containing location was in this data frame showing the various tide gauge location names. A column for the sea surface height data was also in this data frame. Finally, a final ‘h2’ column was created. This contained offset ‘h’ data to ensure the timeseries plots were arbitrarily offset. The dataset was instructed to move up per month in the plot. The ‘date_loc’ data frame was created which contained the dates and locations. Finally, the date_loc file was merged into the ‘datasets’. The head() function was used to explore and check what had been created.

datasets <- files %>% map(~read_csv(.))
names(datasets) <- locations
datasets <- datasets %>% imap(~{.x %>% mutate(location = .y)})
datasets <- bind_rows(datasets)
datasets <- datasets %>%  
  group_by(location) %>% 
  mutate(Date=dmy(time), 
         h2 = scale(h,scale=F) + match(location,locations)) %>% 
  select(h, h2, Date, location)

alldates <- seq(ymd("2003-09-15"),
                ymd("2019-02-15"),
                by='month')

date_loc <- cross_df(list(Date=as.character(alldates),
                          location=locations)) 
date_loc$Date <- ymd(date_loc$Date)
datasets <- date_loc %>% left_join(datasets)
head(datasets)
## # A tibble: 6 x 4
##   Date       location       h    h2
##   <date>     <chr>      <dbl> <dbl>
## 1 2003-09-15 Arklow   -0.0714 0.993
## 2 2003-10-15 Arklow   -0.0357 1.03 
## 3 2003-11-15 Arklow    0.0673 1.13 
## 4 2003-12-15 Arklow   -0.0530 1.01 
## 5 2004-01-15 Arklow    0.0217 1.09 
## 6 2004-02-15 Arklow   -0.158  0.906

Finally, the ggplot of the NTG time series was created.

ggplot(datasets,aes(x=Date,y=h2,group=location)) + 
  geom_line() +
  theme_linedraw() + 
  scale_y_continuous(name=element_blank(),
                     breaks=1:13,
                     labels = locations) + 
  scale_x_date(date_labels = "%Y",date_breaks = "2 years")+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank())

All the NTG timeseries’ show similar fluctuations during certain years, particularly during increasing height years. For example, a large increase in sea surface height occurs around 2016 across all timeseries, excluding those with missing data. Other events similar to this occurred around the end of 2013 and the start of 2014. With such similar annual fluctuations in height, the tide height around Ireland may be influenced by similar mechanisms, with these fluctuations representing invididual events. Important to note is the sudden and dramatic drop of sea level in Fenit at around 2018. This seems unusual and may be due to an error in data input or an error in reading the sea level at the tide gauge. Many of the datasets also show a large decreasing height since 2018. However, many of the stations show missing data from around 2018, such as at Malinhead and Howth. Missing data can be easily seen in this plot, such as for Portoriel which has large gaps in its data. Also, to note, all of these timeseries are relatively short as they begin in the early 2000s. It is therefore difficult to pick out an overall trend, while annual fluctuations are more easily identifiable.

Plotting the PSMSL Tide Gauge Time Series

Next, the 5 PSMSL datasets were plotted. These were plotted by ‘year’ rather than ‘time’ as there was no ‘time’ column available. This was done using the plot() function.

plot(DublinPS$Year, DublinPS$Rlr - 7500, type = 'l', col = 'red', xlab = 'Year', ylab = ' ', ylim = c(-1000, 2250), xlim = c(1900, 2020), yaxt = 'n', main = "PSMSL Tide Gauge record lengths")
lines(PortrushPS$Year, PortrushPS$Rlr - 7000, col = 'purple')
lines(BelfastPS$Year, BelfastPS$Rlr - 6500, col = 'dark blue')
lines(BangorPS$Year, BangorPS$Rlr - 6000, col = 'pink')
lines(MalinheadPS$Year, MalinheadPS$Rlr - 5500, col = 'brown')
legend("topleft", 
       legend = c("Malinhead", "Bangor", "Belfast", "Portrush", "Dublin"), 
       col = c("brown", "pink", "dark blue", "purple", "red"),
       cex = (0.7),
       pch = c(20), 
       bty = "0", 
       pt.cex = 1.3, 
       text.col = "black")

The plot shows, based on the x axis values, that these PSMSL datasets are significantly longer than the NTG datasets. The earliest record being Belfast which runs from the 1950s to almost the 1980s. Due to the longer length of these records, trends can be spotted more easily than in he NTG timeseries plot. A clear trend can be spotted in the Dublin timeseries with a significant increase since around the year 2000. While these time series overlap in duration, this increasing trend appears to be less pronounced in the Bangor timeseries and almost cannot be seen in the Portrush timeseries. Belfast appears to have more of an unchanging trend until 1950, where it then begins to decrease until the timeseries ends. Also, to note around the 1990s both Malinhead and Dublin show a decreasing trend in height, which occurs at Malinhead a few years before Dublin. It is slightly more difficult to spot similarities between the 5 timeseries regarding annual fluctuations due to the longer length of these time series. However, a large upward spike in sea height can be seen in both Malinhead and Dublin around 1980.

Merging the PSMSL and NTG Dublin datasets

Firstly, the column was removed. The PSMSL and NTG height data columns were changed into the same format, in order to merge onto one data frame. The column headings were renamed to ‘Year’ and ‘Month’ for both Dublin datasets. Both Dublin datasets were copied into new data frames (‘Dub1’, ‘Dub2’). This kept the original data in case it was required. 7007 mm was taken from the height column from the Dub1 (PSMSL) data. This information came from the PSMSL website. The mean of the ‘Rlr’ height column was also removed.

Dublin2$X<- NULL
colnames(Dublin2) <- c("Month", "Year", "h", "time", "lat", "lon")

Dub1 <- DublinPS
Dub2 <- Dublin2

Dub1$Rlr <- Dub1$Rlr-7007
Dub1$Rlr <- Dub1$Rlr-mean(Dub1$Rlr, na.rm = TRUE)


DubMerged <- merge(Dub1, Dub2, all=TRUE)

Next, the overlap between the two datasets was copied into a new data frame (‘DublinSubset’). A new column called ‘plot’ was added. A copy of the ‘DublinSubset’ height data was moved into this column. The original height data was subtracted from the ‘plot’. Finally, a mean of this new ‘plot’ data was taken. In order to plot, this output was taken away from the NTG data, shown later on.

DublinSubset <- DubMerged %>% slice(832:864)
DublinSubset <- cbind(DublinSubset, NA)
colnames(DublinSubset)<- c("Year", "Month", "Rlr", "h", "time", "lat", "lon", "plot")

DublinSubset$plot<-DublinSubset$Rlr
DublinSubset$plot <- DublinSubset$plot - DublinSubset$h
mean(DublinSubset$plot)
## [1] 206.5467
#The mean value to be subtracted is rounded to 207

The next stage was to merge to two Dublin datasets. Two new data frames with the PSMSL and NTG were created so ensure the scale factor was not repeated as the code ran. Any columns that were not required were removed.

DubA <- DublinPS
colnames(DubA)<- c("Year", "Month", "h")

DubB <- Dublin2
DubB$time<- NULL
DubB$lat<- NULL
DubB$lon<- NULL
DubB$X<- NULL
colnames(DubB)<- c("Month", "Year", "h")

The overlapping dates had to be removed in order to merge. This was done by manually scrolling to find the rows: in this case rows 832 to 864 were not required in the PSMSL dataset. These were removed. The mean of the plot column was taken away from the NTG dataset (DubB). Finally both datasets were combined via the rbind() function and plotted.

DubA <- DubA[-c(832:864), ]

DubA$h <- DubA$h-7007

DubB$h <- DubB$h+207

DubC <- rbind(DubA, DubB)

plot(DubC$h~DubC$Year, type ='l', xlim = c(1930, 2020), xlab = "Year", ylab = "h (mm)", main= "Merged Dublin Sea Level")

The merged Dublin plot shows clearly the dramatic increase of sea surface height since around 2000. Until then the trend had been relatively stable. There may be a number of reasons as to Dublin’s dramatic increase in recent years. As mentioned previously, the finger prints from glacial isostatic adjustment may be at play as the north, northeast and central Ireland is known to be rebounding per year. Local ocean dynamics may be at play as well as the increasing melting ice sheets.

The Malinhead datasets could be merged similarly to the Dublin datasets above. However, they have a gap between them of missing data. They could still be merged by using a station which is geographically close to it, such as Portrush. As can be seen on the plots previous, Portrush bridges the gap left by the missing dates between both Malinhead datasets. By using lm() to calculate the trend within both the overlapping period (i.e. the start and end of the Portrush dataset), this can be used to work out the trend, and therefore bridge the gap in the Malinhead dataset. The Portrush dataset is used as a proxy to extend the Malinhead dataset.

Mean Sea Level Curve

In order to create an Irish mean sea level curve, the Virtual Station approach developed by Jevrejeva et al. (2008) could be used. This approach splits the global oceans into 12 distinct regions. In each region the tide gauge data from two stations which are geographically closest to each other are locally corrected by undergoing an algorithm. This results in 12 virtual stations, 1 for each region (Dangendorf et al., 2017). The total average of these regions when creates a global average of sea level. The mean sea level curve can then be found by merging the resulting virtual station data to ultimately create a curve (Dangendorf et al,2017). Data may be missing in certain stations in this study. Also, there are only 13 stations of various lengths in this study. The geographical coverage of the coast of the Island of Ireland in this study while spread to all corners, is still relatively lacking. Using the Virtual Station approach for this region may aid in creating a more accurate mean sea level curve as it will fill in the geographical gaps left between the stations in this study.

References

Brooks, A. J., Bradley, S. L., Edwards, R. J., Glenn, A. M., Horton, B. & Shennan, I. (2008) “Post-Glacial relative sea-level observations from Ireland and their role in glacial rebound modelling” Journal or Quaternary Science 23.

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 National Academy of Sciences.

Jevrejeva, S., Moore, J. C., Grinsted, A., & Woodworth, P. L. (2008 “Recent global sea level acceleration started over 200 years ago?” Geophysical Research Letters 35.

Klemann, V., Heim, B., Henning, A. B., Wetterich, S. & Opel, T. (2015) “Sea-level evolution of the Laptev Sea and the East Siberian Sea since the last glacial maximum” arktos 1.