Type: | Package |
Title: | Stochastic Rainfall Generator Bartlett-Lewis Rectangular Pulse Model |
Version: | 1.0 |
Date: | 2017-10-04 |
Author: | Christoph Ritschel |
Maintainer: | Christoph Ritschel <christoph.ritschel@met.fu-berlin.de> |
Depends: | R6 |
Description: | Due to a limited availability of observed high-resolution precipitation records with adequate length, simulations with stochastic precipitation models are used to generate series for subsequent studies [e.g. Khaliq and Cunmae, 1996, <doi:10.1016/0022-1694(95)02894-3>, Vandenberghe et al., 2011, <doi:10.1029/2009WR008388>]. This package contains an R implementation of the original Bartlett-Lewis rectangular pulse model (BLRPM), developed by Rodriguez-Iturbe et al. (1987) <doi:10.1098/rspa.1987.0039>. It contains a function for simulating a precipitation time series based on storms and cells generated by the model with given or estimated model parameters. Additionally BLRPM parameters can be estimated from a given or simulated precipitation time series. The model simulations can be plotted in a three-layer plot including an overview of generated storms and cells by the model (which can also be plotted individually), a continuous step-function and a discrete precipitation time series at a chosen aggregation level. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
RoxygenNote: | 5.0.1 |
NeedsCompilation: | no |
Packaged: | 2017-10-06 09:37:15 UTC; kruud |
Repository: | CRAN |
Date/Publication: | 2017-10-06 11:42:37 UTC |
Accumulation of a precipitation stepfunction
Description
BL.acc
accumulates the BLRPM stepfunction for a given accumulation time t.acc
at a given accumulation level acc.val
. An offse
can be defined. The unit is typically hours.
Usage
BL.acc(sfn, t.acc = 240, acc.val = 1, offset = 0)
Arguments
sfn |
stepfunction of precipitation |
t.acc |
|
acc.val |
|
offset |
|
Value
p.acc data.frame
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
t.sim <- 240
t.acc <- t.sim
acc.val <- 1
offset <- 0
simulation <- BL.sim(lambda,gamma,beta,eta,mux,t.sim)
sfn <- BL.stepfun(simulation$cells)
ts <- BL.acc(sfn,t.acc,acc.val,offset)
Simulating storms and cells
Description
Bartlett-Lewis Rectangular Pulse Model
Usage
BL.sim(lambda = 4/240, gamma = 1/10, beta = 0.3, eta = 2, mux = 4,
t.sim = 240)
Arguments
lambda |
value specifying the generation rate of storms [1/h] |
gamma |
value specifying the storm duration [1/h] |
beta |
value specifying the generation rate of cells [1/h] |
eta |
value specifying the cell duration [1/h] |
mux |
value specifying the cell intensity [mm/h] |
t.sim |
value specifying the simulation time [h] |
Details
Model description (Rodriguez-Iturbe et al., 1987):
The model is a combination of 2 poisson processes and simulates storms and cells. During the given simulation time storms are generated in a poisson process with rate lambda. Those storms are given a exponetially distributed duration with parameter gamma. During its duration the storm generates in a second poisson process cells with rate beta. The first cell has to be instantaneous at the time of the storm arrival. The cell duration is exponentially distributed with parameter eta. For the whole lifetime each cell is given a constant intensity which is exponentially distributed with parameter 1/mux.
Aggregation:
The intensities of all cells alive at time t are summed up for total precipitation at time t.
Parameter estimation:
The model parameters (lambda,gamma,beta,eta,mux) can be estimated from simulated or
observed precipitation time series using the method of moments. Certain moments, e.g. mean, variance
can be calculated from the time series at different aggregation levels. These moments
can also be calculated theoretically from model parameters. Both sets of statistics can be
compared in an objective function, similar to a squared error estimator. By numerical optimization
the model parameters can be tuned to match the time series characteristics.
BL.sim
generates model realisations of storms and cells by using given model
parameters lambda,gamma,beta,eta,mux
for a given simulation time t.sim
Value
BL.sim
returns storms; data.frame
of all storms containing information about occurence time, end time and number of cells
BL.sim
returns cells; data.frame
of all cells containing information about occurence time, end time, intensity and storm index
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
t.sim <- 240
simulation <- BL.sim(lambda,gamma,beta,eta,mux,t.sim)
BLRPM continous stepfunction of precipitation
Description
BL.stepfun
calculates a continous stepfunction of precipitation from
the data.frame
cells
Usage
BL.stepfun(cells)
Arguments
cells |
|
Value
sfn returns stepfunction of precipitation
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
t.sim <- 240
simulation <- BL.sim(lambda,gamma,beta,eta,mux,t.sim)
stepfun <- BL.stepfun(simulation$cells)
BLRPM objective function for parameter estimation
Description
BLRPM.OF
is the objective function used for parameter estimation of the BLRPM parameters.
Given a set of BLRPM parameters par
this function calculates a set of model statistics at
given accumulation time steps acc.vals
. These model statistics are compared with given
time series statistics stats
in the objective function. The user is able to define weights
for each statistic (has to be the same length as statistics input vector). Option for debugging is given.
A scale
parameter defines a criterium for which different kinds of model statistics are calculated.
This criterium is mainly based on the timescale difference between storm duration parameter gamma and cell duration
parameter eta.
If use.log
is true, the objective function needs logarithmic input parameters. The value
of OF
defines the kind of objective function to be used: 1= quadratic 2= quadratic extended 3= absolute 4= absolute extended.
Usage
BLRPM.OF(par, stats, acc.vals = c(1, 3, 12, 24), weights = rep(1,
length(stats)), debug = FALSE, scale = 1, use.log = TRUE, OF = 2)
Arguments
par |
|
stats |
|
acc.vals |
|
weights |
|
debug |
|
scale |
|
use.log |
|
OF |
|
Value
Z returns value of objective function for input parameters and input statistics
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
BLRPM class
Description
BLRPM.class
defines a new class for objects of type BLRPM containing the information about storms,
cells, stepfunction and the precipitation time series.
Usage
BLRPM.class
Format
An object of class R6ClassGenerator
of length 24.
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
BLRPM Parameter Estimation function
Description
BLRPM.est
estimates the five Bartlett-Lewis rectangular pulse model parameters lambda,gamma,beta,eta,mux
for a given time series data
. At first the time series statistics at given accumulation levels acc.vals
are calculated. These statistics are given over to the parameter estimation algorithm together with
parameter starting values par
. An objective function O.Fun
can be specified, default is BLRPM.OF
.
In addition the weights for different statistics and accumulation levels weights.mean, weights.var, weights.cov, weights.pz
can be specified. For the BLRPM objective function the user can select the measure of distance between observation
and model with OF
: =1 quadratic, =2: quad extended, =3: absolute, =4: abs extended.
A scale
parameter controls different cases in the objective function for differences in the scale of duration
parameters gamma and eta.
If a debugging is wished, debug
can be set to TRUE
and a log file is created in working directory.
Several optim
parameters can be also defined. For specifics see ?optim
.
Usage
BLRPM.est(RR,acc.vals,pars.in,O.Fun,
weights.mean,weights.var,weights.cov,weights.pz,OF,debug,
scale,method,lower,upper,use.log,maxit,ndeps,trace)
Arguments
RR |
|
acc.vals |
|
pars.in |
|
O.Fun |
|
weights.mean |
|
weights.var |
|
weights.cov |
|
weights.pz |
|
OF |
|
debug |
set |
scale |
|
method |
|
lower |
|
upper |
|
use.log |
|
maxit |
|
ndeps |
|
trace |
|
Value
$est returns vector
of estimated parameters lambda,gamma,beta,eta,mux
$conv returns value
of convergence of optimization, see optim
for details
$mess returns character
message about optimization if using "L-BFGS-B" method
$Z returns value
of objective function for estimated parameters
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
t.sim=240
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
pars <- c(lambda,gamma,beta,eta,mux)
sim <- BLRPM.sim(lambda,gamma,beta,eta,mux,t.sim)
est <- BLRPM.est(sim$RR,pars.in=pars,method="BFGS",use.log=TRUE)
Simulating precipitation with the BLRPM
Description
BLRPM.sim
is the main function for simulating precipitation with the Bartlett-Lewis rectangular pulse model.
It generates storms and cells using the given five BLRPM parameters lambda, gamma, beta, eta, mux
for a given
simulation time t.sim
. The function BLRPM.sim
then accumulates a precipitation time series of length
t.akk
(typically the same as t.sim) with an accumulation time step interval
from the generated
storms and cells. An offset
can be used to delay the precipitation time series for initialization reasons.
BLRPM.sim
returns a list of different variables and data.frames: Storms, Cells, Stepfun, Precip, time
.
Usage
BLRPM.sim(lambda,gamma,beta,eta,mux,t.sim,t.acc,interval,offset)
Arguments
lambda |
|
gamma |
|
beta |
|
eta |
|
mux |
|
t.sim |
|
t.acc |
|
interval |
|
offset |
|
Value
$storms returns data.frame
containing information about storms: start, end, number of cells
$cells returns data.frame
containing information about cells: start, end, intensity, storm index
$sfn returns stepfunction
used to accumulate precipitation time series
$RR returns vector
of accumulated precipitation with time step interval
[mm/interval]
$time returns vector
of time steps [interval]
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
t.sim <- 240
t.acc <- t.sim
interval <- 1
offset <- 0
simulation <- BLRPM.sim(lambda,gamma,beta,eta,mux,t.sim,t.acc=t.sim,interval,offset)
Beta function needed in objective function
Description
Beta.fun
is a help function for OF
Usage
Beta.fun(a, b)
Arguments
a |
|
b |
|
Value
beta returns value of Beta.fun
for parameters a and b
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Delta function needed in objective function
Description
Delta.fun
is a help function for OF
Usage
Delta.fun(kappa, MStrich)
Arguments
kappa |
|
MStrich |
|
Value
Delta returns value of Delta.fun
for kappa and MStrich
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Accumulation of a time series
Description
TS.acc
accumulates a given time series x
at a given accumulation level acc.val
. Minimum value
for acc.val is 2 [unit time]
Usage
TS.acc(x,acc.val)
Arguments
x |
|
acc.val |
|
Value
x.acc TS.acc
returns a vector
of an accumulated time series
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
x <- rgamma(1000,1)
x.2 <- TS.acc(x,acc.val=2)
calculating statistics of a time series needed for parameter estimation
Description
TS.stats
calculates statistics of a given time series x
at given accumulation
levels acc.vals
. The calculated statistics are the mean of the first accumulation level,
the variance, auto-covariance lag-1 and the probability of zero rainfall of all given accumulation
levels of the time series. These statistics are needed for estimating the BLRPM parameters.
Usage
TS.stats(x,acc.vals)
Arguments
x |
|
acc.vals |
|
Value
stats TS.stats
returns a vector
of statistics calculated at given accumulation levels
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
Examples
time.series <- rgamma(1000,shape=1)
statistics <- TS.stats(time.series,acc.vals=c(1,3,12,24))
Plotting of an object of class
BLRPM
Description
plot.BLRPM
plots an object of class
BLRPM returned by the function BLRPM.sim
with an option to plot
either only the storms and cells or to additionally plot the stepfunction and the precipitation time series
in a multiframe plot.
Usage
## S3 method for class 'BLRPM'
plot(x, ..., OSC = FALSE, start.time = NULL,
end.time = NULL, legend = TRUE, c.axis = 1.5, c.lab = 1.5,
c.legend = 1.5)
Arguments
x |
|
... |
Arguments to be passed to methods, such as graphical parameters (see |
OSC |
|
start.time |
|
end.time |
|
legend |
|
c.axis |
|
c.lab |
|
c.legend |
|
Author(s)
Christoph Ritschel christoph.ritschel@met.fu-berlin.de
See Also
Examples
lambda <- 4/240
gamma <- 1/10
beta <- 0.3
eta <- 2
mux <- 4
t.sim <- 240
t.acc <- t.sim
interval <- 1
offset <- 0
simulation <- BLRPM.sim(lambda,gamma,beta,eta,mux,t.sim,t.acc=t.sim,interval,offset)
plot(simulation,OSC=FALSE)
plot(simulation,OSC=TRUE,start.time=1,end.time=24)