In [1]:
import pygslib
import numpy as np
import vtk
from vtk.numpy_interface import dataset_adapter as dsa



In [2]:
# need to define
nx=100
ny=100
nz=50
xorg=0.0
yorg=0.0
zorg=0.0
dx=20
dy=20
dz=10
# these are the values of point data (block corners)
P1 = dsa.numpyTovtkDataArray(np.random.rand(nx*ny*nz), name='Random', array_type=None)


C:\Users\AMartinez\AppData\Local\Continuum\miniconda3\lib\site-packages\vtk\util\numpy_support.py:137: FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.
  assert not numpy.issubdtype(z.dtype, complex), \

In [3]:
ufgrid = vtk.vtkUniformGrid()
ufgrid.SetOrigin(xorg,yorg,zorg)
ufgrid.SetSpacing(dx,dy,dz)
ufgrid.SetDimensions(nx,ny,nz)
ufgrid.GetPointData().SetScalars(P1)


Out[3]:
0

In [7]:
# balck points 
for i in range(10):
    for j in range(10):
        for k in range(10):
            ufgrid.BlankPoint(i,j,k)

In [8]:
w = vtk.vtkXMLImageDataWriter()
w.SetFileName("mod_cat.vti")
w.SetDataModeToBinary()
w.SetInputData(ufgrid)
w.Write()


Out[8]:
1

In [ ]:
# note that paraview read this as image but you have a new property VTKGhostType.