c4h_downscale
Description
Downscale and calibrate climate data.
c4h_downscale(
downscale_function,
exp,
obs = NULL,
exp_cor = NULL,
bbox = NULL,
ncores = NULL,
target_grid = NULL,
method_bc = NULL,
method_remap = NULL,
points = NULL,
method_point_interp = NULL,
method_lr = NULL,
loocv = TRUE,
...
)Arguments
downscale_function: The downscaling function to use. Options are: “Interpolation”, “Intbc”, “Intlr”, “Analogs”.exp: The experimental data to downscale. It must be an s2dv_cube.obs: The observational data to downscale. It must be an s2dv_cubeexp_cor: Optional data to downscale. It must be an s2dv_cube If provided, it will be downscaled using exp and obs; if not provided, the exp will be downscaled instead. The default value is NULL.bbox: A numeric vector indicating the borders of the region defined in obs. It consists of four elements in this order: North, West, South, East. If set to NULL (default), the function c4h_downscale will take the minimum and maximum values of the latitudes and longitudes.ncores: An integer indicating the number of cores to use in parallel computation. The default value is NULL.target_grid: A character vector indicating the target grid (in the case of Interpolation techniques) or the coarse grid (in the case of Analogs) to be passed to CDO. It must be a grid recognised by CDO or a NetCDF file. The default value is NULL. If NULL, the grid of obs will be used as the target grid for Interpolation techniques, and the grid of exp will be used as the coarse grid for Analogs.method_bc: A character vector indicating the bias adjustment method to be applied after an interpolation. Accepted methods are ‘quantile_mapping’, ‘dynamical_bias’, ‘bias’, ‘evmos’, ‘mse_min’, ‘crps_min’, ‘rpc-based’. The abbreviations ‘dbc’,‘qm’ can also be used. The default value is NULL.method_remap: A character vector indicating the regridding method to be passed to CDORemap. Accepted methods are “con”, “bil” (or “bilinear”), “bic”, “nn”, “con2”. If “nn” method is to be used, CDO_1.9.8 or newer version is required. The default value is NULL.points: A list of two elements containing the point latitudes and longitudes of the locations to downscale the model data. The list must contain the two elements named as ‘latitude’ and ‘longitude’. If the downscaling is to a point location, only regular grids are allowed for exp and obs. Only needed if the downscaling is to a point location.method_point_interp: A character vector indicating the interpolation method to interpolate model gridded data into the point locations. Accepted methods are “nearest”, “bilinear”, “9point”, “invdist4nn”. Only needed if the downscaling is to a point location.method_lr: A character vector indicating the linear regression method to be applied. Accepted methods are ‘basic’ and ‘9nn’. The ‘basic’ method fits a linear regression using high resolution observations as predictands and the interpolated model data as predictor. Then, the regression equation is applied to the interpolated model data to correct the interpolated values. The ‘9nn’ method uses a linear regression with the nine nearest neighbours as predictors and high-resolution observations as predictands. Instead of constructing a regression model using all nine predictors, principal component analysis is applied to the data of neighboring grids to reduce the dimension of the predictors. The linear regression model is then built using the principal components that explain 95% of the variance. The ‘9nn’ method does not require a pre-interpolation process. The default value is NULL.loocv: A logical indicating whether to apply leave-one-out cross-validation when applying the bias correction. The default is TRUE. In this case, when applying the bias correction or building the regression model for a given year, the corresponding values from that year are removed....: Additional arguments to be passed to the CSDownscale function.
Returns
A list of statistically downscaled data as s2dv_cube objects.
Note
See clim4health_downscaling.Rmd in the package vignettes for a detailed tutorial on function arguments and usage.
Examples
# DISCLAIMER: The purpose of these examples is to show the functionality
# of the different functions. To perform downscaling and calibration, a
# much larger time series is required.
hcst <- c4h_load(system.file("extdata", "hindcast", package = "clim4health"),
variable = "t2m",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
ext = "nc")
lats <- hcst$coords$latitude
lons <- hcst$coords$longitude
obs <- c4h_load(system.file("extdata", "reanalysis",
package = "clim4health"),
variable = "t2m",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
bbox = c(max(lats), min(lons),
min(lats), max(lons)),
ext = "nc")
### Example with gridded data
dwn <- c4h_downscale("Interpolation", exp = hcst,
method_remap = "bilinear",
target_grid = system.file("extdata",
"reanalysis/t2m_201001.nc",
package = "clim4health"))
## Example with polygon data
shp_path <- system.file("extdata", "areas", "munip_vallecauca.gpkg",
package = "clim4health")
obs_agg <- c4h_space(obs,
areas = shp_path,
fun = "mean",
areas_id = "munip_code")
hcst_agg <- c4h_space(hcst,
areas = shp_path,
fun = "mean",
areas_id = "munip_code")
hcst_agg_cal <- c4h_downscale(downscale_function = "Intbc",
exp = hcst_agg,
obs = obs_agg,
method_bc = "evmos")
## Example with station data
point_locs <- clim4health::c4h_load(system.file("extdata",
"stations",
package = "clim4health"),
ext = "csv",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
variable = "temp_mean")
points <- list(latitude = point_locs$attrs$location$latitude,
longitude = point_locs$attrs$location$longitude)
point_locs <- c4h_time(point_locs,
time_aggregation = "monthly",
dim_aggregation = "sdate",
fun = "mean")
dwn <- c4h_downscale("Interpolation", exp = hcst,
points = points, method_point_interp = "bilinear")