Previous: Changing Bundle Properties Next: Tag Index Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting

7.1.8 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.

Subsetting in Jython
This is an example of how to programatically create a data source, find a data choice, create a DataSelection for subsetting and do a stride, spatial subset, time selection and level.
def exampleSubsetting():
	#Create a data source
	dataSource = makeDataSource("ruc.nc")

	#Find the temperature dataChoice
	dataChoice = dataSource.findDataChoice("T")

	#create a DataSelection
	dataSelection = DataSelection()

	#Set both the x and y stride on it
	dataSelection.setXYStride(5);

        #Note: you can also do:
        #dataSelection.setXStride(5);
        #dataSelection.setYStride(5);
        #dataSelection.setZStride(5);

	#Set the spatial bounds. This takes north, west, south, east
	dataSelection.setBounds(45,-120,40,-100)

	#create a list of times and add an integer 0 to it
	#This says use the first time
	times = ArrayList()
	times.add(Integer(0))
	dataSelection.setTimes(times)

        #Set the level to use. For example, this is the 5th level (they are 0 based)
        dataSelection.setLevel(Integer(4))

	#Now get the data and create the display
	tempField = dataSource.getData(dataChoice, None,dataSelection,None)
	createDisplay('planviewcolor', tempField,"T")
subset.py

 


Previous: Changing Bundle Properties Next: Tag Index Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting