-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add yt volume rendering scripts for focus session
- Loading branch information
Showing
3 changed files
with
617 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.