Closed lllxllll closed 5 years ago
I do not know. I will need more information.
Please just follow the bug report template (just set) or this guidelines (https://github.com/codeforamerica/howto/blob/master/Good-GitHub-Issues.md) for a better way to create issues.
Does gempy v2 still have an export_to_vtk() function? I wasn't able to find it - if it doesn't yet, let me know and I'll write one. :)
Update: couldn't find the built-in export to vtk function, so here's how to do it in gempy v2, using the pyevtk package:
# Simple export to VTK:
print('regular grid:\t', sol.grid.regular_grid.resolution, '\t', sol.grid.regular_grid.extent.astype(int))
#Export whole, uncropped lith_block
#Get coordinate info from grid & create VTK cells info:
xmin = sol.grid.regular_grid.extent[0]
xmax = sol.grid.regular_grid.extent[1]
xres = sol.grid.regular_grid.resolution[0]
dx = (xmax-xmin)/xres #pixel width
xvals = np.arange(xmin,xmax+dx,dx)
ymin = sol.grid.regular_grid.extent[2]
ymax = sol.grid.regular_grid.extent[3]
yres = sol.grid.regular_grid.resolution[1]
dy = (ymax-ymin)/yres
yvals = np.arange(ymin,ymax+dy,dy)
zmin = sol.grid.regular_grid.extent[4]
zmax = sol.grid.regular_grid.extent[5]
zres = sol.grid.regular_grid.resolution[2]
dz = (zmax-zmin)/zres
zvals = np.arange(zmin,zmax+dz,dz)
print('x:', xmin,xmax,xres,dx)
print('y:', ymin,ymax,yres,dy)
print('z:', zmin,zmax,zres,dz)
g = sol.lith_block.copy() #make a copy to avoid messing up original
g = np.reshape(g, (xres,yres,zres)) #reshape lith block to 3D
print('shape of array to export:', g.shape)
plt.imshow(g[:,:,zres-1])
path = r'C:\Users\Chloe\Desktop\ParaView files\geo_v2_morepts' #set file path to save to (should have no extension)
pyevtk.hl.gridToVTK(path, xvals, yvals, zvals, cellData={'data': g}) #export to VTK
Hello, is there already a way to export also the triangulated surfaces and the input data? This would be very useful in general, and in Windows particularly since the built in VTK visualization is very slow. On the other hand having the model exported to Paraview will open a lot of possibilities.
Thanks!
Hello @cfandel, I tried the code above, but at line
g = geo_model.lith_block.copy()
I get this error:
AttributeError: 'Model' object has no attribute 'lith_block'
What property should I use?
Thanks very much!
yes, gp.plot.export_vtk
. This export directly vtk files with surfaces and volume for paraview. For the input I do not have a direct function yet though but pandas can export csvs that can be used in paraview to generate points and so.
Thanks!
If the model has no lith block, it may not have run properly in the first place. You can also try sol.lith_block.
Hello, there were two typos, or the names have changed:
1) geo_model.lith_block
actually is geo_model.solutions.lith_block
2) gp.plot.export_vtk
actually is gp.plot.export_to_vtk
The latter is pretty clear except the block
option:
(geo_model, path='./VTK/', name='VTK', voxels=True, block=True, surfaces=True)
How does it work? Is it possible to export only the lithology or also the potential field associated to each series (stratigraphic and fault)?
Thanks very much!
yes, sorry for being lazy with the exact names of the functions. With autocompletion my brain does not memorize them :D
block is the volumetric results (i.e. voxels of the regular grid). I think I do not have the option to export the scalar field yet but it should be easy to add to the function, if you want to try. In the end is just another regular grid but with different values stored in geo_model.solutions.scalar_field_matrix[number_of_series-1, :]
In any case, thank you both for these discussions. I am sure they will be useful for someone at some point!
I am using the latest version of gempy and gp.plot.export_to_vtk(geo_model, file, block=mblock, surfaces=False) does not work! I recieve this error: module 'gempy.plot.plot_api' has no attribute 'export_to_vtk'
I'm using gempy
version 2.2.9
and recieve the same error:
module 'gempy.plot.plot_api' has no attribute 'export_to_vtk'
What is the correct way of exporting to vtk now?
Hey @mkondratyev85,
try gp._plot.export_to_vtk
:)
Thank you so much for the help! It almost worked. But now I have very strange error from pyvista. But I've created another issue for this. #641
when I run this code I got the vtr file as follow,Is this the lithology scalar filed? export_to_vtk(geo_data, lith_block=lith_block[1], vertices=ver, simplices=sim)