Dear Didier,
Thank you for your answer. My simulations work pretty well and as I wish.
Though I would like to simulate the precipitation which in this file, one hour after another. You will find below the code I am using. However, to simulate one hour after another, I change manually the locator inside the first data base and use the same variogram model
- Code: Select all
model.1
for each simulation. Would you know a way to do it in a more automatic way ?
Thank you for your answer.
P.S.: how do I say that the issue is solved ?
- Code: Select all
#### GIVE IT A LOCATOR ####
flood_05.db <- db.locate(db = flood_05.db,
names = c("X2005.02.12_0900"),
loctype = "z", start = 1)
flood_05.db
#
# ## plot the data of the first variable ##
# x11()
# plot(flood_05.db, pch = 21, col = "black",
# title = "12/02/2005 00:00")
#### TRANSFORMATION OF THE DATA TO HAVE NORMAL DISTRIBUTION ####
flood_05.transform <- anam.fit(db = flood_05.db,
names = c("X2005.02.12_0900"), type = "gaus")
# in the name, be careful to write "X[...]", otherwise the function
# does not run
flood_05.db <- anam.z2y(anam = flood_05.transform,
db = flood_05.db,
names = c("X2005.02.12_0900"), radix = "GAUSS")
flood_05.db
# ### DETERMINATION OF THE VARIOGRAM ####
# flood_05.gauss.vario <- vario.calc(flood_05.db,
# lag = 1000, nlag = 30)
#
# plot(flood_05.gauss.vario, npairpt = 1, npairdw = TRUE,
# title = "Variogram 12 00:00")
#
# #### ESTIMATE THE VARIOGRAM MODEL ####
# model <- model.auto(flood_05.gauss.vario,
# struct = c("Exponential", "Spherical"))
# model.1 <- model.fit(flood_05.gauss.vario)
# model.plot(model.1)
#### neighbourhood definition ####
unique.neigh <- neigh.input(ndim = 2)
#### GRID CREATION ####
grid.db <- db.create(flag.grid = TRUE,
nx = c(29, 28), dx=c(1000, 1000),
x0=c(4463500, 5534500))
# grid.db <- db.grid.init(flood_05.db, nodes = c(29, 28),
# origin = c(4463500, 5534500))
#### TURNING BANDS SIMULATION ####
#### -conditional- ####
grid.db <- simtub(dbin = flood_05.db, dbout = grid.db,
model = model.1, neigh = unique.neigh,
nbsimu = 100, nbtuba = 15)
grid.db
#### back transformation ####
backtransfoStart <- Sys.time()
grid.db <- anam.y2z(anam = flood_05.transform,
db = grid.db, ngrep = "Simu.GAUSS.X2005.02.12_0900")
backtransfoEnd <- Sys.time()-backtransfoStart
backtransfoEnd
grid.db
#### mean -conditional- ####
grid.db <- db.compare(db = grid.db, fun = "mean",
ngrep = "Raw.Simu.GAUSS.X2005.02.12_0900")