Function:

`void extract_noise(int average, int which, float *in, int n,
float delta_t, double *whiten_out, double *power)`

This function calculates the real-time noise power
spectrum of a detector, using a Hann window and averaging the
spectrum for two overlapped data sets, if desired.

The arguments of `extract_noise()` are:

`average:`Input. An integer variable that should be set equal to 1 if the values of the real-time noise power spectra corresponding to two overlapped data sets are to be averaged.`which:`Input. An integer variable specifying which internally-defined static buffer should be used when overlapping the new input data set with data saved from a previous call. The allowed values are .`in:`Input.`in[0..n-1]`is an array of floating point variables containing the values of the assumed continuous-in-time whitened data stream produced by the detector. is the convolution of detector whitening filter with the data stream , where is the gravitational strain and is the noise intrinsic to the detector. The variables`in[]`have units of rHz (or ), which follows from the definition of as a strain and as the ``inverse'' of the square root of the noise power spectrum .`in[i]`contains the value of evaluated at the discrete time , where .`n:`Input. The number of data points corresponding to an observation time , where is the sampling period of the detector, defined below. should equal an integer power of 2.`delta_t:`Input. The sampling period (in sec) of the detector.`whiten_out:`Input.`whiten_out[0..n-1]`is an array of double precision variables containing the values of the real and imaginary parts of the spectrum of the whitening filter of the detector. These variables have units (or ), which are inverse to the units of the square root of the noise power spectrum .`whiten_out[2*i]`and`whiten_out[2*i+1]`contain, respectively, the values of the real and imaginary parts of evaluated at the discrete frequency , where .`power:`Output.`power[0..n/2-1]`is an array of double precision variables containing the values of the real-time noise power spectrum of the detector. Explicitly,

(11.15.240) `power[i]`contains the value of evaluated at the discrete frequency , where .

`extract_noise()` calculates the real-time noise power spectrum
as follows:

- (i)
- It first stores the input data stream in the last
two-thirds of an appropriately chosen static buffer
`buf[0..3*n/2-1]`. The first one-third of this buffer contains the input data left over from the previous call. - (ii)
- It then multiplies the first two-thirds of this buffer
by the Hann window function:

(11.15.241) *Numerical Recipes in C*, p.553. It is needed to offset the reduction in power that is introduced by the windowing. - (iii)
- The windowed data is then Fourier transformed into the frequency domain, where it is unwhitened by dividing by the (complex) spectrum of the whitening filter of the detector. The resulting unwhitened frequency components are denoted by ; the superscript indicates that we are analyzing the first of two overlapped data sets.
- (iv)
- The real-time noise power spectrum is then calculated
according to:

(11.15.242) - (v)
- The data contained in the last two-thirds of the buffer is then copied to the first two-thirds of the buffer, and steps (ii)-(iv) are repeated, yielding a second real-time noise power spectrum .
- (vi)
- If average=1, is given by:

(11.15.243) - (vii)
- Finally, the data contained in the last two-thirds of the
buffer is again copied to the first two-thirds, in preparation for the
next call to
`extract_noise()`. The data saved in the first one-third of this buffer will match onto the next input data stream if the input data from one call of`extract_noise()`to the next is continuous.

Note: One should call `extract_noise()` with
, when one suspects that the current input data is
*not* continuous with the data that was saved from the previous call.
This is because a discontinuity between the ``old'' and ``new'' data
sets has a tendency to introduce spurious large frequency components
into the real-time noise power spectrum, which should not be present.
Since a single input data stream by itself is continuous,
the noise power spectrum (which is calculated on the
second pass through the data) will be free of these spurious large
frequency components.
This is why we set equal to --and not equal to
--when
.

- Authors: Bruce Allen, ballen@dirac.phys.uwm.edu, and Joseph Romano, romano@csd.uwm.edu
- Comments:
In the context of stochastic background simulations, it would be
more efficient to extract the real-time noise power spectra at
*two*detectors simultaneously. However, for modularity of design, and to allow this function to be used possibly for ``single-detector'' gravity-wave searches, we decided to write the above routine instead.