MetPy "interpolate_to_isosurface" results in "IndexError: Unlabeled multi-dimensional array cannot be used for indexing: pressure_level" #3819
Unanswered
beuraieon-a
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, newbie Python programmer here... I need help on the usage of MetPy's
interpolate_to_isosurface
function.My goal was to interpolate a gridded meteorological dataset, such that its vertical coordinate is transformed from pressure-based (isobaric surfaces in hPa) to altitude-based (in kilometers above mean sea level). I used a NetCDF file containing gridded meteorological data from ERA5 that I preprocessed such that I end up with the following variables of concern:
WVF_u
,WVF_v
andWVF_w
(zonal, meridional and vertical components of isobaric water vapor flux), andheight
(height above sea level of isobaric surface). All of these variables have the dimensionspressure_level
(vertical coordinate in terms of pressure level, i.e. pressure of isobaric surface, in hPa),latitude
andlongitude
. I want to do the interpolation forWVF_u
,WVF_v
andWVF_w
; whileheight
serves to provide the necessary altitude data for the interpolation. The NetCDF file is here.So far, my unfinished script looks like this:
But this results in an
IndexError: Unlabeled multi-dimensional array cannot be used for indexing: pressure_level
, with this error message:And this confuses me because, upon checking, the variables
WVF_u
,WVF_v
,WVF_w
andheight
are proper xarray DataArrays and that their dimensions and coordinates are defined. Example, forheight
:And for
WVF_u
:Even a simple script such as the following would result in the same
IndexError: Unlabeled multi-dimensional array cannot be used for indexing: pressure_level
:Is there something wrong with the NetCDF file, or with how I manipulated the dataset? Or I am using the
interpolate_to_isosurface
function improperly? Or is there a better way to do this?Beta Was this translation helpful? Give feedback.
All reactions