There are several data sources that are important to the hydrologist; rainfall, streamflow, evaporation (or evapotranspiration), groundwater levels, topography, soil characteristics, vegetation and the built environment, to name just a few. In this tutorial, we will be investigating just rainfall.
The publication Australian Rainfall and Runoff, is the Australian guidebook for all Hydrologists working in Australia. It is currently undergoing a revision, and draft chapters, presentations and details on all the 24 projects are available from the ARR Project page.
Chapter 2 of Book 3 in the revised ARR is going to be of particular interest in this course: Flood Frequency
Rainfall is the primary mechanism for the generation of runoff. In Hydrology that part of rainfall that becomes runoff is known as excess rainfall. We will study this in more detail later.
Rainfall can be studied on an event basis, or over a time-scale of interest (daily, weekly, monthly, annual or decadal). In hydrology, the typical analysis involves event data or the aggregates of daily, monthly or annual rainfall or a statistical representation of rainfall, known as design rainfall. The design rainfall event incorporates the Intensity, Frequency and Duration of the rainfall characteristics of interest.
To start our investigation into rainfall, download all the daily rainfall from the Palmwoods Bureau of Meteorology Website. These data can be accessed from the Climate and Past Weather tab.
We will import these data into R through the RStudio interface using the read.csv import function. The column headings of the data are used as the variable names when the file is imported. These are a bit long and cumbersome for coding, so I recommend changing them to shorter headings. You can see for yourself what the headings are by typing the command names(Rain.Data).
The new names are assigned by the command: names(Rain.Data)<-c(“code”,“StNum”,“year”,“mnth”,“day”,“Rainfall”,“RainDays”,“quality”)
The attach(Rain.Data) command is used as it allows us to access the data through the headings we have just created without having to use the name of the dataset (eg. Rain.Data)
Once the data has been imported, the time series of rainfall can be plotted.
plot(Rainfall)
This plot isn't very satisfactory as we want to plot the dates along the x-axis. This is a known as timeseries data. In the downloaded data the elements of the dates are included as day, month and year. We could coerce these data into dates by concatenating the data, however it is easier to use the 'zoo' package and 'zoo' the rainfall data. To create the dates for our zoo function, we can use a sequence command. To make sure we can use the code for other files, we can create the first and last date of the data, by using an index of the first and last values of the day, month and year. The first index is easy - 1; however to return the last index, we can use the command “nrow(Rain.Data)” as the last index.
fdate<-as.Date(paste(day[1],mnth[1],year[1],sep="/"),format="%d/%m/%Y")
nr<-nrow(Rain.Data)
ldate<-as.Date(paste(day[nr],mnth[nr],year[nr],sep="/"),format="%d/%m/%Y")
dates<-seq(fdate,ldate,"days")
library(zoo)
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
rainz<-zoo(Rainfall,dates)
plot(rainz,col="blue",ylab="Rainfall (mm)",main=paste("Daily Rainfall for",StNum[1],sep=" "))
We can also quickly make a histogram of the Rainfall Data:
hist(Rainfall)
This histogram is very skewed because all the days without rainfall are included. We can try to improve this histogram by only including the days in which rain did fall. This is achieved by using the 'which' function.
hist(Rainfall[which(Rainfall!=0)])
However, this new histogram is not much more satisfactory than the previous one. We can explore transforming the data to produce a histogram that is easier to interpret.
hist(log(Rainfall[which(Rainfall!=0)]),col="blue",xlab="Log(Rainfall) (mm)",main="Log(Rainfall) Histogram")
When you download the .Rmd file, this is where you place any notes you wish to take through the lecture or tutorial.