torchsig.datasets.dataset_metadata.NarrowbandMetadata

class torchsig.datasets.dataset_metadata.NarrowbandMetadata(num_iq_samples_dataset: int, fft_size: int, impairment_level: int, sample_rate: float = 10000000.0, num_signals_min: int | None = None, num_signals_distribution: ndarray | List[float] | None = None, snr_db_min: float = 0.0, snr_db_max: float = 50.0, signal_duration_min: float | None = None, signal_duration_max: float | None = None, signal_bandwidth_min: float | None = None, signal_bandwidth_max: float | None = None, signal_center_freq_min: float | None = None, signal_center_freq_max: float | None = None, transforms: list = [], target_transforms: list = [], class_list: List[str] = ['ook', '4ask', '8ask', '16ask', '32ask', '64ask', '2fsk', '2gfsk', '2msk', '2gmsk', '4fsk', '4gfsk', '4msk', '4gmsk', '8fsk', '8gfsk', '8msk', '8gmsk', '16fsk', '16gfsk', '16msk', '16gmsk', 'bpsk', 'qpsk', '8psk', '16psk', '32psk', '64psk', '16qam', '32qam', '32qam_cross', '64qam', '128qam_cross', '256qam', '512qam_cross', '1024qam', 'ofdm-64', 'ofdm-72', 'ofdm-128', 'ofdm-180', 'ofdm-256', 'ofdm-300', 'ofdm-512', 'ofdm-600', 'ofdm-900', 'ofdm-1024', 'ofdm-1200', 'ofdm-2048', 'fm', 'am-dsb-sc', 'am-dsb', 'am-lsb', 'am-usb', 'lfm_data', 'lfm_radar', 'chirpss', 'tone'], class_distribution=None, num_samples: int | None = None, **kwargs)[source]

Bases: DatasetMetadata

Narrowband Dataset Metadata Class

This class encapsulates the metadata for a narrowband dataset, extending the base DatasetMetadata class. It provides useful information about the dataset such as the number of samples, the sample rate, the FFT size, the impairment level, and signal-related parameters. Additionally, it handles specific properties for narrowband signals, such as oversampling rates and center frequency offset (CFO) error percentage.

minimum_params

List of minimum required parameters for the narrowband dataset.

Type:

List[str]

Methods

add_parent

Add parent Seedable object and set up RNGs accordingly

get_distribution

get_second_seed

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds

seed

Seed number generators with given seed.

setup_rngs

Initialize torch and numpy number generators, and update its children.

to_dict

Converts the dataset metadata into a dictionary format.

update_from_parent

Update numpy and torch number generators with parent seed

Attributes

class_distribution

Signal modulation class distribution for dataset generation.

class_list

Signal modulation class list for dataset.

dataset_bandwidth_max

The maximum possible bandwidth for a signal

dataset_bandwidth_min

The minimum possible bandwidth for a signal

dataset_center_freq_max

The maximum center frequency for a signal

dataset_center_freq_min

The minimum center frequency for a signal

dataset_duration_in_samples_max

The maximum duration in samples possible within the dataset

dataset_duration_in_samples_min

The minimum duration in samples possible within the dataset

dataset_duration_max

The maximum duration possible within the dataset

dataset_duration_min

The minimum duration possible within the dataset

dataset_type

Type of dataset.

fft_frequency_max

The maximum frequency associated with the FFT

fft_frequency_min

The minimum frequency associated with the FFT

fft_frequency_resolution

Frequency resolution of the spectrogram

fft_size

The size of FFT (number of bins) to be used in spectrogram.

fft_stride

The stride of input samples in FFT (number of samples)

frequency_max

Maximum representable frequency

frequency_min

Minimum representable frequency

impairment_level

Level of signal impairments to apply to signals (0-2)

impairments

Impairment signal and dataset transforms

minimum_params

noise_power_db

Reference noise power (dB) for the dataset

num_iq_samples_dataset

Length of I/Q array per sample in dataset.

num_samples

Getter for the number of samples in the dataset.

num_signals_distribution

Probabilities for each value in num_signals_range.

num_signals_max

Max number of signals in each sample in the dataset

num_signals_min

Minimum number of signals in each sample in the dataset.

num_signals_range

Range of num_signals can be generated by a sample.

sample_rate

Sample rate for the dataset.

signal_bandwidth_max

Defines the maximum bandwidth for a signal in the dataset Must be within the boundary provided by dataset_bandwidth_max().

signal_bandwidth_min

