Time Series Dygraphs of Monthly Rainfall in Ireland (1850-2014)

Introduction

We were tasked with “Creating a dygraph of the weather stations at Belfast, Dublin Airport, University College Galway, and Cork Airport showing time series of rainfall on a monthly basis. Include a RangeSelector control that simultaneously changes the time window on the four time series”.

Packages installed

This Rainfall data will be analysed using various packages in R. They include tidyverse, RColorBrewer and dygraph.

Tidyverse is a collection of R packages designed for reading data. Some important packages in tidyverse are used in this research include dplyr.

RColorBrewer is a package that allows users to choose color schemes to present their data in an easier manor.

Dygraphs will be the main component of this project. It is a package which is an R interface allowing users to chart time-series data in R which is applicable to this project work.

Dplyr package will also be used for data manipulation. dplyr is a part of tidyverse, which is a grammar of data manipulation, providing a consistent set of functions that help in solving some common data manipulation challenges in this research:

This projects goal is to make a dygraph for the stations at Belfast, Dublin Airport, University College Galway and Cork Airport while showing a time series of monthly rainfall including a range selector that controls all four time series on the one window simultaneously.

In order to achieve this will be achieved is by using the cbind function to combine 4 time series into one titling it four_ts. The following code creates the time series for the 4 weather stations.

Data Methods

library(tidyverse) 
library(RColorBrewer)
library(dygraphs)
library(dplyr)
load("rainfall.RData")
rain<- rain

##Filtering using dplyr and Pipes

belfast_ts<- rain %>%  group_by(Year,Month) %>% filter(Station=="Belfast") %>%
  summarise(Rainfall=sum(Rainfall)) %>% ungroup() %>% transmute(Rainfall) %>%
  ts(start=c(1850,1),freq=12)->  bel_ts
## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
dublin_ts <- rain %>%  group_by(Year,Month) %>% filter(Station=="Dublin Airport") %>%
  summarise(Rainfall=sum(Rainfall)) %>% ungroup() %>% transmute(Rainfall) %>%
  ts(start=c(1850,1),freq=12)->  dublin_ts
## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
galway_ts<- rain %>%  group_by(Year,Month) %>% filter(Station=="University College Galway") %>%
  summarise(Rainfall=sum(Rainfall)) %>% ungroup() %>% transmute(Rainfall) %>%
  ts(start=c(1850,1),freq=12) ->  galway_ts
## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
cork_ts<- 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
## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
four_ts <-cbind(belfast_ts,dublin_ts,galway_ts,cork_ts)

A Multiple station interactive dygraph overview

four_ts %>% dygraph(width=800,height=400, main="Belfast, Dublin, Galway and Cork monthly rainfall 1850-2014") %>% dyRangeSelector

The plot above represents the time series dygraphs for monthly rainfall for four stations, which are coloured per individual station. The bright green is the Belfast time series, blue for Dublin Airport time series, dark green for Galway University time series and purple for Cork Airport time series. Using the full range period (1850-2014) variation between years can be seen in the rainfall levels recorded however the dygraph when expanded from 1850 until 2014 makes the data difficult to read and to identify long term trends. If we reduce the time range with the dyRangeselector tool, a closer observation from between Jan 2000 to Dec 2014 can be investigated, we can see the difference in rainfall level of the individual stations. For example, from Jan 2000 to Dec 2014, these four stations have a difference in the level of rainfall. We observe that all stations have increased in the recorded monthly rainfall overall, however to improve observations cyclical and seasonal should be compared. Dublin has consistently recorded the lowest rainfall level in this period, while Cork and Galway have a high level of monthly rainfall. Galway has the highest outlierlevel of rainfall in this period in November 2009 with 329.4 mm, which is around 100mm more than for Cork and almost 3 times as much as Dublin and Belfast.Whilst overall both cork and Galway had the highest recorded rainfall recorded overall.

** The Multiple simultaneous embedded Dygraph for four stations**

