3.13.0.3 WRF Analysis: Formulas
Formulas in the IDV
Built-in Forumlas

The IDV is not only a data visualization package, but it is also a powerful analysis package. The IDV has several built-in functions that range from very simple operations, such as negating a field (that is, changing the sign of all of the values on the grid), to more complex operations, such as computing the horizontal flux divergence field. These built-in operations can be accessed through the `Field Selector` tab by clicking on `Forumlas` in the Data Sources side panel.

As an example, let's use a formula to compute the 500 mb - 850 mb wind speed shear:

1. Clear any existing displays by clicking the red and white eraser symbol found just below the Main Menu bar on either the Dashboard to Main View window.
3. In the `Field Selector` panel, select `Formulas` from the Data Sources panel and click , then select `Color Filled Contour Plan View` as the display and click `Create Display`.

The IDV will prompt you for which levels you would like to calculate the shear between (top and bottom), and the fields (u, v, and z) needed to compute the layer shear.

1. For field `u`, expand the data source for your WRF output and select the field.
2. For field `v`, expand the data source for your WRF output and select the field.
3. For field `z`, expand the data source for your WRF output and select the field.
4. Click the `Create Display` button.

Formulas in the IDV are defined using Jython, which means extending the analysis capabilities of the IDV can be done by adding new Jython functions (much easier than editing the IDV Java code!) As an example, let's add a Jython formula to compute wind speed (although one already exists, it's still a good exercise to go through):

1. Remove all displays.
2. From the main menu, click on . The `Formula Editor` window should appear.
3. Enter the `Name` of your forumla: `windspeed` (one word - no space).
4. Enter the mathematical formula definition in the `Formula` entry field using the Jython syntax. The formula is
`sqrt(u**2 + v**2)`
5. Open the `Advanced` panel in the Formula Editor.
6. Enter a `Description` for the forumula: `wind speed from u and v`.
7. For `Group` enter `Workshop`.
8. Now we will tell the IDV which display types our formula can use:
• In the `Displays` section, click the `Use selected` radio button, then click the `All off` button.
• Expand the `Plan Views` category and check the `Contour Plan View` option. Also, expand the `3D Surface` category and check the `Isosurface` option.
9. Click on `Add Formula`.

A new item `wind speed from u and v` should appear in the `Field Selector` window's `Fields` panel, under `Workshop`. We've only touched on the basics of the use of formulas in the IDV - please see the IDV Formulas for more details.