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
KINDEX
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
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
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
Is it possible to do in automatically? Many thanks.
Cloudy
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
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
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
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
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
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
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
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