import gstlearn as gl
import gstlearn.plot as gp
import gstlearn.document as gdoc
import gstlearn.widgets as gw
import matplotlib.pyplot as plt
import ipywidgets as widgets
from ipywidgets import HBox, VBox
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display
import gstlearn as gl
%matplotlib inline
%matplotlib notebook
import math
gdoc.setNoScroll()
Defining the initial values for main parameters and creating the Grid
nx = 120
rangeInit = 20
nbtubaInit = 200
basicInit = gl.ECov.EXPONENTIAL
db = gl.DbGrid.create(nx = [nx,nx],dx = [1,1])
Constitute the Dictionary of all available basic structures (starting from the Enum), restricted to the only ones that can be simulated using the Turning Bands method.
modelList = gl.CovHelper.getAllCovariances(flagSimtub = True)
models = dict()
for rank in range(len(modelList)):
loctype = gl.ECov.fromKey(modelList[rank])
locname = gl.ECov.getDescr(loctype)
models[locname] = loctype
Performing a non-conditional simulation (with Turning Bands method) and display the results.
All these operations are set in a function (called iteration) as it will be called recursively for demonstration sake. This function is set with all variable arguments (where arguments are set by default to their initial values°.
def iterationPlot(ax, title):
ax.raster(db,"*Simu")
ax.axes.axis("off")
ax.decoration(title=title)
def iteration(ax, basic = basicInit, range = rangeInit, nbtuba = nbtubaInit):
model = gl.Model.createFromParam(basic,range = range)
db.deleteColumn("*Simu")
err = gl.simtub(None,db,model,nbtuba=nbtuba)
title = f'{basic.getDescr()} {":"} {"Range ="} {range} {"-"} {"Nbtuba ="} {nbtuba}'
iterationPlot(ax, title)
fig,ax = plt.subplots(1,1,figsize=(5,5))
iteration(ax)
def sliderNbtubaEventhandler(change):
iteration(ax1, nbtuba=change.new)
widgetNbtuba = gw.sliderInt(title='Nb. Bands',
value=nbtubaInit, mini=10, maxi=1000,
eventhandler=sliderNbtubaEventhandler)
display(widgetNbtuba)
fig,ax1 = plt.subplots(1,1,figsize=(5,5))
iteration(ax1)
IntSlider(value=200, continuous_update=False, description='Nb. Bands', max=1000, min=10)
def sliderRangeEventhandler(change):
iteration(ax2, range=change.new)
widgetRange = gw.sliderFloat(title='Range',
value = rangeInit, mini=5, maxi=100,
eventhandler=sliderRangeEventhandler)
display(widgetRange)
fig,ax2 = plt.subplots(1,1,figsize=(5,5))
iteration(ax2)
FloatSlider(value=20.0, continuous_update=False, description='Range', min=5.0, step=1.0)
def sliderTypeEventhandler(change):
iteration(ax3, basic=models[change.owner.value])
widgetModelType = gw.dropDown(title='Basic Structure', options = models.keys(),
eventhandler=sliderTypeEventhandler)
display(widgetModelType)
fig,ax3 = plt.subplots(1,1,figsize=(5,5))
iteration(ax3)
Dropdown(description='Basic Structure', options=('Nugget effect', 'Exponential', 'Spherical', 'Gaussian', 'Cub…