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

Improve isentropic interpolation #3324

Merged
merged 2 commits into from
Dec 15, 2023
Merged

Conversation

dopplershift
Copy link
Member

Description Of Changes

This addresses some limitations in isentropic_interpolation and isentropic_interpolation_as_dataset identified in #3315, which is trying to use the functionality on WRF output natively on a sigma vertical coordinate.

  • Don't blindly assume that the vertical coordinate is pressure in isentropic_interpolation_as_dataset but check the dimensionality and issue a more useful ValueError
  • Tweak the handling of pressure in isentropic_interpolation to work with a passed-in 3D pressure field, since internally we were already using a 3D pressure field
  • Allow isentropic_interpolation_as_dataset to work with data on non-pressure coordinates by accepting a pressure kw-only argument in this case, which overrides using the vertical coordinate.

Checklist

Internally we were already using 3D pressure, so just avoid needless
broadcasting outside the 1D pressure case. This paves the way for direct
interpolation from e.g. sigma coords. See Unidata#3315.
@dopplershift dopplershift added Type: Bug Something is not working like it should Type: Enhancement Enhancement to existing functionality Area: Plots Pertains to producing plots Area: Calc Pertains to calculations Area: Gridding Pertains to calculating values on a regular grid Area: Xarray Pertains to xarray integration labels Dec 14, 2023
@dopplershift dopplershift added this to the December 2023 milestone Dec 14, 2023
@dopplershift dopplershift requested a review from a team as a code owner December 14, 2023 23:19
@dopplershift dopplershift requested review from dcamron and removed request for a team December 14, 2023 23:19
isentropic_interpolation_as_dataset was blindly assuming that the
vertical coordinate was pressure, resulting in a confusing unit error
when calling isentropic_interpolation. Check the dimensionality and
raise a clearer ValueError when this is not the case. Also allow users
to manually pass (as a keyword) an appropriate pressure array to use instead.
Copy link
Member

@dcamron dcamron left a comment

Choose a reason for hiding this comment

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

Got to a really helpful place here, I think. Looks good!

@dcamron dcamron merged commit 5081dc1 into Unidata:main Dec 15, 2023
34 checks passed
@dopplershift dopplershift deleted the fix-3315 branch December 15, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Area: Gridding Pertains to calculating values on a regular grid Area: Plots Pertains to producing plots Area: Xarray Pertains to xarray integration Type: Bug Something is not working like it should Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Units issue with isentropic_interpolation_as_dataset and CONUS404 data
2 participants