def test_sample_dist(self): model = Gaussian(dim=1, var=3.5, len_scale=8.0) pdf, cdf, ppf = model.dist_func rad = self.rng.sample_dist(size=self.few_modes, pdf=pdf, cdf=cdf, ppf=ppf, a=0) self.assertEqual(rad.shape[0], self.few_modes) model = Gaussian(dim=2, var=3.5, len_scale=8.0) pdf, cdf, ppf = model.dist_func rad = self.rng.sample_dist(size=self.few_modes, pdf=pdf, cdf=cdf, ppf=ppf, a=0) self.assertEqual(rad.shape[0], self.few_modes) model = Gaussian(dim=3, var=3.5, len_scale=8.0) pdf, cdf, ppf = model.dist_func rad = self.rng.sample_dist(size=self.few_modes, pdf=pdf, cdf=cdf, ppf=ppf, a=0) self.assertEqual(rad.shape[0], self.few_modes)
def setUp(self): self.cov_model_1d = Gaussian(dim=1, var=1.5, len_scale=3.5, mode_no=100) self.cov_model_2d = copy.deepcopy(self.cov_model_1d) self.cov_model_2d.dim = 2 self.cov_model_3d = copy.deepcopy(self.cov_model_1d) self.cov_model_3d.dim = 3 self.seed = 19031977 self.x_grid = np.linspace(0.0, 10.0, 9) self.y_grid = np.linspace(-5.0, 5.0, 16) self.z_grid = np.linspace(-6.0, 7.0, 8) self.x_grid = np.reshape(self.x_grid, (len(self.x_grid), 1, 1, 1)) self.y_grid = np.reshape(self.y_grid, (1, len(self.y_grid), 1, 1)) self.z_grid = np.reshape(self.z_grid, (1, 1, len(self.z_grid), 1)) self.x_tuple = np.linspace(0.0, 10.0, 10) self.y_tuple = np.linspace(-5.0, 5.0, 10) self.z_tuple = np.linspace(-6.0, 8.0, 10) self.x_tuple = np.reshape(self.x_tuple, (len(self.x_tuple), 1)) self.y_tuple = np.reshape(self.y_tuple, (len(self.y_tuple), 1)) self.z_tuple = np.reshape(self.z_tuple, (len(self.z_tuple), 1)) self.rm_1d = RandMeth(self.cov_model_1d, 100, self.seed) self.rm_2d = RandMeth(self.cov_model_2d, 100, self.seed) self.rm_3d = RandMeth(self.cov_model_3d, 100, self.seed)
def test_rotation_unstruct_3d(self): self.cov_model = Gaussian( dim=3, var=1.5, len_scale=4.0, anis=(0.25, 0.5), mode_no=100 ) x_len = len(self.x_grid_c) y_len = len(self.y_grid_c) z_len = len(self.z_grid_c) x_u, y_u, z_u = np.meshgrid( self.x_grid_c, self.y_grid_c, self.z_grid_c ) x_u = np.reshape(x_u, x_len * y_len * z_len) y_u = np.reshape(y_u, x_len * y_len * z_len) z_u = np.reshape(z_u, x_len * y_len * z_len) srf = SRF(self.cov_model, mean=self.mean, mode_no=self.mode_no) field = srf((x_u, y_u, z_u), seed=self.seed, mesh_type="unstructured") field_str = np.reshape(field, (y_len, x_len, z_len)) self.cov_model.angles = (-np.pi / 2.0, -np.pi / 2.0) srf = SRF(self.cov_model, mean=self.mean, mode_no=self.mode_no) field_rot = srf( (x_u, y_u, z_u), seed=self.seed, mesh_type="unstructured" ) field_rot_str = np.reshape(field_rot, (y_len, x_len, z_len)) self.assertAlmostEqual(field_str[0, 0, 0], field_rot_str[-1, -1, 0]) self.assertAlmostEqual(field_str[1, 2, 0], field_rot_str[-3, -1, 1]) self.assertAlmostEqual(field_str[0, 0, 1], field_rot_str[-1, -2, 0])
def get_srf_2d(model, mean=None, var=None, len_scale=None): # covariance model for conductivity field cov_model = Gaussian(dim=2, var=var, len_scale=len_scale, anis=[1]) srf = SRF(model=cov_model, mean=mean, seed=1000) cond = np.exp(srf.mesh(model.msh)) return cond
def test_srf(self): D0 = np.array((0.0, 0.0)) cov_model = Gaussian(dim=2, var=0.01, len_scale=10.0) srf = SRF(cov_model, generator="VectorField", seed=5747387) sim = Simulation(2, srf, D0, self.T, self.dt) sim.initial_condition(self.pos_2d, self.distribution_2d) mean_drift = srf.generator.mean_u * (self.T / self.dt) sim() self.assertAlmostEqual(sim.pos[0, 0], mean_drift, places=0) self.assertAlmostEqual(sim.pos[1, 1], 0.0, places=0) self.assertAlmostEqual(sim.pos[0, -1], mean_drift, places=0)
def test_meshio(self): points = np.array([ [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], ]) cells = [("tetra", np.array([[0, 1, 2, 3]]))] mesh = meshio.Mesh(points, cells) model = Gaussian(dim=3, len_scale=0.1) srf = SRF(model) srf.mesh(mesh, points="points") self.assertEqual(len(srf.field), 4) srf.mesh(mesh, points="centroids") self.assertEqual(len(srf.field), 1)
def test_special_models(self): # matern converges to gaussian model1 = Matern() model1.set_arg_bounds(nu=[0, 101]) model1.nu = 100 model2 = Gaussian(rescale=0.5) self.assertAlmostEqual(model1.variogram(1), model2.variogram(1)) self.assertAlmostEqual(model1.spectrum(1), model2.spectrum(1), 2) # stable model gets unstable for alpha < 0.3 with self.assertWarns(AttributeWarning): Stable(alpha=0.2) with self.assertWarns(AttributeWarning): TPLStable(alpha=0.2) # corner case for JBessel model with self.assertWarns(AttributeWarning): JBessel(dim=3, nu=0.5)
def setUp(self): self.test_dir = tempfile.mkdtemp() # structured field with a size 100x100x100 and a grid-size of 1x1x1 x = y = z = range(100) model = Gaussian(dim=3, var=0.6, len_scale=20) self.srf_structured = SRF(model) self.srf_structured((x, y, z), mesh_type="structured") # unstrucutred field seed = MasterRNG(19970221) rng = np.random.RandomState(seed()) x = rng.randint(0, 100, size=10000) y = rng.randint(0, 100, size=10000) model = Exponential( dim=2, var=1, len_scale=[12.0, 3.0], angles=np.pi / 8.0 ) self.srf_unstructured = SRF(model, seed=20170519) self.srf_unstructured([x, y])
def test_incomprrandmeth(self): self.cov_model = Gaussian(dim=2, var=0.5, len_scale=1.0, mode_no=100) srf = SRF( self.cov_model, mean=self.mean, mode_no=self.mode_no, generator="IncomprRandMeth", mean_velocity=0.5, ) field = srf((self.x_tuple, self.y_tuple), seed=476356) self.assertAlmostEqual(field[0, 0], 1.23693272) self.assertAlmostEqual(field[0, 1], 0.89242284) field = srf( (self.x_grid, self.y_grid), seed=4734654, mesh_type="structured" ) self.assertAlmostEqual(field[0, 0, 0], 1.07812013) self.assertAlmostEqual(field[0, 1, 0], 1.06180674)
def setUp(self): self.cov_model_2d = Gaussian(dim=2, var=1.5, len_scale=2.5) self.cov_model_3d = copy.deepcopy(self.cov_model_2d) self.cov_model_3d.dim = 3 self.seed = 19031977 self.x_grid = np.linspace(0.0, 10.0, 9) self.y_grid = np.linspace(-5.0, 5.0, 16) self.z_grid = np.linspace(-6.0, 7.0, 8) self.x_tuple = np.linspace(0.0, 10.0, 10) self.y_tuple = np.linspace(-5.0, 5.0, 10) self.z_tuple = np.linspace(-6.0, 8.0, 10) self.rm_2d = IncomprRandMeth(self.cov_model_2d, mode_no=100, seed=self.seed) self.rm_3d = IncomprRandMeth(self.cov_model_3d, mode_no=100, seed=self.seed)
def setUp(self): self.cov_model = Gaussian(dim=2, var=1.5, len_scale=4.0, mode_no=100) self.mean = 0.3 self.mode_no = 100 self.seed = 825718662 self.x_grid = np.linspace(0.0, 12.0, 48) self.y_grid = np.linspace(0.0, 10.0, 46) self.z_grid = np.linspace(0.0, 10.0, 40) self.x_grid_c = np.linspace(-6.0, 6.0, 8) self.y_grid_c = np.linspace(-6.0, 6.0, 8) self.z_grid_c = np.linspace(-6.0, 6.0, 8) rng = np.random.RandomState(123018) self.x_tuple = rng.uniform(0.0, 10, 100) self.y_tuple = rng.uniform(0.0, 10, 100) self.z_tuple = rng.uniform(0.0, 10, 100)
from gstools import Gaussian, krige from pykrige.ok import OrdinaryKriging from matplotlib import pyplot as plt # conditioning data data = np.array( [ [0.3, 1.2, 0.47], [1.9, 0.6, 0.56], [1.1, 3.2, 0.74], [3.3, 4.4, 1.47], [4.7, 3.8, 1.74], ] ) # grid definition for output field gridx = np.arange(0.0, 5.5, 0.1) gridy = np.arange(0.0, 6.5, 0.1) # a GSTools based covariance model cov_model = Gaussian( dim=2, len_scale=1, anis=0.2, angles=-0.5, var=0.5, nugget=0.1 ) # ordinary kriging with pykrige OK1 = OrdinaryKriging(data[:, 0], data[:, 1], data[:, 2], cov_model) z1, ss1 = OK1.execute("grid", gridx, gridy) plt.imshow(z1, origin="lower") plt.show() # ordinary kriging with gstools for comparison OK2 = krige.Ordinary(cov_model, [data[:, 0], data[:, 1]], data[:, 2]) OK2.structured([gridx, gridy]) OK2.plot()
inverse for the kriging matrix, which is enabled by default. This will result in the average value for the redundant data. Example ^^^^^^^ In the following we have two different values at the same location. The resulting kriging field will hold the average at this point. """ import numpy as np from gstools import Gaussian, krige # condtions cond_pos = [0.3, 1.9, 1.1, 3.3, 1.1] cond_val = [0.47, 0.56, 0.74, 1.47, 1.14] # resulting grid gridx = np.linspace(0.0, 8.0, 81) # spatial random field class model = Gaussian(dim=1, var=0.5, len_scale=1) ############################################################################### krig = krige.Ordinary(model, cond_pos=cond_pos, cond_val=cond_val) krig(gridx) ############################################################################### ax = krig.plot() ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") ax.legend()
""" Detrended Ordinary Kriging -------------------------- """ import numpy as np from gstools import SRF, Gaussian, krige def trend(x): """Example for a simple linear trend.""" return x * 0.1 + 1 # synthetic condtions with trend/drift drift_model = Gaussian(dim=1, var=0.1, len_scale=2) drift = SRF(drift_model, seed=101) cond_pos = np.linspace(0.1, 8, 10) cond_val = drift(cond_pos) + trend(cond_pos) # resulting grid gridx = np.linspace(0.0, 15.0, 151) drift_field = drift(gridx) + trend(gridx) # kriging model = Gaussian(dim=1, var=0.1, len_scale=2) krig_trend = krige.Ordinary(model, cond_pos, cond_val, trend) krig_trend(gridx) ax = krig_trend.plot() ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") ax.plot(gridx, trend(gridx), ":", label="linear trend") ax.plot(gridx, drift_field, "--", label="original field") ax.legend()
def test_assertions(self): cov_model_1d = Gaussian(dim=1, var=1.5, len_scale=2.5) self.assertRaises(ValueError, IncomprRandMeth, cov_model_1d)
#import anaflow as ana from ogs5py import OGS, by_id, show_vtk, specialrange #from matplotlib import pyplot as plt from gstools import SRF, Gaussian # discretization and parameters rad = specialrange(0, 1000, 100, typ="cub") obs = rad[21] angles = 32 storage = 1e-3 transmissivity = 1e-4 rate = -1e-3 # covariance model for conductivity field cov_model = Gaussian(dim=2, var=2, len_scale=100, anis=[1]) srf = SRF(model=cov_model, mean=-9, seed=1000) # model setup model = OGS(task_root="pump_2d_steady", task_id="model", output_dir="out") model.pcs.add_block( PCS_TYPE="GROUNDWATER_FLOW", NUM_TYPE="NEW", TIM_TYPE="STEADY") # generate a radial mesh and geometry ("boundary" polyline) model.msh.generate("radial", dim=2, rad=rad, angles=angles) model.gli.generate("radial", dim=2, rad_out=rad[-1], angles=angles) model.gli.add_points([0.0, 0.0, 0.0], "pwell") # generate a 2D conductivity field cond = np.exp(srf.mesh(model.msh)) model.mpd.add(name="conductivity")
def test_covmodel_class(self): model_std = Gaussian(rescale=3, var=1.1, nugget=1.2, len_scale=1.3) model_var = Gau_var(rescale=3, var=1.1, nugget=1.2, len_scale=1.3) model_cov = Gau_cov(rescale=3, var=1.1, nugget=1.2, len_scale=1.3) model_cor = Gau_cor(rescale=3, var=1.1, nugget=1.2, len_scale=1.3) var = model_std.variogram(2.5) cov = model_std.covariance(2.5) corr = model_std.correlation(2.5) cor = model_std.cor(2.5) self.assertFalse(check_bounds(bounds=[0])) self.assertFalse(check_bounds(bounds=[1, -1])) self.assertFalse(check_bounds(bounds=[0, 1, 2, 3])) self.assertFalse(check_bounds(bounds=[0, 1, "kk"])) self.assertRaises(ValueError, model_std.set_arg_bounds, wrong_arg=[1]) self.assertRaises(ValueError, model_std.set_arg_bounds, wrong_arg=[-1, 1]) # checking some properties model_par = Stable() self.assertFalse(model_par.do_rotation) self.assertEqual(len(model_par.arg), len(model_par.arg_list)) self.assertEqual(len(model_par.iso_arg), len(model_par.iso_arg_list)) self.assertEqual(len(model_par.arg), len(model_par.iso_arg) + 2) self.assertEqual(len(model_par.len_scale_vec), model_par.dim) self.assertFalse(Gaussian() == Stable()) model_par.hankel_kw = {"N": 300} self.assertEqual(model_par.hankel_kw["N"], 300) # arg in bounds check model_std.set_arg_bounds(var=[0.5, 1.5]) with self.assertRaises(ValueError): model_std.var = 0.4 with self.assertRaises(ValueError): model_std.var = 1.6 model_std.set_arg_bounds(var=[0.5, 1.5, "oo"]) with self.assertRaises(ValueError): model_std.var = 0.5 with self.assertRaises(ValueError): model_std.var = 1.5 with self.assertRaises(ValueError): model_std.var_bounds = [1, -1] with self.assertRaises(ValueError): model_std.len_scale_bounds = [1, -1] with self.assertRaises(ValueError): model_std.nugget_bounds = [1, -1] with self.assertRaises(ValueError): model_std.anis_bounds = [1, -1] # reset the standard model model_std = Gaussian(rescale=3, var=1.1, nugget=1.2, len_scale=1.3) # std value from bounds with neg. inf and finit bound model_add = Mod_add() model_add.set_arg_bounds(alpha=[-np.inf, 0]) self.assertAlmostEqual(model_add.alpha, -1) # special treatment of anis check model_std.set_arg_bounds(anis=[2, 4, "oo"]) self.assertTrue(np.all(np.isclose(model_std.anis, 3))) # dim specific checks with self.assertWarns(AttributeWarning): Gau_fix(dim=1) self.assertRaises(ValueError, Gaussian, dim=0) self.assertRaises(ValueError, Gau_fix, latlon=True) # check inputs self.assertRaises(ValueError, model_std.percentile_scale, per=-1.0) self.assertRaises(ValueError, Gaussian, anis=-1.0) self.assertRaises(ValueError, Gaussian, len_scale=[1, -1]) self.assertRaises(ValueError, check_arg_in_bounds, model_std, "wrong") self.assertWarns(AttributeWarning, Gaussian, wrong_arg=1.0) with self.assertWarns(AttributeWarning): self.assertRaises(ValueError, Gaussian, len_rescaled=1.0) # check correct subclassing with self.assertRaises(TypeError): class Gau_err(CovModel): pass self.assertAlmostEqual(var, model_var.variogram(2.5)) self.assertAlmostEqual(var, model_cov.variogram(2.5)) self.assertAlmostEqual(var, model_cor.variogram(2.5)) self.assertAlmostEqual(cov, model_var.covariance(2.5)) self.assertAlmostEqual(cov, model_cov.covariance(2.5)) self.assertAlmostEqual(cov, model_cor.covariance(2.5)) self.assertAlmostEqual(corr, model_var.correlation(2.5)) self.assertAlmostEqual(corr, model_cov.correlation(2.5)) self.assertAlmostEqual(corr, model_cor.correlation(2.5)) self.assertAlmostEqual(cor, model_var.cor(2.5)) self.assertAlmostEqual(cor, model_cov.cor(2.5)) self.assertAlmostEqual(cor, model_cor.cor(2.5))
# -*- coding: utf-8 -*- import numpy as np from ogs5py import OGS, by_id, show_vtk from gstools import SRF, Gaussian # covariance model for conductivity field cov_model = Gaussian(dim=3, var=2, len_scale=10, anis=[1, 0.2]) srf = SRF(model=cov_model, mean=-9, seed=1000) # model setup model = OGS(task_root="pump_3d_steady", task_id="model", output_dir="out") model.pcs.add_block( # set the process type PCS_TYPE="GROUNDWATER_FLOW", NUM_TYPE="NEW", TIM_TYPE="STEADY") # generate a radial 3D mesh and conductivity field model.msh.generate("radial", dim=3, angles=64, rad=np.arange(101), z_arr=-np.arange(11)) cond = np.exp(srf.mesh(model.msh)) model.mpd.add(name="conductivity") model.mpd.add_block( # edit recent mpd file MSH_TYPE="GROUNDWATER_FLOW", MMP_TYPE="PERMEABILITY", DIS_TYPE="ELEMENT", DATA=by_id(cond), ) model.mmp.add_block( # permeability, storage and porosity GEOMETRY_DIMENSION=3, PERMEABILITY_DISTRIBUTION=model.mpd.file_name)
ogs.msh.rotate(angle=np.pi / 2.0, rotation_axis=(1., 0., 0.)) # round nodes ogs.msh.NODES[:, 1] = np.around(ogs.msh.NODES[:, 1], 0) ogs.msh.NODES[:, 0] = np.around(ogs.msh.NODES[:, 0], 4) ogs.msh.NODES[:, 2] = np.around(ogs.msh.NODES[:, 2], 4) # ------------------------ heterogeneous field -------------------------------- # # get the centroids of the mesh-elements to evaluate the field cent = ogs.msh.centroids_flat # split up in x and z coordinates x = cent[:, 0] z = cent[:, 2] # generate the random field cov_model = Gaussian(dim=dim, var=var, len_scale=len_scale) srf = SRF(cov_model, mean=mean, seed=seed) # use unstructured for a 2D vertical mesh field = srf((x, z), mesh_type='unstructured', force_moments=True) #, mode_no=100) # conductivities as log-normal distributed from the field data cond = np.exp(field) from scipy.stats.mstats import gmean, hmean arimean = np.mean(cond) harmean = hmean(cond) geomean = gmean(cond) print("The geometric mean is: " + str(geomean)) #plt.hist(field) # show the heterogeneous field
""" External Drift Kriging ---------------------- """ import numpy as np from gstools import SRF, Gaussian, krige # synthetic condtions with a drift drift_model = Gaussian(dim=1, len_scale=4) drift = SRF(drift_model, seed=1010) cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7] ext_drift = drift(cond_pos) cond_val = ext_drift * 2 + 1 # resulting grid gridx = np.linspace(0.0, 15.0, 151) grid_drift = drift(gridx) # kriging model = Gaussian(dim=1, var=2, len_scale=4) krig = krige.ExtDrift(model, cond_pos, cond_val, ext_drift) krig(gridx, ext_drift=grid_drift) ax = krig.plot() ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") ax.plot(gridx, grid_drift, label="drift") ax.legend()
def a(): nx = 6 ny = 2 if False: xc = contours.contours(nx, 2, 1) yc = contours.contours(ny, 1, 1) xc = [[0] + list(accumulate(list(q))) for q in xc] yc = [[0] + list(accumulate(list(q))) for q in yc] xc = [[(x0 + x1) / 2.0 for (x0, x1) in zip(q[:-1], q[1:])] for q in xc] yc = [[(y0 + y1) / 2.0 for (y0, y1) in zip(q[:-1], q[1:])] for q in yc] xc = [[qq - (max(q) + min(q)) / 2.0 for qq in q] for q in xc] yc = [[qq - (max(q) + min(q)) / 2.0 for qq in q] for q in yc] def fs(): for (sx, sy) in product(xc, yc): def f(x, y): return sx[x] + sy[y] yield f elif False: samples = [2 * (x + 0.5) / nx - 1 for x in range(nx)] xc = [] xc.append([0] * nx) xc.append(samples) xc.append([-x for x in samples]) # a(x-x0)^2 -> 2a(x-x0) <= 1 -> a <= 1/(2(1-x0)) for x0 in [0.0, -0.2, -0.4, -0.6, -0.8]: a = 1.0 / (2.0 * (1.0 - x0)) print(a) xc.append([a * xx * xx for x in samples for xx in [x - x0]]) xc.append([-a * xx * xx for x in samples for xx in [x - x0]]) xc.append([a * xx * xx for x in samples for xx in [-x - x0]]) xc.append([-a * xx * xx for x in samples for xx in [-x - x0]]) yc = [[-0.5, 0.5], [0.5, -0.5], [0, 0]] def fs(): for (sx, sy) in product(xc, yc): def f(x, y): return sx[x] + sy[y] yield f else: scale = 20 model = Gaussian(dim=2, var=1, len_scale=scale) def fs(): for seed in range(256): srf = SRF(model, seed=seed) def f(x, y): # 0 -> -1, 4 -> 1 # 0 -> -.25, 1 -> .25 return srf((x * .5 - 1.0, y * .5 - .25)) print(seed) yield f fs_lst = list(fs()) v = [1, 1, 2, 2, 3, 3] assert len(v) == nx lst = list(knuth_lexical_permute(v)) print(len(lst)) best = [] best_data = [] for perm in lst: print(perm) worst = None for f in fs_lst: diff = 0 for (idx, dev) in enumerate(perm): for y in range(ny): x = idx if y == 0 else nx - 1 - idx tmp = f(x, y) if dev == 1: diff += tmp elif dev == 2: diff -= tmp if worst is None or abs(diff) > worst: worst = abs(diff) worst_f = f assert worst is not None best_data.append((worst, perm, worst_f)) for tuple in sorted(best_data): print("%.4f" % tuple[0], tuple[1])
import numpy as np import matplotlib.pyplot as pt from gstools import SRF, Gaussian from gstools.random import MasterRNG x = y = np.arange(100) model = Gaussian(dim=2, var=1, len_scale=10) srf = SRF(model) ens_no = 4 field = [] seed = MasterRNG(20170519) for i in range(ens_no): field.append(srf((x, y), seed=seed(), mesh_type="structured")) fig, ax = pt.subplots(2, 2, sharex=True, sharey=True) ax = ax.flatten() for i in range(ens_no): ax[i].imshow(field[i].T, origin="lower") pt.show()
from matplotlib import pyplot as plt try: from gstools import Gaussian GS_IMP = True except ImportError: GS_IMP = False # conditioning data data = np.array([[0.3, 1.2, 0.47], [1.9, 0.6, 0.56], [1.1, 3.2, 0.74], [3.3, 4.4, 1.47], [4.7, 3.8, 1.74]]) # grid definition for output field gridx = np.arange(0.0, 5.5, 0.1) gridy = np.arange(0.0, 6.5, 0.1) # a GSTools based covariance model if GS_IMP: cov_model = Gaussian(dim=2, len_scale=4, anis=.2, angles=-.5, var=.5, nugget=.1) else: cov_model = "gaussian" # ordinary kriging with pykrige OK1 = OrdinaryKriging(data[:, 0], data[:, 1], data[:, 2], cov_model) z1, ss1 = OK1.execute('grid', gridx, gridy) plt.imshow(z1, origin="lower") if 'CI' not in os.environ: # skip in continous integration plt.show()