SP = specf(F) returns a structure SP containing the 1D power
spectrum of the vector or scalar field(s) F. If F is an array of
fields, the average spectrum is returned. Note: The factor 1/2, usually
used in the definition of energy, is _not_ included here, so that the
integral of the power spectrum over wavenumbers is given by the mean
square of the input field (see Parseval below).
SP = specf(F,'hann') applies a Hann (or Hanning) apodization window
to the fields along each direction in order to reduce aliasing. Note
that, in this case, energy is not conserved (the amount of energy
lost in the apodization is about 60%, but the exact value depends on
the details of the energy distribution).
The X and Y dimensions of the fields must be even. If one of the
dimension is odd, the last column/row is discarded.
Use the syntax SP = specf(F, ..., 'disp'), or specf(F, ...) without
output argument, to also display the spectrum. This works only for
square fields (see below).
specf(SP) displays the spectrum, where SP has been previously computed
using SP=specf(...). If SP is a structure array, loops over all spectra
(press a key between each display).
specf(..., 'comp', n) shows the spectrum multiplied by k^n (compensated
spectrum).
specf(..., 'k2') shows the spectrum multiplied by k^2 (dissipation
spectrum). Equivalent to specf(..., 'comp', 2).
For vector field(s), the structure SP contains:
kx,ky: wavenumbers along x and y
exvx: 1D power spectrum of F_x along x
exvy: 1D power spectrum of F_y along x
eyvx: 1D power spectrum of F_x along y
eyvy: 1D power spectrum of F_y along y
exvz: 1D power spectrum of F_z along x (for 3D fields)
eyvz: 1D power spectrum of F_z along y (for 3D fields)
k: wavenumber
el, et: 1D longitudinal and transverse power spectra
e: 1D power spectrum (sum of el and et)
unitk: unit of wavenumber
unite: unit of power spectrum (energy density)
appod: Apodization window ('Hann' or 'None')
nfields: number of fields used in the computation
history: remind from which field specf has been called.
For scalar field(s), the structure SP contains:
kx,ky: wavenumbers along x and y
ex: 1D power spectrum of F along x
ey: 1D power spectrum of F along y
k: wavenumber
e: 1D power spectrum (average of ex and ey)
unitk: unit of wavenumber
unite: unit of power spectrum (energy density)
appod, nfields, history: idem as for vector fields
Note that the long. and transv. spectra (el and et) are computed only
for square fields. Use truncf if you want to first extract the central
square from the fields.
The unit for the wavenumber is the inverse of the unit for the spatial
scale (e.g. in 1/mm). The length of the spectrum is half the length of
the field (negative wavenumbers ignored). Some useful properties:
sp.k(1) is equal to 0 (zero mode = mean component of the field)
sp.k(2) is the wavenumber increment, Delta k = 2*pi/L, where L is the
size of the field.
sp.k(end) is pi/dx, where dx is the mesh size of the field.
The unit for the spectra (exvx, el, et, e...) is given by the unit of
the input field squared, times the unit of scale. For instance, for a
velocity field given in m/s with spatial scale in mm, the unit for the
spectra is (m^2/s^2)*mm, i.e. (m^3/s^2)/1000.
Example
v=loadvec('*.vc7'); % assuming v in m/s and r in mm
sp=specf(truncf(v));
loglog(sp.k*1000, sp.el/1000);
xlabel('k (m^{-1}');
ylabel('E(k) (m^3 s^{-2}');
Energy Conservation (Parseval theorem)
For a scalar field, energy conservation requires that
SUM(SP.EX)*SP.KX(2) = SUM(SP.EY)*SP.KY(2) = MEAN(F.W(:).^2)
and, if the field is square with equal scales along X and Y:
SUM(SP.E)*SP.K(2) = MEAN(F.W(:).^2)
For a vector field, energy conservation requires that
SUM(SP.EXVX)*SP.KX(2) = SUM(SP.EYVX)*SP.KY(2) = MEAN(F.VX(:).^2)
SUM(SP.EXVY)*SP.KX(2) = SUM(SP.EYVY)*SP.KY(2) = MEAN(F.VY(:).^2)
and, if the field is square with equal scales along X and Y:
SUM(SP.EL)*SP.K(2) = (MEAN(F.VX(:).^2)+MEAN(F.VY(:).^2))
Example
Verification of energy conservation for a scalar field:
v=truncf(loadvec('b00001.vc7'));
c=vec2scal(v,'ux');
sp=specf(c);
st=statf(c);
% The 3 computations should give the same number (in m2/s2):
st.rms.^2 % (twice the) energy in physical space
sum(sp.ex)*sp.kx(2) % energy in Fourier space (computation 1)
sum(sp.ey)*sp.ky(2) % energy in Fourier space (computation 2)
See Also
spec2f, tempspecf, statf, vsf, ssf, truncf, corrf.
Published output in the Help browser
showdemo specf