[SciPy-User] numpy.squeeze not squeezing

Bruce Ford bruce@clearscienceinc....
Thu Oct 1 13:18:59 CDT 2009


Ryan's solution works great.  Finally...a break!

Bruce
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
bruce@clearscienceinc.com



On Wed, Sep 30, 2009 at 9:25 PM, Ryan May <rmay31@gmail.com> wrote:
> On Wed, Sep 30, 2009 at 5:21 PM, Robert Kern <robert.kern@gmail.com> wrote:
>> 2009/9/30 Bruce Ford <bruce@clearscienceinc.com>:
>>> print type(swh1)  #gave <type 'numpy.ndarray'>
>>>
>>> print type(swh)  #gave <type 'netCDF4.Variable'>
>>
>> Ah, yes. The latter is what I meant.
>>
>> Yup, my diagnosis is correct. np.squeeze() is interpreting swh as a
>> scalar (or rank 0 array) with dtype=object rather than an array. You
>> will have to get a real ndarray from the Variable. I am not familiar
>> with the netcdf4 API, so you will have to refer to its documentation
>> on how to do that. It won't be as simple as np.asarray(swh), I am
>> afraid.
>
> If it's anything like the other NetCDF bindings, it's just:
>
>   swh_arr = swh[:]
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
> Sent from Norman, Oklahoma, United States
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list