ajdawson / windspharm

A Python library for spherical harmonic computations on vector winds.
http://ajdawson.github.io/windspharm
MIT License
82 stars 36 forks source link

prep_data on np.float arrays raises exception #89

Closed t0medwards closed 6 years ago

t0medwards commented 6 years ago

I am having problems when converting numpy float arrays using the prep_data command with recent versions of windpharm. The following code:

import numpy as np
from windspharm.tools import prep_data

u = np.zeros([180,360], np.float)

uwnd, uwnd_info = prep_data(u, 'yx')

Causes the following error:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    uwnd, uwnd_info = prep_data(u, 'yx')
  File "/home/tom/tmp/windpharm-bug/two/windspharm/lib/windspharm/tools.py", line 98, in prep_data
    pdata, intshape = __reshape(pdata)
  File "/home/tom/tmp/windpharm-bug/two/windspharm/lib/windspharm/tools.py", line 46, in __reshape
    out = d.reshape(d.shape[:2] + (np.prod(d.shape[2:]),))
TypeError: 'numpy.float64' object cannot be interpreted as an index

With numpy 1.12 and 1.13 (anaconda nomkl installs).

However, I may be using prep_data incorrectly?

ajdawson commented 6 years ago

Closed by #90.