mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-30 00:33:27 +08:00
Merge branch 'visulization' of https://bitbucket.org/rcockett/simpeg into visulization
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
{
|
||||
"metadata": {
|
||||
<<<<<<< HEAD
|
||||
"name": "3D rendering with vtkTools"
|
||||
=======
|
||||
"name": ""
|
||||
>>>>>>> develop
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
"worksheets": [
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
<<<<<<< HEAD
|
||||
"input": "import numpy as np, vtk\nimport SimPEG as simpeg",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 1
|
||||
=======
|
||||
"input": [
|
||||
"import numpy as np, vtk\n",
|
||||
"import SimPEG as simpeg"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 5
|
||||
>>>>>>> develop
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
<<<<<<< HEAD
|
||||
"input": "#Make a mesh and model\nx0 = np.zeros(3)\nh1 = np.ones(20)*5\nh2 = np.ones(10)*10\nh3 = np.ones(5)*20\n\nmesh = simpeg.mesh.TensorMesh([h1,h2,h3],x0)\n",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 2
|
||||
=======
|
||||
"input": [
|
||||
"#Make a mesh and model\n",
|
||||
"x0 = np.zeros(3)\n",
|
||||
"h1 = np.ones(20)*50\n",
|
||||
"h2 = np.ones(10)*100\n",
|
||||
"h3 = np.ones(5)*200\n",
|
||||
"\n",
|
||||
"mesh = simpeg.mesh.TensorMesh([h1,h2,h3],x0)\n"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 6
|
||||
>>>>>>> develop
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
<<<<<<< HEAD
|
||||
"input": "# Make a models that correspond to the cells, faces and edges.\nmodels = {'cell':{'Test':np.arange(0,mesh.nC),'AllOnce':np.ones(mesh.nC)},'face':{'Test':np.arange(0,np.sum(mesh.nF)),'AllOnce':np.ones(np.sum(mesh.nF))},'edge':{'Test':np.arange(0,np.sum(mesh.nE)),'AllOnce':np.ones(np.sum(mesh.nE))}}\n# Make the vtk viewer object.\nvtkViewer = simpeg.visulize.vtk.vtkView(mesh,models) \n ",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 3
|
||||
=======
|
||||
"input": [
|
||||
"# Make a models that correspond to the cells, faces and edges.\n",
|
||||
"models = {'cell':{'Test':np.arange(0,mesh.nC),'AllOnce':np.ones(mesh.nC)},'face':{'Test':np.arange(0,np.sum(mesh.nF)),'AllOnce':np.ones(np.sum(mesh.nF))},'edge':{'Test':np.arange(0,np.sum(mesh.nE)),'AllOnce':np.ones(np.sum(mesh.nE))}}\n",
|
||||
"# Make the vtk viewer object.\n",
|
||||
"vtkViewer = simpeg.visualize.vtk.vtkView(mesh,models) \n",
|
||||
" "
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 7
|
||||
>>>>>>> develop
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
<<<<<<< HEAD
|
||||
"input": "# Show the image \nvtkViewer.Show(imageType='cell')\n",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": "",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 4
|
||||
=======
|
||||
"input": [
|
||||
"# Show the image \n",
|
||||
"vtkViewer.Show()\n"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": "*"
|
||||
>>>>>>> develop
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
{
|
||||
"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": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user