[yt-users] Colorbar and labels on volume rendered images

Elizabeth Harper-Clark h-clark at cita.utoronto.ca
Wed Jan 5 09:22:23 PST 2011


Hi guys,

I found the annotate_image option within yt.visualization.image_writer but I
am missing something:

*Script*:

from yt.mods import *
from matplotlib import pylab
import numpy as na
from yt.visualization.image_writer import *

output_file = "aaWoC/%s/MovieFrame_%04i"

for i in range(0,189):
    print "Merging", i
    image1 = pylab.imread("aaWoC/%s/3D3Movie_%04i.png" % (sys.argv[-1],i))
    image2 = pylab.imread("aaWoC/%s/ColourBar.png" % sys.argv[-1])

    new_image = na.concatenate([image1, image2], axis=1)
    bitmap = write_image(new_image,output_file % (sys.argv[-1],i ))
    annotate_image(bitmap, "Test", 50, 50)
    write_bitmap(bitmap, output_file % (sys.argv[-1],i))


*Error*:

[h-clark at tpb5 my_scripts]$ python2.6 MergeImages.py GMCidresbig128a
yt         INFO       2011-01-05 12:18:10,296 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)
Merging 0
yt         INFO       2011-01-05 12:18:10,473 Using only channel 1 of
supplied image
Traceback (most recent call last):
  File "MergeImages.py", line 15, in <module>
    annotate_image(bitmap, "Test", 50, 50)
  File "/home/h-clark/YT/src/yt-hg/yt/visualization/image_writer.py", line
235, in annotate_image
    au.simple_writing(font_path, 0, dpi, font_size, text, image, xpos, ypos)
AttributeError: 'module' object has no attribute 'simple_writing'


????

Also is there a way to change font colour? (in vol rend background is black
so I want text in white!). will text_args = {'color':'w'} work?

Many thanks,

Libby




On 5 January 2011 12:05, Elizabeth Harper-Clark <h-clark at cita.utoronto.ca>wrote:

> Thanks Britton,
>
> Concatenating is working :-) now to work out labels......
>
> Thanks,
>
> Libby
>
>
> On 5 January 2011 11:29, Britton Smith <brittonsmith at gmail.com> wrote:
>
>> It is possible to attach a colormap to a volume render image.  I can't
>> quite remember how to do that.  If someone else could chime in on that, that
>> would be great.
>> If you already have the colorbar image you want, you can concatenate two
>> image arrays easily and then write out the new image, provided the arrays
>> are the same size in one direction.  With pylab, you can do something like
>> this:
>> from matplotlib import pylab
>> import numpy as na
>> from yt.visualization.image_writer import write_bitmap
>> image1 = pylab.imread(file1)
>> image2 = pylab.imread(file2)
>> new_image = na.concatenate([image1, image2], axis=1)
>> write_bitmap(new_image, output_file)
>>
>> I believe the image_writer now supports adding text as well, so that
>> should take care of the labels.
>>
>> Britton
>>
>> On Wed, Jan 5, 2011 at 10:46 AM, Elizabeth Harper-Clark <
>> h-clark at astro.utoronto.ca> wrote:
>>
>>> Good morning everyone,
>>>
>>> I was wondering how to add colorbars and text labels (e.g. with the time)
>>> to images produced through volume rendering. I am unsure of how to adapt all
>>> the usual techniques I know for projections etc. gievn the different
>>> technique for drawing the images. I am using a constant colorbar so if
>>> anyone can suggest a post-processing way of adding to created images that
>>> would work too!
>>>
>>> I am using the following to create my volume rendered images:
>>>     for i, snapshot in enumerate(cam.rotation(2.*na.pi, n_angles)):
>>>         print "     drawing:  dump =", numb, "angle =",  i, "shot=",shott
>>>         if cam._mpi_get_rank() == 0:
>>>             write_bitmap(snapshot, frame_template % (sys.argv[-1],shott))
>>>             pl.draw()
>>>             shott = shott+1
>>>
>>> Many thanks,
>>>
>>> Libby
>>>
>>> --
>>> Elizabeth Harper-Clark MA MSci
>>> PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT
>>> Sciences and Engineering Coordinator, Teaching Assistants' Training
>>> Program, UofT
>>>
>>> www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark>
>>> h-clark at cita.utoronto.ca
>>> Astronomy office phone: +1-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
>>
>>
>
>
> --
> 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
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20110105/14c73330/attachment.htm>


More information about the yt-users mailing list