Skip to contents

Bias correction for climate model output with observations using the package qmap by Lukas Gudmundsson.

Usage

doQuantileMapping(hist_obs, hist_sim, fut_sim)

Arguments

hist_obs

Tibble with historical observations for 1 or more stations. The tibble must contain the columns Date (class: Date), Basin (class: chr) and Ta OR Pr (class: num) whereby Ta contains temperatures in deg C and Pr precipitation in mm.

hist_sim

Tibble with simulations of historical time series for the region of interest. The tibble must contain the columns Date (class: Date), Model (class: chr) and Ta OR Pr (class: num) whereby Ta contains temperatures in deg C and Pr precipitation in mm. Model specifies the climate model.

fut_sim

Tibble with simulations of future climate in the region of interest. The tibble must contain the columns Date (class: Date), Model (class: chr) for the climate model, Scenario (class: chr) for the CC scenario and Ta OR Pr (class: num) whereby Ta contains temperatures in deg C and Pr precipitation in mm.

Value

NULL for failure.

Details

It is assumed that the observations used for bias correction fit into one single tile of the climate model output.
Temperatures are transformed to deg K.

Examples

hist_obs <- tibble::tribble(~Date, ~Basin, ~Pr,
                            "1979-01-01", "K_eb1", 0.1,
                            "1979-01-01", "K_eb2", 0.2,
                            "1979-01-01", "K_eb3", 0.3,
                            "1979-01-02", "K_eb1", 0.4,
                            "1979-01-02", "K_eb2", 0.5,
                            "1979-01-02", "K_eb3", 0.6) |>
  dplyr::mutate(Date = as.Date(Date))
hist_sim <- hist_obs |>
  dplyr::filter(Basin == "K_eb1") |>
  dplyr::select(-Basin) |>
  dplyr::mutate(Pr = Pr + 1, Model = "A")
hist_sim <- hist_sim |>
  dplyr::add_row(hist_sim |>
                   dplyr::mutate(Pr = Pr + 2, Model = "B"))
fut_sim <- hist_sim |>
  dplyr::mutate(Scenario = "a") |>
  dplyr::add_row(hist_sim |>
                   dplyr::mutate(Pr = Pr + 1, Scenario = "b"))
fut_sim <- fut_sim |>
  dplyr::add_row(fut_sim |>
                   dplyr::mutate(Date = as.Date(Date) + 2))

results <- doQuantileMapping(hist_obs, hist_sim, fut_sim)
#> QM hist_sim - Processing model:  A 
#> QM hist_sim - Processing model:  B 
#> QM fut_sim - Processing Model: A and Scenario a 
#> QM fut_sim - Processing Model: A and Scenario b 
#> QM fut_sim - Processing Model: B and Scenario a 
#> QM fut_sim - Processing Model: B and Scenario b 
#> DONE!
mapped_hist_sim <- results[[1]]
mapped_fut_sim <- results[[2]]