[Numpy-discussion] recfunctions.stack_arrays

Ryan May rmay31@gmail....
Tue Jan 27 13:37:51 CST 2009


Pierre (or anyone else who cares to chime in),

I'm using stack_arrays to combine data from two different files into a single
array.  In one of these files, the data from one entire record comes back
missing, which, thanks to your recent change, ends up having a boolean dtype.
There is actual data for this same field in the 2nd file, so it ends up having
the dtype of float64.  When I try to combine the two arrays, I end up with the
following traceback:

    data = stack_arrays((old_data, data))
  File "/home/rmay/.local/lib64/python2.5/site-packages/metpy/cbook.py", line
260, in stack_arrays
    output = ma.masked_all((np.sum(nrecords),), newdescr)
  File "/home/rmay/.local/lib64/python2.5/site-packages/numpy/ma/extras.py", line
79, in masked_all
    a = masked_array(np.empty(shape, dtype),
ValueError: two fields with the same name

Which is unsurprising.  Do you think there is any reasonable way to get
stack_arrays() to find a common dtype for fields with the same name?  Or another
suggestion on how to approach this?  If you think coercing one/both of the fields
to a common dtype is the way to go, just point me to a function that could figure
out the dtype and I'll try to put together a patch.

Thanks,

Ryan

P.S.  Thanks so much for your work on putting those utility functions in
recfunctions.py  It makes it so much easier to have these functions available in
the library itself rather than needing to reinvent the wheel over and over.

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


More information about the Numpy-discussion mailing list