spect2d - Computes forward and inverse spectra of 2-D data.

SYNOPSIS

spect2d  [ parameter=value ... ]  [ inputfile outputfile ]
spect2d  [ parameter=value ... ]  [ inputfile ... directory ]

Parameters are: include_vars, forward, window, mag_phase, remove_means, sample_freqs, freq_vars, freq_units, power_units, fft_out_dims.

DESCRIPTION

spect2d computes forward and inverse spectra of 2-D variables. The spectra are computed via the fast fourier transform (FFT) method. The forward spectra can be power and phase spectra, or real and imaginary spectra. The real and imaginary spectra are intended to be used for band-pass filtering, so that subsequent inverse transforms can be performed.

In the case of forward transforms to power and phase spectra:

The output variables for each input variable are the power spectrum and phase spectrum (in degrees). The names of these output variables are the original variable name(s) appended to the prefixes, POW_ and PHS_, respectively. The variables being transformed must all have the same two dimensions. The dimension lengths (M and N) must be each a power of two; if not, they will be padded to the next biggest power of two with the mean value of the 2D image. The padding is done symmetrically around the edges of the image. The size of the dimensions in the output dataset are M/2+1 and N, where M and N are the power of twos used in the FFT calculation. For M=16 and N=32, the output spectra are layed out as follows:

                     N=32  Frequencies

          Nyquist   +freq     0    -freq
              v               v
           0 >|-------------------------------
              |               |              |
              |               |              |
    M/2+1=9   |               |              |
  Frequencies |               |              |
              |               |              |
              |               |              |
              |               |              |
     Nyquist >|-------------------------------

Two one-dimensional variables are written to each output dataset that contain the frequency (or wavelength) values of the 2-D spectra. These values are computed from the two input dimension lengths and the value of the sampling frequencies which are specified by sample_freqs. These variables have lengths M/2+1 and N, respectively.

Options are provided for removing the mean(s), applying a 2-D window to the data before transforming, for renaming the dimensions in the output, and for specifying names for the frequency variables, their units, and the units of the power spectra.

In the case of forward transforms to real and imaginary spectra:

The output variable for each input variable is a 2-D complex spectrum. The name of this output variable is the original variable name, its units are modified to have the prefix "CMPLX_". This output variable has the same two dimensions it had in the input, although: 1) it has one more dimension named "complex" that has length two, and 2) the two dimensions must each be a power of two (M and N), if not they are padded out with the mean value of the image to size MxN (see above). The size of the complex variable's dimensions in the output dataset are MxNx2. For M=16 and N=32, the real and imaginary parts of the complex complex spectra are layed out as follows:

                     N=32  Frequencies

              0     +freq  Nyquist   -freq
              v               v
           0 >|-------------------------------
              |               |              |
              |               |              |
              |               |              |
       +freq  |               |              |
              |               |              |
              |               |              |
              |               |              |     M=16
     Nyquist >|-------------------------------  Frequencies
              |               |              |
              |               |              |
              |               |              |
       -freq  |               |              |
              |               |              |
              |               |              |
              |-------------------------------

Two one-dimensional variables are written to each output dataset that contains the frequency (or wavelength) values of the 2-D spectra. These values are computed from the two input dimension lengths and the value of the sampling frequencies which are specified by sample_freqs. They have lengths M and N, respectively.

Options are provided for removing the mean(s), applying a 2-D window to the data before transforming, and for specifying names for the frequency variables and their units.

In the case of inverse transforms of real and imaginary spectra:

The data are assumed to be complex output from spect2d (see diagram and description above).

The output variable will have the same name it had originally on input, with the same (original) units. The dimension lengths will be the original length or the powers of 2 the variable was padded to (see above).

In this case, a 2-D window can be applied to the complex data in order to filter the data. The window should have the same lengths as the fft dimension being inverse transformed, i.e. should have the same representation with respect to frequencies as the diagram above.

PARAMETERS

include_vars

Specifies which variables in the input dataset(s) are to be tranformed.

The default is all variables in the input dataset(s).

forward

Specifies whether a forward or inverse transform should be performed. See explanation above and parameter descriptions below for more detailed description of inputs and outputs for these cases.

Valid responses are [yes or no]. The default is yes.

window

Specifies a Terascan dataset containing a two-dimensional variable named "x" containing the windowing function. If forward=yes, the dimensions of "x" must be the the powers of two to be used in the forward FFT computation (see description above). In this case, the window is applied before the transform as a means of reducing variance leakage. If forward=no, the dimensions of "x" must be the lengths of the data being inverse transformed (see above). In this case, the window is used for band-pass filtering the data to remove unwanted frequencies. Simple windowing datasets can be created with fakedata or emath. Note: variance loss due to tapering is not accounted for internally in the final forward-transform spectral values.

The default is none, i.e. apply no window function.

mag_phase

If forward=yes, this specifies whether to output the forward transform as two separate power and phase spectra variables or one three-dimensional complex (2D plus one complex dimension) spectrum so that band-pass filtering can be performed.

Valid responses are [yes or no]. The default is yes.

remove_means

If forward=yes, this specifies whether to remove the mean of each 2D image before the fourier transform is applied.

Valid responses are [yes or no]. The default is yes.

sample_freqs

If forward=yes, this specifies the sampling frequencies of the 2 input dimensions. For exmaple, if the sampling frequencies of the input values are every five days in line and every 100 km in sample, then values of 0.2 and 0.01 might be specified if the frequency units (freq_units) are specified as cycles/day and cycles/kilometer (see below).

The defaults are 1 1.

freq_vars

If forward=yes, this specifies the names of the 2 output variables containing the frequency values of the computed spectra. These variables will be associated with the output dimensions (i.e. dim->var, see datasets).

The defaults are linefreqs sampfreqs.

freq_units

If forward=yes, this specifies the names of the units of 2 output variables freq_vars.

The default is no units.

power_units

If forward=yes and mag_phase=yes, this specifies the units of output variables containing the power spectra, i.e. the variables named POW_"invar".

The default is power.

fft_out_dims

If forward=yes and mag_phase=yes, this specifies the names of the two dimensions being transformed for the output dataset. Thus, if the two input dimensions are "time" and "distance", it may be appropriate to name the corresponding dimensions in the output dataset "frequency" and "wavelength".

The defaults are linefreq sampfreq.

EXAMPLES

See Examples in spect.

SEE ALSO

datasets, spectral, xspect, randata, emath, fakedata, lagspect, spect, dimavg, xcorrel.

NOTES

In the case of forward tranforms to power spectra, the variance (integrated sum of power spectra) can be reduced from that in the input series due to tapering which is dependent on the window function. The variance can also be reduced due to padding the input out to the nearest power of 2. In the case of padding a 2D LxM image to NxP, the variance is reduced by (L*M)/(N*P).

Reference: Bendat, J.S. and Piersol, A. B., Random Data: Analysis and Measurement Procedures, 2nd Edition, Wiley, 1986.


Last Update: $Date: 1998/05/29 20:45:01 $