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

Sam Skillman samskillman at gmail.com
Tue Jan 4 14:17:11 PST 2011


Britton, thanks for reminding me of that script...I forgot about the rotate
function.

You should also be able to use the rotation function as well.  The syntax
looks like:

from yt.visualization.image_writer import write_bitmap
... all the other setup ...
for i, snapshot in enumerate(cam.rotation(2.*na.pi, 30)):
    if cam._mpi_get_rank() == 0:
        write_bitmap(snapshot, "auto_rotation_%04i.png" % i)
        pl.imshow(snapshot/snapshot.max())
        pl.draw()

The write is inside the root-only check since not all processors have the
final composited image if made in parallel.  This usage above would do a
rotation of 360 degrees in 30 steps.  There is also a rot_vector keyword,
whose docstrings are:

rot_vector  : array_like, optional
            Specify the rotation vector around which rotation will
            occur.  Defaults to None, which sets rotation around the
            original `north_vector`

If this doesn't work, please let me know.  It worked for me a while back...

Best,
Sam

On Tue, Jan 4, 2011 at 2:12 PM, Britton Smith <brittonsmith at gmail.com>wrote:

> On second thought, you might want to go with this one instead.  I was doing
> some nonstandard stuff with the transfer functions in the first one.
> http://paste.enzotools.org/show/1473
>
> Both what I pasted before and the link here were used to make parts of this
> movie: http://vimeo.com/17100442
> The earlier paste was used to make the part where a single changing contour
> is shown.
>
> Britton
>
>
> On Tue, Jan 4, 2011 at 4:08 PM, Britton Smith <brittonsmith at gmail.com>wrote:
>
>> Here's one I ripped off from Sam Skillman, featuring the rotate function
>> in the volume render camera.  You'll have to comb through it for any values
>> I may have hard-coded in that don't apply.
>> http://paste.enzotools.org/show/1472/
>>
>> Britton
>>
>> On Tue, Jan 4, 2011 at 3:51 PM, Elizabeth Harper-Clark <
>> h-clark at cita.utoronto.ca> wrote:
>>
>>> Hi Britton,
>>>
>>> Works now, thank you :-)
>>>
>>> Also - has anyone written a bit of script to smoothly scan around a
>>> volume in a circle starting at an off-axis vector? the one I wrote has bugs
>>> in the trig function usage. I will think on it more but if someone has
>>> already done it and is willing to share that would be great!
>>>
>>> Libby
>>>
>>>
>>> On 4 January 2011 15:44, Britton Smith <brittonsmith at gmail.com> wrote:
>>>
>>>> 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
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> yt-users at lists.spacepope.org
>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>>
>>>>
>>>
>>>
>>> --
>>> Elizabeth Harper-Clark MA MSci
>>> PhD Candidate, Astrophysics, UofT
>>>
>>> www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark>
>>> h-clark at cita.utoronto.ca
>>> AIM: edphc1
>>> MSN: edphc1 at hotmail.com
>>> Skype: eharperclark
>>> Office phone: 416-978-5759
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> 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/20110104/e23fd87c/attachment.htm>


More information about the yt-users mailing list