Skip to content

iq_loader

IQ sample loaders for NumPy (.npy) and MATLAB (.mat) file formats.

rfsoc_rfdc.iq_loader

Attributes

Classes

IqLoader(file_path)

Source code in rfsoc_rfdc/iq_loader.py
def __init__(self, file_path):
    self.file_path = file_path
    self.iq = None
Attributes
file_path = file_path instance-attribute
iq = None instance-attribute
Functions
check_file_exist()
Source code in rfsoc_rfdc/iq_loader.py
def check_file_exist(self):
    if not os.path.isfile(self.file_path):
        raise FileNotFoundError(
            f"The specified file does not exist: {self.file_path}")
scale_to_int16(iq, range_max) staticmethod
Source code in rfsoc_rfdc/iq_loader.py
@staticmethod
def scale_to_int16(iq, range_max):
    real_max, imag_max = np.max(
        np.abs(np.real(iq))), np.max(np.abs(np.imag(iq)))
    raw_max = max(real_max, imag_max)
    scaled_iq = iq * (range_max / raw_max)
    return scaled_iq
get_iq(repeat_times=1)
Source code in rfsoc_rfdc/iq_loader.py
def get_iq(self, repeat_times=1):
    if isinstance(repeat_times, int) and repeat_times != 1:
        return np.tile(self.iq.real, repeat_times), np.tile(self.iq.imag, repeat_times)
    return self.iq
load_iq() abstractmethod
Source code in rfsoc_rfdc/iq_loader.py
@abstractmethod
def load_iq(self):
    pass

NumpyIqLoader(file_path, key='wave')

Bases: IqLoader

Source code in rfsoc_rfdc/iq_loader.py
def __init__(self, file_path, key='wave'):
    super().__init__(file_path)
    self.check_file_exist()
    self.load_iq()
    self.iq = self.scale_to_int16(self.iq, MyRFdcType.DAC_MAX_SCALE)
Attributes
iq = self.scale_to_int16(self.iq, MyRFdcType.DAC_MAX_SCALE) instance-attribute
Functions
load_iq()
Source code in rfsoc_rfdc/iq_loader.py
def load_iq(self):
    try:
        self.iq = np.load(self.file_path)
    except KeyError:
        raise KeyError(
            f"The key '{self.key}' was not found in the MATLAB file {self.file_path}.")

MatlabIqLoader(file_path, key='wave')

Bases: IqLoader

Source code in rfsoc_rfdc/iq_loader.py
def __init__(self, file_path, key='wave'):
    super().__init__(file_path)
    self.key = key
    self.check_file_exist()
    self.load_iq()
    self.iq = self.scale_to_int16(self.iq, MyRFdcType.DAC_MAX_SCALE)
Attributes
key = key instance-attribute
iq = self.scale_to_int16(self.iq, MyRFdcType.DAC_MAX_SCALE) instance-attribute
Functions
load_iq()
Source code in rfsoc_rfdc/iq_loader.py
def load_iq(self):
    try:
        self.iq = scipy.io.loadmat(self.file_path)[self.key]
    except KeyError:
        raise KeyError(
            f"The key '{self.key}' was not found in the MATLAB file {self.file_path}.")