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
Fix poor assumptions in lfc() logic #1023
Conversation
metpy/calc/thermo.py
Outdated
@@ -5,6 +5,7 @@ | |||
|
|||
from __future__ import division | |||
|
|||
from math import isclose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python 3.5+ here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's good because our docs say:
We support Python >= 3.6 and currently support Python 2.7.
😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, Python 2.7. DOH!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My world will be so much better when Python 2.7 is just a distant memory.
Ok, now that #1022 is in, can you rebase so we can see what this looks like? |
Currently, some of the logic in the lfc() function assumes a surface parcel is being considered, but that is no longer necessarily the case. This commit addresses the two places where a surface parcel has been assumed. First, when looking for intersections, the code assumed the first point of the parcel trajectory had an identical temperature to the environment. This is only true if a surface-based parcel is being used. Second, the LCL of the parcel is computed using surface values. This, too, is not appropriate if the parcel is not a surface parcel. The lfc_ml2 testcase was giving wrong results because of the second problem. This commit addresses both problems and corrects the associated testcase.
This test gives 990 hPa for the LFC (the LCL value in this case) if the fix to the find_intersections() call is not present.
c6a05ad
to
a319cb9
Compare
OK, I think it is in good shape now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fixes make sense. I'm not wild about adding the dewpt_start
parameter, but I don't have an easy alternative. What we probably need eventually is a good way to represent a parcel or profiles or something. What you've done works.
This PR depends on #1022 and addresses additional problems with the
lfc()
calculation. Parts of the logic inlfc()
assume the parcel for which the LFC is desired is the surface parcel. One test case is updated, and another is added to show the differences.The first example:
Because the current code uses the surface parcel when computing the LCL internally, the LFC is determined to be over 1000 mb. However, the LCL of the mixed parcel is under 1000 mb. With this PR, the correct value of 982 mb for the LFC (and LCL) is returned.
The second example:
Without the fixes to the find_intersections() logic that this PR includes, the LFC is computed to be 990 mb (which is the LCL), but the actual value is 983 mb, as indicated in the new test.