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

Fix poor assumptions in lfc() logic #1023

Merged
merged 3 commits into from Apr 10, 2019

Conversation

sgdecker
Copy link
Contributor

This PR depends on #1022 and addresses additional problems with the lfc() calculation. Parts of the logic in lfc() 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:
lfc_bug
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:
lfc_bug5
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.

@@ -5,6 +5,7 @@

from __future__ import division

from math import isclose
Copy link
Contributor

Choose a reason for hiding this comment

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

python 3.5+ here :)

Copy link
Member

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.

😁

Copy link
Member

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!

Copy link
Member

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.

@dopplershift
Copy link
Member

Ok, now that #1022 is in, can you rebase so we can see what this looks like?

@dopplershift dopplershift added Area: Calc Pertains to calculations Type: Bug Something is not working like it should labels Apr 9, 2019
@dopplershift dopplershift added this to the 0.11 milestone Apr 9, 2019
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.
@sgdecker
Copy link
Contributor Author

OK, I think it is in good shape now.

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.

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.

@dopplershift dopplershift merged commit 16f68a9 into Unidata:master Apr 10, 2019
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: Bug Something is not working like it should
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants