-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
71 lines (54 loc) · 1.9 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
message = FALSE
)
```
# budyko
The goal of `budyko` is to facilitate fitting of hydrologic data to Budyko-type curves. The package includes the original Budyko (1974) formulation, as well as several single-parameter formulations like those of Fu (1981), Turc (1954), Pike (1964), and Wang & Tang (2014).
## Installation
You can install budyko from github using devtools:
```{r gh-installation, eval = FALSE}
devtools::install_github("tylerbhampton/budykoR")
```
## Sample Plots and Data
We can use the function `blankBC` to create a blank Budyko Curve plot, which includes the energy and water boundaries.
```{r}
library(ggplot2)
library(budyko)
blankBC
blankBC+coord_cartesian(xlim=c(0,3))
```
The package comes with a sample dataset. This is annual Water-Year (October through September) data for 30 years. blankBC has pre-set aesthetics for columns `PET.P` on the x axis and `AET.P` on the y axis. We can simply add `testdata` to the plot.
```{r}
testdata=budyko::testdata
head(testdata)
blankBC+geom_point(data=testdata)+coord_cartesian(xlim=c(0,5))
```
## Curves and Curve Fitting
The package contains several Budyko-type curves. We can use the default setting of `budyko_sim()` to generate the original Budyko curve.
```{r}
ogbudyko=budyko_sim()
blankBC+geom_line(data=ogbudyko)+coord_cartesian(xlim=c(0,5))
blankBC+
geom_line(data=ogbudyko)+
geom_point(data=testdata)+
coord_cartesian(xlim=c(0,5))
```
We can also use `budyko_fit()` to custom fit the data.
```{r}
fit1=budyko_fit(data=testdata,method="Fu",dif="mae",silent = TRUE)
fit1
sim1=budyko_sim(fit=fit1)
blankBC+
geom_line(data=ogbudyko,col=2)+
geom_line(data=sim1)+
geom_point(data=testdata)+
coord_cartesian(xlim=c(0,5))
```