BGlib.gmode.proc.signal_filter.SignalFilter

class BGlib.gmode.proc.signal_filter.SignalFilter(h5_main, frequency_filters=None, noise_threshold=None, write_filtered=True, write_condensed=False, num_pix=1, phase_rad=0, **kwargs)[source]

Bases: Process

Filters the entire h5 dataset with the given filtering parameters. :param h5_main: Dataset to process :type h5_main: h5py.Dataset object :param frequency_filters: Frequency (vertical) filters to apply to signal :type frequency_filters: (Optional) single or list of pycroscopy.fft.FrequencyFilter objects :param noise_threshold: Noise tolerance to apply to data. Value must be within (0, 1) :type noise_threshold: (Optional) float. Default - None :param write_filtered: Whether to write the filtered data to file :type write_filtered: (Optional) bool. Default - True :param write_condensed: Whether to write the condensed data in frequency space to file. Use this for datasets that are very

large but sparse in frequency space.

Parameters:
  • num_pix ((Optional) uint. Default - 1) – Number of pixels to use for filtering. More pixels means a lower noise floor and the ability to pick up weaker signals. Use only if absolutely necessary. This value must be a divisor of the number of pixels in the dataset

  • phase_rad ((Optional). float) – Degrees by which the output is rotated with respect to the input to compensate for phase lag. This feature has NOT yet been implemented.

  • h5_target_group (h5py.Group, optional. Default = None) – Location where to look for existing results and to place newly computed results. Use this kwarg if the results need to be written to a different HDF5 file. By default, this value is set to the parent group containing h5_main

  • kwargs ((Optional). dictionary) – Please see Process class for additional inputs

Methods

compute

Creates placeholders for the results, applies the _unit_computation() to chunks of the dataset

test

Tests the signal filter on a single pixel (randomly chosen unless manually specified) worth of data. :param pix_ind: Index of the pixel whose data will be used for inference :type pix_ind: int, optional. default = random :param excit_wfm: Waveform against which the raw and filtered signals will be plotted. This waveform can be a fraction of the length of a single pixel's data. For example, in the case of G-mode, where a single scan line is yet to be broken down into pixels, the excitation waveform for a single pixel can br provided to automatically break the raw and filtered responses also into chunks of the same size. :type excit_wfm: array-like, optional. default = None.

use_partial_computation

Extracts the necessary parameters from the provided h5 group to resume computation

Attributes

write_condensed

Remember that the default number of pixels corresponds to only the raw data that can be held in memory In the case of signal filtering, the datasets that will occupy space are: 1.

parms_dict

The name of the HDF5 dataset that should be present to signify which positions have already been computed This is NOT a fully private variable so that multiple processes can be run within a single group - Eg Fitter In the case of Fitter - this name can be changed from 'completed_guesses' to 'completed_fits' check_for_duplicates will be called by the Child class where they have the opportunity to change this variable before checking for duplicates

compute(override=False, *args, **kwargs)

Creates placeholders for the results, applies the _unit_computation() to chunks of the dataset

Parameters:
  • override (bool, optional. default = False) – By default, compute will simply return duplicate results to avoid recomputing or resume computation on a group with partial results. Set to True to force fresh computation.

  • args (list) – arguments to the mapped function in the correct order

  • kwargs (dict) – keyword arguments to the mapped function

Returns:

h5_results_grp – Group containing all the results

Return type:

h5py.Group

parms_dict

The name of the HDF5 dataset that should be present to signify which positions have already been computed This is NOT a fully private variable so that multiple processes can be run within a single group - Eg Fitter In the case of Fitter - this name can be changed from ‘completed_guesses’ to ‘completed_fits’ check_for_duplicates will be called by the Child class where they have the opportunity to change this variable before checking for duplicates

test(pix_ind=None, excit_wfm=None, **kwargs)[source]

Tests the signal filter on a single pixel (randomly chosen unless manually specified) worth of data. :param pix_ind: Index of the pixel whose data will be used for inference :type pix_ind: int, optional. default = random :param excit_wfm: Waveform against which the raw and filtered signals will be plotted. This waveform can be a fraction of the

length of a single pixel’s data. For example, in the case of G-mode, where a single scan line is yet to be broken down into pixels, the excitation waveform for a single pixel can br provided to automatically break the raw and filtered responses also into chunks of the same size.

Return type:

fig, axes

use_partial_computation(h5_partial_group=None)

Extracts the necessary parameters from the provided h5 group to resume computation

Parameters:

h5_partial_group (h5py.Group) – Group containing partially computed results

write_condensed

Remember that the default number of pixels corresponds to only the raw data that can be held in memory In the case of signal filtering, the datasets that will occupy space are: 1. Raw, 2. filtered (real + freq space copies), 3. Condensed (substantially lesser space) The actual scaling of memory depends on options: