C Extensions
Warning
The modules documented before are compiled C extensions and are subject
to change. It is recommended that users use the standard modules detailed
in the previous sections over directly using these modules.
GoFast! Readers
Go Fast! (TM)  TBW, TBN, DRX, DR Spectrometer, and VDIF readers written in C

lsl.reader._gofast.readDRSpec()
Function to read in a DR spectrometer header structure and data and return
a drspec.Frame instance.
Note
This function normalizes the spectra by the number of relevant fills. For
products that are a function of more than one primary input, i.e., XY* or
I, the minimum fill of X and Y are used for normalization.

lsl.reader._gofast.readDRX()
Function to read in a single DRX frame (header+data) and store the contents
as a Frame object. This function serves as a replacement for the pure python
reader lsl.reader.drx.readFrame.
In order to use this reader in place of lsl.reader.drx.readFrame change:
>>> import lsl.reader.tbn as drx
>>> fh = open('somedrxfile.dat', 'rb')
>>> frame = drx.readFrame(fh)
to:
>>> import lsl.reader.drx as drx
>>> from lsl.reader._gofast import ReadDRX, syncError, eofError
>>> fh = open('somedrxfile.dat', 'rb')
>>> frame = readDRX(fh, tbn.Frame())
In addition, the exceptions checked for in the try...except blocks wrapping the
frame reader need to be changed to ‘IOError’ since syncError and eofError are
are subclasses of IOError.
Changed in version 0.4.0: The Go Fast! readers are the default readers used by the lsl.reader.drx
module.

lsl.reader._gofast.readTBN()
Function to read in a single TBN frame (header+data) and store the contents
as a Frame object. This function serves as a replacement for the pure python
reader lsl.reader.tbn.readFrame.
In order to use this reader in place of lsl.reader.tbn.readFrame change:
>>> import lsl.reader.tbn as tbn
>>> fh = open('sometbnfile.dat', 'rb')
>>> frame = tbn.readFrame(fh)
to:
>>> import lsl.reader.tbn as tbn
>>> from lsl.reader._gofast import ReadTBN, syncError, eofError
>>> fh = open('sometbnfile.dat', 'rb')
>> frame = readTBN(fh, tbn.Frame())
In addition, the exceptions checked for in the try...except blocks wrapping the
frame reader need to be changed to ‘IOError’ since syncError and eofError are
are subclasses of IOError.
Changed in version 0.4.0: The Go Fast! readers are the default readers used by the lsl.reader.tbn
module.

lsl.reader._gofast.readTBW()
Function to read in a single TBW frame (header+data) and store the contents
as a Frame object. This function serves as a replacement for the pure python
reader lsl.reader.tbw.readFrame.
In order to use this reader in place of lsl.reader.tbw.readFrame change:
>>> import lsl.reader.tbw as tbw
>>> fh = open('sometbwfile.dat', 'rb')
>>> frame = tbw.readFrame(fh)
to:
>>> import lsl.reader.tbw as tbw
>>> from lsl.reader._gofast import ReadTBW, syncError, eofError
>>> fh = open('sometbwfile.dat', 'rb')
>>> frame = readTBW(fh, tbw.Frame())
In addition, the exceptions checked for in the try...except blocks wrapping the
frame reader need to be changed to ‘IOError’ since syncError and eofError are
are subclasses of IOError.
Changed in version 0.4.0: The Go Fast! readers are the default readers used by the lsl.reader.tbw
module.

lsl.reader._gofast.readVDIF()
Function to read in a single VDIF frame (header+data) and store the contents
as a Frame object. This function serves as a replacement for the pure python
reader lsl.reader.vdif.readFrame.
In order to use this reader in place of lsl.reader.vdif.readFrame change:
>>> import lsl.reader.vdif as vdif
>>> fh = open('somevdiffile.dat', 'rb')
>>> frame = vdif.readFrame(fh)
to:
>>> import lsl.reader.vdif as vdif
>>> from lsl.reader._vdif import readVDIF, syncError, eofError
>>> fh = open('somevdiffile.dat', 'rb')
>> frame = readVDIF(fh, vdif.Frame())
In addition, the exceptions checked for in the try...except blocks wrapping the
frame reader need to be changed to ‘IOError’ since syncError and eofError are
are subclasses of IOError.

exception lsl.reader._gofast.eofError
Exception raised when a reader encounters the endoffile while reading.

exception lsl.reader._gofast.syncError
Exception raised when a reader encounters an error with one or more of the four sync. words.
Power Spectral Density Calculation
Linear Polarization
Extension to take timeseries data and convert it to the frequency domain.
 The functions defined in this module are:
 FPSDR2  FFT and integrate function for computing a series of overlapped
Fourier transforms for a realvalued (TBW) signal from a collection of
stands all at once.
 FPSDR3  Similar to FPSDR2, but allows for a window function to be applied
to the data.
 FPSDC2  FFT and integrate function for computing a series of overlapped
Fourier transforms for a complexvalued (TBN and DRX) signal from a
collection of stands/beams all at once.
 FPSDC3  Similar to FPSDC2, but allows for a window function to be applied
to the data.
See the inidividual functions for more details.
Changed in version 1.0.1: Removed the polyphase filterbank versions of the four core functions.

lsl.correlator._spec.FPSDC2()
Perform a series of Fourier transforms on complexvalued data to get the
PSD.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 2D numpy.double (stands by channels) of PSD data

lsl.correlator._spec.FPSDC3()
Perform a series of Fourier transforms with windows on complexvalued data
to get the PSD.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 2D numpy.double (stands by channels) of PSD data

lsl.correlator._spec.FPSDR2()
Perform a series of Fourier transforms on realvalued data to get the PSD.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 2D numpy.double (stands by channels) of PSD data

lsl.correlator._spec.FPSDR3()
Perform a series of Fourier transforms with windows on realvalued data to
get the PSD.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 2D numpy.double (stands by channels) of PSD data
Stokes Parameters
Extension to take X and Y timeseries data and create the four Stokes
parameters.
 The functions defined in this module are:
 FPSDR2  FFT and integrate function for computing a series of overlapped
Fourier transforms for a realvalued (TBW) signal from a collection of
stands all at once.
 FPSDR3  Similar to FPSDR2, but allows for a window function to be applied
to the data.
 FPSDC2  FFT and integrate function for computing a series of overlapped
Fourier transforms for a complexvalued (TBN and DRX) signal from a
collection of stands/beams all at once.
 FPSDC3  Similar to FPSDC2, but allows for a window function to be applied
to the data.
Also included is an XEngine for use with the lsl.correlator._core module to
perform crosscorrelations for the stokes parameters.
See the inidividual functions for more details.

lsl.correlator._stokes.FPSDR2()
Perform a series of Fourier transforms on realvalued data to get the PSD
for the four Stokes parameters: I, Q, U, and V.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 3D numpy.double (Stokes parameter (I,Q,U,V) by stands by channels) of PSD data

lsl.correlator._stokes.FPSDR3()
Perform a series of Fourier transforms with windows on realvalued data to
get the PSD for the four Stokes parameters: I, Q, U, and V.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 3D numpy.double (Stokes parameter (I,Q,U,V) by stands by channels) of PSD data

lsl.correlator._stokes.FPSDC2()
Perform a series of Fourier transforms on complexvalued data to get the
PSD for the four Stokes parameters: I, Q, U, and V.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 3D numpy.double (Stokes parameter (I,Q,U,V) by stands by channels) of PSD data

lsl.correlator._stokes.FPSDC3()
Perform a series of Fourier transforms with windows on complexvalued data
to get the PSD for the four Stokes parameters: I, Q, U, and V.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 psd: 3D numpy.double (Stokes parameter (I,Q,U,V) by stands by channels) of PSD data
FX Correlator Core
Cbased F and X engines for the LWA software FX correlator. These function
are meant to provide an alternative to the lsl.correlator.fx.correlate function and
provide a muchneeded speed boost to crosscorrelation.
 The function defined in this module are:
 FEngineR2 Fengine for computing a series of overlapped Fourier transforms with
delay corrections for a realvalued (TBW) signal from a collection of stands all at
once.
 FEngineR3  Similar to FEngineR2, but allows for a window function to be applied
to the data.
 FEngineC2  Fengine for computing a series of overlapped Fourier transforms with
delay corrections for a complexvalued (TBN) signal from a collection of stands all at
once.
 FEngineC3  Similar to FEngineC2, but allows for a window function to be applied
to the data.
 XEngine2  Similar to XEngine, but works with a collection of stands all at
once.
See the inidividual functions for more details.

lsl.correlator._core.FEngineC2()
Perform a series of overlapped Fourier transforms on complexvalued data
using OpenMP.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 frequency: 1D numpy.double array of frequency values in Hz for the
FFT channels
 delays: 1D numpy.double array of delays to apply to each stand
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 SampleRate: sample rate of the data (default=100e3)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 fsignals: 3D numpy.complex64 (stands by channels by FFT_set) of FFTd
data
 valid: 2D numpy.uint8 (stands by FFT_set) of whether or not the FFT
set is valid (1) or not (0)

lsl.correlator._core.FEngineC3()
Perform a series of overlapped Fourier transforms on complexvalued data
using OpenMP and allow for windowing of the data.
 Input arguments are:
 signals: 2D numpy.complex64 (stands by samples) array of data to FFT
 frequency: 1D numpy.double array of frequency values in Hz for the
FFT channels
 delays: 1D numpy.double array of delays to apply to each stand
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 SampleRate: sample rate of the data (default=100e3)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 fsignals: 3D numpy.complex64 (stands by channels by FFT_set) of FFTd
data
 valid: 2D numpy.uint8 (stands by FFT_set) of whether or not the FFT
set is valid (1) or not (0)

lsl.correlator._core.FEngineR2()
Perform a series of overlapped Fourier transforms on realvalued data using
OpenMP.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 frequency: 1D numpy.double array of frequency values in Hz for the
FFT channels
 delays: 1D numpy.double array of delays to apply to each stand
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 SampleRate: sample rate of the data (default=196e6)
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 fsignals: 3D numpy.complex64 (stands by channels by FFT_set) of FFTd
data
 valid: 2D numpy.uint8 (stands by FFT_set) of whether or not the FFT
set is valid (1) or not (0)

lsl.correlator._core.FEngineR3()
Perform a series of overlapped Fourier transforms on realvalued data using
OpenMP and windows.
 Input arguments are:
 signals: 2D numpy.int16 (stands by samples) array of data to FFT
 frequency: 1D numpy.double array of frequency values in Hz for the
FFT channels
 delays: 1D numpy.double array of delays to apply to each stand
 Input keywords are:
 LFFT: number of FFT channels to make (default=64)
 Overlap: number of overlapped FFTs to use (default=1)
 SampleRate: sample rate of the data (default=196e6)
 window: Callable Python function for generating the window
 ClipLevel: count value of ‘bad’ data. FFT windows with instantaneous powers
greater than or equal to this value greater are zeroed. Setting the ClipLevel
to zero disables timedomain blanking
 Outputs:
 fsignals: 3D numpy.complex64 (stands by channels by FFT_set) of FFTd
data
 valid: 2D numpy.uint8 (stands by FFT_set) of whether or not the FFT
set is valid (1) or not (0)

lsl.correlator._core.XEngine2()
Perform all XMACs for a data stream out of the F engine using OpenMP.
Changed in version 0.5: The second signal is not longer input as a conjugated array. Rather
the conjucation is performed as part of the crosscorrelation.
 Input arguments are:
 fsignals1: 3D numpy.complex64 (stand by channels by FFT_set) array of FFTd
data from an F engine.
 fsignals2: 3D numpy.complex64 (stand by channels by FFT_set) array of
FFTd data from an F engine.
 sigValid1: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the first signal.
 sigValid2: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the second signal.
 Ouputs:
 visibility: 2D numpy.complex64 (baseline by channel) array of cross
correlated and averaged visibility data.

lsl.correlator._core.XEngine3()
Perform all XMACs for a data stream out of the F engine using OpenMP that
creates the four linear polarization products
New in version 1.1.2.
 Input arguments are:
 fsignals1: 3D numpy.cdouble (stand by channels by FFT_set) array of FFTd
data from an F engine.
 fsignals2: 3D numpy.cdouble (stand by channels by FFT_set) array of FFTd
data from an F engine.
 sigValid1: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the first signal.
 sigValid2: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the second signal.
 Ouputs:
 visibility: 3D numpy.cdouble (Stokes parameter (XX,XY,YX,YY) by baseline by
channel) array of crosscorrelated and averaged visibility data.

lsl.correlator._stokes.XEngine2()
Perform all XMACs for a data stream out of the F engine using OpenMP that
creates the four Stokes parameters: I, Q, U, and V.
 Input arguments are:
 fsignals1: 3D numpy.cdouble (stand by channels by FFT_set) array of FFTd
data from an F engine.
 fsignals2: 3D numpy.cdouble (stand by channels by FFT_set) array of FFTd
data from an F engine.
 sigValid1: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the first signal.
 sigValid2: 1D numpy.uint8 (FFT_set) array of whether or not the FFT_set is
valid (1) or not (0) for the second signal.
 Ouputs:
 visibility: 3D numpy.cdouble (Stokes parameter (I,Q,U,V by baseline by
channel) array of crosscorrelated and averaged visibility data.
DPStyle Signal Processing
This module contains a collection of function to speed up FIR filtering of TBW
data (represented as numpy.int16 arrays) and the SoftwareDP class. The funtions
provided in this module are:
 integer16: Apply a FIR filter to numpy.int16 data,
 integer16Delayed: Apply a FIFO delay and a FIR filter to numpy.int16 data, and
 integerBeamformer: Software implementation of the DP beamformer.

lsl.common._fir.integer16()
Given a 1D numpy.int16 array of data values and a numpy.int16 array of FIR
coefficients, apply the coefficients to the data.
 Inputs arguments are:
 data: 1D numpy.int16 array of data
 coeffs: 1D numpy.int16 array of FIR coefficients
 Outputs:
 result: 1D numpy.float32 array of the filtered data

lsl.common._fir.integer16Delayed()
Given a 1D numpy.int16 array of data values, a numpy.int16 array of FIR
coefficients, and a FIFO sample delay, delay the signal and apply the
coefficients to the data.
 Inputs arguments are:
 data: 1D numpy.int16 array of data
 coeffs: 1D numpy.int16 array of FIR coefficients
 sampleDelay: interger number of samples to delay the signal (must be >=0)
 Outputs:
 result: 1D numpy.float32 array of the delayed and filtered data

lsl.common._fir.integerBeamformer()
Given a 2D numpy.int16 array (stands by samples) of data values, 3D array of FIR
filter coefficients (stands by filters by taps), a 1D numpy.int16 array of course
(FIFO) delays, a 1D numpy.int16 array of fine delay FIR filters, and a 2D array of
gains (stands by [XX, XY, YX, YY]), apply the delays and sum the signals.
 Inputs arguments are:
data: 2D numpy.int16 array of data (stands by samples)
coeffs: 3D numpy.int16 array of FIR coefficients (stands by filters by taps)
course: 1D numpy.int16 array of FIFO delays in samples
fine: 1D numpy.int16 array of which FIR filter to apply for fine delay
 gain: 2D numpy.int16 arry of gains (stands by [XX, XY, YX, YY]), where XX is the X
contribution to the output X pol., XY is the X contribution to the output Y
pol., YX is the Y contribtion to the output X pol., and YY is the Y contribu
tion to the output Y pol.
 Outputs:
 results: two element tuple (output X, outpuY) of the beamformer sum. Each element is
a 1D numpy.float32 array.
Note
The structure of data is assumed to be that the polarizations are ordered, e.g., the X
polarization of stand 1 is immediately followed by the Y polarization.