gamcorrect: Fit General Additive Model to correct UKCP18 data

Description Usage Arguments Details Value Examples

View source: R/workerfunctions.R

Description

Fit General Additive Model to correct UKCP18 data

Usage

1
gamcorrect(observed, ukcp, Trace = TRUE, positive = TRUE)

Arguments

observed

object of class spatialarray of observed climate data

ukcp

object of class spatialarray of UKCP18 climate data for the corresponding period and location

Trace

optional logical indicating whether to plot model fit

positive

optional logical indicating whether all values are positive (as with e.g. radiation)

Details

This function ranks the values of observed and ukcp and fits a General Additive Model (GAM) to these data. The area and time period covered by observed and ukcp, and the spatial resolution of the data should be identical. If the datasets contain more than 10,000 values then 10000 values spanning the full range of data are selected. If positive is TRUE, then only values greater than 0 are selected when fitting the GAM.

Value

an object of class gam.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Takes a few seconds to run
modfit <- radfit(sis_2005)
# Takes a few minutes to run
ukcpsishourly <- hourlysis(sis_ukcpdaily, modfit, 2000)
# Select data for 2005
tme <- ukcpsishourly$times
sel <- which(tme$year + 1900 == 2005)
xx <-  ukcpsishourly$arraydata[,,sel]
ukcp_2005 <- list(arraydata = xx, times = tme[sel], crs = ukcpsishourly$crs,
                 extent = ukcpsishourly$extent, units = ukcpsishourly$array.units,
                 description = ukcpsishourly$array.description)
class(ukcp_2005) <- "spatialarray"
od_obs <- opticaldepth(sis_2005)
od_pre <- opticaldepth(ukcp_2005)
gam.mod <- gamcorrect(od_obs, od_pre)

ilyamaclean/UKCP18adjust documentation built on Nov. 4, 2019, 2:08 p.m.