-
Just to better find this question again, I'll copy paste and reference it here: Hello Sebastian, I am a grad student in geotechnical engineering and I am considering the use of GSTools for simulating spatial random fields. It seems to be an excellent package for this purpose compared to others I have looked into. I have a question about whether it is possible to use a nonstationary mean and variance with the current algorithm? Many soil profile case studies I am dealing are expected to show changes in the mean and variance of parameters (e.g., strength, permeability) as you move in a certain direction. I want to be able to capture a linear increase in the mean and variance of the soil strength with depth for example. I believe I may be able to manually change the mean scaling to account for this, however, I am not sure if it is possible to capture changes in the variance. I suppose this would require changes to the variogram depending on spatial location. Any help, or potential updates to the algorithm for this, would be much appreciated! Thank you, Patrick Originally posted by @pbassal in #121 (comment) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @pbassal, But for now you can apply this by hand: import numpy as np
import gstools as gs
import matplotlib.pyplot as plt
def mean(x, y):
"""Mean increases in x-direction."""
return 0.5 * x
def var(x, y):
"""Variance increases in y-direction."""
return 1 + 0.2 * y
x = y = range(51)
# generate an unstructured grid from x-y axes for calling above functions
xx, yy = np.meshgrid(x, y, indexing="ij")
# use mean of 0 and variance of 1 to get a standard field
model = gs.Exponential(dim=2, var=1, len_scale=10, anis=0.5)
srf = gs.SRF(model=model, mean=0, seed=1111)
# generate the structured field (from x-y axes)
srf.structured((x, y))
# apply mean and variance
srf.field = np.sqrt(var(xx, yy)) * srf.field + mean(xx, yy)
# plot the field
srf.plot()
# some cross-sections
fig, ax = plt.subplots()
ax.plot(x, srf.field[:, 0], label="y=0")
ax.plot(x, srf.field[:, 25], label="y=25")
ax.plot(x, srf.field[:, 50], label="y=50")
ax.plot(x, mean(np.array(x), 0), color="k", label="mean")
ax.legend()
fig.show() You can clearly see, that the mean increases in x direction and variance get higher with y. Hope that helps! Originally posted by @MuellerSeb in #121 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @MuellerSeb ! This is exactly what I was looking for. I will try some different mean and variance trend functions for my work and let you know if anything else comes up. I will look forward to the 1.3 release. Originally posted by @pbassal in #121 (reply in thread) |
Beta Was this translation helpful? Give feedback.
Hey @pbassal,
thanks for using GSTools! We are working hard on the
1.3
release at the moment, and there we plan to include the option to add a trend to the field (variable functional mean of the field).But for now you can apply this by hand: