The program estimates the 2D power spectra for each input section by performing one or more forward transforms, taking their magnitude, and averaging the results. This can then be smoothed if desired.
The controls in the user interface include a standard set of controls for selecting the input file, output file, and region of interest and for starting and interrupting processing. The other controls are organized as follows:
There are a couple things to note about this application:
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line
The input region can be processed to remove an offset or trend before the data is broken into blocks, tapered, and transformed. To display the controls for this processing, press the button labeled Set preprocessing in the main dialog. There are five types of processing that can be done; select one by pressing the appropriate toggle in the dialog. The processing options are:
If you are intending to taper the data and the data does not already have a zero mean, you should consider using the mean subtraction, linear trend removal, or polynomial fit options.
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line
This application provides two ways to reduce the variance of the spectra estimate: breaking the input region into blocks which are handled separately and then averaged and smoothing of the spectra.
Breaking the input into blocks is controlled by the parameters of the top half of the dialog opened with the Set averaging/smoothing button. The inputs are the x and y size in pixels for each block, the percent of the block that overlaps with the block to the left and to the bottom, and the number of blocks in x and y. When the Automatically adjust for best coverage toggle is on, changing the overlap or size will cause the count to be adjusted so there is as many blocks as possible, and when the number of blocks is adjusted, the size will be changed so that it is an efficiently handled size and as much of the input region is covered as possible. When the toggle is off, the size, overlap, and count can be varied independently within the constraint that the blocks must all fit in the input region. When breaking the input into blocks, a common approach is to fully taper each block and have a 50% overlap.
The amount of smoothing done is set in the Size field at the bottom of the dialog. Each output pixel is the summation of the unsmoothed result over a rectangle of the size shown. The size in each direction must be a positive odd integer. To ensure that a purely real input results in a spectra with the correct symmetry about the origin, choose the smoothing size for a dimension such that
(floor(n / 2) - floor(s / 2) + s - 1) / s
is even where n is the block size in that dimension.
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line
Applying a windowing function, also called tapering, multiplies the data by a function which goes to zero (or near zero) at the edges of the data. This is done after preprocessing and splitting the data into blocks to remove discontinuities at the edges which can complicate the interpretation of frequency spectra; the disadvantage of applying a window is that it essentially throws away parts of the input and it broadens features in the spectra. The former problem can be alleviated by overlapping the blocks that are transformed.
The windowing functions used are separable, i.e, the windowing function, W(x,y), can be written as the product of WX(x) and WY(y). WX and WY are calculated from the same formula but with different inputs for the number of pixels, n, and the fraction, f, of the dimension that is attenuated by the windowing function. The two values in the Coverage field are the values of f divided by two for the x and y directions respectively. Commonly used values for the coverage are 0.5 (a "full taper") and 0.1 (a 10% taper). The power, x, is used by half-sine windowing function.
The functions used to calculate the windowing functions are shown below. i is the pixel index and runs from 0 to n minus 1, and e is given by
{ floor(0.5 + f / 2.0 * n) n even
e = {
{ floor(0.5 + f / 2.0 * (n - 1)) n odd
{ 0 i < e
w(i) = { 1 e <= i <= n - e
{ 0 i > n - e
Because of the sharp cutoffs of the rectangular window, it is not particularly useful; it's provided for completeness.
{ i / e i < e
w(i) = { 1 e <= i <= n - e
{ (n - i) / e i > n - e
{ (sin(pi * i / (2 * e)))^x i < e
w(i) = { 1 e <= i <= n - e
{ (sin(pi * (n - i) / (2 * e)))^x i > n - e
{ 0.54 - 0.46 * cos(pi * i / e) i < e
w(i) = { 1 e <= i <= n - e
{ 0.54 - 0.46 * cos(pi * (n - i) / e) i > n - e
{ cos(pi * i / e) i < e
a(i) = { -1 e <= i <= n - e
{ cos(pi * (n - i) / e) i > n - e
w(i) = 0.34 - a(i) * (0.5 - a(i) * 0.16)
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line
The output spectra is scaled so that summing over the spectra gives an estimate of the variance of the input data. By default the frequencies are ordered so that zero frequency is at (0, 0) and positive Nyquist frequency in both directions is located at (nx/2, ny/2) where nx and ny are the sizes of a block. Use the button labeled Set output format in the main dialog to open a dialog with controls that allow modifications to the default format. The available options are:
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line
FPwrSpec2D accepts the command-line arguments described in Region.html. In addition, FPwrSpec2D accepts the options shown below (optional parts are shown in brackets). If mutually exclusive options (i.e. for selection of the windowing function), the last option that appears on the command line takes precedence. The default is to calculate the power spectrum without any preprocessing, no tapering of the data, and no averaging or smoothing.
-subtract=value or -subtract=mean
-linear_detrend
-polyfit=n
-block_size=nx:ny
-block_overlap=x_overlap:y_overlap
-block_count=nx:ny
-smooth_size=nx:ny
-rectangular=x_coverage:y_coverage
-triangular=x_coverage:y_coverage
-halfsine=x_coverage:y_coverage
-halfsine_power to set the exponent, which controls
the sharpness of the window edges.
-halfsine_power=p
-hamming=x_coverage:y_coverage
-blackman=x_coverage:y_coverage
-center_zero
-log10
As an example, the following estimates the power spectrum from noise.dat which is assumed to be at least 512 x 512. The input is broken into 9 blocks of 256 x 256, the blocks are individually tapered with a triangular windowing function, and the results (after centering the spectra and taking the logarithm base 10) are written to window 1.
FPwrSpec2D noise.dat 1 -block_size=256:256 -block_count=3:3 \
-block_overlap=50:50 -triangular=.5:.5 -log10 -center_zero
Overview | Region processing | Preprocessing | Averaging/Smoothing | Window/taper | Output format | Command line