Add downdraft CAPE calculation
Closes #728 by adding a downdraft CAPE calculation. As it stands there are still some things to discuss/clear up:
- [x] How should we let folks specify custom bounds for the integration? A custom parcel?
- [ ] Need to add tests
The main difficulty currently is that this does not appear to compare well with the SPC DCAPE values. Looking at their results I'm not sure there isn't a bug on one or both ends. Take the two soundings below. To me one should have positive DCAPE, the other negative as in one the parcel path is to the left of the environmental temperature, and it is to the right in the other. Also, to get values anywhere near as large as these I have to integrate the entire lower 400 hPa, not the surface up to the minimum theta-e in the lowest 400 hPa. Any comments welcome as we need to nail this down before testing and merging.

Ok working on this some more there are some implementation details to think about. The kwargs bottom and top make sense when using the default parcel. But when using a parcel kwarg that is currently a tuple of pressure and temperature at which we want to start a parcel. It would then go down the moist adiabat to the surface. Then the bottom and top_pressure arguments are ambiguous as to their utilization. Maybe we only take the profile as a complete profile that the user wants? Thoughts @dopplershift?
So the RAOB program also calculates DCAPE and can do so in three different ways. It appears to do it via a lowest depth (e.g., 6 km) through either a density weighted average (most accurate), average wet-bulb, or coldest wet bulb (least accurate) [accuracy info from RAOB program]. Attached are two images using the coldest wet bulb temperature over the lowest 6 km from RAOB for the two times in the above examples from OUN for 17 April 2018 (ignore the month - its the same data). This gives different values from the NSHARP values given in the above figures - likely a different method.

Speaking of the NWS method (is this the NSHARP way?), I found the following PDF that talks about the DCAPE process (see slide number 6 DCAPE_Web.pdf).
To summarize the process:
- From 700 mb (or anywhere 500-700 mb), determine the LCL.
- Follow moist adiabat to surface from LCL found in 1.
- DCAPE is the negative area (positive value) between the downdraft moist adiabat and the temperature profile.
Are there any updates to the status of this, or what needs to be done before this can get merged? This would be very helpful for a couple ongoing projects in the research group I'm in.
@jthielen So we just need some help validating that what we're doing is actually correct. A scholarly source to cite for the method plus some good values to double check our work are what's needed.
I'm working in a proyect and I need the calculation of the Downdraft CAPE (DCAPE) and I'm testing this function and the other mentioned here. My surprise is that I found diferent results if I compared whith the data of the sounding.
I choose this sounding (https://www.spc.noaa.gov/exper/soundings/22081900_OBS/) and I realized the calculus whith the function downdraft_cape described in this post and the function created by jillianndufort and described in https://github.com/jillianndufort/Calculation-for-DCAPE
I found different results for the same data and differents of the result DCAPE in the sounding.
1.- This function downdraft_cape: dcape = 117.76574757857342 delta_degree_Celsius * joule / kilogram 2.- The jillianndofort's function: {'DD_method1': {'metpy': 41165.230535591356, 'Magnus': 0.0, 'Wexler': 0.0, 'Buck': 0.0}, 'DD_method2': {'metpy': 473702.59788943676, 'Magnus': 2.241814634518002, 'Wexler': 2.2423655314996664, 'Buck': 2.242472299362524}, 'DD_method3': {'metpy': -71.44700746827606, 'Magnus': 26.86878193998087, 'Wexler': nan, 'Buck': 29.057112541161665}} 3.- Sounding: DCAPE = 983 j/KG
I don't understand what is happening because I think that the functions are OK in the sense of the programming.
I attached the data file so you can do the tests.
One last comment, in this downdraft cape function, I found a problem in the dcape.to('J/kg') conversion giving me an error:
DimensionalityError: Cannot convert from 'delta_degree_Celsius * joule / kilogram' ([length] ** 2 * [temperature] / [time] ** 2) to 'joule / kilogram' ([length] ** 2 / [time] ** 2)
Ignoring this, the result is the commented. I have the same problem when I check this function whith the test_dcape_defaults. Whithout to('J/kg') it works fine.
Could you help me?
datos.txt
Thanks for kicking the tires on this calculation. Given that unit error, the implementation of the calculation is definitely not correct. Whether that's causing the difference in values, though, is unclear. Unfortunately, I don't have any cycles at the moment to dig into this.
I also think that they are two independent problems: the problem with the units and the calculus of the DCAPE. I'll try to check this these days, before my holidays. I think that it doesn't seem easy to solve. If someone can have a look, will be welcome. Thanks a lot.
Superseded by #3120.