[SciPy-User] numpy.squeeze not squeezing
Bruce Ford
bruce at clearscienceinc.com
Wed Sep 30 18:15:22 EDT 2009
print type(swh1) #gave <type 'numpy.ndarray'>
print type(swh) #gave <type 'netCDF4.Variable'>
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
bruce at clearscienceinc.com
bruce.w.ford.ctr at navy.smil.mil
http://www.ClearScienceInc.com
Phone/Fax: 904-379-9704
8241 Parkridge Circle N.
Jacksonville, FL 32211
Skype: bruce.w.ford
Google Talk: fordbw at gmail.com
On Wed, Sep 30, 2009 at 6:05 PM, Robert Kern <robert.kern at gmail.com> wrote:
> On Wed, Sep 30, 2009 at 17:03, Bruce Ford <bruce at clearscienceinc.com> wrote:
>> Robert, thanks for responding. Your response makes me things
>> something in my array is preventing squeeze form working correctly.
>> Here's a cleaned up version of my script:
>>
>>
>> #!/usr/local/env python
>> from mpl_toolkits.basemap import Basemap
>> import numpy as np #used to preform simple math functions on data
>> from netCDF4 import Dataset
>> #decide which file to open
>> year = 1995
>> month = "%02d" % 5
>>
>> #Set up file names
>> filename = "/data/ww3/NetCDF/3_hourly/ww3."+str(year)+str(month)+ ".nc"
>> opennc = Dataset(filename, mode="r")
>>
>> swh = opennc.variables['sig_wav_ht']
>> print swh.shape #gives (248,1,181,360)
>> swh1 = np.squeeze(swh)
>>
>> print 'SWH shape: ', swh1.shape #gives ()
>
> print type(swh1)
>
> I'm not sure that swh1 is actually an ndarray. It might be a different
> class that masquerades as a numpy array.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-User
mailing list