Learn R Programming

SpatialDownscaling (version 0.1.2)

bcsd: Bias Correction Spatial Disaggregation (BCSD) for statistical downscaling

Description

Implements the BCSD method for statistical downscaling of climate data. The approach consists of two main steps: (1) bias correction using quantile mapping and (2) spatial disaggregation using interpolation.

Usage

bcsd(
  coarse_data,
  fine_data,
  method = "bilinear",
  n_quantiles = 100,
  reference_period = NULL,
  extrapolate = TRUE,
  normalize = TRUE
)

Value

Object of class BCSD containing the trained model components:

quantile_map

Quantile mapping function for bias correction.

interpolation_params

Parameters for spatial interpolation.

axis_names

Names of the axes in the fine data.

scalers

List of scalers. If normalize = TRUE, the list contains scalers coarse and fine for the coarse and fine data, respectively. If normalize = FALSE, the list is empty.

model_params

List of all model parameters.

Arguments

coarse_data

A 3D array of coarse resolution input data. The two first dimensions are the spatial coordinates (e.g., latitude and longitude) in grid, and the third dimension refers to the training samples (e.g. time).

fine_data

A 3D array of fine resolution output data. The two first dimensions are the spatial coordinates (e.g., latitude and longitude) in grid, and the third dimension refers to the training samples (e.g. time).

method

Character. Interpolation method that is used by resample to perform predictions. The options are ('bilinear', 'ngb') that refer to bilinear and nearest neighbor interpolation, respectively. Default: 'bilinear'.

n_quantiles

Integer. Number of quantiles for bias correction. Default: 100.

reference_period

Vector. Start and end indices for the reference period. Default: NULL (use all data).

extrapolate

Logical. Indicating whether to extrapolate corrections outside the range of the training data. Default: TRUE.

normalize

Logical. Indicating whether to normalize data before processing. Default: TRUE.

Details

The BCSD method is a statistical downscaling technique that combines bias correction and spatial disaggregation. It uses quantile mapping to correct biases in coarse resolution data and then applies spatial interpolation to disaggregate the data to a finer resolution.

The function allows for the interpolation methods "bilinear" and "ngb", that perform bilinear and nearest neighbor interpolation, respectively. For more information on these methods, please refer to the documentation for resample. The function provides the option to normalize data before processing, by using the normalize argument. The quantile mapping step involves calculating quantiles from the coarse data and mapping them to the fine data. The interpolation step uses the specified method to create a fine resolution grid from the coarse data.

Examples

Run this code
# Simple example with random data
coarse <- array(rnorm(8 * 8 * 10), dim = c(8, 8, 10))  # e.g. lat x lon x time 
fine <- array(rnorm(16 * 16 * 10), dim = c(16, 16, 10))    # e.g. lat x lon x time
model <- bcsd(coarse, fine, method = "bilinear", n_quantiles = 100)
coarse_new <- array(rnorm(8 * 8 * 3), dim = c(8, 8, 3))  # e.g. lat x lon x time 
predictions <- predict(model, coarse_new)

Run the code above in your browser using DataLab