Skip to content
Snippets Groups Projects
util.py 721 B
Newer Older
Christoph Fischer's avatar
Christoph Fischer committed
from enstools.feature.util.enstools_utils import get_vertical_dim, get_longitude_dim, get_latitude_dim
# calc dt and dt^2 (first and second derivative)
def calc_adv(cv, u, v):

Christoph Fischer's avatar
Christoph Fischer committed
    lon_str = get_longitude_dim(cv)
    lat_str = get_latitude_dim(cv)

    dxcv = cv.differentiate(coord=lon_str)  # optional: add edge_order=2. default is 1.
    dycv = cv.differentiate(coord=lat_str)  # optional: add edge_order=2. default is 1.

    adv = -( u *dxcv) - ( v *dycv)           # adv = u*d/dx(cv) + v*d/dy(cv)

Christoph Fischer's avatar
Christoph Fischer committed
    dxadv = adv.differentiate(coord=lon_str)
    dyadv = adv.differentiate(coord=lat_str)

    advadv = ( u *dxadv) + ( v *dyadv)  # to constrain adv to locations where there is a local min.
    return (adv, advadv)