mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-28 07:34:52 +08:00
142 lines
4.1 KiB
Plaintext
142 lines
4.1 KiB
Plaintext
{
|
|
"metadata": {
|
|
"name": "VisualizeWithvtkView-updated"
|
|
},
|
|
"nbformat": 3,
|
|
"nbformat_minor": 0,
|
|
"worksheets": [
|
|
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import SimPEG as simpeg, matplotlib as mpl"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"The history saving thread hit an unexpected error (OperationalError('disk I/O error',)).History will not be written to the database.\n",
|
|
"Warning: mumps solver not available."
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Simple notebook of how to use vtkView to visualize SimPEG models. It will pop-up external vtk windows."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Make a mesh and model\n",
|
|
"x0 = np.zeros(3)\n",
|
|
"h1 = np.ones(60)*50\n",
|
|
"h2 = np.ones(60)*100\n",
|
|
"h3 = np.ones(50)*200\n",
|
|
"\n",
|
|
"mesh = simpeg.mesh.TensorMesh([h1,h2,h3],x0)\n",
|
|
"\n",
|
|
"# Make a models that correspond to the cells, faces and edges.\n",
|
|
"t = np.ones(mesh.nC)\n",
|
|
"t[10000:50000] = 100\n",
|
|
"t[100000:120000] = 100\n",
|
|
"t[100000:120000] = 50\n",
|
|
"# Make models called 'Test' for all with a range. \n",
|
|
"models = {'C':{'Test':np.arange(0,mesh.nC),'Model':t},'F':{'Test':np.arange(0,mesh.nF)},'E':{'Test':np.arange(0,mesh.nE)}}\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Make the vtk viewer object.\n",
|
|
"vtkViewer = simpeg.visualize.vtk.vtkView(mesh,models)\n",
|
|
"# Set the .viewprop for which model to view\n",
|
|
"vtkViewer.viewprop = {'F':'Test'}\n",
|
|
"# Show the image\n",
|
|
"vtkViewer.Show()\n",
|
|
"\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 3
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Set subset of the mesh to view (remove padding)\n",
|
|
"vtkViewer.extent = [4,14,0,7,0,3]\n",
|
|
"vtkViewer.Show()\n",
|
|
"\n",
|
|
"# Change viewing property \n",
|
|
"vtkViewer.viewprop = {'C':'Model'}\n",
|
|
"# Set the color range\n",
|
|
"# Reset extent. Error check will reset the limits correctly.\n",
|
|
"vtkViewer.extent = [-1,1000,-1,1000,-1,1000]\n",
|
|
"# Set the range\n",
|
|
"vtkViewer.range = [0.,100.]\n",
|
|
"# Show\n",
|
|
"vtkViewer.Show()\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stderr",
|
|
"text": [
|
|
"/home/Gudni/Codes/python/simpeg/SimPEG/visualize/vtk/vtkView.py:116: UserWarning: Lower bounds smaller then 0\n",
|
|
" warnings.warn('Lower bounds smaller then 0')\n",
|
|
"/home/Gudni/Codes/python/simpeg/SimPEG/visualize/vtk/vtkView.py:128: UserWarning: Upper bounds greater then number of cells\n",
|
|
" warnings.warn('Upper bounds greater then number of cells')\n",
|
|
"/home/Gudni/Codes/python/simpeg/SimPEG/visualize/vtk/vtkView.py:137: UserWarning: Changed given extent from [-1, 1000, -1, 1000, -1, 1000] to [0, 59, 0, 59, 0, 49]\n",
|
|
" warnings.warn('Changed given extent from {:s} to {:s}'.format(value,valnp.tolist()))\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Change color scale, has to be set to bytes=True.\n",
|
|
"vtkViewer.cmap = mpl.cm.copper(np.arange(0.,1.,0.01),bytes=True)\n",
|
|
"vtkViewer.Show()\n",
|
|
"# Set limits of values to view \n",
|
|
"vtkViewer.limits = [5.0,100.0]\n",
|
|
"vtkViewer.Show()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 5
|
|
}
|
|
],
|
|
"metadata": {}
|
|
}
|
|
]
|
|
} |