dedrift: Function to remove drift from model runs

Description Usage Arguments Examples

View source: R/dedrift.R

Description

Simple drift correction of model runs given a corresponding control run

Usage

1
dedrift(data, ctl)

Arguments

data

(list of) input time series of type NetCDF

ctl

(list of) control run time series of type NetCDF

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## synthetic historical and control time series
xx <- t(rnorm(400) + c(-4,0,3,1) + seq(0,sqrt(10), length=400)**2)
attr(xx, 'time') <- seq(1900, by=0.25, length=400)
class(xx) <- 'NetCDF'

## synthetic control runs
xctl <- t(as.vector(outer(c(-5,-3,-2,-1), log(seq(1, 100, length=300)), '*')) + rnorm(1200))
attr(xctl, 'time') <- seq(1750, by=0.25, length=length(xctl))
class(xctl) <- 'NetCDF'

## without dedrifting
plot(xx, type='ts', seas=T, main='Synthetic time series (forced simulation)')

## control run
plot(xctl, type='ts', seas=T, main='Synthetic control')

## dedrifted forced run
plot(dedrift(xx, xctl), type='ts', seas=T, main='Dedrifted forced simulation')
plot(xx, type='ts', seas=T, lwd=1, lty=2, add=T)

jonasbhend/geoutils documentation built on May 19, 2019, 7:27 p.m.