pygwb.notch.StochNotchList

class pygwb.notch.StochNotchList(notch_list)[source]

Bases: list

__init__(notch_list)[source]

A list of notches. All these notches are represented by an object of the StochNotch class.

Parameters:

notch_list (list) – A list of length-3 tuples of the (min, max) frequency (in Hz); description for the notches.

Notes

Raises:

ValueError: If the list is malformed.

__call__(*args, **kwargs)

Call self as a function.

Methods

__init__(notch_list)

A list of notches.

append(object, /)

Append object to the end of the list.

check_frequency(freq)

Checks whether a given frequency is inside the notch list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

get_notch_mask(frequency_array[, ...])

Get a boolean mask for the frequencies in frequency_array in the notch list.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

load_from_file(filename)

Load an already existing notch list from a txt-file (with formatting as produced by this code).

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse(/)

Reverse IN PLACE.

save_notch_mask(frequency_array, filename)

Saves a boolean mask for the frequencies in frequency_array in the notch list.

save_to_txt(filename)

Saves the notch list to a .txt file (after sorting).

sort(*[, key, reverse])

Sort the list in ascending order and return None.

sort_list()

Sorts the notch list based on the minimum frequency of the notches.

append(object, /)

Append object to the end of the list.

check_frequency(freq)[source]

Checks whether a given frequency is inside the notch list.

Parameters:

freq (float) – The frequency to check (in Hz).

Returns:
True/False:

If freq inside any of the notches, return True, else False.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

get_notch_mask(frequency_array, save_file_flag=False, filename='')[source]

Get a boolean mask for the frequencies in frequency_array in the notch list.

Parameters:
  • frequency_array (np.ndarray) – An array of frequencies (in Hz).

  • save_file_flag (bool) – A boolean flag indicating whether to save the notch mask in a file or not.

  • filename (str) – The name of the file where to store the notch mask if save_file_flag is True.

Returns:
notch_mask: np.ndarray

An array of booleans that are False for frequencies in the notch.

Notes

This notches any frequency that may have overlapping frequency content with the notch.

index(value, start=0, stop=sys.maxsize, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)

Insert object before index.

classmethod load_from_file(filename)[source]

Load an already existing notch list from a txt-file (with formatting as produced by this code).

Parameters:

filename (str) – Filename of the file containing the notchlist to be read in.

pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse(/)

Reverse IN PLACE.

save_notch_mask(frequency_array, filename)[source]

Saves a boolean mask for the frequencies in frequency_array in the notch list.

Parameters:
  • frequency_array (np.ndarray) – An array of frequencies (in Hz).

  • filename (str) – Name of the target file.

Notes

This saves notch_mask in a .txt file. Notch_mask is an array of booleans that are False for frequencies in the notch.

save_to_txt(filename)[source]

Saves the notch list to a .txt file (after sorting).

Parameters:

filename (str) – Name of the target file.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

sort_list()[source]

Sorts the notch list based on the minimum frequency of the notches.