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

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 <gokhansever@…287…> 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

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.goodman@…4442…> 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

–

Gökhan

On Sat, Mar 29, 2014 at 4:32 PM, Gökhan Sever <gokhansever@…287…> 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

–

As for the rest of the two suggestions: [https://github.com/pmarshwx/SHARPpy/tree/gui

https://github.com/PyAOS/aoslib]

there doesn’t seem be routines included for CAPE and CIN calculations.

I am working on idealized orographic precipitation simulations in WRF that will hopefully be presented in the Mountain Meteorology conference in August. Perhaps I am extra cautious, but I need a good control especially on CAPE calculation (independent of data-points, being able to specify where to lift the parcel and specify mixed layer depth etc.).

This could be a good subject to discuss on the coming SciPy conference. The abstract deadline is tomorrow. I might join if I can get some funding to attend the conference. Is there any symposium planned for atmospheric science people? Thanks again.

## ···

On Sat, Mar 29, 2014 at 6:32 PM, Gökhan Sever <gokhansever@…287…> 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

–

Gökhan