Defines the minimum bandwidth for a signal in the dataset Must be within the boundary provided by dataset_bandwidth_min().

signal_center_freq_max

Defines the maximum center frequency boundary for a signal.

signal_center_freq_min

Defines the minimum center frequency boundary for a signal.

signal_duration_in_samples_max

The maximum duration in samples for a signal

signal_duration_in_samples_min

The minimum duration in samples for a signal

signal_duration_max

Getter for the maximum signal duration.

signal_duration_min

Getter for the minimum signal duration.

snr_db_max

Minimum SNR in dB for signals in dataset

snr_db_min

Minimum SNR in dB for signals in dataset

target_transforms

Target Transform to apply.

transforms

Transforms to perform on signal data (after signal impairments).

__init__(num_iq_samples_dataset: int, fft_size: int, impairment_level: int, sample_rate: float = 10000000.0, num_signals_min: int | None = None, num_signals_distribution: ndarray | List[float] | None = None, snr_db_min: float = 0.0, snr_db_max: float = 50.0, signal_duration_min: float | None = None, signal_duration_max: float | None = None, signal_bandwidth_min: float | None = None, signal_bandwidth_max: float | None = None, signal_center_freq_min: float | None = None, signal_center_freq_max: float | None = None, transforms: list = [], target_transforms: list = [], class_list: List[str] = ['ook', '4ask', '8ask', '16ask', '32ask', '64ask', '2fsk', '2gfsk', '2msk', '2gmsk', '4fsk', '4gfsk', '4msk', '4gmsk', '8fsk', '8gfsk', '8msk', '8gmsk', '16fsk', '16gfsk', '16msk', '16gmsk', 'bpsk', 'qpsk', '8psk', '16psk', '32psk', '64psk', '16qam', '32qam', '32qam_cross', '64qam', '128qam_cross', '256qam', '512qam_cross', '1024qam', 'ofdm-64', 'ofdm-72', 'ofdm-128', 'ofdm-180', 'ofdm-256', 'ofdm-300', 'ofdm-512', 'ofdm-600', 'ofdm-900', 'ofdm-1024', 'ofdm-1200', 'ofdm-2048', 'fm', 'am-dsb-sc', 'am-dsb', 'am-lsb', 'am-usb', 'lfm_data', 'lfm_radar', 'chirpss', 'tone'], class_distribution=None, num_samples: int | None = None, **kwargs)[source]

Initializes Narrowband Metadata. Sets dataset_type=”narrowband.

Parameters:
  • num_iq_samples_dataset (int) – The length of I/Q array per sample in the dataset.

  • fft_size (int) – The size of FFT (number of bins) to be used in spectrogram calculation.

  • impairment_level (int) – Signal impairment level.

  • sample_rate (float, optional) – The sample rate for the dataset (default is 10e6).

  • num_signals_min (int, optional) – Minimum number of signals per sample (default is 0).

  • num_signals_distribution (np.ndarray | List[float], optional) – The probability distribution for generating samples with a specific number of signals. Defaults to uniform distribution if None.

  • snr_db_min (float, optional) – Minimum SNR (Signal-to-Noise Ratio) for the signals (default is 0.0).

  • snr_db_max (float, optional) – Maximum SNR for the signals (default is 50.0).

  • signal_duration_min (float, optional) – Minimum duration of a signal (Default is None).

  • signal_duration_max (float, optional) – Maximum duration of a signal (Default is None).

  • signal_bandwidth_min (float, optional) – Minimum bandwidth of a signal. Default is None.

  • signal_bandwidth_max (float, optional) – Maximum bandwidth of a signal. Default is None.

  • signal_center_freq_min (float, optional) – Minimum center frequency of a signal. Default is None.

  • signal_center_freq_max (float, optional) – Maximum center frequency of a signal. Default is None.

  • transforms (list, optional) – Transforms to apply on the dataset (default in []).

  • target_transforms (list, optional) – Transforms for targets (default is an empty list).

  • class_list (List[str], optional) – List of signal class names (default is all signals from TorchSigSignalLists).

  • class_distribution (np.ndarray | List[float], optional) – Probability distribution for classes (default is None).

  • num_samples (int, optional) – Length of the dataset. If None, an infinite dataset is assumed (default is None).

__repr__() str

Return repr(self).

__str__() str

Return str(self).

add_parent(parent) None

Add parent Seedable object and set up RNGs accordingly

property class_distribution: ndarray | List[str]

Signal modulation class distribution for dataset generation.

