https://github.com/norskregnesentral/brffa
https://github.com/norskregnesentral/brffa
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/norskregnesentral/brffa
- Owner: NorskRegnesentral
- Created: 2018-05-07T13:03:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-17T09:24:12.000Z (almost 5 years ago)
- Last Synced: 2025-01-10T16:46:13.915Z (9 months ago)
- Language: R
- Size: 271 KB
- Stars: 0
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---# Bayesian regional flood frequency analysis (FFA)
This tutorial describes the data and analysis considered for Bayesian hierachical model for Regional flood frequency analysis.
## Installation
First, you need to install the SpatGEVBMA package from NorskRegnesentral GitHub respository
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("NorskRegnesentral/SpatGEVBMA")```
Then load the data and functions used for the analysis.
```{r}
# Load yearly flood time series and covariates
load("~/BRFFA/data/norwayFlood.Rdata")# Load functions
source('~/BRFFA/scripts/functions.R')
```We start by exploring some descriptive plots of the covariates. Considering first histograms of the record length, catchment area, percentage of lake, average rain in April and August and percentage of flood contributed to rain vs. snowmelt.
```{r}
# Define location for map plotting
S <- cbind(covariates$longitude,covariates$latitude)#Plot histograms for some covariates
par(mar=c(5,4,1,1),mfrow=c(2,3),cex.axis=1.3,cex.lab=1.5)
hist(rowSums(!is.na(floodData)),xlab='Record length (years)',ylab='Stations',main = '')
hist(log(covariates$area.total),xlab='Catchment area (km²)',ylab='',main = '',xaxt='n')
axis(1,at=log(c(40,10^(2:6))),labels=c(40,10^(2:6)))
hist(covariates$pct.eff.lake,xlab='Lake percentage',ylab='',main = '')
hist(covariates$avg.rain.april,xlab='Average rain April (mm)',ylab='Stations',main = '')
hist(covariates$avg.rain.august,xlab='Average rain August (mm)',ylab='',main = '')
hist(covariates$avg.frac.rain,xlab='Rain contribution (%)',ylab='',main = '')```
Now we plot the time series of some selected stations.
```{r}
matplot(1870:2015,t(floodData[c(7,50,80,2,23),])*1000,type='l',lty=1,xlab='Year',ylab = 'Yearly Maximum Flood (l/s/km²')
legend('topleft',lty=1,col=1:5,legend=covariates$station.name[c(7,50,80,2,23)])
```Then we plot the percentage of flood contributed to rain vs. snowmelt according to longitude and latitude of the each considered station, to reveal the spatial distribution of this covariate.
```{r,message=FALSE, warning=FALSE, cache=FALSE}
#Plot map for some covariates
library(maps)
all.colors <- colorRampPalette(c("yellow","forestgreen", "blue"))(7) #heat.colors(7)[7:1]
par(mar=c(5,4,1,1),mfrow=c(1,1))
var1 <- covariates$avg.frac.rain
mugr <- rep(NA,length(var1))
gr <- seq(0, 1, length.out=6)
#gr <- c(0,0.1,0.2,0.3,0.5,0.7,1)
for (g in 1:(length(gr)-1)){
mugr[var1>=gr[g] & var1