Skip to contents

Downscale TraCE21ka data

Usage

downscaleTrace(
  files_n,
  indir,
  outdir,
  mod_data,
  model,
  model_bin = NULL,
  vars = NULL,
  lon_lim = c(-25, 25),
  lat_lim = c(25, 50),
  selection_vars = NULL,
  globalAttributes = NULL
)

Arguments

files_n

Integer indicating the number of the desired file. Default to 36, which is the file with the data incorporating the most recent (historical) period.

indir

Character string with the relative path to the TraCE21ka data folder

outdir

Character string indicating the output directory where to save the downscaled data.

mod_data

List object in climate4R format used to calibrate the model that is going to be used to downscale the TraCE21ka data.

model

Model object from the climate4R framework to be used to download the TraCE21ka data. See downscaleR::downscaleTrain

model_bin

Optional model object from the climate4R framework to be used for binary projection prior to the quantitative projection. See downscaleR::downscaleTrain.

vars

String vector with the name of the vars to include in the output. Default is null, which return tas, tasmin, tasmax, pr, ps, hurs, cld, u, and v.

lon_lim

Numeric vector of length 2 with the longitudinal limits of the area of interest to be loaded.

lat_lim

Numeric vector of length 2 with the latitudinal limits of the area of interest to be loaded.

selection_vars

Character vector indicating the name of the variables that are going to be kept in the output. This is useful when computing wind speed (wss) but the two wind components are not of interest and want to be excluded from the output.

globalAttributes

Optional. A list of global attributes included in the NetCDF file. Same format as varAttributes.

Value

Character string "Done" when completed sucessfully. However, the real output of the function are the downscaled data saved in the output directory.

Examples

if (FALSE) { # \dontrun{
vars <- c(
  "tas", "tasmin", "tasmax", "hurs@992.5561", "ps",
  "pr", "cld", "wss"
)

spatial.pars <- list(
  which.combine = vars,
  v.exp = .95,
  rot = FALSE
)

uerra <- loadUerra(
  "../../Data/UERRA/UERRA-HARMONIE/2m_temperature/latlon/1961-90_2m_temperature.nc",
  "tas"
)

trace.file.names <- traceFileNames("../../Data/TraCE21ka/")
hist.trace <- loadTrace(trace.file.names, vars, years = 1961:1990)

data <- downscaleR::prepareData(hist.trace,
  uerra,
  spatial.predictors = spatial.pars
)

model <- downscaleR::downscaleTrain(data,
  method = "GLM",
  family = gaussian(link = "identity")
)

downscaleTrace(4,
  "../Data/TraCE21ka/",
  "output/TraCE21ka/",
  mod_data = data,
  model = model
)
} # }