[yt-users] need to plot a box with borders

henry wasker henry.wasker at gmail.com
Sun Sep 15 07:18:19 PDT 2013


Hi,

I have just upgraded from Squeeze Debian to Wheezy. After the installation
of yt dev and a "yt update && yt update --all", I  can't get now to draw a
box on volume rendering with draw_domain.

Here's the script :

------------------------------------------------------------------------------------------

from yt.mods import *
from yt.utilities.amr_kdtree.api import AMRKDTree
from time import time
import matplotlib.colorbar as cb
from yt.visualization.eps_writer import *
import pyx

# Load up your dataset
num='70'
pf = load('RD00'+num+'/RedshiftOutput00'+num)
c = [0.5]*3 # Center
L = [1.0,1.0,1.0] # Viewpoint
W = na.sqrt(3) # Width
N = 768 # Pixels (512^2)
up = [0.,0.,1.]
# Get density min, max
# These might take a long time, so I'd suggest hand-coding mi, ma so
# that you don't have to find the maxima and minima each time you
# test. Note that mi, ma, should be a log value since we are
# rendering the log of density.
mi, ma = pf.h.all_data().quantities['Extrema']('Density')[0]
mi, ma = na.log10(mi), na.log10(ma)
print mi, ma
#mi, ma = -31.0, -26.0
# Construct transfer function, pad the TF space by a bit so that
# gaussians sampling the data range don't hit the edge.
tf = ColorTransferFunction((mi-10, ma+10), nbins=1024)
# Sample transfer function with 20 gaussians. Use col_bounds keyword
# to restrict color mapping to true data range.
tf.add_layers(20, w=0.001,
        col_bounds=(mi,ma),colormap='jet')
# Create the camera object
cam = pf.h.camera(c, L, W, (N,N), transfer_function=tf, north_vector=up,
        no_ghost=True)

cam.rotate(na.pi*105/200,[1, 1, 0])
im = cam.snapshot("volume_rendered%s.png" % num, clip_ratio=8.0)
cam.draw_domain(im)
write_bitmap(im, "volume_rendered%s_with_domain.png" % num)

------------------------------------------------------------------------------------------

It produces the following figure :

http://i.imgur.com/C9nutUh.png

as you can see, the borders are not drawn

Anyone could see what's wrong ?

Thanks


---------- Forwarded message ----------
From: henry wasker <henry.wasker at gmail.com>
Date: 2013/1/22
Subject: need to plot a box with borders
To: yt-users at lists.spacepope.org


Hello,

I am new to yt and I am interesting in plotting a volume rendering with
output file from enzo cosmology simulation.

For the time being, I get to plot a box ; here's the result :

http://imgur.com/dPwSQEh

I would like now to plot borders of this box too like on this image :

http://imgur.com/bJ25I0l

Here's the yt script I use :

------------------------------------------------------------------------------------------------------------

from yt.mods import *
from yt.utilities.amr_kdtree.api import AMRKDTree
from time import time
import matplotlib.colorbar as cb

# Load up your dataset
num='70'
pf = load('RD00'+num+'/RedshiftOutput00'+num)
c = [0.5]*3 # Center
L = [1.0,1.0,1.0] # Viewpoint
W = na.sqrt(3) # Width
N = 768 # Pixels (512^2)
up = [0.,0.,1.]
# Get density min, max
# These might take a long time, so I'd suggest hand-coding mi, ma so
# that you don't have to find the maxima and minima each time you
# test. Note that mi, ma, should be a log value since we are
# rendering the log of density.
mi, ma = pf.h.all_data().quantities['Extrema']('Density')[0]
mi, ma = na.log10(mi), na.log10(ma)
print mi, ma
#mi, ma = -31.0, -26.0
# Construct transfer function, pad the TF space by a bit so that
# gaussians sampling the data range don't hit the edge.
tf = ColorTransferFunction((mi-10, ma+10), nbins=1024)
# Sample transfer function with 20 gaussians. Use col_bounds keyword
# to restrict color mapping to true data range.
tf.add_layers(20, w=0.001,
        col_bounds=(mi,ma),colormap='jet')
# Create the camera object
cam = pf.h.camera(c, L, W, (N,N), transfer_function=tf, north_vector=up,
        no_ghost=True)
cam.snapshot("volume_rendered%s.png" % num, clip_ratio=8.0)

------------------------------------------------------------------------------------------------------------

Is there an option for 'camera" or "snapshot" which allows to add the
borders for this box ?

Any help would be really appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130915/35298b17/attachment.htm>


More information about the yt-users mailing list