[SciPy-user] Conversion of scipy array to numarray array

Lo Marcus marcus_mklo at hotmail.com
Sat Feb 11 07:18:45 CST 2006


I am trying to convert a scipy array to numarray, without success.  What I 
do is the following:

data = scipy.asarray(pyfits.getdata('j6mi10021_crj.fits', 'sci'))
nadata = numarray.asarray(data)

>>> import scipy
>>> import numarray
>>> import pyfits
>>> data = scipy.asarray(pyfits.getdata('j6mi10021_crj.fits', 'sci'))
>>> nadata = numarray.asarray(data)
>>> print data
[[ 22.37952614  10.05145359  21.6661377  ...,  11.43289948   5.52833033
   17.19585037]
 [ 24.8036232   -6.39581585  12.05591202 ..., -10.39195728   3.03895354
    8.70327473]
 [  5.82899857  14.48854351  11.53882504 ...,  12.11074352  20.28095627
   20.44524193]
 ..., 
 [ 19.73381042  28.00988197  25.39971733 ...,  -1.82318735   2.51478434
   10.70707226]
 [ 24.23790932  -2.87376475  18.93963051 ...,   7.07922268   3.27009034
   10.84160519]
 [  1.5277524   19.00962639  26.82912445 ...,   3.01001763  12.66541958
    5.03601742]]
>>> print nadata
[[  2.20320337e+03  -2.62657490e+01   3.32307458e+00 ...,
    2.63358146e-14   9.39821272e-26   6.01923401e-23]
 [ -2.55308349e+11  -6.42477458e-35   5.38966492e-36 ...,
    2.49919068e+32   1.51550048e-05  -2.54168066e-21]
 [  1.50687839e-14   5.28608336e-27   2.39567241e-34 ...,
   -3.26330855e-22   2.26241264e+23  -8.08608425e+16]
 ..., 
 [ -1.95813585e+15   3.63466777e-02  -3.78610938e-20 ...,
    2.07603975e-07   1.84727460e-03   7.39564714e-13]
 [  1.13161571e-01  -4.70435547e+02   1.19427208e+18 ...,
   -9.09748823e+37   4.47014387e-14   1.47328838e-05]
 [  2.09204790e+22  -8.79733216e-06   2.50890015e-31 ...,
    1.11300791e-18  -1.62988577e-29   2.06619783e-30]]

data is an 1024 x 1024 float32 array.  It doesn't have any problem in small 
array, as I have tested it by hand.  And if I deliberately use float64 
array, there is no problem.

I have installed the latest numarray(1.5.1) and 
scipy(0.4.5.1598)/numpy(0.9.5.2055) package.

Marcus Lo




More information about the SciPy-user mailing list