Skip to content

Instantly share code, notes, and snippets.

View TonyLadson's full-sized avatar

Tony Ladson TonyLadson

View GitHub Profile
# This script takes the standard download of annual max, min, mean data from
# http://data.water.vic.gov.au/monitoring.htm
# Plots a bar plot with ggplot
library(stringr)
library(dplyr)
library(lubridate)
library(ggplot2)
library(devtools)
library(scales)
# Usage
#
# source_gist('https://gist.github.com/TonyLadson/280fd3ae3e730b3bb370')
# DeltaTable_Kite(g = 0.1, aep = 0.02)
# [1] 2.3425
DeltaTable_Kite <- function(g, aep){
# g = skew
# aep = annual exceedance probability
@TonyLadson
TonyLadson / Routing.R
Last active March 10, 2016 22:55
Runoff Routing based on Mein, R. G., E. M. Laurenson and T. A. McMahon (1974) see https://tonyladson.wordpress.com/2016/03/10/routing-in-rorb/
# Routing
# Based on discussion in
# Mein, R. G., E. M. Laurenson and T. A. McMahon (1974).
# "Simple nonlinear model for flood estimation." Journal of the Hydraulics Division, American Society of Civil Engineers 100(HY11): 1507-1518.
# Time stepping solution - ideas from Section 23.2, p490 of
# Jones, O., Maillardet, R. and Robinson, A. (2014) Introduction to scientific programming and simulation using R.
# CRC Press
@TonyLadson
TonyLadson / Routing_DE.R
Last active April 11, 2016 12:07
Solving the routing equation using a differential equation solver. See https://tonyladson.wordpress.com/2016/03/15/routing-in-rorb-ii/
library(deSolve)
# dQ/dt = (I - Q)/(kmQ^(m-1))
# Specify the inflow hydrograph, using a function as discussed at
# https://tonyladson.wordpress.com/2015/07/21/hydrograph-as-a-function/
my.Qmin <- 0
my.Qmax <- 1
@TonyLadson
TonyLadson / FindGEVparameters.R
Created April 11, 2016 12:05
Find the GEV parameters used to generate design rainfalls
#
# Interpolating design rainfall intensities
#
library(dplyr)
library(stringr)
library(optimx)
# Assemble data
####################################################################
#
# Influence of shape factor in regional flood estimation
# See https://tonyladson.wordpress.com/2016/04/13/shape-factor-in-regional-flood-estimation/
#
####################################################################
# Plot of shape factor distribution
####################################################################
#
# Influence of shape factor in regional flood estimation
# See https://tonyladson.wordpress.com/2016/04/13/shape-factor-in-regional-flood-estimation/
#
####################################################################
# Plot of shape factor distribution
@TonyLadson
TonyLadson / FindP3Params.R
Created April 18, 2016 01:37
Find parameters of the Pearson III distribution given three quantile values
# Find parameters of the Pearson III distribution given three quantile values
# Function for the Pearson III frequency factor
# details at https://tonyladson.wordpress.com/2015/03/10/frequency-factors-2/
Ky_gamma <- function(g, aep){
if(abs(g) < 1e-8) { # Use the Wilson-Hilferty approximation to avoid numerical
# issues near zero
#remove(list = objects())
library(stringr)
library(dplyr)
library(ggplot2)
library(devtools)
library(readr)
library(repmis)
# Hourly data from Victorian monitoring site
# This script takes the standard download of hourly max, min, mean data from
# http://data.water.vic.gov.au/monitoring.htm
# File is downloaded as 'gaugenumber.csv'
#remove(list = objects())