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

Check that pressure decreases monotonically in parcel calculations #1967

Merged
merged 4 commits into from
Aug 2, 2021

Conversation

sgdecker
Copy link
Contributor

This commit addresses #1339 using ideas from #1654. A new exception
is added on the theory that parcel calculations are complicated, so
there may be other problems with input soundings (extreme
supersaturation?) that might want to be flagged in the future.


Description Of Changes

See commit message above.

Checklist

@sgdecker
Copy link
Contributor Author

Hmm, will need to see if the xarray tutorial actually uses a non-monotonic sounding.

@sgdecker
Copy link
Contributor Author

Yes, the xarray tutorial is calling mpcalc.surface_based_cape_cin with an "upside-down" sounding. Please advise whether I should fix that as part of this pull request or open a new issue. Longer term, I suppose the most robust interface would allow the profile pressure to be monotonic (decreasing or increasing), and flip the direction when needed automatically.

@sgdecker
Copy link
Contributor Author

I went ahead and fixed the tutorial. Will be pushing the revisions shortly.

This commit addresses Unidata#1339 using ideas from Unidata#1654.  A new exception
is added on the theory that parcel calculations are complicated, so
there may be other problems with input soundings (extreme
supersaturation?) that might want to be flagged in the future.
The xarray tutorial called mpcalc.surface_based_cape_cin with a
dataset where the pressure increased with increasing index, but the
function requires the other order.  Here, we correct the order.

In addition, the latitude is changed to a location where the CAPE is
nonzero.
@sgdecker
Copy link
Contributor Author

Codacy doesn't like the added file to define the exception. I can make adjustments as needed, just let me know.

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.

This is in really good shape, thanks for taking this on. Codacy is flagging the new file as increasing complexity (😆 ok, whatever), I think its actual problem is some unused variables in the new test. I commented there, let's see if that change quiets Codacy. Otherwise, only "major" change is to make the new exception part of the public API by importing in metpy.calc.__init__.

tutorials/xarray_tutorial.py Show resolved Hide resolved
tests/calc/test_thermo.py Outdated Show resolved Hide resolved
tests/calc/test_thermo.py Outdated Show resolved Hide resolved
src/metpy/calc/exceptions.py Outdated Show resolved Hide resolved
@dopplershift dopplershift added Area: Calc Pertains to calculations Type: Enhancement Enhancement to existing functionality labels Jul 23, 2021
@dopplershift dopplershift added this to the 1.1.0 milestone Jul 23, 2021
@dopplershift dopplershift merged commit c74b471 into Unidata:main Aug 2, 2021
@dopplershift
Copy link
Member

Thanks for knocking this out @sgdecker !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Considerations for high-res soundings
2 participants