Convert numpy.ndarray into "normal" array

Piet van Oostrum piet at cs.uu.nl
Fri Apr 24 19:30:27 EDT 2009


>>>>> Johannes Bauer <dfnsonfsduifb at gmx.de> (JB) wrote:

>JB> Hi group,
>JB> I'm confused, kind of. The application I'm writing currently reads data
>JB> from a FITS file and should display it on a gtk window. So far I have:

>JB> [...]
>JB> pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
>JB> pb_pixels = pb.get_pixels_array()

>JB> print(type(fits_pixels))
>JB> print(type(pb_pixels))

>JB> which gives

>JB> <type 'numpy.ndarray'>
>JB> <type 'array'>
[...]
>JB> So now I've been trying to somehow convert the array in a fast manner,
>JB> but just couldn't do it. What exactly is "array" anyways? I know
>JB> "array.array", but that's something completely different, right? Does
>JB> anyone have hints on how to go do this?

I think it is array from Numeric, because the releases of pygtk are
still built with Numeric instead of numpy. In SVN it has been converted
to use Numpy instead, so then type(pb_pixels) would also be
'numpy.ndarray' and no conversion would be necessary. 

So try to install the version from SVN.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list