torchsig.utils.dsp.update_signal_snr_bandwidth¶
- torchsig.utils.dsp.update_signal_snr_bandwidth(dataset: TorchSigIterableDataset, new_signal: Signal) None[source]¶
Updates the SNR and bandwidth of a signal based on dataset parameters.
This function performs two main operations: 1. Corrects the SNR of the signal by comparing the estimated SNR from the signal’s
spectrogram with the target SNR range defined in the signal metadata.
Updates the signal’s bandwidth metadata to better fit the bounding box by estimating the 99% bandwidth from the signal’s spectral content.
- Parameters:
dataset (TorchSigIterableDataset) – The dataset object containing FFT parameters, noise floor information, and other metadata needed for processing.
new_signal (Signal) – The signal object to be processed, containing: - data: The time-domain signal data - snr_db_min: Minimum target SNR in dB - snr_db_max: Maximum target SNR in dB - bandwidth: Current bandwidth value (will be updated)
- Returns:
The function modifies the new_signal object in place.
- Return type:
None
Notes
The SNR correction is performed by: 1. Computing a spectrogram of the signal 2. Estimating the current SNR from the spectrogram 3. Calculating a correction factor to match the target SNR 4. Applying this correction to the signal data
The bandwidth update is performed by: 1. Finding frequency bins where the signal exceeds the noise floor by 3dB 2. Determining the frequency range of these bins 3. Widening this range by half the FFT frequency resolution 4. Updating the signal’s bandwidth metadata with this new range
The signal data itself is not resampled - only the metadata is updated.