[yt-users] VR: colorbar and camera

Agarwal, Shankar sagarwal at ku.edu
Sun Apr 17 10:01:12 PDT 2011


Hi,

I recently made some volume rendered images using the following script (along the lines of Britton's http://paste.enzotools.org/show/1472/). Basically, it loops over all the redshifts, creating a snapshot - each snapshot rotated a bit using the YT-camera object. I wanted to know how can I add a colorbar (something as in http://vimeo.com/17100442)? Also, I would like to display a few cosmology variables like:

    pf['CosmologyCurrentRedshift']
    pf['CosmologyOmegaBaryonNow']

My attempts with the image_writer are a disaster. I found that Libby had the same question a few months back, where she had a separate colorbar image and she joined 2 images. Please let me know how to modify the following script.

Regards
Shankar


my_script.py
-----------------

from yt.mods import *
import yt.visualization.volume_rendering.api as vr

output_dir = 'movie'
c = [0.5]*3 # Center
L = [1.0,1.0,1.0] # Viewpoint
W = na.sqrt(4.0) # Width
N = 1024 # Pixels
up = [0.,0.,1.] # Set the north vector
n_colors = 3
angle = 4 * na.pi / 360.0

for n in range(0,112): # each n is a unique redshift dump
 fin = 'lp7/seed1/RD%04i/RedshiftOutput%04i' % (n,n)  # parameter file to load
 pf = load(fin) # load data
 dd = pf.h.all_data()
 min, max = na.log10(dd.quantities["Extrema"]("Density")[0])
 print min, max

 fout = "%s/%04i.png" % (output_dir,n)

 width = 0.3 * (max - min) / float(n_colors)
 alpha = na.logspace(-3.5, -1, n_colors)

 tf = vr.ColorTransferFunction((min-3, max+1))
 tf.add_layers(n_colors,w=width, alpha=alpha, min=min, max=max, col_bounds=(min,max), colormap='gist_ncar')

 cam = vr.Camera(c, L, W, (N,N), fields=['Density'], transfer_function=tf, pf=pf, use_kd=True, l_max=None,
                 north_vector=up, tree_type='domain',no_ghost=True, steady_north=True)

 cam.rotate((n * angle))
 cam.snapshot(fout)
 del cam
 del tf
 del alpha



More information about the yt-users mailing list