## KINDEX

How do I...?
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

### KINDEX

A user asked me about calculating a Kindex from a grib file. The equation is

def Kindex(T850,T500,Td850,T700,Td700):
"""T850 = Temperature @ isobaric of 850 mb
T500 = Temperature @ isobaric of 500 mb
Td850 = Dewpoint depression @ 850 mb
T700 = Temperature @ isobaric 700 mb
Td700 = Dewpoint depression @ 700 mb
"""

Kindex=(T850-T500)+Td850-(T700-Td700)
return Kindex

When trying to use this formula, an error about a manifold dimension is return. Also, is there a way to force the automatic selection of a field so that user would not have to pick each field every time they use the formula?

I sent the grib file as an attachment in the support form.

Thanks, Joleen
Attachments
error.log
Last edited by joleenf on Thu Jun 09, 2011 8:04 pm, edited 1 time in total.
Rick
Posts: 404
Joined: Fri Jan 16, 2009 8:20 pm

### Re: KINDEX

Hi Joleen,

You need to make a 2D slice prior to doing the arithmetic. Use this function on each of your variables:

make2D(slice)

I created a foreground formula and it works correctly:
(make2D(T850)-make2D(T500))+make2D(Td850)-(make2D(T700)-make2D(Td700))

I'll have to get back to you on specifying specific parameters - so you don't have to manually choose.

Rick
Cloudy
Posts: 25
Joined: Tue Mar 02, 2010 12:15 am

### Re: KINDEX

I use the KIndex formula and works fine, but do I select the variables manually.
Is it possible to do in automatically? Many thanks.
Cloudy
jayh
Posts: 415
Joined: Thu Jan 15, 2009 10:34 pm

### Re: KINDEX

Hi Cloudy-

I'd recommend using a bundle to use a formula automatically. For example, I displayed the 12 hour forecast K Index from the latest GFS model run, added an enhancement, then saved the session in a bundle (without the data). When I reload this bundle, the current 12 hour forecasted K Index is displayed from the latest GFS model run without having to choose each variable manually.

If you want to use this in background scripting, you can use the openBundle function to call the K Index bundle. Currently there is not a way to individually load variables from files into formulas in the scripting code. This is something we still aim to do in the future.

Thanks, Jay
McIDAS User Services
ghansham
Posts: 170
Joined: Thu Nov 11, 2010 5:40 pm

### Re: KINDEX

Hi Cloudy
I think you need to to create a derived variable for that.
That will allow to automatically create a derived variable whenever
you load a dataset with all those variables. I can send a sample snippet.

Another important thing I want to point out.
The geogrid datasource loads all the levels in the
visad data object. This is at times a wasteful way.
For example if I want to display temperature for
four pressure levels it will load all.pressure levels four times.
Another limitation is I can load contiguous level with an exception to
z level striding. But what if I have to load first fourth fifth and ninth pressure
level. It is currently not possible.
I had to write my own plugin to do away with these issues.
regards
ghansham
mhiley
Posts: 90
Joined: Mon Jan 23, 2012 10:22 pm

### Re: KINDEX

Hi ghansham,

Would you be willing to post your plugin? We're developing a scripting function that uses geogrid datasource to load netcdf/hdf/grib grids so I'd be very grateful to be able to take a look at your code

No worries if you feel it's not ready to share of course... thanks!

Mike
ghansham
Posts: 170
Joined: Thu Nov 11, 2010 5:40 pm

### Re: KINDEX

Hi Mike Sir
Its really nice to hear from you.
I developed that plugin as I had to generate images
of temperature profiles of selected pressure levels and I
found the stated limitations. It is pretty much developed.
I am using jython with IDV in server mode to generate
those images. Its is good shape. I can share the core part
which is changed. The full part may not be relevant
as it is written for a specific datasource. Will upload on
ftp server and inform you
regards
ghansham