Returns:

List of class probabilites.

Return type:

np.ndarray | List[str]

property class_list: List[str]

Signal modulation class list for dataset.

Returns:

List of signal modulation class names

Return type:

List[str]

property dataset_bandwidth_max: float

The maximum possible bandwidth for a signal

Provides a boundary for the maximum bandwidth of a signal, which is the sampling rate.

Returns:

the maximum bandwidth for a signal

Return type:

float

property dataset_bandwidth_min: float

The minimum possible bandwidth for a signal

Provides a boundary for the minimum bandwidth of a signal, which is the bandwidth of a tone, which is sample rate / number of samples.

Returns:

the minimum bandwidth for a signal

Return type:

float

property dataset_center_freq_max: float

The maximum center frequency for a signal

The maximum is a boundary condition such that the center frequency will not alias across the upper sampling rate boundary.

The calculation includes a small epsilon such that the center_freq_max is never equal to sample_rate/2 to avoid the aliasing condition because -sample_rate/2 is equivalent to sample_rate/2.

Returns:

maximum center frequency boundary for signal

Return type:

float

property dataset_center_freq_min: float

The minimum center frequency for a signal

The minimum is a boundary condition such that the center frequency will not alias across the lower sampling rate boundary.

Returns:

minimum center frequency boundary for signal

Return type:

float

property dataset_duration_in_samples_max: float

The maximum duration in samples possible within the dataset

The maximum is a boundary condition such that the signal duration in number of samples will not exceed the total number of samples within the dataset.

Returns:

maximum duration for a signal in number of samples

Return type:

float

property dataset_duration_in_samples_min: float

The minimum duration in samples possible within the dataset

The minimum is a boundary condition such that the signal duration in number of samples will not exceed the total number of samples within the dataset.

Returns:

minimum duration for a signal in number of samples

Return type:

float

property dataset_duration_max: float

The maximum duration possible within the dataset

The maximum is a boundary condition such that the signal duration will not exceed the total time duration of the dataset.

Returns:

maximum duration for a signal

Return type:

float

property dataset_duration_min: float

The minimum duration possible within the dataset

The minimum is a boundary condition such that the signal duration will not be less than a specified minimum.

Returns:

minimum duration for a signal

Return type:

float

property dataset_type: str

Type of dataset.

Returns:

Dataset type name

Return type:

str

property fft_frequency_max: float

The maximum frequency associated with the FFT

Defines the largest frequency within the FFT of the spectrogram. The FFT has discrete bins and therefore each bin has an associated frequency. This frequency is associated with the N-1’th bin or right-most frequency bin.

Returns:

maximum FFT frequency

Return type:

float

property fft_frequency_min: float

The minimum frequency associated with the FFT

Defines the smallest frequency within the FFT of the spectrogram. The FFT has discrete bins and therefore each bin has an associated frequency. This frequency is associated with the 0th bin or left-most frequency bin.

Returns:

minimum FFT frequency

Return type:

float

property fft_frequency_resolution: float

Frequency resolution of the spectrogram

The frequency resolution, or resolution bandwidth, of the FFT.

Returns:

frequency resolution

Return type:

float

property fft_size: int

The size of FFT (number of bins) to be used in spectrogram.

The FFT size used to compute the spectrogram for the wideband dataset.

Returns:

FFT size

Return type:

int

property fft_stride: int

The stride of input samples in FFT (number of samples)

The FFT stride controls the distance in samples between successive FFTs. A smaller FFT stride means more averaging between FFTs, a larger stride means less averaging between FFTs. fft_stride = fft_size means there is no overlap of samples between the current and next FFT. fft_stride = fft_size/2 means there is 50% overlap between the input samples of the the current and next fft.

Returns:

FFT stride

Return type:

int

property frequency_max: float

Maximum representable frequency

Boundary edge for testing the upper Nyquist sampling boundary. Due to the circular nature of the frequency domain, both -fs/2 and fs/2 represent the boundary, therefore an epsilon value is used to back off the upper edge slightly.

Returns:

maximum frequency

Return type:

float

property frequency_min: float

Minimum representable frequency

Boundary edge for testing the lower Nyquist sampling boundary.

Returns:

minimum frequency

Return type:

float

get_second_seed(seed: int) int

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds

Parameters:

seed (int) – Seed to use.

Returns:

New seed.

Return type:

int

property impairment_level: int

Level of signal impairments to apply to signals (0-2)

Returns:

Impairment level.

