Dynlib utils functions

Revision as of 20:25, 29 January 2013 by Csp001 (talk | contribs)

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:

Arguments:
Type Dim Description
dat real (nz,ny,nx) Input data
Returns:
Type Dim Description
res real (nz,ny,nx) output data

The ubiquitous inputs dx and dy are all of the form

Type Dim Description
dx real (ny,nx) dx(j,i) = x(j, i+1) - x(j, i-1) (in metres)
dy 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.mirror_y_domain : make data periodic in y for FFT

res = mirror_y_domain(dat,dx,dy)

Returns the data extended along complementary meridians (to facilitate FFT). For each lon, the reflected (lon+180) is attached below so that data is periodic in x and y. NOTE: Input data must be lats -90 to 90, and nx must be even.

Arguments:
Type Dim Description
dat real (nz,ny,nx) input data
Returns:
Type Dim Description
res real (nz,2*ny-2,nx) output data

dynlib.diag.sum_kix : sum along k for flagged k-values

This function is currently not available in dynlib. Use python dat[kix].sum() instead.

(res,nres) = sum_kix(dat,kix,dx,dy)

Calculates sum along k dimension for k values which are flagged to 1 in kix vector (length nz).

Arguments:
Type Dim Description
dat real (nz,ny,nx) input data
kix int (nz) index flag for summation
Returns:
Type Dim Description
res real (ny,nx) (summed) output data
nres int 0 Number of data summed = sum(kix)

dynlib.diag.sum_kix is typically used for calculating seasonal means. To do this, kix is set to 1 for times in the relevant season and 0 elsewhere. After (further) summing res and nres over all years, res/nres gives the mean for the season for all years.

dynlib.diag.high_enough : flags points which are sufficiently above ground

This function is currently not available in dynlib. Use python res = zdata[zdata > ztest+zthres] instead.

res = high_enough(zdata,ztest,zthres,dx,dy)

Arguments:
Type Dim Description
zdata real (nz,ny,nx) geopotential of gridpoints
ztest real (1,ny,nx) geopotential of topography
zthres real 0 threshold geopotential height difference


Returns:
Type Dim Description
res int*1 (nz,ny,nx)
Flag array set to:
1 if zdata(t,y,x) > (ztest(1,y,x) + zthres)
0 otherwise