1import numpy as np
2from enthought.tvtk.api import tvtk, write_data
3
4data = np.random.random((10,10,10))
5
6grid = tvtk.ImageData(spacing=(10, 5, -10), origin=(100, 350, 200),
7 dimensions=data.shape)
8grid.point_data.scalars = np.ravel(order='F')
9grid.point_data.scalars.name = 'Test Data'
10
11# Writes legacy ".vtk" format if filename ends with "vtk", otherwise
12# this will write data using the newer xml-based format.
13write_data(grid, 'test.vtk')
14