# PSI2FIELDS is the jOceans module of jLab.

``` PSI2FIELDS  Velocity and other fields from the streamfunction. [with P.E. Isachsen]

CV=PSI2FIELDS(PSI) where PSI is a matrix of streamfunction values,
returns the complex velocity U+iV.

[CV,ZETA,N,S,P]=PSI2FIELDS(PSI) also returns velocity gradient fields:

ZETA    - Vorticity               dv/dx-du/dy
N    - Normal strain           du/dx-dv/dy
S    - Shear strain            dv/dx+du/dy
P    - Okubo-Weiss parameter   S^2+N^2-ZETA^2

PSI should be oriented with the X-dimension along *columns* and the
Y-dimensions along the *rows*.  Both of these must be of even length.

The output fields are all the same size as PSI.

PSI can have additional dimensions after the first two, for example,
with time in the third dimensions.  Up to four dimensions are possible.

PSI2FIELDS(DX,PSI) uses the grid spacing DX, in units of kilometers, in
computing the gradient fields. By default, DX is set to unity.

PSI is taken to have units of meters squared per second.  The units of
CV are given in centimeters per second, ZETA, N, and S have units of
inverse seconds, and P has units of inverse seconds squared.
__________________________________________________________________

Algorithm choice

PSI2FIELDS can use two different algorithms.

PSI2FIELDS(PSI,'spectral'), the default hehavior, computes the gradient
fields in the spectral domain.  This is particularly appropriate when
PSI is doubly periodic.

PSI2FIELDS(PSI,'spatial') alternately computes the gradient fields
in the spatial domain, using first central differences for derivatives.

PSI2FIELDS(PSI,'arakawa') computes gradients in the spatial domain
with the weighted central difference scheme used by Arakawa (1966).

PSI2FIELDS(PSI,'spatial',STR) or PSI2FIELDS(PSI,'arakawa',STR)
specifies the boundary conditions for derivatives at the domain edges.

The default behavior for spatial derivatives is STR='periodic'.  Other
choices are 'mirror' and 'zeros'.  See VDIFF for more details.
__________________________________________________________________

'psi2fields --t' runs some tests.
'psi2fields --f' generates two sample figures.

Usage: cv=psi2fields(psi);
[cv,zeta,N,S,P]=psi2fields(psi);
[cv,zeta,N,S,P]=psi2fields(dx,psi);
[cv,zeta,N,S,P]=psi2fields(dx,psi,'spatial');
__________________________________________________________________
This is part of JLAB --- type 'help jlab' for more information
(C) 2013--2015 J.M. Lilly and P.E. Isachsen
--- type 'help jlab_license' for details
```