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:

- 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.
- Make sure your WRF ouput is loaded.
- In the
`Field Selector`

panel, select`Formulas`

from the Data Sources panel and click`Grids→Layer Wind Shear`

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

- For field
`u`

, expand the data source for your WRF output and select the`3D grid→u_wind @ isobaric`

field. - For field
`v`

, expand the data source for your WRF output and select the`3D grid→v_wind @ isobaric`

field. - For field
`z`

, expand the data source for your WRF output and select the`3D grid→Geopotential_height @ isobaric`

field. - Click the
`Create Display`

button.

Adding Custom Functions

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):

- Remove all displays.
- From the main menu, click on
`Edit→Formulas→Create Formula`

. The`Formula Editor`

window should appear. - Enter the
`Name`

of your forumla:`windspeed`

(one word - no space). - Enter the mathematical formula definition in the
`Formula`

entry field using the Jython syntax. The formula issqrt(u**2 + v**2)

- Open the
`Advanced`

panel in the Formula Editor. - Enter a
`Description`

for the forumula:`wind speed from u and v`

. - For
`Group`

enter`Workshop`

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