Previous: Formulas Next: Derived Data Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Data Analysis

7.3.1 Jython Methods
The IDV allows you to write your own Jython methods using the Jython Library editor. From the main menu bar, select the Edit->Formulas->Jython Library menu item.
images/JythonLibraryEditor.gif
The Jython Library window has a tree view on the left that shows the different (categorized) library files available. The files that are listed under "Local Jython" are those that you can edit. The System files cannot be edited. On the right is the edit pane for the selected file.

There is documentation available for the System Jython Libraries.


1.0 FAQ

1.1. What is Jython?

A. Jython is a Java implementation of the Python language. It is used within the IDV for data analysis. Complex routines can be written in the IDV Jython editor and called from the IDV Formulas.


1.2. How do I learn to write Jython?

A. There are a number of books available on the language as well as a number of web sites:


1.3. How does Jython work with my data in the IDV?

A. The IDV uses the VisAD package as as an underlying data model. There is a VisAD/Jython Tutorial available. There is also an IDV Workshop Section on writing Jython.


1.4. I don't like editing in this editor. How do I use my own editor?

A. You can use this edit window or, optionally you can define the path to an external text editor (e.g., emacs, vi, etc.) through the main User Preferences. Once defined there will be a File menu entry in the Jython Library "Edit in External Editor". The file that is being edited is monitored by the IDV and, when it is saved by the external editor is loaded and checked for correct syntax. When the external editor exits the file is reinserted into the internal IDV editor.

When you save the file thought the external editor or the IDV editor the code is checked for valid Jython syntax; If there is an error, a pop-up window will appear with an error message. The actual error will also be printed in the console window running the IDV. Correct the error and try to save again.


1.5. Creating/Removing library files

A. To create a new file uses the File→New Jython Library... menu. To remove the currently displayed library file use the File→Remove Library menu.


1.6. Calling procedures from formulas

A. When creating a formula with the Formula Editor you can call any routines you have defined in the Jython Library Simply enter the procedure name in the formula, with appropriate arguments, if any. For example a formula might be "convertCToF(atemp)". When evaluating the formula for display, this will call the routine that you define in the Jython Library.


1.7. Create a formula from my procedure

A. Right click on a procedure definition within the IDV editor window and choose Make formula for .... This is a convenience that brings up the Formula creation dialog with a call to that procedure.

Also, as another convenience you can right click to show the Insert Procedure Call menu. This lists all of the currently defined procedures in the other Jython libraries.


 


Previous: Formulas Next: Derived Data Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Data Analysis