# Difference between revisions of "Dynlib diag functions"

## Dynlib diagnostic functions

The functions generally operate on real arrays with dimension (nz,ny,nx) where nz is number of times or levels, and ny and nx are the number of latitudes and longitudes, respectively. The function descriptions below contain detailed descriptions of arguments and returns where there is any deviation from this pattern; otherwise they may be assumed to be of the form:

Type Dim Description real (nz,ny,nx) Zonal velocity real (nz,ny,nx) Meridional velocity real (nz,ny,nx) Potential vorticity
Type Dim Description real (nz,ny,nx) output data

The ubiquitous inputs dx and dy are all of the form

Type Dim Description real (ny,nx) dx(j,i) = x(j, i+1) - x(j, i-1) (in metres) real (ny,nx) dy(j,i) = y(j+1, i) - y(j-1, i) (in metres)

Typically, the results for each level or time are computed individually in 2-D fashion, though they are returned as a 3-D array of the same size as the input.

### dynlib.diag.vor : 2-D vorticity

`res=vor(u,v,dx,dy)`

Calculates the z component of vorticity of (u,v), using centred differences.

### dynlib.diag.div : 2-D divergence

`res=div(u,v,dx,dy)`

Calculates the 2-D divergence of (u,v), using centred differences.

### dynlib.diag.def_shear : shear deformation

`res=def_shear(u,v,dx,dy)`

Calculates the shear (antisymmetric) deformation of (u,v), using centred differences.

### dynlib.diag.def_stretch : stretch deformation

`res=def_stretch(u,v,dx,dy)`

Calculates the stretch (symmetric) deformation of (u,v), using centred differences.

### dynlib.diag.def_total : total deformation

`res=def_total(u,v,dx,dy)`

Calculates the total (rotation-independent) deformation of (u,v), using centred differences.

### dynlib.diag.def_angle : deformation angle

`res=def_angle(u,v,dx,dy)`

Calculates the angle between the x-axis and the dilatation axis of the deformation of (u,v).

### dynlib.diag.isoline_angle : iso-line contour angle

`res=isoline_angle(pv,dx,dy)`

Calculates the angle between the x-axis and the iso-lines of (for example) PV.

### dynlib.diag.isoline_to_deformation_angle : angle between dilatation axis and iso-lines

`res=isoline_to_deformation_angle(u,v,pv,dx,dy)`

Calculates the angle between the dilatation axis and the iso-lines of (for example) PV.

### dynlib.diag.stretch_stir : fractional stretching rate and angular rotation rate of grad(PV)

`(stretch,stir)=stretch_stir(u,v,pv,dx,dy)`

Returns real arrays, dim (nz,ny,nx):

```stretch
= fractional PV gradient stretching rate
= 1/|gradPV| * d/dt(|gradPV|)
= gamma, 'stretching rate' (Lapeyre Klein Hua)[1]
= -1/|gradPV| * Fn (Keyser Reeder Reed)[2]
```
```Fn = 0.5*|gradPV|(D-E*cos(2*beta))
=  1/|gradPV| * F (Markowski Richardson)[3]
```
```stir
= angular rotation rate of grad(PV) (aka stirring rate)
= d(theta)/dt (Lapeyre Klein Hua)[1]
```
```= 1/|gradPV| * Fs  (Keyser Reeder Reed)[2]
Fs = 0.5*|gradPV|(vort+E*sin(2*beta))
```

### dynlib.diag.geop_from_montgp : geopotential

`res = geop_from_montgp(m,theta,p,dx,dy)`

Calculates geopotential (res) from montgomery potential (m), potential temperature (theta) and pressure (p)

### dynlib.diag.grad_rev : PV gradient reversal

`(resa,resc,resai,resci,resaiy,resciy,tested) = grad_rev(pv,highenough,latitudes,ddythres,dx,dy)`

Finds the reversals of PV y-gradient (where the negative y-gradient exceeds some threshold) and classifies them as c (cyclonic) or a (anticyclonic). Three measures of c and a reversals are returned (6 in total). Only points flagged in highenough are tested.

Type Dim Description real (nz,ny,nx) potential vorticity int*1 (nz,ny,nx) array of flags denoting whether to test the point for reversal real (ny) vector of latitudes real 0 Cutoff y-gradient for pv

highenough is typically the output of the dynlib.diag.highenough function, which returns 1 where the surface is sufficiently above ground level and 0 elsewhere.

