HydroTools is a simple R package for basic hydrological analysis. It provides functions for runoff estimation and flow duration analysis using commonly used hydrological methods.
This package was developed as an independent learning project to practice R package development, hydrological computation, documentation, and unit testing in R.
HydroTools currently includes three main functions:
| Function | Description |
|---|---|
rational_method() |
Estimates peak runoff discharge using the Rational Method |
scs_curve_number() |
Calculates direct runoff depth using the SCS Curve Number method |
flow_duration() |
Computes flow duration statistics from streamflow data |
You can install the package from GitHub using:
install.packages("devtools")
devtools::install_github("sthamandip11/hydrotools")After installation, load the package:
library(hydrotools)The Rational Method estimates peak runoff discharge from rainfall intensity, drainage area, and runoff coefficient.
Q <- rational_method(
C = 0.9,
I = 50,
A = 2,
units = "metric"
)
QWhere:
C= runoff coefficientI= rainfall intensityA= drainage areaunits="metric"or"imperial"
For metric units, the result is returned in cubic meters per second.
The SCS Curve Number method estimates direct runoff depth from rainfall depth and curve number.
Q <- scs_curve_number(
P = 100,
CN = 70,
Ia_ratio = 0.2,
units = "metric"
)
QWhere:
P= rainfall depthCN= curve numberIa_ratio= initial abstraction ratiounits="metric"or"imperial"
For metric units, the runoff depth is returned in millimeters.
The flow_duration() function calculates selected flow duration values and basic streamflow statistics.
flows <- c(10, 20, 30, 40, 50)
result <- flow_duration(
flow = flows,
percentiles = c(10, 50, 90)
)
resultThe output includes:
- percentile flow values such as
Q10,Q50, andQ90 - mean flow
- median flow
- number of valid observations
- number of zero-flow days
Unit tests are written using the testthat package.
To run the tests:
devtools::test()To run a full package check:
devtools::check()hydrotools/
├── R/
│ ├── flow_duration.R
│ ├── rational_method.R
│ └── scs_curve_number.R
├── man/
│ ├── flow_duration.Rd
│ ├── rational_method.Rd
│ └── scs_curve_number.Rd
├── tests/
│ ├── testthat/
│ │ ├── test-flow_duration.R
│ │ ├── test-rational_method.R
│ │ └── test-scs_curve_number.R
│ └── testthat.R
├── DESCRIPTION
├── LICENSE
├── NAMESPACE
└── README.md
This package is intended for basic hydrological calculations and learning purposes. It does not perform advanced rainfall-runoff modeling, flood forecasting, watershed simulation, model calibration, or uncertainty analysis.
The methods included are simplified hydrological methods and should be applied carefully with proper understanding of watershed conditions, input data quality, watershed characteristics, and method assumptions.
A short demonstration video is available here:
This project is licensed under the MIT License.
Mandip Shrestha