awips2/docs/edex/derived-parameters.md
2017-06-13 10:44:01 -06:00

5.8 KiB

AWIPS will calculate derived parameters using XML file definitions which refer to Python scripts where the actual calculations take place. If and when there is an effort to verify calculated fields in Unidata Python packages, these should come in handy (along with the GEMPAK FORTRAN routines).

For gridded data there are three directories to know which contain derived parm XML files: awips2 com.raytheon.uf.common.dataplugin.grid https://github.com/Unidata/awips2/tree/unidata_16.1.5/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/derivedParameters/definitions awips2-core com.raytheon.uf.common.derivparam https://github.com/Unidata/awips2-core/tree/unidata_16.1.4/common/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions awips2-core com.raytheon.uf.common.derivparam.python https://github.com/Unidata/awips2-core/tree/unidata_16.1.4/common/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters Notice the first is from the "awips2" repo, while the others are from "awips2-core", so if a derived parm field is not showing up in directory listings or search results for one repo, be sure to search the other.

Helicity, for example, from https://github.com/Unidata/awips2-core/blob/unidata_16.1.4/common/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/Heli.xml

The first three blocks act as constructors allowing for different levels to be passed the main method, which determines the calculation to be performed. Name="Heli" here refers to the derivedParameter file Heli.py located at https://github.com/Unidata/awips2-core/blob/unidata_16.1.4/common/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/Heli.py

So three fields will be passed to Heli.py for the calculation (uWStk, vWStk, RM5), but each is a derived paremeter as well, with its own xml (let's go deeper). uWStk https://github.com/Unidata/awips2/blob/unidata_16.1.5/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/derivedParameters/definitions/uStk.xml

vWStk https://github.com/Unidata/awips2/blob/unidata_16.1.5/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/derivedParameters/definitions/vStk.xml RM5 https://github.com/Unidata/awips2/blob/unidata_16.1.5/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/derivedParameters/definitions/RM5.xml

Finally, the Python function Heli.py https://github.com/Unidata/awips2-core/blob/unidata_16.1.4/common/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/Heli.py

def execute(uStk, vStk, RM5):

umot,vmot = RM5
u1 = uStk[0]
v1 = vStk[0]
u2 = uStk[-1]
v2 = vStk[-1]
# First do our motion, lower bulk shear computation.
hptr = (v2-v1)*umot+(u1-u2)*vmot
for i in range(1, len(uStk)):
    u1 = uStk[i-1]
    v1 = vStk[i-1]
    u2 = uStk[i]
    v2 = vStk[i]
    hptr += u2*v1-u1*v2
return hptr

from the three files above, we can see that the grid fields used to calculate helicity are uW, vW, USTM, and VSTM, with the last two used by yet another function Vector.py: https://github.com/Unidata/awips2-core/blob/unidata_16.1.4/common/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/Vector.py

Method names like Or, Union, and Alias that don't map to Python functions are handled by Java in com.raytheon.uf.common.derivparam (see https://github.com/Unidata/awips2-core/tree/unidata_16.1.4/common/com.raytheon.uf.common.derivparam/src/com/raytheon/uf/common/derivparam/tree)