pygwb.postprocessing

The postprocessing module combines all methods which are useful in the end stages of the analysis, more specifically when combining spectrograms into spectra, and spectra into one overall point estimate for the gravitational-wave background.

This module contains methods such as postprocess_Y_sigma, which combines point estimate and sigma spectrograms into spectra using a method where odd and even segments are treated differently if the data are overlapping. To account for the overlap, it uses another function of the postprocessing module, odd_even_segment_postprocessing. Additional information about this procedure can be found here.

These spectrograms are computed from the cross spectral density (CSD) and the power spectral density (PSD). The postprocessing module also contains the method which takes care of the above, namely calculate_point_estimate_sigma_spectra. Starting from a set of CSD and PSD spectrograms, one can compute the point estimate and sigma spectrograms, objects that contain both frequency and segment data information. Then, the spectrograms are combined into spectra with these methods. These spectra then have to be combined into one single point estimate and its variance, which is achieved by calling calc_Y_sigma_from_Yf_sigmaf.

Examples

Starting from averaged PSDs and the CSD of a baseline, we can compute the overall point estimate for the gravitational-wave background.

Assuming we already computed the CSDs and PSDs, see for example in pygwb.spectral, we also need the overlap reduction function, see pygwb.orfs. With these at hand, we can compute the point estimate spectrogram and its variance.

>>> Y_spectrogram, var_spectrogram = calculate_point_estimate_sigma_spectra(
        CSD_baseline.frequencies.value,
        CSD_baseline[2:-2],
        ifo_1.average_psd.crop_frequencies(3.12500000e-02,2.048e+03),
        ifo_2.average_psd.crop_frequencies(3.12500000e-02,2.048e+03),
        orf,
        sample_rate=4096,
        segment_duration=192,
        window_fftgram_dict={"window_fftgram": "hann"},
        overlap_factor=0.5,
        fref=25.0,
        alpha=0.0,
    )

For this example, we used some pre-computed CSD and PSDs, for some baseline, together with its overlap reduction function. The above returns the point estimate and variance as a function of frequency and time, i.e., for each segment. These can be combined over all analysis segments into a single point estimate and sigma spectrum, i.e. as a function of frequency only.

>>> Y_spectrum, var_spectrum = postprocess_Y_sigma(
        Y_spectrogram.value,
        var_spectrogram.value,
        segment_duration=192,
        deltaF=1/32.,
        new_sample_rate=4096,
        frequency_mask=True,
        badtimes_mask=None,
        window_fftgram_dict={"window_fftgram": "hann"},
        window_fftgram_dict_welch={"window_fftgram": "hann"},
        overlap_factor=0.5,
        overlap_factor_welch=0.5,
        N_avg_segs=2,
    )

To compute a single point estimate and its variance for the magnitude of the GWB, one uses the frequency spectra computed above and relies on the following method:

>>> Y, sigma = postpp.calc_Y_sigma_from_Yf_sigmaf(
        Y_spectrum, np.sqrt(var_spectrum), frequency_mask=True, alpha=None, fref=None
    )

The result is an overall point estimate and standard deviation. Additional information on the various methods outlined above can be found in the following dedicated API documentation of the module.

Functions

calc_Y_sigma_from_Yf_sigmaf(Y_f, sigma_f[, ...])

Calculate the omega point estimate and sigma from their respective spectra, or spectrograms, taking into account the desired spectral weighting.

calculate_point_estimate_sigma_spectra(...)

Calculate the Omega point estimate and associated sigma integrand, given a set of cross-spectral and power-spectral density spectrograms.

combine_spectra_with_sigma_weights(...)

Combine different statistically independent spectra \(S_i(f)\) using spectral weights \(w_i(f)\), as

odd_even_segment_postprocessing(Y_fs, ...[, ...])

Perform averaging which combines even and odd segments for overlapping data.

postprocess_Y_sigma(Y_fs, var_fs, ...[, ...])

Run postprocessing of point estimate and sigma spectrograms, combining even and odd segments in the case of overlapping data.