[yt-users] Volume rendering error: "No module named extensions.volume_rendering"

Britton Smith brittonsmith at gmail.com
Tue Jan 4 12:44:13 PST 2011


Hi Libby,

The imports have changed since you last used this script.  For the volume
rendering, you now want
import yt.visualization.volume_rendering.api as vr
from yt.visualization.image_writer import write_bitmap

Also, I don't think you need the yt.amr_utils import.

Britton

On Tue, Jan 4, 2011 at 3:39 PM, Elizabeth Harper-Clark <
h-clark at astro.utoronto.ca> wrote:

> Hi guys,
>
> 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):
>
> *[h-clark at tpb4 my_scripts]$ python2.6 VolumeRunNew.py GMCidresbig128a
> yt         INFO       2011-01-04 15:32:52,325 Loading plugins from
> /home/h-clark/.yt/my_plugins.py
> /home/h-clark/YT/lib/python2.6/site-packages/matplotlib/__init__.py:833:
> UserWarning:  This call to matplotlib.use() has no effect
> because the the backend has already been chosen;
> matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
> or matplotlib.backends is imported for the first time.
>
>   if warn: warnings.warn(_use_error_msg)
> Traceback (most recent call last):
>   File "VolumeRunNew.py", line 2, in <module>
>     import yt.extensions.volume_rendering as vr
> ImportError: No module named extensions.volume_rendering
> *
> I tried with the simple volume rendering code in the cookbook too and get
> the same error. I tried updating yt:
>
> *[h-clark at tpb4 yt-hg]$ hg pull
> pulling from http://hg.enzotools.org/yt/
> searching for changes
> adding changesets
> adding manifests
> adding file changes
> added 134 changesets with 198 changes to 91 files (-1 heads)
> (run 'hg update' to get a working copy)
> [h-clark at tpb4 yt-hg]$ hg update
> 75 files updated, 0 files merged, 3 files removed, 0 files unresolved
> [h-clark at tpb4 yt-hg]$ hg identify
> 4db47be8e251 (yt) tip*
>
> but still get the same error. What am I doing wrong?
>
> Thanks,
>
> Libby
>
>
>
> Script:
>
> from yt.mods import *
> import yt.extensions.volume_rendering as vr
> import numpy as na
> import yt.amr_utils as au
> import yt.extensions.image_writer as iw
>
> N = 1024
>
> pi =
> 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
> frame_template = "aaSN/%s/3D3_%04i_%02i.png"
> #frame_template = "aaWoC/%s/3D3_%04i_%02i.png"
>
> alpha_channel = 255*na.ones((N,N,1), dtype='uint8')
> def save(arr, fn, norm = 0.5):
>     arr = arr / (norm*arr.max()) # assume min = 0
>     arr = na.clip( arr*255, 0, 255).astype("uint8")
>     arr = na.concatenate( [arr, alpha_channel], axis=-1)
>     au.write_png(arr.copy(), fn)
>
> for numb in range(50,51):
>     print "Numb = ",numb
>     pf =
> load(os.path.expanduser("/home/h-clark/my_scripts/SciNet/%s/DD%04i/data%04i"
> % (sys.argv[-1],numb, numb)))
>     #pf =
> load(os.path.expanduser("/home/h-clark/my_scripts/WOCOUT/%s/DD%04i/data%04i"
> % (sys.argv[-1],numb, numb)))
>     #c = pf.h.find_max("Density")[1]
>     c = [0.5,0.5,0.5]
>     W = 1.0
>     tf = vr.ColorTransferFunction((-24, -20.0))
>     dd = pf.h.sphere(c, 0.1)
>     print dd.quantities["Extrema"]("Density")
>     hv = vr.HomogenizedVolume(fields = ["Density"], pf = pf)
>     h5fn = "%s_partitioned.h5" % pf
>     if not os.path.exists(h5fn):
>         hv.initialize_source()
>         hv.store_bricks(h5fn)
>     else:
>         hv.load_bricks(h5fn)
>     tf.add_layers(10, colormap='hot', w=0.03)
>
>     for theta in range (0,1):
>         zeta = 0.8
>         epz = 0.5
>         athe = 0.5*pi
>         aphi = 0.62 + 2*pi*theta/100 #2*pi*phi/20
>         print athe,aphi
>         lx = na.sin(athe)*na.cos(aphi)
>         ly = na.sin(athe)*na.sin(aphi)
>         lz = na.cos(athe)
>         print lx,ly,lz
>         mx = lx*na.cos(zeta) + ly*na.sin(zeta)
>         my = ly*na.cos(zeta) - lx*na.sin(zeta)
>         mz = lz
>         ny = my*na.cos(epz) + mz*na.sin(epz)
>         nz = mz*na.cos(epz) - my*na.sin(epz)
>         nx = mx
>         print "vector:",nx,ny,nz
>         L = [nx, ny, nz]
>         cam = vr.Camera(c, L, W, (N,N),
>                 transfer_function = tf,
>                 pf = pf, volume = hv, sub_samples=10)
>         frame = cam.snapshot()
>         save(frame, frame_template % (sys.argv[-1],numb,theta), norm = 0.5)
>
>
> _______________________________________________
> 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/20110104/9418a44f/attachment.html>


More information about the yt-users mailing list