ddythres is the cutoff y-gradient for pv. The magnitude of (negative) d(pv)/dy must be above ddythres for reversal to be detected; this applies to revc, reva, revci,revai. Typical value: 4E-12.

Type Dim Description int*1 (nz,ny,nx) Flag =1 for cyclonic reversal (threshold test applied) int*1 (nz,ny,nx) Flag =1 for anticyclonic reversal (threshold test applied) real (nz,ny,nx) Absolute PV gradient where reversal is cyclonic (threshold test applied) real (nz,ny,nx) Absolute PV gradient where reversal is anticyclonic (threshold test applied) real (nz,ny,nx) Absolute PV y-gradient where reversal is cyclonic (no threshold test applied) real (nz,ny,nx) Absolute PV y-gradient where reversal is anticyclonic (no threshold test applied) int*1 (nz,ny,nx) flag to 1 all tested points: where highenough==1 and point not on grid edge

### dynlib.diag.contour_rwb : detects RWB events, Riviere algorithm

`(beta_a_out,beta_c_out) = contour_rwb(pv_in,lonvalues,latvalues,ncon,lev,dx,dy)`

Detects the occurrence of anticyclonic and cyclonic wave-breaking events from a PV field on isentropic coordinates.

Reference: Riviere 2009 [4]: See the appendix C.

Type Dim Description real (nz,ny,nx) isentropic pv. Should be on a regular lat-lon grid and 180W must be the first longitude. (If 180W is not the first longitude, the outputs will have 180W as the first, so must be rearranged) real (nx) vector of longitudes real (ny) vector of latitudes int 0 number of contours to test, normally 41 or 21 real 0 potential temperature of the level
Type Dim Description int (nz,ny,nx) flag array, =1 if anticyclonic wave breaking int (nz,ny,nx) flag array, =1 if cyclonic wave breaking

### dynlib.diag.v_g : geostrophic velocity

`(resx,resy) = v_g(mont,lat,dx,dy)`

Calculates geostrophic velocity. Returns zero on equator.

### dynlib.diag.okuboweiss : Okubo-Weiss criterion

`res = okuboweiss(u,v,dx,dy)`

Calculates Okubo-Weiss criterion lambda_0=1/4 * (sigma^2-omega^2)= 1/4 W, where sigma is total deformation and omega is vorticity.

This is the square of the eigenvalues in Okubo's paper[5] (assumes divergence is negligible).

### dynlib.diag.dot_uv : Lagrangian acceleration

`(resx,resy) = dot_uv(u,v,mont,lat,dx,dy)`

Calculates Lagrangian acceleration on the isentropic surface, based on Montgomery potential.

Type Dim Description real (nz,ny,nx) zonal velocity real (nz,ny,nx) meridional velocity real (nz,ny,nx) Montgomery potential real (ny) vector of latitudes

### dynlib.diag.accgrad_eigs : Lagrangian acceleration gradient tensor eigenvalues

`(respr,respi,resmr,resmi) = accgrad_eigs(u,v,mont,lat,dx,dy)`

Calculates eigenvalues of the lagrangian acceleration gradient tensor.

Type Dim Description real (nz,ny,nx) zonal velocity real (nz,ny,nx) meridional velocity real (nz,ny,nx) Montgomery potential real (ny) vector of latitudes
Type Dim Description real (nz,ny,nx) Real part of positive eigenvalue real (nz,ny,nx) Imaginary part of positive eigenvalue real (nz,ny,nx) Real part of negative eigenvalue real (nz,ny,nx) Imaginary part of negative eigenvalue int 0 number of contours to test, normally 41 or 21 real 0 potential temperature of the level

### dynlib.diag.dot_def_angle : Lagrangian time derivative of the deformation angle

`res = dot_def_angle(u,v,mont,lat,dx,dy)`

Calculates Lagrangian time derivative of the deformation angle from deformation and Lagrangian acceleration tensor. That quantity corresponds to

• d(gamma)/dt (Spensberger and Spengler 2013[6]) and
• -d(phi)/dt (Lapeyre et. al 1999[1] ).

Spensberger, C., Spengler, T. - Deformation: A new diagnostic for large-scale flow

