simGwexModel: simGwexModel

View source: R/GWex_lib.r

simGwexModelR Documentation

simGwexModel

Description

Simulate from a GWex model

Usage

simGwexModel(
  objGwexFit,
  nb.rep = 10,
  d.start = as.Date("01011900", "%d%m%Y"),
  d.end = as.Date("31121999", "%d%m%Y"),
  objGwexObs = NULL,
  prob.class = c(0.5, 0.75, 0.9, 0.99),
  objGwexSim = NULL,
  nCluster = 1,
  useSeed = FALSE
)

Arguments

objGwexFit

an object of class GwexFit

nb.rep

number of repetitions of scenarios

d.start

a starting date for the simulation

d.end

an ending date for the simulation

objGwexObs

optional: an object of class GwexObs if we need the observations to simulate (disaggregation prec 3D -> 1D)

prob.class

vector of probabilities indicating class of "similar" mean intensities

objGwexSim

optional: an object of class GwexSim if we need simulations to simulate (temp conditional to prec)

nCluster

optional, number of clusters which can be used for the parallel computation

useSeed

optional: a logical variable indicating if we control the seed of the simulations or not

Value

GwexSim

an object of class GwexSim. Contains sim (3D-array with the simulations) and a vector of dates

Author(s)

Guillaume Evin

Examples

# vector of dates
vecDates = seq(from=as.Date("01/01/2005",format="%d/%m/%Y"),
to=as.Date("31/12/2014",format="%d/%m/%Y"),by='day')

###############################################################
#               FIT AND SIMULATE FROM THE PRECIPITATION MODEL
###############################################################
# Format observations: create a G-Wex object
myObsPrec = GwexObs(variable='Prec',date=vecDates,obs=dailyPrecipGWEX[,1,drop=FALSE])

# Fit GWEX precipitation model, default options except for the threshold th
myParPrec = fitGwexModel(myObsPrec,listOption=list(th=0.5)) # fit model

# Generate 2 scenarios for one year, using the 'GwexFit' object
mySimPrec = simGwexModel(objGwexFit=myParPrec, nb.rep=2, d.start=vecDates[1],
d.end=vecDates[10])
mySimPrec # print object

###############################################################
#     FIT AND SIMULATE FROM THE TEMPERATURE MODEL
###############################################################
# Format observations: create a G-Wex object
myObsTemp = GwexObs(variable='Temp',date=vecDates,obs=dailyTemperGWEX)

# Fit GWEX temperature model
myParTemp = fitGwexModel(myObsTemp,listOption=list(hasTrend=TRUE,typeMargin='Gaussian',
depStation='Gaussian'))

# Generate 2 scenarios for one year, using an existing 'GwexFit' object
mySimTemp = simGwexModel(objGwexFit=myParTemp, nb.rep=2, d.start=vecDates[1], 
                          d.end=vecDates[365],objGwexObs=myObsPrec)
mySimTemp # print object

guillaumeevin/GWEX documentation built on Dec. 10, 2024, 12:14 p.m.