Return type:

int

property impairments: Impairments

Impairment signal and dataset transforms

Returns:

Transforms or impairments

Return type:

Impairments

property noise_power_db: float

Reference noise power (dB) for the dataset

The noise power is a common reference to be used for all signal generation in order to establish accurate SNR calculations. The noise power dB is given in decibels. The PSD estimate of the AWGN is calculated such that the averaging across all frequency bins average to noise_power_db.

Returns:

noise power in dB

Return type:

float

property num_iq_samples_dataset: int

Length of I/Q array per sample in dataset.

Returns the number of IQ samples of the dataset, this is the length of the array that contains the IQ samples

Returns:

number of IQ samples

Return type:

int

property num_samples: int

Getter for the number of samples in the dataset.

This property returns the number of samples that the dataset is configured to have. If the value is set to None, it indicates that the number of samples is considered infinite.

Returns:

The number of samples in the dataset, or a representation of infinite samples if set to None.

Return type:

int

property num_signals_distribution: List[float]

Probabilities for each value in num_signals_range.

Returns:

Probabilties sample generates N signals per sample.

Return type:

List[float]

property num_signals_max: int

Max number of signals in each sample in the dataset

Returns the number of distinct signals in the wideband dataset

Returns:

max number of signals

Return type:

int

property num_signals_min: int

Minimum number of signals in each sample in the dataset.

Returns:

min number of signals

Return type:

int

property num_signals_range: List[int]

Range of num_signals can be generated by a sample.

Returns:

List of num_signals possibilities.

Return type:

List[int]

property sample_rate: float

Sample rate for the dataset.

Returns the sampling rate associated with the IQ samples of the dataset

Returns:

sample rate

Return type:

float

seed(seed: int) None

Seed number generators with given seed.

Parameters:

seed (int) – Seed to use.

setup_rngs() None

Initialize torch and numpy number generators, and update its children.

property signal_bandwidth_max: float

Defines the maximum bandwidth for a signal in the dataset Must be within the boundary provided by dataset_bandwidth_max().

Returns:

maximumum bandwidth for a signal

Return type:

float

property signal_bandwidth_min: float

Defines the minimum bandwidth for a signal in the dataset Must be within the boundary provided by dataset_bandwidth_min().

Returns:

minimum bandwidth for a signal

Return type:

float

property signal_center_freq_max: None

Defines the maximum center frequency boundary for a signal. Must be within the boundary provided by dataset_center_freq_max().

Returns:

maximum center frequency for signal

Return type:

float

property signal_center_freq_min: None

Defines the minimum center frequency boundary for a signal. Must be within the boundary provided by dataset_center_freq_min().

Returns:

minimum center frequency for signal

Return type:

float

property signal_duration_in_samples_max: int

The maximum duration in samples for a signal

Provides a maximum duration for a signal in number of samples.

Returns:

the maximum duration in samples for a signal

Return type:

float

property signal_duration_in_samples_min: int

The minimum duration in samples for a signal

Provides a minimum duration for a signal in number of samples.

Returns:

the minimum duration in samples for a signal

Return type:

float

property signal_duration_max: float

Getter for the maximum signal duration.

Returns:

The maximum of the signal duration.

Return type:

float

property signal_duration_min: float

Getter for the minimum signal duration.

Returns:

The minimum of the signal duration.

Return type:

float

property snr_db_max: float

Minimum SNR in dB for signals in dataset

Signals within the dataset will be assigned a signal to noise ratio (SNR), across a range defined by a minimum and maximum value. snr_db_max is the high end of the SNR range.

Returns:

maximum SNR in dB

Return type:

float

property snr_db_min: float

Minimum SNR in dB for signals in dataset

Signals within the dataset will be assigned a signal to noise ratio (SNR), across a range defined by a minimum and maximum value. snr_db_min is the low end of the SNR range.

Returns:

minimum SNR in dB

Return type:

float

property target_transforms: list

Target Transform to apply.

Returns:

_description_

Return type:

TargetTransform

to_dict() Dict[str, Any]

Converts the dataset metadata into a dictionary format.

This method organizes various metadata fields related to the dataset into categories such as general dataset information, signal generation parameters, and dataset writing information.

Returns:

A dictionary representation of the dataset metadata.

Return type:

Dict[str, Any]

property transforms: list

Transforms to perform on signal data (after signal impairments).

Returns:

Transform to apply to data.

Return type:

Transform

update_from_parent() None

Update numpy and torch number generators with parent seed