Skip to content

Instantly share code, notes, and snippets.

View TonyLadson's full-sized avatar

Tony Ladson TonyLadson

View GitHub Profile
# Description
# Calc_slope_ea(x,y) calculates teh equal area slope
# Arguments
#
# x = distance along the stream in km
# y = elevation along the stream in m
# Details
library(quantreg)
library(dplyr)
library(lubridate)
library(stringr)
library(readr)
library(ggplot2)
library(devtools)
library(splines)
library(tidyverse)
library(deming)
# Functions ---------------------------------------------------------------
# given a point (x1, y1) and a line defined by a slope m and intercept c1
# function to return the point x on the line where a line drawn perpendicular to x1, y1
# will intercept the line
library(tidyverse)
#pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
# Probability of 1, 1% flood in 100 years
dbinom(1, size = 100, prob = 0.01, log = FALSE)
choose(100,1) *0.01^1*0.99^99
library(tidyverse)
issues <- tribble(~issue, ~pc,
'Inflows', 6,
'Demand changes', 6,
'System operation', 18,
'Equity of water sharing arrangements', 10,
'State entitlements and policies', 10,
'Environmental water', 11,
'Reliability of different licences', 4,
'Miscellaneous', 4,
@TonyLadson
TonyLadson / ARF_poly_interp.R
Last active May 23, 2020 12:14
Polynomial interpolation of ARF values between 12 and 24 hours. See https://tonyladson.wordpress.com/2020/05/23/smooth-interpolation-of-arf-curves/
# Smooth interpolation between long and short duration ARFs using a cubic.
library(tidyverse)
library(pracma)
devtools::source_url("https://gist.githubusercontent.com/TonyLadson/fc870cf7ebfe39ea3d1a812bcc53c8fb/raw/d8112631a92a32be749cabe334a22931c035711e/ARF2019.R?raw=TRUE")
library(tidyverse)
xdf <- tribble(~area_min, ~area_max, ~dur_min, ~dur_max, ~type,
10, 1000, 0, 12, 'short',
10, 30000, 24, 168, 'long',
10, 30000, 12, 24, 'interpolation',
0, 1, 0, 168, 'ARF = 1',
1, 10, 0, 12, 'Interp3',
1, 10, 12, 24, 'Interp2',
1, 10, 24, 168, 'Interp1')
@TonyLadson
TonyLadson / ARF_interp.R
Created May 12, 2020 00:03
Code to reproduce the figures in the blog: ARR2019 – Areal Reduction Factors: interpolating between short and long duration ARFs
# Load the functions we need
devtools::source_url("https://gist.githubusercontent.com/TonyLadson/fc870cf7ebfe39ea3d1a812bcc53c8fb/raw/d8112631a92a32be749cabe334a22931c035711e/ARF2019.R?raw=TRUE")
#source(file.path('ARR2019_ARF', "ARF_2019.R"))
#source(file.path('ARR2019_ARF', "ARF_tests.R")) # Check that we pass tests
# Functions and constants ------------------------------------------------------
library(tidyverse)
library(optimx)
devtools::source_url("https://gist.githubusercontent.com/TonyLadson/fc870cf7ebfe39ea3d1a812bcc53c8fb/raw/d8112631a92a32be749cabe334a22931c035711e/ARF2019.R?raw=TRUE")
#source(file.path('ARR2019_ARF', "ARF_2019.R"))
#source(file.path('ARR2019_ARF', "ARF_tests.R")) # Check that we pass tests
library(tidyverse)
devtools::source_url("https://gist.githubusercontent.com/TonyLadson/fc870cf7ebfe39ea3d1a812bcc53c8fb/raw/d8112631a92a32be749cabe334a22931c035711e/ARF2019.R?raw=TRUE")
#source(file.path('ARR2019_ARF', "ARF_2019.R"))
#source(file.path('ARR2019_ARF', "ARF_tests.R"))
# Functions and data ------------------------------------------------------