downscalePredict: Downscale climate data for a given statistical model.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/downscalePredict.R

Description

Downscale data to local scales by statistical models previously obtained by downscaleTrain.

Usage

1
downscalePredict(newdata, model)

Arguments

newdata

The grid data. It should be an object as returned by prepareNewData.

model

An object containing the statistical model as returned from downscaleTrain.

Value

A regular/irregular grid object.

Author(s)

J. Bano-Medina

See Also

downscaleTrain for training a downscaling model prepareNewData for predictor preparation with new (test) data downscale.cv for automatic cross-validation downscaleR Wiki for downscaling seasonal forecasting and climate projections.

Other downscaling.functions: downscaleCV(), downscaleChunk(), downscaleTrain(), downscale()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Loading data
require(transformeR)
require(climate4R.datasets)
data("VALUE_Iberia_tas")
y <- VALUE_Iberia_tas
data("NCEP_Iberia_hus850", "NCEP_Iberia_psl", "NCEP_Iberia_ta850")
x <- makeMultiGrid(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)

# Example1: Basic example (without cross-validation)
data <- prepareData(x = x, y = y, spatial.predictors = list(v.exp = 0.95))
model.analogs <- downscaleTrain(data, method = "analogs", n.analogs = 1)
newdata <- prepareNewData(x,data)
pred <- downscalePredict(newdata, model.analogs)
# This produces the same result as model.analogs$pred

# Example2:  Splitting data in train and test (simple cross-validation)
xT <- subsetGrid(x, years = 1983:1999)  # training predictors
yT <- subsetGrid(y, years = 1983:1999)   # training predictands
data <- prepareData(xT,yT)       # preparing the data
model.analogs <- downscaleTrain(data, method = "analogs", n.analogs = 1)
xt <- subsetGrid(x, years = 2000)       # test predictors
yt <- subsetGrid(y, years = 2000)       # test predictors
newdata <- prepareNewData(xt,data)     # preparing the new predictors
pred  <- downscalePredict(newdata, model.analogs)  # predicting
# Plotting the results for station 5
plot(yt$Data[,5],pred$Data[,5])

SantanderMetGroup/downscaleR documentation built on Aug. 30, 2020, 5:39 p.m.