-
Notifications
You must be signed in to change notification settings - Fork 443
Description
In trying to implement a robust CAPE/CIN calculation, we've discovered that the complication really should lie in the parcel path calculation. Currently the parcel path calculation function call looks like this:
def parcel_profile(pressure, temperature, dewpt)Only the starting temperature and dew point are needed and the pressures at which the path is wanted. Ideally we need to implement the following options:
Virtual Temperature
- Use the correction
- Don't use the correction
Moist Adiabats
- pseudoadiabats
- pseudoadiabats with ice
- reversible pseudoadiabats
- reversible pseudoadiabats with ice
The virtual temperature should be implemented now. A hook for adiabats can be put in, but only have the option of pseudoadiabats for now.
Here's a simple sketch of what a path assumptions object could look like:
class parcelPathAssumptions(object):
"""
Holds assumptions made about the parcel path during calculations.
"""
__slots__ = ('use_virtual_temperature')
def __init__(self):
self.use_virtual_temperature = True
self.moist_adiabat = 'pseudoadiabatic'The function would then use the default options from __init__.
def parcel_profile(pressure, temperature, dewpt, assumptions=parcelPathAssumptions()):The biggest complication I see here is that for the virtual temperature correction (assuming I understand it correctly) we'll be needing the full dew point profile from the sounding. Then parcel_profile could be modified something like:
# Do virtual temperature correction
if assumptions.use_virtual_temperature:
Rv = mpcalc.mixing_ratio(mpcalc.saturation_vapor_pressure(dewpt_prof), pressure)
t1 = mpcalc.virtual_temperature(t1, Rv)
Rv = mpcalc.mixing_ratio(mpcalc.saturation_vapor_pressure(t2), pressure)
t2 = mpcalc.virtual_temperature(t2, Rv)Discussion on how to tweak the API on this would be useful. I don't like the idea of dewpt_prof being a kwarg really, but it doesn't belong in the assumptions object either.