Create a VTK file for 3D visualisation

Geogrid objects can be exported to VTK fiels for visualisation in 3-D in any of the (free) VTK viewers (e.g. Paraview, Mayavi, Visit). The VTK export requires a running installation of the Python vtk package (can be a headache to install...) and the higher-level functions provided by evtk (available on: https://bitbucket.org/pauloh/pyevtk).

We start here with a geogrid from a pickled file and export it to VTK:


In [13]:
import os
import sys
# as long as not in Pythonpath, we have to set directory:
sys.path.append(r'/Users/flow/git/pygeomod')
import geogrid
import pickle

In [14]:
import numpy as np

In [27]:
reload(geogrid)
# load geogrid from pickled file
G1 = pickle.load(open(r'/Users/flow/Documents/02_work/01_own_docs/02_papers/GeoResJ/SPB_diffgrid_hres.pkl', 'r'))

In [16]:
# export to VTK
G1.export_to_vtk(vtk_filename = "SPB_Diff",
                 real_coords = True,
                 var_name = "Stratigraphic Distance")

That's it!


In [4]:
print os.getcwd()


/Users/flow/git/github/pygeomod/notebooks

In [5]:
G1.delx


Out[5]:
array([ 1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,  1560.,
        1560.,  1560.,  1560.,  1560.])

In [8]:
np.shape(G1.grid)


Out[8]:
(100, 100, 100)

In [12]:
tmp = geogrid.GeoGrid()

In [24]:
reload(geogrid)


Out[24]:
<module 'geogrid' from '/Users/flow/git/pygeomod/geogrid.py'>

In [33]:
reload(geogrid)
# load geogrid from pickled file
G1 = pickle.load(open(r'/Users/flow/Documents/02_work/01_own_docs/02_papers/GeoResJ/SPB_diffgrid_hres.pkl', 'r'))
G1.export_to_csv()

In [23]:
print os.getcwd()


/Users/flow/git/github/pygeomod/notebooks

In [32]:
G1.grid[50,50,0]


Out[32]:
0.0

In [ ]: