The first thing you want to figure out before you do any calculations is what 'kind' of CAPE you want. Do you want Surface Based CAPE, Mixed Layer CAPE, Most Unstable CAPE, low level 3km CAPE? You might have to research each type if you're unsure what is what, but generally speaking you *probably* want either Surface Based or Mixed Layer.

Surface Based CAPE is the most generic type, which is what you would calculate if you didn't know what the differences between these were. It's lifting the surface parcel from the ground (assuming that if a storm fires, it's going to draw in air from the surface) and lifting that. Mixed Layer mixes the lowest 100mb temperature and dew point (basically just averaging the temperatures in the lowest 100mb of the surface) and raising the parcel from the surface given your mixed temperatures of dew point and temperature before lifting the parcel.

Now that you have your parcel trace you want, here's the process for calculating CAPE.

Its first best to visualize the area of CAPE so you know what you're going to end up getting... CAPE Is the area bounded by the parcel temperature on the right side of the sounding and the environmental temperature on the to the 'left' or cold side of the parcel temperature between the LFC (Level of Free Convection) where the parcel first becomes warmer than the environmental temperature as the parcel comes up from the ground) and the EL (Equilibrium Level) which is generally up around 300-200mb where the parcel becomes colder than the environmental temperature again... this is also where the tropopause is -- anvil level.

If there are several layers of inversion it's possible to get nominal amounts of CAPE below the LFC in spots, and this too could be calculated into your total CAPE value if you wanted to go that far. Generally speaking this isn't something you need to worry about if you're calculating this by hand. If you're writing a program to calculate it for you, then its easy to include this by simply looking for any areas where the parcel temp is warmer than the environmental temp from the surface on up.

Now the calculation itself is actually pretty easy... It's an integral or iteration of area between the LFC and EL. So you're just adding up the space in that area. The way to do it is by taking blocks of space (the more, smaller blocks you do the more accurate this is going to be), and adding up the value you get using the following equation:

CAPE(i) = (((ParcelTempInKelvin) - (EnvironmentalTempAtThisLevelInKelvin)) / (EnvironmentalTempInKelvin)) * (HeightOfLayer1inMeters - HeightOfLayer2inMeters)

Then at the end of that you add up your array of CAPE(i) values and take that total amount and multiply it by 9.8.

This is then your total CAPE in J/KG.

Quick example using 25mb "chunks" of the atmosphere but only doing a small portion of it for example purposes. This hypothetical CAPE area only goes a matter of 50mb deep... which isn't realistic for whole atmosphere CAPE, but it works for showing you how it works...

We start out with an imaginary LFC of 400mb, and end at an imaginary EL of 350mb. Here are the numbers we're going to use for our example:

400mb    Temp:    -19.1c    Parcel:    -8.2c      Height:    7605
375mb    Temp:    -22.9c    Parcel:    -11.2c     Height:     8082
350mb    Temp:    -26.9c    Parcel:    -14.6c    Height:    8583

CAPE in the range from 400mb to 375mb:

All of the temperatures are at 400mb converted to Kelvin by taking the temperature in degrees C and adding 273.15. Note that the "HeightOfLayer1inMeters" is the height of the next layer (375mb) and the "HeightOfLayer2inMeters" is the height of the this layer (400mb).

CAPE1 = (((264) - (253)) / (253)) * (8082- 7605) (you should get a total of CAPE(i) = 20

Then you do another calculation for the next layer... 375mb to 350mb

CAPE2 = (((261) - (250)) / (250)) * (8583- 8082) (you should get a total of CAPE(i) = 22

Now we add up CAPE1 and CAPE2 to get 42.

This is all we want for our example (we're not going to do like 25 levels like we might normally do).. and we finish it off by taking 42 and multiplying it by 9.8 to get 411.6.

Which means from 400mb to 350mb there is 411 joules of CAPE.