Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting
7.1.6 Scripting with Jython
Jython and ISL
The IDV also supports writing scripts in Jython. This means that
you can create a Jython script that includes calls to special
methods (defined below), and also does "normal" Jython things.
Please Note: Some of the APIs described below will likely change
in the coming months!
To start with, here is an example Python script.
Scripting in Jython allows for flexibility and a more
"programming" flavor for IDV scripting, though you can still
do much of the functionality using Jython that you can do using ISL.
The benefit of the ISL is that it is more declarative and requires
(hopefully) less knowledge of programming.
To run the IDV with a Jython script, do:
runIDV -islfile your-script.py
Below, each of the available methods in the Jython
scripting interface will be described.
- setOffScreen(value)
If you want to do your rendering in the "background", then
the value should be set to 1 (true). If you want
the window(s) to pop-up, set the value to 0 (false).
- setDebug(value)
To enable some debug during your development, set the value
to 1 (true).
- loadBundle(filename, data_files)
Loads a bundle with the given filename. You may
also provide a dictionary of datasource:file items
similar to the ISL setfiles.
- pause()
Pause until all displays have been created. This is useful
between loadBundle() and writeImage() for example.
- writeImage(filename, parameters, quality)
Write out an image file. The filename should have the
file extension of the type of image file you want to write (.jpg,
.gif, .png).
The parameters variable is a string
that contains any parameter information (see the
ISL description of parameters)
It is in the form:
"clip north=40; matte background=green top=20; resize height=300 width=300"
The quality value is 1.0 for the best, down to 0.0 for,
well, no quality at all...
- writeMovie(filename, parameters)
Write out the display as a movie. The filename should have the
file extension of the type of image file you want to write (.mov)
The parameters variable is a string
that contains any parameter information (see the
ISL description of parameters)
It is in the form:
"clip north=40; matte background=green top=20; resize height=300 width=300"
- An alternative way to get an Image, manipulate it and then
save it:
- getImage()
- resizeImage(image, width, height)
- matteImage(image, color, top, bottom, left, right)
- df = findDisplayControl(id) then "dc.getImage()"
- writeImageToFile(image, filename)
Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting