[Go to Previous] [Go to Next]


Jython Methods

McIDAS-V allows you to write your own Jython methods using the Jython Library editor. From the main menu bar, select the Tools->Formulas->Jython Library menu item in the Main Display window. Alternatively, the Jython Library can be brought up with Alt+J.

Image 1: Jython Libraries Window
Image 1: Jython Libraries Window

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 can be edited. Any libraries added via a plugin will be listed under Local Jython. The naming of the items in the list will be based on the name of the plugin (e.g. From: VIIRS_Formulas1.5.jar). The System files should not be edited by the user, and you should contact the McIDAS Help Desk for assistance if you wish to modify them. On the right is the edit panel for the selected file.

There is documentation available for the System Jython Libraries.

The Jython libraries window includes syntax highlighting, which colors different parts of the text in different colors. For example, strings will be pink and comments specified with a pound symbol (#) will be green.

The Jython Library contains a search feature at the bottom of the window that will search for text in the currently viewed library.

Image 2: Jython Library Search Menu
Image 2: Jython Library Search Menu

There are various keyboard shortcuts that can be used with this Find menu:

Menus

The File menu has these unique items:


FAQ

Q. What is Jython?

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

Q. 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:

Q. How does Jython work with my data in McIDAS-V?

A. McIDAS-V uses the VisAD package as as an underlying data model. There is a VisAD/Jython Tutorial available.

Q. Creating/Removing library files

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

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

Q. Create a formula from my procedure

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

As another convenience you can also right-click on the Formula: field of the Formula Editor to show the Insert Procedure Call menu. This lists all of the currently defined procedures in the other Jython libraries.

Q. Why do I see "TypeError: object is not callable" messages when scripting?

A. This error occurs when a user gives a variable the same name as a reserved keyword or function. For a list of reserved Jython functions, please see Built-in Functions. Variable names should be unique.

[Go to Previous] [Go to Next]