Hi Libby,<br><br>The imports have changed since you last used this script.  For the volume rendering, you now want<br>import yt.visualization.volume_rendering.api as vr<br>from yt.visualization.image_writer import write_bitmap<br>
<br>Also, I don't think you need the yt.amr_utils import.<br><br>Britton<br><br><div class="gmail_quote">On Tue, Jan 4, 2011 at 3:39 PM, Elizabeth Harper-Clark <span dir="ltr"><<a href="mailto:h-clark@astro.utoronto.ca">h-clark@astro.utoronto.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi guys,<br><br>I think I am doing something stupid. I have just returned to try to do some volume rendering and I now get the following error (Script at end of email) (please note: I have no problems with any of my other yt scripts):<br>

<br><i>[h-clark@tpb4 my_scripts]$ python2.6 VolumeRunNew.py GMCidresbig128a<br>yt         INFO       2011-01-04 15:32:52,325 Loading plugins from /home/h-clark/.yt/my_plugins.py<br>/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/__init__.py:833: UserWarning:  This call to matplotlib.use() has no effect<br>

because the the backend has already been chosen;<br>matplotlib.use() must be called *before* pylab, matplotlib.pyplot,<br>or matplotlib.backends is imported for the first time.<br><br>  if warn: warnings.warn(_use_error_msg)<br>

Traceback (most recent call last):<br>  File "VolumeRunNew.py", line 2, in <module><br>    import yt.extensions.volume_rendering as vr<br>ImportError: No module named extensions.volume_rendering<br></i><br clear="all">

I tried with the simple volume rendering code in the cookbook too and get the same error. I tried updating yt:<br><br><i>[h-clark@tpb4 yt-hg]$ hg pull<br>pulling from <a href="http://hg.enzotools.org/yt/" target="_blank">http://hg.enzotools.org/yt/</a><br>

searching for changes<br>adding changesets<br>adding manifests<br>adding file changes<br>added 134 changesets with 198 changes to 91 files (-1 heads)<br>(run 'hg update' to get a working copy)<br>[h-clark@tpb4 yt-hg]$ hg update<br>

75 files updated, 0 files merged, 3 files removed, 0 files unresolved<br>[h-clark@tpb4 yt-hg]$ hg identify<br>4db47be8e251 (yt) tip</i><br><br>but still get the same error. What am I doing wrong?<br><br>Thanks,<br><br>Libby<br>

<br><br><br>Script:<br><br>from yt.mods import *<br>import yt.extensions.volume_rendering as vr<br>import numpy as na<br>import yt.amr_utils as au<br>import yt.extensions.image_writer as iw<br><br>N = 1024<br><br>pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679<br>

frame_template = "aaSN/%s/3D3_%04i_%02i.png"<br>#frame_template = "aaWoC/%s/3D3_%04i_%02i.png"<br><br>alpha_channel = 255*na.ones((N,N,1), dtype='uint8')<br>def save(arr, fn, norm = 0.5):<br>    arr = arr / (norm*arr.max()) # assume min = 0<br>

    arr = na.clip( arr*255, 0, 255).astype("uint8")<br>    arr = na.concatenate( [arr, alpha_channel], axis=-1)<br>    au.write_png(arr.copy(), fn)<br><br>for numb in range(50,51):<br>    print "Numb = ",numb<br>

    pf = load(os.path.expanduser("/home/h-clark/my_scripts/SciNet/%s/DD%04i/data%04i" % (sys.argv[-1],numb, numb)))<br>    #pf = load(os.path.expanduser("/home/h-clark/my_scripts/WOCOUT/%s/DD%04i/data%04i" % (sys.argv[-1],numb, numb)))<br>

    #c = pf.h.find_max("Density")[1]<br>    c = [0.5,0.5,0.5]<br>    W = 1.0<br>    tf = vr.ColorTransferFunction((-24, -20.0))<br>    dd = pf.h.sphere(c, 0.1)<br>    print dd.quantities["Extrema"]("Density")<br>

    hv = vr.HomogenizedVolume(fields = ["Density"], pf = pf)<br>    h5fn = "%s_partitioned.h5" % pf<br>    if not os.path.exists(h5fn):<br>        hv.initialize_source()<br>        hv.store_bricks(h5fn)<br>

    else:<br>        hv.load_bricks(h5fn)<br>    tf.add_layers(10, colormap='hot', w=0.03)<br>        <br>    for theta in range (0,1):<br>        zeta = 0.8<br>        epz = 0.5<br>        athe = 0.5*pi<br>        aphi = 0.62 + 2*pi*theta/100 #2*pi*phi/20<br>

        print athe,aphi<br>        lx = na.sin(athe)*na.cos(aphi)<br>        ly = na.sin(athe)*na.sin(aphi)<br>        lz = na.cos(athe)<br>        print lx,ly,lz<br>        mx = lx*na.cos(zeta) + ly*na.sin(zeta)<br>        my = ly*na.cos(zeta) - lx*na.sin(zeta)<br>

        mz = lz<br>        ny = my*na.cos(epz) + mz*na.sin(epz)<br>        nz = mz*na.cos(epz) - my*na.sin(epz)<br>        nx = mx<br>        print "vector:",nx,ny,nz<br>        L = [nx, ny, nz]<br>        cam = vr.Camera(c, L, W, (N,N),<br>

                transfer_function = tf,<br>                pf = pf, volume = hv, sub_samples=10)<br>        frame = cam.snapshot()<br>        save(frame, frame_template % (sys.argv[-1],numb,theta), norm = 0.5)<br><br>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br>