Package 'kwb.impetus'

Title: R Package with Functions Used in Project IMPETUS
Description: R Package with Functions used in Project IMPETUS.
Authors: Michael Rustler [aut, cre] , IMPETUS [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Michael Rustler <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-10-30 03:32:14 UTC
Source: https://github.com/KWB-R/kwb.impetus

Help Index


Label for Decade Year Range

Description

Label for Decade Year Range

Usage

decade_label(decade)

Arguments

decade

start of decade as integer, e.g. 1990L

Value

character string, e.g. "1990 - 1999"


ggplot2 ribbon between q05 and q95

Description

ggplot2 ribbon between q05 and q95

Usage

decade_ribbons(alpha = 0.1)

Arguments

alpha

passed to geom_ribbon


Tibble with Decade Names and Values

Description

Tibble with Decade Names and Values

Usage

decades_tibble(
  decade_labels,
  colors = c("darkblue", "blue", "darkgreen", "lightgreen", "orange", "red")
)

Arguments

decade_labels

decade labels

colors

colour values

Value

tibble with columns names and values


Download GFZ Model Layers

Description

Download GFZ Model Layers

Usage

download_gfz_model(target_dir = tempdir())

Arguments

target_dir

target directory to extract files (default: tempdir())

Value

extracts GFZ model layers in target directory


DWD Dataset (Precipitation and Potential Evaporation) Averaged for Berlin

Description

A dataset containing the precipitation and potential diamonds.

Usage

dwd_berlin_monthly

Format

A data frame with 3852 rows and 12 variables:

parameter_name

self-defined name for parameter

parameter

original DWD parameter name (required for requests)

file

name of raw data file

year

year

month

month

mean

spatial mean value for month

sd

spatial standard deviation value for month

min

spatial minimum value for month

max

spatial maximum value for month

n_values

number of 1x1km2 grids used for spatial statistics calculation

parameter

parameter name

url

full url to raw data file

Examples

## Not run: 
############################################################################
#### R code used for creation of "dwd_berlin_monthly.rds"
############################################################################

remotes::install_github("kwb-r/kwb.dwd")

library(kwb.impetus)

shape_obj <- kwb.dwd:::get_shape_of_german_region(name = "berlin")
shape_file <- "berlin.shp"

shape_obj %>% 
 sf::st_as_sf() %>% 
 sf::write_sf(shape_file)

### Plot to check if Berlin boundaries are plotted correctly.
### Set target CRS
crs_target <- 4326
shape_pt <- sf::st_read(shape_file) %>%
 sf::st_transform(crs = crs_target)
basemap <- shape_pt %>%
 leaflet::leaflet() %>%
 leaflet::addTiles() %>%
 leaflet::addProviderTiles(leaflet::providers$CartoDB.Positron) %>%
 leaflet::addPolygons(color = "red", fill = FALSE)
basemap
yearmonth_start <- "188101"
yearmonth_end <- "202208"
kwb.dwd:::list_monthly_grids_germany_asc_gz("x")
dwd_monthly_vars <- c(#"air temperature (mean)" = "air_temperature_mean"#,
 "drought index" = "drought_index",
 "evaporation, potential" = "evapo_p",
 "evaporation, real" = "evapo_r",
 "precipitation" = "precipitation",
 "soil moisture" = "soil_moist",
 "soil temperature (5 cm)" = "soil_temperature_5cm"
)

system.time(
 dwd_berlin_monthly_list <- stats::setNames(lapply(dwd_monthly_vars, function(dwd_var) {
   kwb.dwd::read_monthly_data_over_shape(
     file = shape_file,
     variable = dwd_var,
     from = yearmonth_start,
     to = yearmonth_end,
     quiet = TRUE
   )
 }), nm = dwd_monthly_vars))


dwd_berlin_monthly <- dplyr::bind_rows(dwd_berlin_monthly_list, .id = "parameter")

dwd_berlin_monthly <- tibble::tibble(parameter_name = names(dwd_monthly_vars), 
                                    parameter = as.character(dwd_monthly_vars)) %>%  
 dplyr::left_join(dwd_berlin_monthly)


usethis::use_data(dwd_berlin_monthly, overwrite = TRUE)


## End(Not run) 



# Dataset

dwd_berlin_monthly


# Covered time period for each parameter

dwd_berlin_monthly %>%  
dplyr::group_by(.data$parameter_name,
.data$parameter) %>%
dplyr::summarise(date_min = min(.data$date),
date_max = max(.data$date))

floor to decade

Description

floors to previous decade.

Usage

floor_decade(value)

Arguments

value

year

Value

decade

Examples

floor_decade(2000:2020)

Continuous x scale for months

Description

Continuous x scale for months

Usage

ggplot2_scale_x_continuous_12()

Group by Dekade_Label

Description

Group by Dekade_Label

Usage

group_by_decade_label(data)

Arguments

data

data frame


Group by Decade, Decade_Label, Month, Label

Description

Group by Decade, Decade_Label, Month, Label

Usage

group_by_decade_month_label(data)

Arguments

data

data frame


Group by Messstellennummer, Decade, Decade_Label, Month, Label

Description

Group by Messstellennummer, Decade, Decade_Label, Month, Label

Usage

group_by_site_decade_month_label(data)

Arguments

data

data frame


Group by Messstellennummer, Year, Month, Label

Description

Group by Messstellennummer, Year, Month, Label

Usage

group_by_site_year_month_label(data)

Arguments

data

data frame


Group by Year, Month

Description

Group by Year, Month

Usage

group_by_year_month(data)

Arguments

data

data frame


Unnamed Quantile Value

Description

Unnamed Quantile Value

Usage

numeric_quantile(x, prob)

Arguments

x

vector of numeric

prob

probability passed to quantile


Plot GFZ Model Raster Layer

Description

Plot GFZ Model Raster Layer

Usage

plot_gfz_layer(layer)

Arguments

layer

a layer as retrieved by read_gfz_layers

Value

plot raster layer


Surface Water Flows (from Niedrigwasserbericht 2018-2020 by SenUVK Berlin)

Description

Extracted parts of table on page 16 from Niedrigwasserbericht 2018-2020 by SenUVK Berlin. Contains only flows from inflows to Berlin (i.e. no data from Sophienwerder and Muehlendammschleuse ware imported)

Usage

q_surface_water

Format

A data frame with 6 rows and 10 variables:

fliessgewaesser

name of surface water

pegel

name of monitoring station

mq.1991_2017

MQ for period 1991-2017 (m3/s))

