Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit redefinition help for /s #2994

Merged
merged 1 commit into from
Apr 7, 2023
Merged

Conversation

kgoebber
Copy link
Collaborator

@kgoebber kgoebber commented Apr 6, 2023

Description Of Changes

The issue has arisen with older model output data where the stored vorticity unit is /s, which will then fail on any action with a unit with the error pint.errors.DefinitionSyntaxError: missing unary operator "/". This solution adds a small fix in the units module to replace /s with s**-1. An example dataset that this occurs with is older GFS data available through the RDA archive.

Minimum example to produce error:

from datetime import datetime

from metpy.units import units
import xarray as xr

ds = xr.open_dataset('https://rda.ucar.edu/thredds/dodsC/aggregations/g/ds083.2/1/TP')

ds.Absolute_vorticity_isobaric.metpy.sel(time=datetime(2000, 1, 4, 12), vertical=500*units.hPa).metpy.quantify()

@kgoebber kgoebber force-pushed the alias_vort_units branch 2 times, most recently from 7b14c28 to 514a8f8 Compare April 7, 2023 02:00
@kgoebber kgoebber marked this pull request as ready for review April 7, 2023 02:00
@kgoebber kgoebber requested a review from a team as a code owner April 7, 2023 02:00
@kgoebber kgoebber requested review from dopplershift and removed request for a team April 7, 2023 02:00
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing it up! I think I have a somewhat simpler solution for the pre-processor.

src/metpy/units.py Outdated Show resolved Hide resolved
@dopplershift dopplershift added Area: Units Pertains to unit information Type: Enhancement Enhancement to existing functionality labels Apr 7, 2023
@dopplershift dopplershift added this to the April 2023 milestone Apr 7, 2023
@dopplershift dopplershift enabled auto-merge April 7, 2023 18:19
@dopplershift dopplershift merged commit 2fdb28b into Unidata:main Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Units Pertains to unit information Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants