io#

IO helper functions

qampy.core.io.load_signal(fn)#

Load a signal object from a zlib compressed pickle file.

Parameters:

fn (basestring) – filename of the file

Returns:

sig – The loaded signal object

Return type:

SignalObject

qampy.core.io.ndarray_from_matlab(fn, keys, transpose=False, dim2cmplx=False, portmap=[[0, 1], [2, 3]])#

Load a signal from matlab and put in the correct numpy array format

Parameters:
  • fn (basestring) – filename of the matlab file

  • keys (list or tuple) –

    Nested list of keys (array names) in the matlab file. Depending on how the data is structured the keys can be in one of the following formats:

    If the symbols are given as a multi-dimensional array of complex numbers:

    [[ keyname ]]

    If the symbols are given as multi-dimensional real arrays pairs for real and imaginary part:

    [[ key_real, key_imag ]]

    If the different symbols of modes are saved in different complex arrays:

    [[key_mode1], …, [key_modeN]]

    If the symbols are given as pairs of real arrays for each mode:

    [[key_mode1_real, key_mode1_imag], … [key_modeN_real, key_modeN_imag]]

  • transpose (boolean, optional) – Whether to transpose the matlab arrays

  • dim2cmplx (boolean, optional) – Whether one of the dimensions is of the matlab arrays indicates real and imaginary parts. This is common for data from a realtime oscilloscope

  • portmap (list, optional) – The mapping of dimension to mode and real and imaginary (or quadrature and in-phase) parts. only used when dim2cmplx is True.

Returns:

symbs – numpy array in the correct format for a signal object

Return type:

ndarray

qampy.core.io.save_signal(fn, signal, lvl=4)#

Save a signal object using zlib compression

Parameters:
  • fn (basestring) – filename

  • signal (SignalObject) – the signal to save

  • lvl (int, optional) – the compression to use for zlib