Skip to content

Instantly share code, notes, and snippets.

@TonyLadson
Created November 8, 2016 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TonyLadson/852415905e9bcea91cf49ea6031b498d to your computer and use it in GitHub Desktop.
Save TonyLadson/852415905e9bcea91cf49ea6031b498d to your computer and use it in GitHub Desktop.
Initial loss: storm v burst. Code for the blog at https://tonyladson.wordpress.com/2016/11/08/initial-loss-storm-v-burst/
library(ggplot2)
library(RColorBrewer)
library(grid)
library(cowplot)
ILb_hill <- function(d, MAR = 700){
1 - 1/(1+142*sqrt(d)/MAR)
}
ILb_rahman <- function(d){
0.5 + 0.25*log10(d)
}
ends <- ILb_hill(100, c(400, 600, 800, 1000))
blues <- brewer.pal(5, 'Blues')
[1] "#EFF3FF" "#BDD7E7" "#6BAED6" "#2171B5"
ggplot(data.frame(x = c(0.1, 72)), aes(x)) +
stat_function(fun = ILb_rahman, geom = "line") +
scale_y_continuous(name = expression(paste(IL[b],'/', IL[s])), limits = c(0,1)) +
scale_x_continuous(name = 'Duration (hour)', limits = c(0,100)) +
theme_grey(base_size = 14)
ggplot(data.frame(x = c(0.1, 72)), aes(x)) +
stat_function(fun = ILb_hill, geom = "line", args = list(MAR = 400), colour = blues[2]) +
stat_function(fun = ILb_hill, geom = "line", args = list(MAR = 600), colour = blues[3]) +
stat_function(fun = ILb_hill, geom = "line", args = list(MAR = 800), colour = blues[4]) +
stat_function(fun = ILb_hill, geom = "line", args = list(MAR = 1000), colour = blues[5]) +
stat_function(fun = ILb_rahman, geom = "line", linetype = 'dashed') +
scale_y_continuous(name = expression(paste(IL[b],'/', IL[s])), limits = c(0,1)) +
scale_x_log10(name = 'Duration (hour)', limits = c(0.1, 100), breaks = c(0.1, 1, 10, 100), expand = c(0.14, 0)) +
annotate(geom = 'text', x = 100, y = ends[1], label = ' 400 mm', colour = blues[2], hjust = 0 ) +
annotate(geom = 'text', x = 100, y = ends[2], label = ' 600 mm', colour = blues[3], hjust = 0 ) +
annotate(geom = 'text', x = 100, y = ends[3], label = ' 800 mm', colour = blues[4], hjust = 0 ) +
annotate(geom = 'text', x = 100, y = ends[4], label = ' 1000 mm', colour = blues[5], hjust = 0 ) +
annotate(geom = 'text', x = 10, y = 0.8, label = 'Rahman equation', colour = 'black', hjust = 1) +
annotate(geom = 'text', x = 12, y = 0.3, label = 'Hill equation', colour = blues[5], hjust = 0) +
theme_grey(base_size = 14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment