[SciPy-user] Data types

Tony Mannucci Tony.Mannucci at jpl.nasa.gov
Mon Mar 6 00:49:30 CST 2006

Dear Scipy community,

I cannot find a clear statement as to allowable data types, and how 
these are specified. I am trying to read in an array using 
read_array. One of the arguments of the function is "atype", to 
specify the dtype of the output array. I cannot figure out what 
format the tuple atype is in.

For example, the following does not work:

import scipy.io.array_import as ARRIN
data = ARRIN.read_array('filename',columns=(0,2),atype=('d','d'))

Yet, if I omit the atype argument, and I do data.dtype.char, I get 
'd'. In the read_array doc, it suggests using a "typecode". I don't 
know what are the allowable typecodes, or the type of a typecode 
(string? number? etc), and cannot seem to locate this from the Numpy 

If Numpy is like Numeric, then, according to "Python In A Nutshell", 
the array objects contain a single type. So, I cannot use several 
values, I would specify only one value for atype. This seems to 
differ from the scipy online documentation, suggesting atype could be 
a tuple. I realize the functionality is evolving.

Along these lines, the following works:
data = ARRIN.read_array('filename',columns=(0,2),atype='d')

and appears to give a double precision array (as evidenced from 
data.dtype.char = 'd'). However, using a few other strings for atype 
does not work, e.g. 'I', or 'L', etc. Yet, these strings were found 
from Table 2.1 in the Numpy book.

Finally, the following does not seem to work:
data = ARRIN.read_array('filename',columns=(2))

so reading a single column appears to cause a problem. The following DOES work:
data = ARRIN.read_array('filename',columns=(0,2))

Perhaps I have an incorrect version of the scipy/Numpy modules. I am 
working on OS X 10.4. Thanks!


Tony Mannucci
Supervisor, Ionospheric and Atmospheric Remote Sensing Group
  Mail-Stop 138-308,                     Tel > (818) 354-1699
  Jet Propulsion Laboratory,              Fax > (818) 393-5115
  California Institute of Technology,     Email > Tony.Mannucci at jpl.nasa.gov
  4800 Oak Grove Drive,                   http://genesis.jpl.nasa.gov
  Pasadena, CA 91109

More information about the SciPy-user mailing list