windspharm.iris
¶
Spherical harmonic vector wind computations (iris
interface).
-
class
windspharm.iris.
VectorWind
(u, v, rsphere=6371200.0, legfunc='stored')[source]¶ Vector wind computations (
iris
interface).Initialize a VectorWind instance.
Arguments:
- u, v
- Zonal and meridional components of the vector wind
respectively. Both components should be
Cube
instances. The components must have the same dimension coordinates and contain no missing values.
Optional argument:
- rsphere
- The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.
- legfunc
- ‘stored’ (default) or ‘computed’. If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses O(nlat**3) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses O(nlat**2) memory, but slows down the spectral transforms a bit.
Example:
Initialize a
VectorWind
instance with zonal and meridional components of the vector wind:from windspharm.iris import VectorWind w = VectorWind(u, v)
-
u
()[source]¶ Zonal component of vector wind.
Returns:
- u
- The zonal component of the wind.
Example:
Get the zonal component of the vector wind:
u = w.u()
-
v
()[source]¶ Meridional component of vector wind.
Returns:
- v
- The meridional component of the wind.
Example:
Get the meridional component of the vector wind:
v = w.v()
-
magnitude
()[source]¶ Wind speed (magnitude of vector wind).
Returns:
- speed
- The wind speed.
Example:
Get the magnitude of the vector wind:
spd = w.magnitude()
-
vrtdiv
(truncation=None)[source]¶ Relative vorticity and horizontal divergence.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- vrt, div
- The relative vorticity and divergence respectively.
See also:
Examples:
Compute the relative vorticity and divergence:
vrt, div = w.vrtdiv()
Compute the relative vorticity and divergence and apply spectral truncation at triangular T13:
vrtT13, divT13 = w.vrtdiv(truncation=13)
-
vorticity
(truncation=None)[source]¶ Relative vorticity.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- vrt
- The relative vorticity.
See also:
Examples:
Compute the relative vorticity:
vrt = w.vorticity()
Compute the relative vorticity and apply spectral truncation at triangular T13:
vrtT13 = w.vorticity(truncation=13)
-
divergence
(truncation=None)[source]¶ Horizontal divergence.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- div
- The divergence.
See also:
Examples:
Compute the divergence:
div = w.divergence()
Compute the divergence and apply spectral truncation at triangular T13:
divT13 = w.divergence(truncation=13)
-
planetaryvorticity
(omega=None)[source]¶ Planetary vorticity (Coriolis parameter).
Optional argument:
- omega
- Earth’s angular velocity. The default value if not specified is 7.292x10**-5 s**-1.
Returns:
- pvorticity
- The planetary vorticity.
See also:
Example:
Compute planetary vorticity using default values:
pvrt = w.planetaryvorticity()
Override the default value for Earth’s angular velocity:
pvrt = w.planetaryvorticity(omega=7.2921150)
-
absolutevorticity
(omega=None, truncation=None)[source]¶ Absolute vorticity (sum of relative and planetary vorticity).
Optional arguments:
- omega
- Earth’s angular velocity. The default value if not specified is 7.292x10**-5 s**-1.
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- avorticity
- The absolute (relative + planetary) vorticity.
See also:
vorticity
,planetaryvorticity
.Examples:
Compute absolute vorticity:
avrt = w.absolutevorticity()
Compute absolute vorticity and apply spectral truncation at triangular T13, also override the default value for Earth’s angular velocity:
avrt = w.absolutevorticity(omega=7.2921150, truncation=13)
-
sfvp
(truncation=None)[source]¶ Streamfunction and velocity potential.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- sf, vp
- The streamfunction and velocity potential respectively.
See also:
streamfunction
,velocitypotential
.Examples:
Compute streamfunction and velocity potential:
sf, vp = w.sfvp()
Compute streamfunction and velocity potential and apply spectral truncation at triangular T13:
sfT13, vpT13 = w.sfvp(truncation=13)
-
streamfunction
(truncation=None)[source]¶ Streamfunction.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- sf
- The streamfunction.
See also:
sfvp
.Examples:
Compute streamfunction:
sf = w.streamfunction()
Compute streamfunction and apply spectral truncation at triangular T13:
sfT13 = w.streamfunction(truncation=13)
-
velocitypotential
(truncation=None)[source]¶ Velocity potential.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- vp
- The velocity potential.
See also:
sfvp
.Examples:
Compute velocity potential:
vp = w.velocity potential()
Compute velocity potential and apply spectral truncation at triangular T13:
vpT13 = w.velocity potential(truncation=13)
-
helmholtz
(truncation=None)[source]¶ Irrotational and non-divergent components of the vector wind.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- uchi, vchi, upsi, vpsi
- Zonal and meridional components of irrotational and non-divergent wind components respectively.
See also:
irrotationalcomponent
,nondivergentcomponent
.Examples:
Compute the irrotational and non-divergent components of the vector wind:
uchi, vchi, upsi, vpsi = w.helmholtz()
Compute the irrotational and non-divergent components of the vector wind and apply spectral truncation at triangular T13:
uchiT13, vchiT13, upsiT13, vpsiT13 = w.helmholtz(truncation=13)
-
irrotationalcomponent
(truncation=None)[source]¶ Irrotational (divergent) component of the vector wind.
Note
If both the irrotational and non-divergent components are required then
helmholtz
should be used instead.Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- uchi, vchi
- The zonal and meridional components of the irrotational wind respectively.
See also:
Examples:
Compute the irrotational component of the vector wind:
uchi, vchi = w.irrotationalcomponent()
Compute the irrotational component of the vector wind and apply spectral truncation at triangular T13:
uchiT13, vchiT13 = w.irrotationalcomponent(truncation=13)
-
nondivergentcomponent
(truncation=None)[source]¶ Non-divergent (rotational) component of the vector wind.
Note
If both the non-divergent and irrotational components are required then
helmholtz
should be used instead.Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- upsi, vpsi
- The zonal and meridional components of the non-divergent wind respectively.
See also:
Examples:
Compute the non-divergent component of the vector wind:
upsi, vpsi = w.nondivergentcomponent()
Compute the non-divergent component of the vector wind and apply spectral truncation at triangular T13:
upsiT13, vpsiT13 = w.nondivergentcomponent(truncation=13)
-
gradient
(chi, truncation=None)[source]¶ Computes the vector gradient of a scalar field on the sphere.
Argument:
- chi
- A scalar field. It must be a
Cube
with the same latitude and longitude dimensions as the vector wind components that initialized theVectorWind
instance.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns:
- uchi, vchi
- The zonal and meridional components of the vector gradient respectively.
Examples:
Compute the vector gradient of absolute vorticity:
avrt = w.absolutevorticity() avrt_zonal, avrt_meridional = w.gradient(avrt)
Compute the vector gradient of absolute vorticity and apply spectral truncation at triangular T13:
avrt = w.absolutevorticity() avrt_zonalT13, avrt_meridionalT13 = w.gradient(avrt, truncation=13)
-
truncate
(field, truncation=None)[source]¶ Apply spectral truncation to a scalar field.
This is useful to represent other fields in a way consistent with the output of other
VectorWind
methods.Argument:
- field
- A scalar field. It must be a
Cube
with the same latitude and longitude dimensions as the vector wind components that initialized theVectorWind
instance.
Optional argument:
- truncation
- Truncation limit (triangular truncation) for the spherical harmonic computation. If not specified it will default to nlats - 1 where nlats is the number of latitudes.
Returns:
- truncated_field
- The field with spectral truncation applied.
Examples:
Truncate a scalar field to the computational resolution of the
VectorWind
instance:scalar_field_truncated = w.truncate(scalar_field)
Truncate a scalar field to T21:
scalar_field_T21 = w.truncate(scalar_field, truncation=21)