This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################################################### | |
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#remove(list = objects()) | |
library(stringr) | |
library(dplyr) | |
library(ggplot2) | |
library(devtools) | |
library(readr) | |
library(repmis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################################### | |
# | |
# Fitting non-linear models in R | |
# See tonyladson | |
# | |
# 5 June 2016 | |
############################################################################################### | |
# | |
# Example data come from Figure 5 from Ian Cordery's thesis | |
# Also Figure 3 from Cordery, 1970 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Confidence intervals for the mean for non-normal data | |
# See https://tonyladson.wordpress.com/2016/01/11/plotting-water-quality-samples-on-a-hydrograph/ | |
# Modified Cox function for calculating confidence intervals for the mean | |
# Based on Olsson, 2005 | |
# http://www.amstat.org/publications/jse/v13n1/olsson.html | |
# x is a set of log-normal data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringr) | |
library(readr) | |
library(dplyr) | |
library(lubridate) | |
library(ggplot2) | |
library(scales) | |
library(treemap) | |
#__________________________________________________________________________________________ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to calculate 100% saturated dissolved oxygen in mg/L as a function of temperature in degrees Celcius | |
Calc_DOsat100 = function(temp){ | |
# temp = temperature in degrees C | |
# relationship between temperature and dissolved oxygen as defined by the APHA | |
# American Public Health Association (1992) | |
# Standard methods for the examination of water and wastewater. 18th ed. Washington DC. | |
# Required constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to calculate 100% saturated dissolved oxygen in water in mg/L as a function of temperature in degrees Celcius | |
Calc_DOsat100 = function(temp){ | |
# temp = temperature in degrees C | |
# relationship between temperature and dissolved oxygen as defined by the APHA | |
# American Public Health Association (1992) | |
# Standard methods for the examination of water and wastewater. 18th ed. Washington DC. | |
# Required constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert from 'HH:MM:SS' to fractions of a day | |
# This also works with HH.HHHH | |
# and is vectorised | |
Time_convert <- function(x){ | |
f <- function(x,y){ | |
as.numeric(x)/60 + as.numeric(y) | |
} | |
split_time <- str_split(x, ':') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Count_censored <- function(my.df) { | |
# number left censored | |
.Count_leftCensored <- function(x) { | |
sum(str_detect(x, '[<]'), na.rm = TRUE) | |
} | |
.Count_rightCensored <- function(x) { | |
sum(str_detect(x, '[>]'), na.rm = TRUE) | |
} |