-
Notifications
You must be signed in to change notification settings - Fork 422
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
Use parcel prof for parcel mix ratio #3751
base: main
Are you sure you want to change the base?
Use parcel prof for parcel mix ratio #3751
Conversation
Calculating the parcel mixing ratio on a pseudo-adiabat should definitely be done using the parcel temperature rather than the environment temperature.
|
@DWesl - Thanks for the quick response about the parcel temperature bug, and the thoughts about negative mixing ratios. I meant to say I plugged in 10hPa and 295K to
Sorry about the confusion. I agree that addressing negative mixing ratio could be handled in another PR, and is beyond the scope of this PR. Perhaps the |
Yeah, it seems like there's a legitimate bug fix here in regards to the virtual temperature correction. It looks like the changes you made for some reason include the changes in #3735; can you rebase onto main? I'm also guessing there are some tests that will need (likely minor) updates to pass with this change. On the mixing ratio, yes the problem with the example in question is that the saturation vapor pressure is 26 hPa at 295 K, which is quite a bit larger than the given total pressure of 10 hPa; essentially at this point you can't actually condense because liquid water is boiling. I suspect the correct behavior in this case would be to return NaN (though I'd like to check some other tools), but that should be a separate PR. |
I will try to rebase onto main. I am not sure how the other PR got in there. |
3c7485f
to
4f47867
Compare
There's still 1 extra commit (b55773f) on there. |
Hmmm. I am not sure what I am doing wrong. I don't know why that other commit keeps sneaking in there. It seems to be some kind of automated commit from "dependabot"? |
Looks like I failed again. |
I can do the rebase and force push it to your branch if you like. Then just need test updates before merging in. |
Use parcel temperature (parcel_profile) instead of environmental temperature (temperature) for parcel_mixing_ratio derivation. This makes a difference if you have a very high temperature point in the stratosphere.
5118865
to
ff39c3a
Compare
Thanks for the offer! I just did it. Think I just needed to eat some lunch first. |
Could I make the changes to the expected cape in the test files and work them into the PR? |
Yes, please make the test changes in this PR so that all the tests pass before we merge the changes. |
I fixed the expected cape and cin in all the tests except
This test was designed around issue #902. |
When deriving the parcel mixing ratio profile, don't use the environmental profile. An earlier commit fixed above the LCL. This commit fixes below the LCL. Since the function uses pressure[0], temperature[0], and dewpoint[0] to get the lcl, use pressure[0] and dewpoint[0] to get the saturation mixing ratio of the parcel below the LCL.
I was so focused on fixing the parcel mixing ratio high in the atmosphere that I forgot to consider below the LCL. The code also needs to use the parcel profile below the LCL, not the environmental profile. So I changed the logic below the LCL to use pressure[0] and dewpoint[0] to derive the parcel mixing ratio below the LCL (not environment pressure and dew point).
|
That seems correct as well. I'll see if I can find some values for that one sounding. |
In the spirit of the other changes, should the LCL be derived using |
@DWesl I'm not convinced that's correct. The use of virtual temperature in CAPE is to get a complete look at the buoyancy of a rising air parcel relative to the environment; virtual temperature accounts for the contribution of water vapor to that buoyancy. There is no buoyancy process in the LCL calculation, but rather you're lifting a parcel, assuming adiabatic dry processes with conserved contained water vapor (constant mixing ratio). That is, the LCL denotes the height at which condensation (and a shift to moist pseudo adiabatic processes) occurs--overall buoyancy plays no in determining that height, only the starting temperature and moisture content. |
I suspect you have more experience with such things than I do, so if you say Mixed-Layer CAPE and Most-Unstable CAPE use the environment temperature and mixing ratio at the surface to find where the mixed-layer or most-unstable parcel would form clouds, or that this function is entirely unsuited for MLCAPE/MUCAPE, I will concede to your experience. (With #3572 not in yet, MLCAPE will be tricky, and MUCAPE may well be covered by applying the current process to soundings starting on successive levels above the surface and taking the largest). |
Just to clear things up, I think @DWesl was suggesting that we use parcel temperature, as opposed to environment temperature, to calculate LCL (nothing to do with virtual temperature). |
@ahijevyc Thanks for that, I got completely confused. My bad. 🐑 |
I think using parcel_profile is more correct in support of arbitrary parcel profiles. In practice, when using profiles calculated by However, this reveals to me that our parcel LCL > parcel mixing ratio > parcel virtual temperature and our LFC calculations assume that the parcel and the environment have the same initial moisture properties, even though I don't think that's something we're going to fix cleanly in time for this release, so I will open a new issue. In the mean time, feel free to go ahead and update the LCL input to be the parcel profile temperature. Stick around for future discussion 😅 |
The PR still fails one of the tests. It fails the "sensitive sounding", which was finely tuned to have a small but non-zero CAPE when the LCL was included in the profile and zero CAPE when the LCL was not included. With the PR change the CAPE is zero when the LCL is included. I'm not sure this test is needed if we always include the LCL. |
This is a bug fix.
In
metpy.calc.thermo.cape_cin
, the parcel mixing ratio above the LCL is derived from the environment temperaturetemperature
instead of the parcel temperatureparcel_profile
.I noted this because this led to a negative mixing ratio when I worked with a test case sounding for CM1.
input_sounding_jordan_allmean: West Indies annual mean (Jordan, 1958, J. Meteor., p. 91)
in which the top level of the sounding is 40000 m, the potential temperature is 1095 K, the pressure is 10 hPa, and the temperature is 295 K. Plugging in 10 hPa and 295 K to
metpy.calc.thermo.mixing_ratio
, one gets a mixing ratio of -1.006 kg/kg. A negative mixing ratio is unphysical. Now I'm not sure if the mixing_ratio function has a bug also, but the problem goes away when you replace the environment temperaturetemperature
with the much lower parcel temperatureparcel_profile
here link to code.Description Of Changes
Change
temperature
toparcel_profile
.