pygwb.notch

Realistic detector data will have noise lines and various other artefacts, which should not be included in the analysis (more information here). These frequencies need to be notched, i.e. removed, from the analysis. The notch module handles all things related to frequency notches. It has two main classes and a few methods that create a notchlist that can be used in the pygwb analysis to get rid of badly behaving frequencies. The code relies on the base class StochNotch, which in turn is based on the Notch class from bilby.gw.detector.strain_data (more information here). It stores a single Notch object containing a small description of the notch and the corresponding minimum and maximum frequency. Next, StochNotchList is the combination of multiple StochNotch objects, and contains information about multiple notches.

Three additional functions are defined in this module to create a StochNotchList object for three of the most prevalent types of notches. The first function is comb which creates a StochNotchList for a certain set of lines in a comb structure. Secondly, we have power_lines which makes a StochNotchList object for the power line harmonic notches, e.g. 60 Hz harmonics in the USA and 50 Hz in Italy. The third and final function, pulsar_injection, generates a StochNotchList object with notches which are contaminated by pulsar injections.

More information on the various types of bad frequency lines that need to be notched can be found here.

Examples

We will generate a StochNotchList from a .txt file containing multiple StochNotch objects and showcase some functions.

First, we import the pygwb.notch module and load notches into a StochNotchList object from a .txt file.

>>> import pygwb.notch as pn
>>> notch_list = pn.StochNotchList.load_from_file("./test/test_data/Official_O3_HL_notchlist.txt")

notch_list now contains information about all notches in the .txt file. The StochNotchList object itself is a container object that collects all notches of the file in different StochNotch objects.

For example, it is known that there is a power line notched around 60 Hz. To check this is indeed the case, one calls:

>>> is_60_in_notch_list = notch_list.check_frequency(60)
True

This allows to check if a certain frequency is present in the container object. If one wants to have information about all the notches in the StochNotchList, one can run

>>> for notch in notch_list:
>>>    notch.print_notch()

This will show the minimum and maximum frequency for all notches in StochNotchList, and prints a small description of the notch itself.

Another important functionality of the StochNotchList object is computing the frequency mask that will be False for frequencies in the StochNotchList object. That mask can then be used to “mask” a real pygwb analysis spectrum and notch out the contaminated frequencies.

For illustrative purposes, we take a random frequency array and mask it using our StochNotchList object:

>>> frequency_array = np.arange(0, 1700,1/32.)
>>> notch_list.get_notch_mask(frequency_array, save_file_flag=False, filename="")

The List function uses the get_notch_mask function from the StochNotch object, and combines the mask over all notches.

One can also save the StochNotchList object to a .txt file using save_to_txt(filename). This will create a .txt file in the same structure as required to make a StochNotchList object from a file, as done in this example. The mask itself can also be saved, using save_notch_mask(frequency_array, filename).

Functions

comb(f0, f_spacing, n_harmonics, df[, ...])

Create a list of comb lines to remove with the form 'f0+n*f_spacing, n=0,1,...,n_harmonics-1'.

power_lines([fundamental, nharmonics, df])

Create list of power line harmonics (nharmonics*fundamental Hz) to remove.

pulsar_injections(filename, t_start, t_end)

Create list of frequencies contaminated by pulsar injections.

Classes

StochNotch(minimum_frequency, ...)

StochNotchList(notch_list)