In [1]:
%pylab inline
from IPython.display import Image
from fatiando.mesher import PrismMesh
from fatiando.utils import SparseList
from fatiando.vis import myv
from line_profiler import LineProfiler
Lets make a mesh with density increasing with depth and to the East
In [16]:
bounds = (0, 1000, 0, 2000, 0, 500)
shape = (20, 20, 20)
mesh = PrismMesh(bounds, shape)
nz, ny, nx = shape
#density = zeros(mesh.size)
#density[::2] = arange(1, mesh.size/2 + 1)
density = SparseList(mesh.size)
density.elements = dict(zip(range(0, mesh.size, 2), arange(1, mesh.size/2)))
mesh.addprop('density', density)
print mesh.size, len(mesh.mask)
backup = copy(density)
In [17]:
mesh.mask = arange(mesh.size)[::3]
print mesh.size, len(mesh.mask)
In [13]:
myv.figure()
myv.prisms(mesh, 'density')
myv.axes(myv.outline(bounds))
myv.savefig('mesher_prismmesh.png')
myv.show()
Image(filename='mesher_prismmesh.png')
Out[13]:
Time dumping it to UBC-GIF format
In [23]:
%timeit mesh.dump('tmp.msh', 'tmp.den', 'density')
In [19]:
mesh.dump('tmp.msh', 'tmp.den', 'density')
all(mesh.props['density'] == backup)
Out[19]:
In [24]:
lp = LineProfiler(PrismMesh.dump)
lp.runcall(mesh.dump, 'tmp.msh', 'tmp.den', 'density')
lp.print_stats()
In [8]:
In [8]:
In [8]:
In [8]: