Skip to content

Commit

Permalink
Add yt volume rendering scripts for focus session
Browse files Browse the repository at this point in the history
  • Loading branch information
jisuoqing committed Jul 25, 2016
1 parent 1175702 commit 2afa0ae
Show file tree
Hide file tree
Showing 3 changed files with 617 additions and 0 deletions.
184 changes: 184 additions & 0 deletions yt-volume_rendering/1_simple_render_and_tf.ipynb

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions yt-volume_rendering/2_camera_and_lens.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import yt\n",
"import numpy as np\n",
"from yt.testing import fake_vr_orientation_test_ds\n",
"\n",
"ds = fake_vr_orientation_test_ds()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# now we do volume rendering\n",
"sc = yt.create_scene(ds, field='density')\n",
"# Change transfer function\n",
"tf = yt.ColorTransferFunction((np.log10(0.1), np.log10(1.)))\n",
"tf.sample_colormap(np.log10(0.9), 0.01, colormap=\"spectral\")\n",
"tf.sample_colormap(np.log10(0.8), 0.01, colormap=\"spectral\")\n",
"tf.sample_colormap(np.log10(0.6), 0.01, colormap=\"spectral\")\n",
"tf.sample_colormap(np.log10(0.2), 0.01, colormap=\"spectral\")\n",
"render_source = sc.get_source(0)\n",
"render_source.transfer_function = tf"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# plane-parallel lens\n",
"cam = sc.add_camera(ds, lens_type='plane-parallel')\n",
"cam.resolution = (500, 500) # equivalent with cam.set_resolution()\n",
"cam.width = ds.quan(4, 'code_length') # equivalent with cam.set_width()\n",
"cam.position = ds.arr([2.5, 0, 0], 'code_length') # equivalent with cam.set_position()\n",
"cam.switch_orientation(normal_vector=[-1, 0, 0],\n",
" north_vector=[0, 0, 1])\n",
"sc.render()\n",
"sc.show(sigma_clip=2.0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# perspective lens\n",
"cam = sc.add_camera(ds, lens_type='perspective')\n",
"cam.resolution = (500, 500)\n",
"cam.width = ds.arr([2, 2, 1], 'code_length')\n",
"cam.position = ds.arr([2.5, 0, 0], 'code_length')\n",
"cam.switch_orientation(normal_vector=[-1, 0, 0],\n",
" north_vector=[0 ,0, 1])\n",
"sc.render()\n",
"sc.show(sigma_clip=6.0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# spherical lens\n",
"cam = sc.add_camera(ds, lens_type='spherical')\n",
"cam.resolution = (1000, 500)\n",
"cam.position = ds.arr([0.5, 0, 0], 'code_length')\n",
"cam.switch_orientation(normal_vector=[-1 ,0 ,0],\n",
" north_vector=[0 ,0 ,1])\n",
"sc.render()\n",
"sc.show(sigma_clip=6.0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# stereo-spherical lens (another similar lens is stereo-perspective)\n",
"cam = sc.add_camera(ds, lens_type='stereo-spherical')\n",
"cam.disparity = ds.domain_width[0] * 1.5e-3 # separation between two eyes\n",
"cam.resolution = (1000, 1000)\n",
"cam.position = ds.arr([0.5, 0, 0], 'code_length')\n",
"cam.switch_orientation(normal_vector=[-1 ,0, 0],\n",
" north_vector=[0, 0, 1])\n",
"sc.render()\n",
"sc.show(sigma_clip=6.0)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 2afa0ae

Please sign in to comment.