Skip to content

Instantly share code, notes, and snippets.

@TonyLadson
Last active February 28, 2016 23:39
Show Gist options
  • Select an option

  • Save TonyLadson/280fd3ae3e730b3bb370 to your computer and use it in GitHub Desktop.

Select an option

Save TonyLadson/280fd3ae3e730b3bb370 to your computer and use it in GitHub Desktop.
# 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
# Table 9-3
# Kite, G. W. (2004) Frequency and risk analysis in hydrology.
# Water Resources Publications, Littleton Co
require(e1071)
if(g > 2 | g < 0) stop('To use delta values from Kite, g must be in the range 0 to 2')
if(aep < 0.01 | aep > 0.5) stop('To use delta values from Kite, AEP must be in the range 0.01 to 0.5')
if(length(aep) > 1 | length(g) >1) stop('g and AEP cannot have length greater than 1')
# load in delta values from Table 9-3 of Kite (2004)
delta.table <-
structure(c(1.0801, 1.0808, 1.083, 1.0866, 1.0918, 1.0987, 1.1073,
1.1179, 1.1304, 1.1449, 1.1614, 1.1799, 1.2003, 1.2223, 1.2457,
1.2701, 1.2952, 1.3204, 1.3452, 1.369, 1.3913, 1.1698, 1.2006,
1.2309, 1.2609, 1.2905, 1.3199, 1.3492, 1.3785, 1.4082, 1.4385,
1.4699, 1.503, 1.5382, 1.5764, 1.6181, 1.6643, 1.7157, 1.7732,
1.8374, 1.9091, 1.9888, 1.3748, 1.4367, 1.4989, 1.561, 1.6227,
1.6838, 1.7441, 1.8032, 1.8609, 1.917, 1.9714, 2.024, 2.0747,
2.1237, 2.1711, 2.2173, 2.2627, 2.3081, 2.3541, 2.4018, 2.4525,
1.6845, 1.781, 1.8815, 1.9852, 2.0915, 2.1998, 2.3094, 2.4198,
2.5303, 2.6403, 2.7492, 2.8564, 2.9613, 3.0631, 3.1615, 3.2557,
3.3455, 3.4303, 3.51, 3.5844, 3.6536, 2.1988, 2.3425, 2.4986,
2.6656, 2.8423, 3.0277, 3.2209, 3.4208, 3.6266, 3.8374, 4.0522,
4.2699, 4.4896, 4.71, 4.9301, 5.1486, 5.3644, 5.5761, 5.7827,
5.9829, 6.1755, 2.6363, 2.8168, 3.0175, 3.2365, 3.4724, 3.7238,
3.9895, 4.2684, 4.5595, 4.8618, 5.1741, 5.4952, 5.824, 6.1592,
6.4992, 6.8427, 7.1881, 7.5339, 7.8783, 8.2196, 8.5562),
.Dim = c(21L, 6L),
.Dimnames = list(seq(0,2,0.1), # row names
c("0.5", "0.2", "0.1", "0.05", "0.02", "0.01"))) # col names
delta.table <- delta.table[ ,6:1] # we need to re-order the data so its from lowest to highest value in each dimension
interpolate(c(g, aep), delta.table)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment