[yt-users] VR: colorbar and camera

Britton Smith brittonsmith at gmail.com
Mon Apr 18 10:36:38 PDT 2011


Hi Shankar,

Omega_baryon is not stored in the Enzo parameter file.  You'll have to set
it manually.

Britton

On Mon, Apr 18, 2011 at 12:44 PM, Agarwal, Shankar <sagarwal at ku.edu> wrote:

> Hi,
>
> Thanks for the scripts, Britton.
>
> Also, in the following piece, I am getting an error : KeyError:
> 'CosmologyOmegaBaryonNow'
>
>  def _Baryon_Overdensity(field, data):
>     return data['Density'] / \
>         (data.pf['CosmologyOmegaBaryonNow'] * rho_crit_now * (data.pf['CosmologyHubbleConstantNow']**2)
> *
>          ((1+data.pf['CosmologyCurrentRedshift'])**3))
>  add_field("Baryon_Overdensity",function=_Baryon_Overdensity,units=r"")
>
>
> I tried data.pf['CosmologySimulationOmegaBaryonNow'] but got the same
> error. Would I need to hard code these parameters in the python scripts?
>
>
> Shankar
>
> ________________________________________
> From: yt-users-bounces at lists.spacepope.org [
> yt-users-bounces at lists.spacepope.org] on behalf of Britton Smith [
> brittonsmith at gmail.com]
> Sent: Sunday, April 17, 2011 1:28 PM
> To: Discussion of the yt analysis package
> Subject: Re: [yt-users] VR: colorbar and camera
>
> Hi Shankar,
>
> The image_writer was an integral part of making the movie you refer to in
> your email.  In brief, I made the frames for the images and colorbars
> separately, then grafted them together using another script.  I have pasted
> an example of a script I used to make the colorbar portion of the frames
> here:
> http://paste.enzotools.org/show/1580/
> I then used the script below to attach the colorbar image to the volume
> render frame.
> http://paste.enzotools.org/show/1581/
> Note the line in this script:
> cmap = cmap[1:,:,:]
> I am chopping off one pixel from the colorbar image so that it has the same
> dimension as the rendering image on the side that they are being attached.
>  If you look at the script, the images are just arrays that are being
> concatenated so you have to make sure that your image dimension work.
>
> I hope this helps.
>
> Britton
>
> p.s. - Thanks again to Matt and Sam who made all of that possible!
>
> On Sun, Apr 17, 2011 at 1:01 PM, Agarwal, Shankar <sagarwal at ku.edu<mailto:
> sagarwal at ku.edu>> wrote:
> 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
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org<mailto:yt-users at lists.spacepope.org>
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20110418/3af10b70/attachment.htm>


More information about the yt-users mailing list