Skip to content

Error when using xarray.DataArray and gsw.geo_strf_dyn_height with numpy < 1.23 #95

@rcaneill

Description

@rcaneill

When using xarray.DataArray as inputs for gsw.geo_strf_dyn_height, the result is only NaNs.
Do you have any idea why this is so?

Example

import gsw
a = [0,1,2]
print(gsw.geo_strf_dyn_height(a, a, a))

Outputs

array([ 0.        , -0.27061522, -0.53269375])

Using xarray

import gsw
import xarray as xr
da = xr.DataArray([0,1,2])
print(gsw.geo_strf_dyn_height(da, da, da))

Outputs

array([nan, nan, nan])

With numpy 1.22.2 I also get a FutureWarning:

/home/romain/.cache/pypoetry/virtualenvs/gsw-xarray-NsrEXKiZ-py3.8/lib/python3.8/site-packages/gsw/geostrophy.py:83: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  pgood = p[ind][igood]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions