NOTE: This document was republished on 28 January 2018 to include a previously missing graph and correct an error with the external link to the Met Éireann data.


Introduction

In understanding the manifestation of climate change signals, or lack thereof, increased focus is being placed on the detection and attribution of change in observational records to provide an evidence base for adaptation planning and investment. (Noone, 2016) However, natural climate variability means that trends based on short records are extremely sensitive to the length of the record and in general do not reflect long-term climate trends. (IPCC, 2013; De Saedeleer, 2016) This means that it is often difficult to discern widely-expected anthropogenic climate change signals from inter-annual variability. (Murphy et al., 2013) If climate scientists wish to better understand, identify, predict, and adapt to climate variability and change then long-term, good quality climate records are a necessity. (Wilby et al., 2006; Noone, 2016) Long-term precipitation records can be used to contextualise recent change and extreme hydrological events, and to validate past observations. (Jones et al., 2006; Watts et al., 2015; Noone, 2016) They also allow for the more accurate identification of emerging trends and provide useful information on how records have changed over longer periods of time. (Noone, 2016) Analysing these records can therefore prove extremely useful.

The R Project for Statistical Computing is a flexible tool which allows for large sets of data, such as long-term climate records, to be analysed efficiently. This assignment presents interactive time series of monthly rainfall totals for four weather stations (Dublin Airport, Cork Airport, Belfast, and University College Galway) for the period 1850-2014 which have been derived from a long-term record. These time series can be used for both local trend detection and the detection of local precipitation anomalies within the record.

Data and Methods

Station data is obtained from the homogenised Island of Ireland Precipitation (IIP) network which comprises 25 stations and a composite series covering the period 1850—2010. The IIP network is the second longest regional precipitation archive in the British Isles. (Noone, 2016; Noone et al., 2016) IIP network data is contained in a single .RData file, Rainfall.RData. Within Rainfall.RData, the rain data frame contains monthly observations of rainfall in millimetres for each year for the period 1850—2014. It also records the station from which the measurement was obtained. The stations data frame contains metadata about each station in the IIP network, including location, elevation, longitude, and latitude. The IIP network data can be downloaded in CSV format from Met Éireann.

Data manipulation is facilitated through the use of the dplyr package. dplyr is a fast, consistent tool for working with data frame like objects and allows for the implementation of a “pipeline” structure. Visualisation is achieved through a combination of R’s default time series function (ts) and the dygraphs package. dygraphs provides rich facilities for charting time series data and extends the default ts function, allowing for the creation of interactive graphs.

The map of the four weather stations is produced using the leaflet package. Additional map data is contained in Maps.RData which includes the counties spatial polygons data frame.

Monotonic trend analysis is provided by the Kendall package which enables the Mann-Kendall test to be run.

In order to facilitate reproducibility, this document was created using RMarkdown in RStudio 1.1.414.

The following chunk of code is used to load the required packages and data.

# Libraries/Packages
# ----------------------
require(leaflet)
require(dplyr)
require(dygraphs)
require(Kendall)

# Working directory
# ----------------------
setwd("C:/Users/Sean/Desktop/Assignments/Time Series Analysis/R")

# IIP/Map Data
# ----------------------
load("Rainfall.RData")
load("Maps.RData")

Table 1 shows the basic structure of the rain data frame. The table includes only the first 25 rows as it is impossible to print the entire data frame in this document. Pagination is used to conserve space.

rain[1:25, ]

Table 1. The first 25 rows of the rain data frame.

Table 2 shows the full list of IIP network stations and associated metadata.

stations

Table 2. The IIP network stations and associated metadata.

Mapping the Stations

Figure 1 illustrates the location and elevation of each of the four weather stations being considered in this assignment: Dublin Airport, Cork Airport, Belfast, and University College Galway. Data for each station was extracted from the station data frame. A colour palette based on ColorBrewer was defined for the elevation values. The map was plotted with leaflet.

# Extract Stations
# ----------------------
locations <- stations[c(7, 11, 14, 16), ]