J. Atmos. Sci. pp. in preparation,2013
Bibtex
Author : Spensberger, C., Spengler, T.
Title : Deformation: A new diagnostic for large-scale flow
In : J. Atmos. Sci. -
Address :
Date : 2013
Type Dim Description real (nz,ny,nx) zonal velocity real (nz,ny,nx) meridional velocity real (nz,ny,nx) Montgomery potential real (ny) vector of latitudes

### dynlib.diag.accgrad_eigs : Lagrangian acceleration gradient tensor eigenvalues

`(respr,respi,resmr,resmi) = accgrad_eigs(u,v,mont,lat,dx,dy)`

Calculates eigenvalues of the lagrangian acceleration gradient tensor.

Type Dim Description real (nz,ny,nx) zonal velocity real (nz,ny,nx) meridional velocity real (nz,ny,nx) Montgomery potential real (ny) vector of latitudes
Type Dim Description real (nz,ny,nx) Real part of positive eigenvalue real (nz,ny,nx) Imaginary part of positive eigenvalue real (nz,ny,nx) Real part of negative eigenvalue real (nz,ny,nx) Imaginary part of negative eigenvalue int 0 number of contours to test, normally 41 or 21 real 0 potential temperature of the level

### dynlib.diag.rotation_strain_ratio : ratio of effective rotation to strain rate

`res = rotation_strain_ratio(u,v,mont,lat,dx,dy)`

Calculates the r disgnostic of Lapeyre et al (1999)[1]; r is the ratio of effective rotation to strain rate, where effective rotation comprises both vorticity and strain-axes rotation.

Type Dim Description real (nz,ny,nx) zonal velocity real (nz,ny,nx) meridional velocity real (nz,ny,nx) Montgomery potential real (ny) vector of latitudes

## References

1. Lapeyre, G., Klein, P., Hua, B. L. - Does the tracer gradient vector align with the strain eigenvectors in 2D turbulence?
Physics of Fluids 11(12):3729-3737,1999
://000083495900013 http://scitation.aip.org/getpdf/servlet/GetPDFServlet?filetype=pdf&id=PHFLE6000011000012003729000001&idtype=cvips&doi=10.1063/1.870234&prog=normal
Bibtex
Author : Lapeyre, G., Klein, P., Hua, B. L.
Title : Does the tracer gradient vector align with the strain eigenvectors in 2D turbulence?
In : Physics of Fluids -
Address :
Date : 1999
2. Keyser, D., Reeder, M. J., Reed, R. J. - A Generalization of Petterssen Frontogenesis Function and Its Relation to the Forcing of Vertical Motion
Monthly Weather Review 116(3):762-780,1988
://A1988N255100017
Bibtex
Author : Keyser, D., Reeder, M. J., Reed, R. J.
Title : A Generalization of Petterssen Frontogenesis Function and Its Relation to the Forcing of Vertical Motion
In : Monthly Weather Review -
Address :
Date : 1988
3. Markowski, Paul - Mesoscale meteorology in midlatitudes
Chichester, West Sussex, UK ;Hoboken, NJ : Wiley-Blackwell, 2010,2010
http://books.scholarsportal.info/viewdoc.html?id=/ebooks/ebooks2/wiley/2011-12-13/2/9780470682104
Bibtex
Author : Markowski, Paul
Title : Mesoscale meteorology in midlatitudes
In : -
Address :
Date : 2010
4. Riviere, G. - Effect of Latitudinal Variations in Low-Level Baroclinicity on Eddy Life Cycles and Upper-Tropospheric Wave-Breaking Processes
Journal of the Atmospheric Sciences 66(6):1569-1592,2009
://000267263300006
Bibtex
Author : Riviere, G.
Title : Effect of Latitudinal Variations in Low-Level Baroclinicity on Eddy Life Cycles and Upper-Tropospheric Wave-Breaking Processes
In : Journal of the Atmospheric Sciences -
Address :
Date : 2009
5. Okubo, A. - Horizontal Dispersion of Foreign Particles in Vicinity of Velocity Singularities Such as Convergences
Transactions-American Geophysical Union 50(4):182-&,1969
://A1969C982700332
Bibtex
Author : Okubo, A.
Title : Horizontal Dispersion of Foreign Particles in Vicinity of Velocity Singularities Such as Convergences
In : Transactions-American Geophysical Union -
Address :
Date : 1969
6. Cite error: Invalid `<ref>` tag; no text was provided for refs named `SpeSpe2013`