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

Curious issue creating WindVector from 2D arrays #108

Open antiantimatter opened 5 years ago

antiantimatter commented 5 years ago

Hi, I'm new to windspharm but already excited to use a package that seems like it will be extremely useful in the future.

However, I'm having a little trouble loading up my input fields as a WindVector object.

surfwind = VectorWind(uwindj, vwindj, gridtype='gaussian')

uwindj and vwindj are, usually, (17, 72, 96) numpy arrays, with dimensions ('lev', 'lat', 'lon')

When I either manually swap the axes to be in the order ('lat', 'lon', 'lev') as the documentation suggests, or use the prep_data method on the arrays - in an attempt to comply with the proper ordering for VectorWind -

uwindj, uwnd_info = prep_data(uwindj, 'zyx')
vwindj, vwnd_info = prep_data(vwindj, 'zyx')

ValueError: invalid input dimensions



However, it is happy to read in the vector with the 'lev' dimension *first*. 

I tried to get around this by just dealing with 2D fields, i.e. creating a new VectorWind instance for 17 separate (72, 96) arrays.

But windspharm refused to create a VectorWind instance from a 2D (72, 96) array altogether, although the docs suggest that it can work with 2D arrays. 

Am I missing something obvious out? 

Thanks. 
Yefee commented 5 years ago

It may be related to #77

ajdawson commented 5 years ago

Windspharm is not complaining about the order of the dimensions, but the values. Gaussian grids are precisely defined, and yours apparently does not match what is expected of a Gaussian grid with 72 latitudes. Is it definitely a Gaussian grid?