MF Class¶
This is the MF (match filter) class. Use this class to apply filters to an incoherent noise spectrum.
- class SSINS.MF(freq_array, sig_thresh, shape_dict={}, tb_aggro=0, N_samp_thresh=None, narrow=True, streak=True, broadcast_dict={}, broadcast_streak=False)[source]¶
Defines the Match Filter (MF) class.
- apply_match_test(INS, event_record=True, apply_samp_thresh=None, freq_broadcast=False, time_broadcast=False)[source]¶
A method that uses the match_test() method to flag RFI. The champion from match_test() is flagged and the mean-subtracted spectrum is recalculated. This repeats until there are no more outliers greater than sig_thresh. Also can apply the samp_thresh_test in each iteration, which flags highly occupied channels between match test iterations.
- Parameters
INS – The INS to flag
event_record (bool) – If True, append events to INS.match_events
apply_samp_thresh (bool) – Deprecated in favor of the time_broadcast keyword.
freq_broadcast (bool) – If True, broadcast flags between iterations using the broadcast_dict
time_broadcast (bool) – If True, broadcasts flags in time if significant flagging in channels. Set tb_aggro parameter for aggression.
- broadcast_dict¶
A dictionary of subbands. Keys are a subband name, values are the lower and upper frequency bounds in Hz.
- broadcast_slc_dict¶
A dictionary whose keys are the same as broadcast_dict and whose values are corresponding slices into the freq_array attribute
- freq_array¶
A 1-d array of frequencies (in hz) for the filter to operate with
- freq_broadcast(INS, event, event_record=False)[source]¶
Broadcast flags in frequency, regardless of flagging fraction. Determined, by the broadcast_dict. An event will be recorded in the match_filter saying which integration/band was flagged.
- Parameters
INS – The incoherent noise spectrum being worked on.
event – The event to broadcast flags for.
event_record (bool) – Whether to record a new event for this flagging entry.
- match_test(INS)[source]¶
The primary test that the filter is used with. The greatest outlier in each shape is put forth and a champion among them is chosen. The time, frequencies, and outlier statistic and shape of this champion is returned to the stack.
- Parameters
INS – An INS to test
- Returns
The time index of the strongest outlier (None if no significant outliers) f_max: The slice in the freq_array for the strongest outlier (None if no significant outliers) R_max: The ratio of the z-score of the outlier to the sig_thresh (-np.inf if no significant outliers) shape_max: The shape of the strongest outlier
- Return type
t_max
- shape_dict¶
A dictionary of shapes. Keys are a shape name, values are the lower and upper frequency bounds in Hz.
- sig_thresh¶
A dictionary of significance thresholds to flag per shape. Keys are shapes and values are thresholds.
- slice_dict¶
A dictionary whose keys are the same as shape_dict and whose values are corresponding slices into the freq_array attribute
- tb_aggro¶
The threshold for flagging an entire channel when some flags exist and apply_samp_thresh() is called. Must be between 0 and 1. Represents a fraction of unflagged data remaining.
- time_broadcast(INS, event, event_record=False)[source]¶
Broadcasts flags in time for a subband (determined by the passed event) if the fraction of unflagged samples in the subband is less than the tb_aggro parameter. If so, the entire subband is flagged for the whole object. A ValueError is raised if the aggro parameter is greater than or equal to 1, which will always flag everything.
- Parameters
INS – An INS to test
event – The event to check.
event_record (bool) – If true, append events to INS.match_events.
- Returns
- Possible new event if more flagging happened. Returns old
event if no additional flagging happened.
- Return type
new_event
- write(prefix, sep='_', clobber=False)[source]¶
Writes out a yaml file with the important information about the filter.
- Parameters
prefix – The filepath prefix for the output file. Output file will be named f’{prefix}{sep}matchfilter.yaml’
sep – The separator character between the prefix and the rest of the output filepath.
clobber – Whether to overwrite an identically named file. True overwrites.