# Colour Palette
# ----------------------
colors <- colorNumeric("YlGn", locations$Elevation)

# Popups
# ----------------------
name <- paste(locations$Station)
coords <- paste(locations$Lat, "&#176N", locations$Long, "&#176W")
elevation <- paste(locations$Elevation, "m a.s.l.")

popups <- paste(sep = "<br>", name, coords, elevation)

# Map
# ----------------------
leaflet(data = locations, height = 430, width = 390) %>%
  addProviderTiles("CartoDB.Positron") %>% setView(-8, 53.5, 6) %>%
  addCircleMarkers(fillColor = ~colors(Elevation), fillOpacity = 1, weight = 0, popup = popups) %>%
  addLegend(pal = colors, values = ~Elevation, title = "Elevation", position = "bottomleft")

Figure 1. Map of the four weather stations.

The station at Cork Airport (154m a.s.l) is located at the highest elevation, followed by Belfast (115m a.s.l), Dublin (71m a.s.l), and finally University College Galway (14m a.s.l.).

Producing the Time Series

National Series

The group_by function is used to group the data in rain by year and then by month. Total rainfall is calculated using the summarise command which creates a new data frame with one entry for each grouping. ungroup undoes the grouping. Unreferenced variables are then dropped by the transmute command which singles out the rainfall column. This column is then converted into a time series object using ts with a start date of 1850 and a monthly (freq = 12) frequency. This object is then stored as rain_ts.

