# [Numpy-discussion] first recarray steps

Vincent Schut schut@sarvision...
Wed May 21 02:03:10 CDT 2008

```Robert Kern wrote:
> On Wed, May 21, 2008 at 1:48 AM, Vincent Schut <schut@sarvision.nl> wrote:
>> Christopher Barker wrote:
>
>>> Also, if you image data is rgb, usually, that's a (width, height, 3)
>>> array: rgbrgbrgbrgb... in memory. If you have a (3, width, height)
>>> array, then that's rrrrrrr....gggggggg......bbbbbbbb. Some image libs
>>> may give you that, I'm not sure.
>> My data is. In fact, this is a simplification of my situation; I'm
>> processing satellite data, which usually has more (and other) bands than
>> just rgb. But the data is definitely in shape (bands, y, x).
>
> I don't think record arrays will help you much, then. Individual
> records need to be contiguous (bar padding). You can't interleave
> them.
>
Hmm, that was just what I was wondering about, when reading Stefan's
reply. So in fact, recarrays aren't just another way to view some data,
no matter in what shape it is.

So his solution:
x.T.reshape((-1,x.shape[0])).view(dt).reshape(x.shape[1:]).T won't work,
than. Or, at least, won't give me a view on my original dat, but would
give me a recarray with a copy of my data.

I guess I was misled by this text on the recarray wiki page:

"We would like to represent a small colour image. The image is two
pixels high and two pixels wide. Each pixel has a red, green and blue
colour component, which is represented by a 32-bit floating point number
between 0 and 1.

Intuitively, we could represent the image as a 3x2x2 array, where the
first dimension represents the color, and the last two the pixel
positions, i.e. "

Note the "3x2x2", which suggested imho that this would work with an
image with (bands,y,x) shape, not with (x,y,bands) shape. But I
understand that it's not shape, but internal representation in memory
(contiguous or not, C/Fortran, etc) that matters?

I know I can change the wiki text, but I'm afraid I still don't feel
confident on this matter...

```