Skip to content

Commit

Permalink
doc(*): index
Browse files Browse the repository at this point in the history
fixes #58
  • Loading branch information
dimfalk committed Mar 6, 2024
1 parent 3826d11 commit 16284e8
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 164 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: kostra2010R
Title: R Interface for KOSTRA-DWD-2010R Dataset
Version: 0.12.0
Version: 0.12.1
Date: 2024-03-06
Authors@R:
person("Dimitri", "Falk", , "[email protected]", role = c("aut", "cre"))
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# version 0.12.0
# version 0.12.1

## features

Expand Down
6 changes: 3 additions & 3 deletions R/calc_designstorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
#' @seealso [get_stats()]
#'
#' @examples
#' kostra <- get_stats("49011")
#' stats <- get_stats("42016")
#'
#' calc_designstorm(kostra, d = 60, tn = 20, type = "EulerII")
#' calc_designstorm(stats, d = 60, tn = 20, type = "EulerII")
calc_designstorm <- function(x = NULL,
d = NULL,
tn = NULL,
type = NULL) {

# debugging ------------------------------------------------------------------

# x <- kostra
# x <- get_stats("42016")
# d <- 60
# tn <- 20
# type <- "EulerII"
Expand Down
6 changes: 3 additions & 3 deletions R/calc_pen.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#' Verworn & Draschoff (2008): PEN-Erweiterung.
#'
#' @examples
#' kostra <- get_stats("49011")
#' stats <- get_stats("42016")
#'
#' calc_pen(kostra)
#' calc_pen(stats)
calc_pen <- function(x = NULL) {

# debugging ------------------------------------------------------------------

# x <- get_stats("49011")
# x <- get_stats("42016")

# check arguments ------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions R/get_centroid.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' get_centroid(c(6.09, 50.46), crs = "epsg:4326")
#' get_centroid(c(367773, 5703579), crs = "epsg:25832")
#'
#' get_centroid("52070")
#' get_centroid("40477")
#' get_centroid("Freiburg im Breisgau")
#' get_centroid("Kronprinzenstr. 24, 45128 Essen")
get_centroid <- function(x = NULL,
Expand All @@ -24,7 +24,7 @@ get_centroid <- function(x = NULL,
# x <- c(367773, 5703579)
# crs <- "epsg:4326"

# x <- "52070"
# x <- "40477"
# x <- "Freiburg im Breisgau"
# x <- "Kronprinzenstr. 24, 45128 Essen"

Expand Down
8 changes: 4 additions & 4 deletions R/get_depth.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
#' Starkniederschlagshöhen für Deutschland (Bezugszeitraum 1951 bis 2010).
#'
#' @examples
#' kostra <- get_stats("49011")
#' stats <- get_stats("42016")
#'
#' get_depth(kostra, d = 60, tn = 50)
#' get_depth(kostra, d = 60, tn = 50, uc = TRUE)
#' get_depth(stats, d = 60, tn = 50)
#' get_depth(stats, d = 60, tn = 50, uc = TRUE)
get_depth <- function(x = NULL,
d = NULL,
tn = NULL,
uc = FALSE) {

# debugging ------------------------------------------------------------------

# x <- get_stats("49011")
# x <- get_stats("42016")
# d <- 60
# tn <- 50
# uc <- TRUE
Expand Down
4 changes: 2 additions & 2 deletions R/get_idx.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#' @seealso [get_centroid()]
#'
#' @examples
#' p <- get_centroid(c(367773, 5703579), crs = "epsg:25832")
#' p <- get_centroid(c(406658, 5761320), crs = "epsg:25832")
#'
#' get_idx(p)
get_idx <- function(x = NULL) {

# debugging ------------------------------------------------------------------

# x <- c(367773, 5703579)
# x <- get_centroid(c(406658, 5761320), crs = "epsg:25832")

# check arguments ------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions R/get_returnp.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#' @seealso [get_stats()]
#'
#' @examples
#' kostra <- get_stats("49011")
#' stats <- get_stats("42016")
#'
#' get_returnp(kostra, hn = 69.3, d = 1440)
#' get_returnp(kostra, hn = 69.3, d = 1440, interpolate = TRUE)
#' get_returnp(stats, hn = 69.3, d = 1440)
#' get_returnp(stats, hn = 69.3, d = 1440, interpolate = TRUE)
get_returnp <- function(x = NULL,
hn = NULL,
d = NULL,
Expand Down
6 changes: 3 additions & 3 deletions R/get_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#' @seealso [idx_build()]
#'
#' @examples
#' get_stats("49011")
#' get_stats("49011", as_depth = FALSE)
#' get_stats("42016")
#' get_stats("42016", as_depth = FALSE)
get_stats <- function(x = NULL,
as_depth = TRUE) {

# debugging ------------------------------------------------------------------

# x <- "49011"
# x <- "42016"
# as_depth <- FALSE

# check arguments ------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions R/idx_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#' @seealso [idx_decompose()]
#'
#' @examples
#' idx_build(row = 49, col = 11)
#' idx_build(row = 42, col = 16)
idx_build <- function(row = NULL,
col = NULL) {

# debugging ------------------------------------------------------------------

# row <- 49
# col <- 11
# row <- 42
# col <- 16

# check arguments ------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions R/idx_decompose.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#' @seealso [idx_build()]
#'
#' @examples
#' idx_decompose(x = "49011")
#' idx_decompose(x = "42016")
idx_decompose <- function(x = NULL) {

# debugging ------------------------------------------------------------------

# x = "49011"
# x = "42016"

# check arguments ------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions R/idx_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#' @export
#'
#' @examples
#' idx_exists("49011")
#' idx_exists("42016")
idx_exists <- function(x = NULL) {

# debugging ------------------------------------------------------------------

# x <- "49011"
# x <- "42016"

# check arguments ------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions R/plot_idf.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
#' @seealso [get_stats()]
#'
#' @examples
#' get_stats("49011") |> plot_idf()
#' get_stats("42016") |> plot_idf()
#'
#' get_stats("49011") |> plot_idf(tn = 100)
#' get_stats("42016") |> plot_idf(tn = 100)
#'
#' get_stats("49011") |> plot_idf(log10 = TRUE)
#' get_stats("42016") |> plot_idf(log10 = TRUE)
plot_idf <- function(x = NULL,
tn = NULL,
log10 = FALSE) {

# debugging ------------------------------------------------------------------

# x <- get_stats("49011")
# x <- get_stats("49011", as_depth = FALSE)
# x <- get_stats("42016")
# x <- get_stats("42016", as_depth = FALSE)

# tn <- 100

Expand Down
8 changes: 4 additions & 4 deletions R/view_spatial.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
#' \dontrun{
#' view_spatial()
#'
#' view_spatial("49011")
#' view_spatial("49011", file = "kostra2010R_49011.png")
#' view_spatial("42016")
#' view_spatial("42016", file = "kostra2010R_42016.png")
#' }
view_spatial <- function(x = NULL,
file = NULL) {

# debugging ------------------------------------------------------------------

# x <- "49011"
# file <- "kostra2010R_49011.png"
# x <- "42016"
# file <- "kostra2010R_42016.png"

# check arguments ------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions R/write_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
#'
#' @examples
#' \dontrun{
#' kostra <- get_stats("49011")
#' stats <- get_stats("42016")
#'
#' write_stats(kostra)
#' write_stats(kostra, file = "kostra2010R_hN_49011.csv")
#' write_stats(stats)
#' write_stats(stats, file = "kostra2010R_hN_42016.csv")
#' }
write_stats <- function(x = NULL,
file = NULL) {

# debugging ------------------------------------------------------------------

# x <- get_stats("49011")
# file <- "kostra2010R_hN_49011.csv"
# x <- get_stats("42016")
# file <- "kostra2010R_hN_42016.csv"

# check arguments ------------------------------------------------------------

Expand Down
38 changes: 19 additions & 19 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ Sometimes identification of grid cells is not accomplished using "INDEX_RC" dire

```{r}
# Generate "INDEX_RC" based on row and column information.
idx_build(row = 49, col = 11)
idx_build(row = 42, col = 16)
```

If you wanted to check whether this constructed "INDEX_RC" field is really present in the dataset (or you found an ID in some report and are not sure, if it is still being used), make use of the following function.

```{r}
# Is the following "INDEX_RC" entry present in the dataset?
idx_exists("49011")
idx_exists("42016")
```

### Get "INDEX_RC" based on spatial information
Expand Down Expand Up @@ -109,18 +109,18 @@ Now that we have messed a little with the grid cell identifiers, let's get a sne
```{r}
# Build a tibble containing statistical precipitation depths as a function of
# duration and return periods for the grid cell specified.
kostra <- get_stats("49011")
stats <- get_stats("42016")
kostra
stats
```

Some describing attributes have been assigned to the tibble.

```{r}
attr(kostra, "id")
attr(kostra, "period")
attr(kostra, "returnperiods_a")
attr(kostra, "source")
attr(stats, "id")
attr(stats, "period")
attr(stats, "returnperiods_a")
attr(stats, "source")
```

### Get precipitation depths, calculate precipitation yield
Expand All @@ -130,14 +130,14 @@ If we now wanted to know the statistical precipitation depth e.g. for an event o
```{r}
# So we are interested in the rainfall amount [mm] for an event lasting 240 min
# with a return period of 100 a.
get_depth(kostra, d = 240, tn = 100)
get_depth(stats, d = 240, tn = 100)
```

In order to respect statistical uncertainties, as proposed in Malitz & Ertel (2015), ranging between 10 % and 20 % as a function of the chosen return period, make use of `uc = TRUE` to get an interval centered around the single value above.

```{r}
# Same data, but with uncertainties considered.
get_depth(kostra, d = 240, tn = 100, uc = TRUE)
get_depth(stats, d = 240, tn = 100, uc = TRUE)
```

If you need precipitation yield values [l/(s\*ha)] instead of precipitation depth [mm] or vice versa, make use of the following helper function.
Expand All @@ -153,8 +153,8 @@ as_depth(43.1, d = 240)
Finally, we want to determine the return period according to the dataset for a precipitation depth and duration given.

```{r}
# Let's assume we measured 72.3 mm in 24 h.
get_returnp(kostra, hn = 72.3, d = 1440)
# Let's assume we measured 75.2 mm in 24 h.
get_returnp(stats, hn = 75.2, d = 1440)
```

Accordingly, the approximate corresponding recurrence interval resp. annuality of this event amounts to something between 30 and 50 years as per KOSTRA-DWD-2010R.
Expand All @@ -163,17 +163,17 @@ The following edge cases are to be mentioned:

```{r}
# 1) In case a class boundary is hit, the return period is replicated.
get_returnp(kostra, hn = 42.8, d = 1440)
get_returnp(stats, hn = 38.2, d = 1440)
```

```{r}
# 2) In case the return period tn is smaller than 1, interval opens with 0.
get_returnp(kostra, hn = 30.2, d = 1440)
get_returnp(stats, hn = 26.4, d = 1440)
```

```{r}
# 3) In case the return period tn is larger than 100, interval closes with Inf.
get_returnp(kostra, hn = 86.3, d = 1440)
get_returnp(stats, hn = 92.8, d = 1440)
```

### Return period interpolation
Expand All @@ -182,7 +182,7 @@ Although it may be somewhat questionable from a scientific perspective, you migh

```{r}
# Using the same example as above, previously resulting in 30 a < tn < 50 a.
get_returnp(kostra, hn = 72.3, d = 1440, interpolate = TRUE)
get_returnp(stats, hn = 75.2, d = 1440, interpolate = TRUE)
```

### Return period extrapolation
Expand All @@ -191,7 +191,7 @@ Since KOSTRA-DWD-2010R has an upper limit of Tn = 100 a, we can make use of e.g.

```{r}
# Output in a separate tibble to not mix up applied methods.
pen <- calc_pen(kostra)
pen <- calc_pen(stats)
pen
```
Expand All @@ -208,7 +208,7 @@ Furthermore, statistical precipitation depths can be used to create design storm

```{r, warning = FALSE}
# Euler Type II design storm with a duration of 60 minutes and a return period of 100 a.
xts <- calc_designstorm(kostra, d = 60, tn = 100, type = "EulerII")
xts <- calc_designstorm(stats, d = 60, tn = 100, type = "EulerII")
xts
```
Expand All @@ -218,7 +218,7 @@ xts
Data can additionally be visualized as intensity-duration-frequency curves using `plot_idf()`, underpinned by `{ggplot2}` ...

```{r, fig.width = 9}
plot_idf(kostra, log10 = TRUE)
plot_idf(stats, log10 = TRUE)
```

... or exported to disk using `write_stats()` based on `write.table()`.
Expand Down
Loading

0 comments on commit 16284e8

Please sign in to comment.