The next four graphs show the change in the monthly rainfall values of four individual stations. The group by demand and dyRangeSelector were used to analyse change in rainfall over the same time period in all four locations simultaneously . Charts belonging to the same group (four_ts) will have the same evaluation timing when changing timing using the dyRangeSelector tool. By seperating the data but still using the simultaneous range selector, it creates a nicer display as the previous is slightly crowded. By individually writing code for each time series and then using the %>% dyRangeSelector function.

dublin_ts %>% dygraph(width=800,height=300,group="four_ts",main="Dublin Airport") 
bel_ts %>% dygraph(width=800,height=300,group="four_ts",main="Belfast")
galway_ts %>% dygraph(width=800,height=300,group="four_ts",main="University College Galway") 
cork_ts %>% dygraph(width=800,height=300,group="four_ts",main="Cork Airport") %>% dyRangeSelector()

Each station separated into an individual dygraph helps facilitate an easier understanding of monthly rainfall patterns, unlike the original multiple dygraph with four stations separated with colour. However using another control dyRoller, a ‘rolling’ mean to edit number of months in window and using 20 years period (240 months) to see the trend of rainfall in individual station allows users to see each station over a 240 month period allowing easier access to see seasonal or outliers within the dataset dygraph.

##Rolling mean Time Series per station, a better look at the data

dublin_ts %>% dygraph(width=800,height=300,group="four_ts",main="Dublin Airport- 20 years rolling rainfall") %>% dyRoller(rollPeriod= 260)

Using dyRoller over a period of 20 years (240 months) we can see the rainfall data has been smoothed. The long term trends can be seen clearer, The start of the data seems to be the high, however the start of the data is not shown proportionately causing the data to seem large at the beginning of the window.However, in terms of trends we can see Dublin having an increase in rainfall recorded each year.

bel_ts %>% dygraph(width=800,height=300,group="four_ts",main="Belfast- 20 years rolling rainfall") %>% dyRoller(rollPeriod= 240)

Belfast records the window size issue at the start of the data causing the Early values fluctuate more, however although Belfast overall has had an increase in monthly Rainfall mm recorded , The lowest rainfall mm recorded was in July 1859 measuring at 76.69mm and started to increase in June 1862 to 80.99mm after recording the least rainfall within the Belfast dataset.Since 1862 the rainfall in monthly and yearly mm recorded has remained above the lowest recorded, however in years after 2000 the amounts of rainfall have continued to increase in monthly mm recorded.

galway_ts %>% dygraph(width=800,height=300,group="four_ts",main="University College Galway- 20 years rolling rainfall") %>% dyRoller(rollPeriod= 240)

The precipitation of University College Galway station has unstable changes throughout the study period. The highest rainfall is in July 1995 measuring at 107.3 mm. However since 1928 the rainfall precipitation has continuously increased monthly. After 2000 the monthly mm of rainfall precipitation has recorded around 106mm roughly, which is just below the highest precipitation recorded in July 1995.

cork_ts %>% dygraph(width=800,height=300,group="four_ts",main="Cork Airport- 20 years rolling rainfall") %>% dyRoller(rollPeriod= 240) %>% dyRangeSelector()

Cork’s rainfall is always higher than the rest of the stations. The highest rainfall is in January 1850 and the lowest is around the year 1858 to 1859. In general, Dublin Airport receives significantly less rainfall than the other four, while Galway and Cork receive the most.

Conclusion

In conclusion, each of the four stations have had a change in their rainfall patterns over the last 164 years.When looking at the multiple dygraph that includes all four stations being investigated, the patterns are hard to distuinguish due to over crowding of the data at full window length. When the stations are seperated into individual dygraphs a better rainfall preci[pitation paattern can be seen, however based from analysis the easiset way to investigate rainfall monthly precipitation using an interactive tool is the dyroller function which allows a rolling mean to be created over a period of time. The most obvious difference between all four stations can be observed within the 240 month window. Dublin Airport receives significantly less rainfall than the other four, while Galway and Cork receive the most. To improve the analysis further the mean rainfall per month for each station should be found using monthplots. Seasonal characteristics should also be investigated to see if short term trends in seasonal differences can be seen in some of the stations where low/high rainfall was recorded.This could give us further insight into whether monthly rainfall has changed overall per season type.