Open anissa111 opened 11 months ago
Adding this comment here so as not to create a new issue for this function. Line 515 of interp_hybrid_to_pressure()
is
output = output.transpose(*dims).assign_coords(coords)
One of the entries in the dictionary coords
will be the (key, value) pair {'plev' : new_levels}
. If the user-supplied new_levels
is not a Numpy array, but rather an xarray DataArray
with dimension named lev_dim
(an easy mistake to make by the caller, in my opinion), then line 515 fails with the error:
ValueError: cannot add coordinates with new dimensions to a DataArray
The source of the error is immediately clear, but is caused when lev_dim
is not 'plev'
.
I think that to avoid this, there should be an assertion early in the function ensuring that new_levels
is a Numpy array and not a DataArray
.
@jhollowed, thanks for noting this!
I believe it's mentioned in the docstring, but agree it'd be good to make this more robust.
Also, thanks to Kenton Wu for bringing these issues to our attention!