Thanks Alex. This seems to be the easiest way to approach the problem. However, for the sake of reproducibility, I am looking for a way to interface to one of the common fortran routines for the task. Your suggested approach will require some sort of interpolation at the very least to make the estimation number of data point insensitive. Putting this in my TODO list.
On Sat, Mar 29, 2014 at 7:56 PM, Alex Goodman <alex.good...@colostate.edu>wrote: > You can easily visualize the CAPE and CIN with matplotlib using > fill_between() on the environmental and parcel temperature curves. As for > actually calculating it though, I don't know of a way to do it directly > from matplotlib. There are probably several other python packages out there > that can, but I am not familiar with them. In any case, why not just write > your own function for calculating the CAPE and CIN? It is a bit surprising > that this functionality isn't be included in the SkewT package, but since > you can use it to get the parcel temperature curve, you should be able to > calculate the CAPE and CIN rather easily by simply discretizing their > respective formulas. Here's a rough example: > > import numpy as np > cape = 9.8 * np.sum(dz * (Tp - T) / T) > > Where Tp and T are the parcel and environmental temperature arrays > respectively, and dz are the height differences between layers. You would > of course need to perform the sum from the LFC to EL for CAPE, so the > arrays would have to to be subsetted. With numpy the easiest way to do this > is with fancy indexing, eg: > > levs = (z >= LFC) & (z <= EL) > Tp = Tp[levs] > T = T[levs] > where z is your array of heights (or pressure levels). > > Does this help? > > Alex > > > On Sat, Mar 29, 2014 at 4:32 PM, Gökhan Sever <gokhanse...@gmail.com>wrote: > >> Hello, >> >> Lately, I am working on plotting sounding profiles on a SkewT/LogP >> diagram. The SkewT package which is located at >> https://github.com/tchubb/SkewT has a nice feature to lift a parcel on >> dry/moist adiabats. This is very useful to demonstrate the regions of CIN >> and CAPE overlaid with the full sounding. >> >> However, the package misses these diagnostic calculations. This is the >> only step holding me back to use Python only (migrating from NCL) for my >> plotting tasks. I am aware that these calculations are usually performed >> in fortran. Are there any routines wrapped in Python to calculate CAPE and >> CIN parameters? Any suggestions or comments would be really appreciated. >> >> -- >> Gökhan >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > > -- > Alex Goodman > Graduate Research Assistant > Department of Atmospheric Science > Colorado State University > -- Gökhan
------------------------------------------------------------------------------
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users