Difference between revisions of "Dynlib utils functions"

(Created page with '== 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…')
 
(Outdated and obsolete, to be deleted.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Dynlib diagnostic functions ==
+
{{db-author}}
 
 
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:
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | dat
 
| real || (nz,ny,nx) || Input data
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="120" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| real || (nz,ny,nx) || output data
 
|}
 
 
 
The ubiquitous inputs ''dx'' and ''dy'' are all of the form
 
{| border="1" class="wikitable" style="text-align:center;"
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | dx
 
| real || (ny,nx) || dx(j,i) = x(j, i+1) - x(j, i-1) (in metres)
 
|-
 
! width="80" | 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 ===
 
 
 
<code>res = mirror_y_domain(dat,dx,dy)</code>
 
 
 
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.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | thedata
 
| real || (nz,ny,nx) || input data
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="120" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | 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
 
<code>thedata[kix].sum()</code> instead.
 
 
 
<code>(res,nres) = sum_kix(thedata,kix,dx,dy)</code>
 
 
 
Calculates sum along k dimension for k values which are flagged to 1 in kix vector (length nz).
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | thedata
 
| real || (nz,ny,nx) || input data
 
|-
 
! width="80" | kix
 
| int || (nz) || index flag for summation
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| real || (ny,nx) || (summed) output data
 
|-
 
! width="80" | 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
 
<code>res = zdata[zdata < ztest+zthres]</code> instead.
 
 
 
<code>res = high_enough(zdata,ztest,zthres,dx,dy)</code>
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | zdata
 
| real || (nz,ny,nx) || geopotential of gridpoints
 
|-
 
! width="80" | ztest
 
| real || (1,ny,nx) ||geopotential of topography
 
|-
 
! width="80" | zthres
 
| real || 0 ||threshold geopotential height difference
 
|}
 
 
 
 
 
{|  border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| int*1 || (nz,ny,nx) ||
 
{| style="text-align:left;"
 
|-
 
| Flag array set to:
 
|-
 
|style="padding-left: 2em" |1 if zdata(t,y,x) > (ztest(1,y,x) + zthres)
 
|-
 
|style="padding-left: 2em" |0 otherwise
 
|}
 
|}
 
 
 
[[Category:Dynlib]]
 

Latest revision as of 16:14, 18 September 2017