Skip to content

Commit

Permalink
nothing much
Browse files Browse the repository at this point in the history
  • Loading branch information
stineb committed Nov 16, 2023
1 parent 9d1b73e commit f702a08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions R/cwd.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,15 @@ cwd <- function(df, varname_wbal, varname_date, thresh_terminate = 0.0, thresh_d
}

# record instance
this_inst <- tibble( idx_start = idx, len = iidx_drop-idx, iinst = iinst, date_start=df[[varname_date]][idx], date_end = df[[varname_date]][iidx_drop-1], deficit = max_deficit )
inst <- inst |> bind_rows(this_inst)
this_inst <- tibble( idx_start = idx,
len = iidx_drop-idx,
iinst = iinst,
date_start = df[[varname_date]][idx],
date_end = df[[varname_date]][iidx_drop-1],
deficit = max_deficit
)
inst <- inst |>
bind_rows(this_inst)

# update
iinst <- iinst + 1
Expand Down
4 changes: 2 additions & 2 deletions vignettes/cwd_example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ df_return |>
labs(x = "Return period (yr)", y = "Magnitude of annual CWD maximum (mm)")
```

Visualise the estimated event size with a return period of $T = 80$ y on top of the distribution of cumulative water deficit events.
Visualise the estimated event size with a return period of $T = 80$ y as the red line on top of the distribution of cumulative water deficit events.
```{r}
ggplot() +
geom_histogram(
data = out_cwd$inst,
aes(x = deficit, y = ..density..),
aes(x = deficit, y = after_stat(density)),
color = "black",
position="identity",
bins = 6
Expand Down

0 comments on commit f702a08

Please sign in to comment.