mnq.1991_2017

MQ for period 1991-2017 (m3/s)

nq.1991_2017

MQ for period 1991-2017 (m3/s))

nnq.value

NNQ value (m3/s)

nnq.date

Date of nnq.value (NA if "often" !)

mq.2018

MQ of year 2018 (m3/s)

mq.2019

MQ of year 2019 (m3/s)

mq.2020

MQ of year 2020 (m3/s)

References

https://www.berlin.de/sen/uvk/_assets/umwelt/wasser-und-geologie/niedrigwasser/niedrigwasser_berlin_2018-2020.pdf#page=16

Examples

kwb.impetus::q_surface_water

Reads a single GFZ Model Layer

Description

Reads a single GFZ Model Layer

Usage

read_gfz_layer(path, as_raster)

Arguments

path

path to GFZ Model Layer

as_raster

convert to raster (default: TRUE)

Value

imported layer file


Reads multiple GFZ Model Layers

Description

Reads multiple GFZ Model Layers

Usage

read_gfz_layers(
  dir_model_data,
  type = "elevation",
  as_raster = TRUE,
  dbg = TRUE
)

Arguments

dir_model_data

path to GFZ Model Layer Data as retrieved by download_gfz_model

as_raster

convert to raster (default: TRUE)

dbg

print debug messaages (default: TRUE)

Value

imported layer files


round to decade

Description

rounds to next decade if end year is >=5 or floors to previous decade if end year <5.

Usage

round_to_decade(values)

Arguments

values

year

Value

decade

Examples

round_to_decade(2000:2020)

ggplot2: scale color decades

Description

ggplot2: scale color decades

Usage

scale_color_decades(decades, ...)

Arguments

decades

decades

...

additional arguments passed to xxx

Value

re-scales ggplot2


ggplot2: scale fill decades

Description

ggplot2: scale fill decades

Usage

scale_fill_decades(decades, ...)

Arguments

decades

decades

...

additional arguments passed to xxx

Value

re-scales ggplot2