[python #LKP-606313]: Metpy Cape Cin monotonically increasing
- Subject: [python #LKP-606313]: Metpy Cape Cin monotonically increasing
- Date: Thu, 07 May 2020 11:54:00 -0600
Hello! Thanks for your question.
Without seeing your data, we've seen this issue recently with high resolution
soundings which can have instances of pressure decreasing as the measurements
are taken. If this happens then the underlying integration code will fail, as
it assumes these values of the independent variable to increase/decrease
monotonically. So, this t is referring to the input variable to this code, not
necessarily temperature. See this github issue to keep up-to-date or contribute
to the discussion on the issue as we plan to handle it:
In the mean time, we suggest either filtering the data with something like
SciPy's `scipy.signal.medfilt` median filter
or otherwise preprocessing your profile to address any regions of decreasing
pressure. Here is some example code for using medfilt:
import metpy.calc as mpcalc
from metpy.units import units
from scipy.signal import medfilt
smooth_pres = medfilt(pres_masked, 5) * units.hPa
# medfilt may have over-filtered our first few pressures values, so we will
smooth_press[:2] = press[:2]
mpcalc.surface_based_cape_cin(smooth_press, temp, td)
I hope this helps! If not, please be sure to reach out again and if you can
attach or point to the data you are trying to apply these calculations on that
will help us out. Thanks again for the question.
All the best,
> I would like to calculate CAPE for numerous vertical profiles that I have.
> I try this:
> temp_masked*units.degC, dp_masked*units.degC)
> And get the error:
> line 235, in odeint
> raise ValueError("The values in t must be monotonically increasing "
> ValueError: The values in t must be monotonically increasing or
> monotonically decreasing; repeated values are allowed.
> Is this saying that the temperature must be monotonically increasing? This
> is real vertical profile and so there is variability, with some values
> increasing. Have you any suggestions on how to get this to work?
Ticket ID: LKP-606313
Department: Support Python
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.