Skip to content

Instantly share code, notes, and snippets.

View TonyLadson's full-sized avatar

Tony Ladson TonyLadson

View GitHub Profile
@TonyLadson
TonyLadson / RFFE_Comparison.R
Last active June 5, 2023 01:02
Regional Flood Frequency Estimation (RFFE) comparison with at-site data. See the blog https://tonyladson.wordpress.com/2019/06/10/on-the-accuracy-of-the-rffe-in-nsw/
#Packages
library(tidyverse)
library(stringr)
library(dplyr)
library(readxl)
library(readr)
library(purrr)
library(ggrepel)
library(hydroGOF)
@TonyLadson
TonyLadson / RFFEScrape.R
Last active June 5, 2023 00:11
Scraping the RFFE see hthttps://tonyladson.wordpress.com/2016/07/04/scraping-the-rffe/
library(RCurl)
library(jsonlite)
library(stringr)
library(dplyr)
library(ggplot2)
rffe.data <- postForm("http://rffe.arr.org.au/",
catchment_name = "test1",
@TonyLadson
TonyLadson / DO_clean.R
Last active February 6, 2023 09:37
R code for the blog
# Figure 1
# DO - date of sample
WQ %>%
ggplot(aes(x = date, y = do.mg.l)) + geom_point() +
labs(y = 'DO (mg/L)', x = 'Date') +
theme_grey(base_size = 16)
# Figure 2
# DO - temperature
@TonyLadson
TonyLadson / IL.R
Created November 8, 2016 01:07
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)
}
AEP2ARI <- function(AEP){
1/-log(1-AEP)
}
ARI2AEP <- function(ARI){
(exp(1/ARI) - 1)/exp(1/ARI)
}
EY2AEP <- function(EY){
ARI2AEP(1/EY)
@TonyLadson
TonyLadson / Hydstra_rating.R
Created November 29, 2016 08:07
Hydstra rating plots explained. Code to accompany the blog at https://tonyladson.wordpress.com/2016/11/29/hydstra-rating-plots-explained/
library(tidyverse)
library(stringr)
library(RColorBrewer)
library(scales)
library(lubridate)
library(readxl)
# Avon River at Stratford, gauge 225201
# Stream gauging and rating data is available at http://www.bom.gov.au/waterdata/
@TonyLadson
TonyLadson / FDC.R
Created November 16, 2015 00:55
Plot a flow duration curve
FDC <- function(Q, xnormal=TRUE, xlab='%time flow equalled or exceeded',
ylab='flow',Qreturn=FALSE, plotFlow=FALSE, add=FALSE, alpha=0.5, ...) {
# Q - flow data (vector of flow values)
# xnormal - logical value to determine if the percentiles should be plotted in a normal (probit) scale
# Qreturn - logical value indicating if quantiles should be returned
# plotFlow - logical value indicating if a time series of flow should be overplotted on flow duration curve
# add - should fdc be added to an existing plot?
# alpha - transparency value for overplotting of flow time series
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
---
title: "Events_blog"
author: "Tony Ladson"
date: "3 October 2016"
output:
html_fragment:
fig_caption: yes
fig_height: 4
fig_width: 6
---
library(stringr)
library(tidyverse)
my.path <- c("...")
my.file <- '404216.rsrspf_org.tab.prn 2.txt'
fname <- str_c(my.path, my.file, sep = '/')
# Read the file in as a character vector
rating_table <- read_lines(fname)