# Data Manipulation
# ----------------------
rain %>% group_by(Year, Month) %>% 
  summarise(Rainfall = sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>%
  ts(start = c(1850, 1), freq = 12) -> rain_ts

An interactive time series is then created by passing the ts object to a dygraph (Figure 2). A dyRangeSelector can be added so that the user can easily view any window that they are interested in.

# Dygraph
# ----------------------
rain_ts %>% dygraph(width = 800, height = 300, main = "Island of Ireland") %>% dyRangeSelector

Figure 2. National time series.

Combined Station Series

The above code can be modified to include a filter command that allows data to be filtered by station.

# Dublin Airport
# ----------------------
rain %>% group_by(Year, Month) %>% filter(Station == "Dublin Airport") %>%
  summarise(Rainfall = sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>%
  ts(start = c(1850, 1), freq = 12) -> dub_ts

# Cork Airport
# ----------------------
rain %>% group_by(Year, Month) %>% filter(Station == "Cork Airport") %>%
  summarise(Rainfall = sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>%
  ts(start = c(1850, 1), freq = 12) -> cork_ts

# Belfast
# ----------------------
rain %>% group_by(Year, Month) %>% filter(Station == "Belfast") %>%
  summarise(Rainfall = sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>%
  ts(start = c(1850, 1), freq = 12) -> bel_ts

# University College Galway
# ----------------------
rain %>% group_by(Year, Month) %>% filter(Station == "University College Galway") %>%
  summarise(Rainfall = sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>%
  ts(start = c(1850, 1), freq = 12) -> ucg_ts

cbind can then be used to produce a single interactive time series with all four stations (Figure 3).

# Combine Stations
# ----------------------
combined_ts <- cbind(dub_ts, cork_ts, bel_ts, ucg_ts)

# Dygraph
# ----------------------
combined_ts %>% dygraph(width = 800, height = 300, main = "Dublin, Cork, Belfast, and UCG") %>% dyRangeSelector

Figure 3. Combined station series.

Individual Station Series

Although it is practical to have all four series on the same graph, the overlapping of the lines make it extremely difficult to interpret unless small windows are used. To get around this, an individual time series can be produced for each station, however they can be grouped using the group commmand such that a single dyRangeSelector controls the window for all four time series (Figure 4).

It is also possible to create a 30 year moving average for each station using dyRoller and a rollPeriod of 360 so that an overall trend might be easier to discern (Figure 5). These can be included in the same group meaning all eight time series can be viewed using the same window without the need for more than one range selector.

Total Rainfall (Fig. 4)
# Dublin Airport
# ----------------------
dub_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Dublin Airport")

Figure 4.1. Time series for Dublin Airport.

# Cork Airport
# ----------------------
cork_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Cork Airport")

Figure 4.2. Time series for Cork Airport.

# Belfast
# ----------------------
bel_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Belfast")

Figure 4.3. Time series for Belfast.

# University College Galway
# ----------------------
ucg_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "University College Galway") %>%
  dyRangeSelector

Figure 4.4. Time series for University College Galway.

30 Year Moving Average (Fig. 5)
# Dublin Airport
# ----------------------
dub_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Dublin Airport") %>% 
  dyRoller(rollPeriod = 360)

Figure 5.1. Thirty year moving average for Dublin Airport.

# Cork Airport
# ----------------------
cork_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Cork Airport") %>% 
  dyRoller(rollPeriod = 360)

Figure 5.2. Thirty year moving average for Cork Airport.

# Belfast
# ----------------------
bel_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "Belfast") %>% 
  dyRoller(rollPeriod = 360)

Figure 5.3. Thirty year moving average for Belfast.

# University College Galway
# ----------------------
ucg_ts %>% dygraph(width = 800, height = 300, group = "grouped", main = "University College Galway") %>% 
  dyRoller(rollPeriod = 360) %>% dyRangeSelector

Figure 5.4. Thirty year moving average for University College Galway.

Combined Moving Average Series

The moving averages are perhaps best visualised on a single graph. The code used to produce the combined station series can be repurposed to display the moving average for each station using dyRoller and a rollPeriod of 360 (Figure 6).

# Combined Moving Average
# ----------------------
combined_ts %>% dygraph(width = 800, height = 300, main = "Dublin, Cork, Belfast, and UCG (30 Yr. Mov. Avg.)") %>% dyRoller(rollPeriod = 360) %>% dyRangeSelector

Figure 6. Combined moving average series.

Discussion

It is clear that the four time series display a substantial amount of inter-annual variability. It is notable that University College Galway and Cork Airport tend to have higher levels of rainfall than Dublin Airport and Belfast. This is likely due to the fact that in the case of University College Galway the station is located along the west coast and as a result the amount of rainfall received here is heavily influenced by the station’s proximity to the North Atlantic. Sweeney (2014) notes that the west coast tends to receive higher amounts of precipitation as it is much more exposed to the cyclonic and convective processes occurring in the North Atlantic than the rest of the country. This also goes toward explaining the higher rainfall at Cork Airport, though elevation is a much more significant factor in this case as the station is located 154m a.s.l. Met Éireann (2018) note that annual amounts of precipitation are subject to increases of 100mm on eastern slopes and 200mm on exposed western slopes for every 100m increase in altitude. This is due to the general uplift of air over raised ground which leads to longer, more intense showers. This also results in many areas toward the east experiencing lower precipitation due to the rain shadow effect, a point corroborated by Sweeney (2014). In general the higher amounts of rainfall at University College Galway and Cork Airport compared to Dublin Airport and Belfast correspond in general with the west-to-east decline in precipitation shown in Figure 7.

Figure 7. 1981–2010 Mean Annual Rainfall. (Met Éireann, 2018)

The 30 year moving average reveals a much more consistent pattern throughout the record with no indication of significant upward or downward trends. Early fluctuations are due to the fact that a full window of data is not available. In general there appears to be an overall upward trend in rainfall for each station between 1850 and 2014 with University College Galway showing the greatest increase, particularly from 1990 onward. There are also noticeable increases at Belfast and Dublin Airport from around 2000.

It is possible to confirm the presence of these trends by conducting a Mann-Kendall test on each of the time series. The Mann-Kendall test is a non-parametric test commonly employed to detect monotonic trends in environmental data series. The Mann-Kendall Z statistic (MKZs) is used to measure the direction and strength of a trend. A positive (negative) MKZs indicates an upward (downward) trend. At the 5% significance level, an |MKZs| of greater than 1.96 indicates a statistically significant trend.

# Function to Return the MKZs
# ----------------------
# Code courtesy of Shaun Harrigan
# ---------------------
MKZs <- function(x) {
  
  S <- MannKendall(x)$S
  varS <- MannKendall(x)$varS
  
  if (S > 0) {
    Zs <- (S-1)/sqrt(varS)
  } else if (S < 0) {
    Zs <- (S+1)/sqrt(varS)
  } else {
    Zs <- 0
  }
  return(Zs)
}

# Print MKZs
# ----------------------
print(c(MKZs(dub_ts), MKZs(cork_ts), MKZs(bel_ts), MKZs(ucg_ts)))
## [1] 1.9568282 0.5486872 2.3088779 1.9075043

The MKZs confirm the presence of increasing trends in each time series, though this trend is only significant for Belfast with an |MKZs| of 2.30. The trends for Dublin Airport and University College Galway are only borderline insignificant though the positive MKZs still indicate a relatively strong upward trend. The trend is not as great for Cork Airport, but is still an upward trend nonetheless.

Further analysis should seek to decompose the time series using STL filtering as described in Cleveland et al. (1990) which may allow for a more comprehensive look at seasonal trends and noise.

Conclusion

This assignment has presented time series of monthly rainfall totals for four weather stations for the period 1850—2014. Data was sourced from the Island of Ireland Precipitation network and the relative ease with which such a large data set was processed highlights the advantages of using R for data analysis. This work is entirely reproducible using the data available from Met Éireann and the embedded code. The straightforward nature of both dplyr and dygraphs also allows for easy adaptation of the code to a similar data set.

References

Cleveland, R. B., Cleveland, W. S., McRae, J. E. and Terpenning, I. (1990) STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6(1), 3–33.

De Saedeleer, B. (2016) Climatic irregular staircases: generalized acceleration of global warming. Nature Scientific Reports, 6(19881). DOI: 10.1038/srep19881.

IPCC (2013) Summary for Policymakers. In: Stocker, T. F. et al., eds. (2013) Climate Change 2013: The Physical Science Basis. Contribution of Working Group I to the Fifth Assessment Report of the Intergovernmental Panel on Climate Change. Cambridge: Cambridge University Press.

Jones, P. D., Lister, D. H., Wilby, R. L. and Kostopoulou, E. (2006) Extended riverflow reconstructions for England and Wales, 1865—2002. International Journal of Climatology, 26, 219—31.

Met Éireann (2018) Climate of Ireland — Rainfall [online]. Available at: https://www.met.ie/climate-ireland/rainfall.asp (accessed 15 January 2018).

Murphy, C., Harrigan, S., Hall, J. and Wilby, R. L. (2013) Climate-driven trends in mean and high flows from a network of reference stations in Ireland. Hydrological Sciences Journal, 58(4), 755—72.

Noone, S. (2016) Development and analysis of a homogenous long-term precipitation network (1850—2015) and assessment of historic droughts for the Island of Ireland. Ph.D. thesis, Maynooth University.

Noone, S., Murphy, C., Coll, J., Matthews, T., Mullan, D., Wilby, R. L. and Walsh, S. (2016) Homogenization and analysis of an expanded long-term monthly rainfall network for the Island of Ireland (1850—2010). International Journal of Climatology, 36, 2837—53.

Sweeney, J. (2014) Regional weather and climates of the British Isles — Part 6: Ireland. Weather, 69(1), 20—27.

Watts, G. et al. (2015) Climate change and water in the UK - past changes and future prospects. Progress in Physical Geography, 39(1), 6—28.

Wilby, R. L. (2006) When and where might climate change be detectable in UK river flows. Geophysical Research Letters, 33. DOI: 10.1029/2006GL027552.

Wilby, R. L. and Quinn, N. W. (2013) Reconstructing multi-decadal variations in fluvial flood risk using atmospheric circulation patterns. Journal of Hydrology, 487, 109—21.