Previous: Jython and VisAD Next: Scripting with IDV Table of contents Frames User guide
Unidata IDV Workshop for version 3.0u2 > Advanced Topics > Diagnostic Functions: Formulas and Jython

4.2.5 Derived Data and Formulas
The IDV uses the Formula infrastructure to also automatically create derived products from loaded data sources. These derived products show up in the list of Fields under a "Derived" tab.

  1. Let's look at the Horizontal Advection formula
    • From the Edit->Formulas->Edit Formulas->Grids menu, select the Horizontal Advection (from %N1% & %N2%) item.
    • The formula looks like:
              DerivedGridFactory.createHorizontalAdvection(scalar_parameter, D1[label=U Component], D2[label=V Component])
              
      The D1 and D2 fields can be automatically bound to specific parameters and scalar_parameter is a field that the user will be prompted for.
    • In the Description, the %N1% and %N2% fields correspond to the names of the bound parameters in the order listed in the formula (not the number after the D]
    • Select the Derived tab.
    • This formula is used as both an end user formula and as a way to automatically create derived quantities. It uses predefined parameter group called u_and_v to find variables in a dataset that can be used to fill in for the D1 and D2 parameters.
    • Click the Cancel button to close the window.
    • Select the Formulas Data Source.
    • Select the System->Horizontal Advection (from %N1% & %N2%) field, select Contour Plan View display and click Create Display. Notice how the formula relates to the dialog that pops up.
    • Click the Cancel button to close the window.
  2. Display Temperature Advection from the derived formula list
    • Load in the ETA 1998-06-29 00:00 data source. Show popup
    • Expand the 3D grid->Derived tab in the Fields panel of the Field Selector and select the Horizontal Advection (from GridRelative_u & GridRelative_v) field. Hold the mouse over the label to look at the tooltip which shows the formula for this field. Notice that the %N1% and %N2% parameters in the formula description have been filled in.
    • Select the Contour Plan View display and click Create Display.
    • When prompted for the scalar parameter, select the 3D grid->temperature field and click OK.
  3. Now, let's create a system formula for Temperature advection that will show up when a grid is loaded.
    • Select the Formulas Data Source.
    • Right click on the System->Horizontal Advection (from %N1% & %N2%) field and select Copy Formula.
      • Change the Name to tadv.
      • Change the Formula to DerivedGridFactory.createHorizontalAdvection(D1, D2, D3).
      • Change the Description to Temperature Advection (from %N1%, %N2% & %N3%).
      • Change the Group to Custom Derived.
      • Select the Derived tab.
      • Clear out the u_and_v under Parameter Groups.
      • Look at the list of available groups. We could use the group created in the prior exercise using the Parameter Groups Editor but for now we will enter the parameter names to match on directly.
      • In the Parameters input area, right click and select the Temperature, U component and V components (one at a time) from the Aliases->Group #1 menu available from the button or type TEMP, UREL, VREL.
      • Click the Change Formula button. The Formulas data source now has a My Derived category in the Fields panel.
    • Right click on the NCEP Model Data data source and select Reload->Data to refresh the list of parameters. Derived data selections are only created when the Data Source is loaded or reloaded.
    • Select the My Derived->Temperature Advection (from T, GridRelative_u & GridRelative_v) parameter and the Contour Plan View display and then click the Create Display button.
    • Compare the two displays.
    • Remove the displays, but not the data.
    • From the Formulas data source, right click on the My Derived->Temperature Advection (from %N1%, %N2% & %N3%) field and select Edit->Formula.
    • Remove the Group for the formula and click Change Formula.
    • Reload the NCEP Model Data ETA datasource.
    • Where did the derived formula go this time?
    • Use the Files chooser to load in the sample_eta_grid.nc file.
    • Does this have a temperature advection field?
  4. Let's just look at the derived.xml file in:

    /home/idv/.unidata/idv/DefaultIdv

    to see what the formula looks like.

 


Previous: Jython and VisAD Next: Scripting with IDV Table of contents Frames User guide
Unidata IDV Workshop for version 3.0u2 > Advanced Topics > Diagnostic Functions: Formulas and Jython