This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Greetings! So unfortunately, in the code sample you sent you're using xarray's own `.sel()` method, which doesn't support units and apparently silently discards them. So the calls to `.sel()` you're making are requesting the 500 and 1000 levels in the native coordinates of the data, which is Pa. That means you're actually selecting the 5 hPa and 10 hPa levels. To properly use the unit support, you need to use MetPy's accessor, as in (note the `.metpy`): u_500 = ds['u-component_of_wind_isobaric'].metpy.sel(isobaric=1000*units.hPa) Alternatively, you can just make sure you request the 100000 Pa surface directly: u_500 = ds['u-component_of_wind_isobaric'].sel(isobaric=100000) I know this is confusing, it's unfortunate that we don't have a way to signal that the units are silently discarded.1 I'm not sure from what you sent if this will resolve all of your issues, but it should definitely help results be more like what you expect I think. Ryan > Hello > > Thanks very much for your work on metpy and support. > > I'm having trouble with calculating the bulk wind difference > (1000hPa-500hPa) for gridded GFS data. > > This is the simple calculation I'm doing: > > [image: image.png] > [image: image.png] > The following plot of wind barbs shows that something is wrong (red=500hPa > winds, black=1000hPa and green is the difference): > > [image: image.png] > The vector differences are not correct. Could you please help me with this > problem? Ticket Details =================== Ticket ID: KPU-861209 Department: Support Python Priority: Low Status: Closed =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.