API
SamRFI
- class samrfi.RadioRFI(vis=False, dir_path=None)
SyntheticRFI
- class samrfi.SyntheticRFI(points_freq=None, points_time=None, min_freq=None, max_freq=None, max_time=None, min_time=None, dir_path=False)
- add_gaussian_rfi_spectrograph(amplitude, center, width, rfi_axis='FREQ', table=False)
Add Gaussian RFI to the spectrograph along the specified axis.
- Parameters:
amplitude (float): The amplitude of the RFI signal. center (float): The center frequency or time of the RFI signal. width (float): The bandwidth or timewidth of the RFI signal. rfi_axis (str): The axis along which to add the RFI (‘FREQ’ or ‘TIME’). table (bool): Whether to add the RFI parameters to the RFI table.
- Returns:
numpy.ndarray: The spectrograph with added Gaussian RFI.
- add_square_rfi_spectrograph(amplitude, center, width, rfi_axis='FREQ', table=False)
Add Square RFI to the spectrograph along the specified axis.
- Parameters:
amplitude (float): The amplitude of the RFI signal. center (float): The center frequency or time of the RFI signal. width (float): The bandwidth or timewidth of the RFI signal. rfi_axis (str): The axis along which to add the RFI (‘FREQ’ or ‘TIME’). table (bool): Whether to add the RFI parameters to the RFI table.
- Returns:
numpy.ndarray: The spectrograph with added Square RFI.
- baseline_profile()
Generates a baseline profile using a normal distribution.
- Returns:
numpy.ndarray: The baseline profile.
- create_model_spectrograph()
Create a model spectrograph based on the given table of RFI parameters.
- Parameters:
table (pandas.DataFrame): A table containing RFI parameters such as amplitude, center frequency, and bandwidth. frequencies (numpy.ndarray): An array of frequencies. points_time (int): The number of time intervals. points_freq (int): The number of points_freq in the spectrograph.
- Returns:
numpy.ndarray: The model spectrograph.
- gaussian_function(x, amplitude, center, width)
Generates a radio frequency interference (RFI) signal.
- Parameters:
amplitude (float): The amplitude of the RFI signal. center_freq (float): The center frequency of the RFI signal. bandwidth (float): The bandwidth of the RFI signal.
- Returns:
numpy.ndarray: An array representing the RFI signal.
- generate_waterfall(mean_rfi=1, std_rfi=5, pers_freq_gauss=1, pers_time_gauss=0, inter_freq_gauss=0, inter_freq_square=0, pers_freq_square=0, pers_time_square=0, noise=10, mean=5, edge_buffer=50)
Generate a waterfall plot with simulated radio frequency interference (RFI).
- Parameters:
pers_freq_gauss (int): The number of persistent RFI signals to add to the waterfall plot in frequency. Default is 1. pers_time_gauss (int): The number of persistent RFI signals to add to the waterfall plot in time. Default is 0. inter_freq_gauss (int): The number of intermittent RFI signals to add to the waterfall plot. Default is 0. noise (float): The noise level of the waterfall plot. Default is 10. mean (float): The mean level of the waterfall plot. Default is 5. edge_buffer (int): The buffer size around the edges of the waterfall plot. Default is 50.
- Returns:
None
- intermittent_rfi(amplitude, center_freq, bandwidth, time_period, duty_cycle, time_offset=0, func_type='GAUSS', table=False)
Add intermittent RFI to the spectrograph in two channels with a specified frequency offset and time period.
Parameters: - spectrograph: The input spectrograph to which RFI will be added. - frequencies: Array of frequency values. - amplitude: Amplitude of the RFI signal. - center_freq: Center frequency of the first RFI channel. - bandwidth: Bandwidth of the RFI signal. - time_period: Time period for the intermittent RFI. - duty_cycle: Fraction of the time period during which the RFI is active. - time_offset: Offset in time for the intermittent RFI (default: 0).
Returns: - modified_spectrograph: The spectrograph with added intermittent RFI.
Plotter
- class samrfi.Plotter(radiorfi_instance)
RFIModels
- class samrfi.RFIModels(sam_checkpoint, sam_type, radiorfi_instance, device='cuda')
- create_RGB_channels(zeroR=False, zeroG=False, zeroB=False)
Generate an RGB combined image from a spectrograph.
- Parameters:
spectrograph (numpy.ndarray): The input spectrograph image.
- Returns:
numpy.ndarray: The RGB combined image.
RFITraining
- class samrfi.RFITraining(rfi_instance, device='cuda')
MetricsCalculator
utility functions
- samrfi.utilities.calcquality(dat, flag)
Need to minimize the score that it returns
- samrfi.utilities.create_patchify_patches(rfi_combined, patch_size=128)
Create patches from a list of images.
- Parameters:
rfi_combined (list of numpy.ndarray): List of images to be patched. patch_size (int): Size of each patch. Default is 128. step (int): Step size for patching. Default is 128.
- Returns:
numpy.ndarray: Array of image patches.
- samrfi.utilities.find_spectrograph_peaks(spectrograph, min_distance=10, threshold_abs=30)
Find peaks in the spectrograph image.
- Parameters:
spectrograph (numpy.ndarray): The input spectrograph image. min_distance (int): The minimum distance between peaks. Default is 10. threshold_abs (int): The minimum intensity value for peaks. Default is 25.
- Returns:
numpy.ndarray: An array of peak coordinates.