Create new variables in Python

VAPOR supports deriving new variables from the variables in the VDC.  We shall illustrate this by deriving a variable named "UVW" which will be equal to the magnitude of the vector with components (U,V,W), where U, V, and W are three-dimensional variables in the VDC.

From the VAPOR Edit menu, click the entry "Edit Python Program defining a new variable".  This will launch the VAPOR Python Editor as follows:

 

Click the "Add 3D Variable" button and specify "UVW" as the 3D output variable name.

Then check the three input 3D variables U, V, and W.

Finally, type the following line into the text input area:

     UVW = numpy.sqrt(U*U+V*V+W*W)

Note:  numpy is the "Numerical Python" library, which supports many Python array operations.  Here we are applying the numpy square root operator "sqrt"  to the array defined by adding the squares of the three wind velocity components.

After typing in the above expression for UVW, click the "Test" button.  You should see a "Successful test" message.  Then click the "Apply" button, and the new variable UVW has been defined.

 

This is only a very simple example of the ways in which Python can be used to derive variables in VAPOR.  For an in-depth discussion of these capabilities, refer to the VAPOR Python Guide .  VAPOR provides several modules for performing analysis with Python, including Python functions that are useful in analyzing and visualizing WRF-ARW data.  These include cloud-top temperature, radar reflectivity, equivalent potential temperature, relative humidity, potential vorticity, horizontal wind shear, sea-level pressure, dewpoint temperature, and temperature in degrees Kelvin.