K index

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
Sim
Posts: 9
Joined: Thu Jun 09, 2011 2:17 am

K index

Post by Sim »

Hello,

I have a grib file with temperatures and dew point temperatures at various levels. I try to plot K-index by creating new formula, but error came out as in the attached figure. May I know how to solve it or how to calculate K-index in another way? Thanks.

K-index = (Temp at 850hPa) - (Temp at 500hPa) + (Dew point at 850hPa) - ( (Temp at 700hPa - Dew point at 700hPa) )

Regards,
Sim
Attachments
K-index.PNG
K-index.PNG (11.16 KiB) Viewed 2569 times
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: K index

Post by joleenf »

Hi Sim,

I think this is the same problem that Rick Kohrs addressed in this post.

viewtopic.php?f=14&t=872&hilit=kindex

You will need to make a 2D slice first. Please see the link.

Hopefully that helps,
Joleen
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: K index

Post by tomw »

Hi Sim...

While I do not have the formula you are trying to use, the error message is a symptom of this: when you slice out a 2D grid from a 3D grid, the data are indeed 2D...however, the spatial domain is still 3D so that the "level" information is still available. In order to do the type of computation you want, you must then "flatten" those sliced grids into a simple 2D domain.

For example, this formula achieves what you want:

Code: Select all

make2D(getSliceAtLevel(T, 850)) - make2D(getSliceAtLevel(T, 500)) + make2D(getSliceAtLevel(TD,850)) - 
( make2D(getSliceAtLevel(T,700)) - make2D(getSliceAtLevel(TD,700)) ) - 273.16

The "getSliceAtLevel()" function will slice out the 2D grid, but keeps the 3D spatial domain. You then must use the "make2D()" function to convert that to a simple 2D grid so you can then do the arithmetic operations.

Hope that helps.

tom
User avatar
Sim
Posts: 9
Joined: Thu Jun 09, 2011 2:17 am

Re: K index

Post by Sim »

Thank you very much ^^
Post Reply