[Numpy-discussion] ragged array implimentation

Christopher Barker Chris.Barker@noaa....
Mon Mar 7 12:42:00 CST 2011


On 3/7/11 9:33 AM, Francesc Alted wrote:
> A Monday 07 March 2011 18:28:11 Christopher Barker escrigué:
>> I'm setting out to write some code to access and work with ragged
>> arrays stored in netcdf files. It dawned on me that ragged arrays
>> are not all that uncommon, so I'm wondering if any of you have any
>> code you've developed that I could learn-from borrow from, etc.

> A list of numpy arrays would not be enough?  Or you want something more
> specific?

Maybe that would, but in mapping to the netcdf data model, I'm thinking 
more like a big 1-d numpy array, with a way to index into it. Also, that 
would allow you to do some math with the arrays, if the broad casting 
made sense, anyway.

But now that you've entered the conversation, does HDF and/or pytables 
have a standard way of dealing with this?

On 3/7/11 9:37 AM, Jeff Whitaker wrote:
> Chris:  The netcdf4-python modules reads netcdf vlen arrays

arethose a netcdf4 feature? So far, I'm still workign with netcdf3 -- 
though this could be a compelling reason to move on!

We've talked about this some on the CF list, and I don't think anyone 
brought that up.

> and returns
> numpy object arrays, where the elements of the object arrays are
> themselves 1d numpy arrays. I don't think there is any other way to do
> it.  In your example, the 'ragged' array would be a 1d numpy array with
> dtype='O', and the individual elements would be 1d numpy arrays with
> dtype=int.  Of course, these arrays are very awkward to deal with and
> operations will be slow.

Depends some of the operations, but yes.

That still may be the best option, but I'm exploring others.

is a "vlen array" stored contiguously in netcdf?

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the NumPy-Discussion mailing list