gwastro / pycbc

Core package to analyze gravitational-wave data, find signals, and study their parameters. This package was used in the first direct detection of gravitational waves (GW150914), and is used in the ongoing analysis of LIGO/Virgo data.
http://pycbc.org
GNU General Public License v3.0
314 stars 348 forks source link

Set random seeds for fake noise in make_skymap example #4883

Closed titodalcanton closed 1 week ago

titodalcanton commented 2 weeks ago

This modifies one of the examples of pycbc_make_skymap to make it clear that random seeds for fake noise must be set explicitly.

Standard information about the request

This is a documentation enhancement.

This change affects one of the examples of pycbc_make_skymap.

Motivation

When simulating noise on multiple detectors via --fake-strain, it is important to set different random seeds in different detectors, otherwise you will get the same noise realization in all detectors, which is usually not how you want to simulate noise!

The example of pycbc_make_skymap that uses simulated noise was not setting the seed explicitly, therefore implicitly using the same seed for all detectors. The resulting skymap looks correct visually, but this can lead to weird results when doing large simulations and checking the results statistically.

Contents

In light of the issue described above, this PR adds explicit seeds to the example.

Links to any issues or associated PRs

N/A

Testing performed

Ran the example before and after this change and plotted the resulting SNR timeseries. Before, I get this:

image

After, I get this:

image

Note the pattern of the noise fluctuations away from the central SNR peaks.

Additional notes

Thanks to Nicolas and Clara for noticing this.

titodalcanton commented 1 week ago

@spxiwh I imagine there is a way to do that, and it sounds like a very good idea, but I would have to dig a bit into the current code to find out.