Data Readers

LSL Developer Primitives

LWA Development Primitives - A set of utilities that should make developing new analysis software easier. These functions wrap the nitty gritty of the file reading and unpacking behind Python objects.

Data format objects included are:
  • TBWFile
  • TBNFile
  • DRXFile
  • DRSpecFile

Also included is the LWA1DataFile function that take a filename and tries to determine the correct data format object to use.

class lsl.reader.ldp.TBWFile(filename=None, fh=None, ignoreTimeTagErrors=False)
Class to make it easy to interface with a TBW file. Methods defined for this class are:
  • getInfo - Get information about the file’s contents
  • getRemainingFrameCount - Get the number of frames remaining in the file
  • readFrame - Read and return a single lsl.reader.tbw.Frame instance
  • read - Read in the capture and return it as a numpy array
read(duration=None, timeInSamples=False)

Read and return the entire TBW capture. This function returns a three-element tuple with elements of:

  1. the actual duration of data read in,
  2. the time tag for the first sample, and
  3. a 2-D Numpy array of data.

The time tag is returned as seconds since the UNIX epoch by default. However, the time tags can be returns as samples at fS if the timeInSamples keyword is set.

The sorting order of the output data array is by digitizer number - 1.

Note

Setting the ‘duration’ keyword has no effect on the read process because the entire capture is always read in.

readFrame()

Read and return a single lsl.reader.tbw.Frame instance.

class lsl.reader.ldp.TBNFile(filename=None, fh=None, ignoreTimeTagErrors=False)
Class to make it easy to interface with a TBN file. Methods defined for this class are:
  • getInfo - Get information about the file’s contents
  • getRemainingFrameCount - Get the number of frames remaining in the file
  • offset - Offset a specified number of seconds into the file
  • readFrame - Read and return a single lsl.reader.tbn.Frame instance
  • read - Read a chunk of data in and return it as a numpy array
  • estimateLevels - Estimate the n-sigma level for the absolute value of the voltages
estimateLevels(nFrames=100, Sigma=5.0)

Estimate the n-sigma level for the absolute value of the voltages. Returns a list with indicies that are the digitizer numbers minus one.

offset(offset)

Offset a specified number of seconds in an open TBN file. This function returns the exact offset time.

Note

The offset provided by this function is relatively crude due to the structure of TBN files.

read(duration, timeInSamples=False)

Read in a chunk (in seconds) of TBN data. This function returns a three-element tuple with elements of:

  1. the actual duration of data read in,
  2. the time tag for the first sample, and
  3. a 2-D Numpy array of data.

The time tag is returned as seconds since the UNIX epoch by default. However, the time tags can be returns as samples at fS if the timeInSamples keyword is set.

The sorting order of the output data array is by digitizer number - 1.

readFrame()

Read and return a single lsl.reader.tbn.Frame instance.

class lsl.reader.ldp.DRXFile(filename=None, fh=None, ignoreTimeTagErrors=False)
Class to make it easy to interface with a DRX file. Methods defined for this class are:
  • getInfo - Get information about the file’s contents
  • getRemainingFrameCount - Get the number of frames remaining in the file
  • offset - Offset a specified number of seconds into the file
  • readFrame - Read and return a single lsl.reader.drx.Frame instance
  • read - Read a chunk of data in and return it as a numpy array
  • estimateLevels - Estimate the n-sigma level for the absolute value of the voltages
estimateLevels(nFrames=100, Sigma=5.0)

Estimate the n-sigma level for the absolute value of the voltages. Returns a list with indicies corresponding to: 0) Tuning 1, X pol. 1) Tuning 1, Y pol. 2) Tuning 2, X pol. 3) Tuning 2, Y pol.

..note::
The returned list always has four items, regardless of whether or not the input DRX file has one or two tunings.
offset(offset)

Offset a specified number of seconds in an open DRX file. This function returns the exact offset time.

read(duration, timeInSamples=False)

Given an open DRX file and an amount of data to read in in seconds, read in the data and return a three-element tuple of the actual duration read in, the time for the first sample, and the data as numpy array.

..note::

This function always returns a 2-D array with the first dimension holding four elements. These elements contain, in order:

  • Tuning 1, polarization X
  • Tuning 1, polarization Y
  • Tuning 2, polarization X
  • Tuning 2, polarization Y
readFrame()

Read and return a single lsl.reader.drx.Frame instance.

class lsl.reader.ldp.DRSpecFile(filename=None, fh=None, ignoreTimeTagErrors=False)

Class to make it easy to interface with a DR Spectrometer file. Methods defined for this class are:

  • getInfo - Get information about the file’s contents
  • getRemainingFrameCount - Get the number of frames remaining in the file
  • offset - Offset a specified number of seconds into the file
  • readFrame - Read and return a single lsl.reader.drspec.Frame instance
  • read - Read a chunk of data in and return it as a numpy array
offset(offset)

Offset a specified number of seconds in an open DR spectrometer file. This function returns the exact offset time.

read(duration, timeInSamples=False)

Given an open DR spectrometer file and an amount of data read in in seconds, read in the data and return a three-element tuple of the actual duration read in, the times at the beginning of each stream, and the data as numpy array.

..note::
This function always returns a 3-D array with the first dimension indexing over data product, the second over time and the third over frequency channel.
readFrame()

Read and return a single lsl.reader.drspec.Frame instance.

lsl.reader.ldp.LWA1DataFile(filename=None, fh=None, ignoreTimeTagErrors=False)

Wrapper around the various classes defined here that takes a file, determines the data type, and initializes and returns the appropriate LDP class.

Low-Level TBW

Python module to reading in data from both 12-bit and 4-bit TBW files. This module defines the following classes for storing the TBW data found in a file:

Frame

object that contains all data associated with a particular TBW frame. The primary consituents of each frame are:

  • FrameHeader - the TBW frame header object and
  • FrameData - the TBW frame data object.

Combined, these two objects contain all of the information found in the original TBW frame.

The functions defined in this module fall into two class:
  1. convert a frame in a file to a Frame object and
  2. describe the format of the data in the file.

For reading in data, use the readFrame function. It takes a python file- handle as an input and returns a fully-filled Frame object. readFrame is designed to work with both 4-bit and 12-bit observations.

For describing the format of data in the file, two function are provided:

getDataBits
read in the first frame of an open file handle and return whether or not the data is 12 or 4-bit
getFramesPerObs

read in the first several frames to see how many stands are found in the data. .. note:

This function is a little flaky on TBW data sets that have less 
than a full complement or 12M (36M) samples.

Changed in version 0.4.0: Switched over from pure Python readers to the new C-base Go Fast! readers.

class lsl.reader.tbw.FrameHeader(frameCount=None, secondsCount=None, tbwID=None)

Class that stores the information found in the header of a TBW frame. All three fields listed in the DP ICD version H are stored as well as the original binary header data.

getDataBits()

Function to parse the TBW ID field and return the size of number of bits that comprise the data. 12 is returned for 12-bit data, and 4 for 4-bit data.

isTBW()

Function to check if the data is really TBW and not TBN by examining the TBW ID field. Returns True if the data is TBW, false otherwise.

parseID()

Function to parse the TBW ID field and return the stand number.

class lsl.reader.tbw.FrameData(timeTag=None, samples=400, xy=None)

Class that stores the information found in the data section of a TBW frame. Both fields listed in the DP ICD version H are stored.

getTime()

Function to convert the time tag from samples since the UNIX epoch (UTC 1970-01-01 00:00:00) to seconds since the UNIX epoch.

class lsl.reader.tbw.Frame(header=None, data=None)

Class that stores the information contained within a single TBW frame. It’s properties are FrameHeader and FrameData objects.

getDataBits()

Convenience wrapper for the Frame.FrameHeader.getDataBits function.

getTime()

Convenience wrapper for the Frame.FrameData.getTime function.

isTBW()

Convenience wrapper for the Frame.FrameHeader.isTBW function.

parseID()

Convenience wrapper for the Frame.FrameHeader.parseID function.

lsl.reader.tbw.readFrame(filehandle, Verbose=False)

Function to read in a single TBW frame (header+data) and store the contents as a Frame object. This function wraps readerHeader and readData[(12)|4].

lsl.reader.tbw.getDataBits(filehandle)

Find out the number of data bits used in the file be reading in the first frame.

lsl.reader.tbw.getFramesPerObs(filehandle)

Find out how many frames are present per observation by examining the first frames for what would be 260 stands. This is done by reading two frames and then skipping the next 30,000.

Note

Post-IOC it is probably simpler to adopt a value of the number of frames per observation of 260 rather than try to find it from the file.

Low-Level TBN

Python module for reading data in from TBN files.This module defines the following classes for storing the TBN data found in a file:

Frame

object that contains all data associated with a particular TBN frame. The primary constituents of each frame are:

  • FrameHeader - the TBN frame header object and
  • FrameData - the TBN frame data object.

Combined, these two objects contain all of the information found in the original TBN frame.

ObservingBlock
object that stores a collection of Frames for all stands/polarizations for a particular time.

In addition to storing the data available in the frame, the Frame object also has attributes for holding information about the gain, central frequency, and filter code used for the observations.

The functions defined in this module fall into two class:
  1. convert a frame in a file to a Frame object and
  2. describe the format of the data in the file.

For reading in data, use the readFrame function. It takes a python file- handle as an input and returns a fully-filled Frame object. The readBlock function reads in a (user-defined) number of TBN frames and returns a ObservingBlock object.

For describing the format of data in the file, two function are provided:

getSampleRate
read in the few frame of an open file handle and return the sampling rate of the data
getFramesPerObs
read in the first several frames to see how many stands are found in the data.

Changed in version 0.4.0: Switched over from pure Python readers to the new C-base Go Fast! readers.

Changed in version 0.5.0: Support for ECR 11 TBN header format change.

class lsl.reader.tbn.FrameHeader(frameCount=None, tuningWord=None, tbnID=None, gain=None)

Class that stores the information found in the header of a TBW frame. All three fields listed in the DP ICD version H are stored as well as the original binary header data.

Changed in version 0.5.0: Added various attributes to retrieve the central frequnecy and gain that are part of the ECR 11 changes.

getCentralFreq()

Convert the tuning word to a frequency in Hz.

getFilterCode()

Function to convert the sample rate in Hz to a filter code.

getGain()

Get the current TBN gain for this frame.

isTBN()

Function to check if the data is really TBN and not TBW by examining the TBN ID field. Returns True if the data is TBN, false otherwise.

parseID()

Function to parse the TBN ID field and return a tuple of the stand number and polarization.

setSampleRate(sampleRate)

Function to set the sample rate of the TBN data in Hz.

class lsl.reader.tbn.FrameData(timeTag=None, iq=None)

Class that stores the information found in the data section of a TBN frame. Both fields listed in the DP ICD version H are stored.

Changed in version 0.5.0: Removed various attributes related to storing a central frequnecy and gain that aren’t needed with ECR 11.

getTime()

Function to convert the time tag from samples since the UNIX epoch (UTC 1970-01-01 00:00:00) to seconds since the UNIX epoch.

class lsl.reader.tbn.Frame(header=None, data=None)

Class that stores the information contained within a single TBN frame. It’s properties are FrameHeader and FrameData objects.

Changed in version 0.5.0: Removed various attributes related to storing a central frequnecy and gain that aren’t needed with ECR 11.

getCentralFreq()

Convenience wrapper for the Frame.FrameHeader.getCentralFreq function.

getFilterCode()

Convenience wrapper for the Frame.FrameData.getFilterCode function.

getGain()

Convenience wrapper for the Frame.FrameHeader.getGain function.

getTime()

Convenience wrapper for the Frame.FrameData.getTime function.

isTBN()

Convenience wrapper for the Frame.FrameHeader.isTBN function.

parseID()

Convenience wrapper for the Frame.FrameHeader.parseID function.

setSampleRate(sampleRate)

Convenience wrapper for the Frame.FrameData.setSampleRate function.

lsl.reader.tbn.readFrame(filehandle, SampleRate=None, Verbose=False)

Function to read in a single TBN frame (header+data) and store the contents as a Frame object.

lsl.reader.tbn.readBlock(filehandle, nFrames=520, SampleRate=None, Verbose=False)

Function to read in a single TBN block (frames set by the nFrames keyword) and store the contents as a ObservingBlock object. This function wraps readFrame.

..warning::
Since the various TBN frames are interleaved on the network before recording, the frames returned by a single call to readBlock may not all have the same frame count/time tag. It is recommended that the lsl.reader.buffer.TBNFrameBuffer be used in order to deal with the out-of-order frames.
lsl.reader.tbn.getSampleRate(filehandle, nFrames=None, FilterCode=False)

Find out what the sampling rate/filter code is from consecutive sets of observations. By default, the rate in Hz is returned. However, the corresponding filter code can be returned instead by setting the FilterCode keyword to True.

lsl.reader.tbn.getFramesPerObs(filehandle)

Find out how many frames are present per observation by examining the first 2,080 TBN frames. Return the number of frames per observations as a two- element tuple, one for each polarization.

So many TBN frames are read in order to try to compensate for the inter- leaving of the packets from the various DP1 boards during the recording.

Note

Post-IOC it is probably simpler to adopt a value of the number of frames per observation of 520 rather than try to find it from the file.

Low-Level DRX

Python module to read in DRX data. This module defines the following classes for storing the DRX data found in a file:

Frame

object that contains all data associated with a particular DRX frame. The primary constituents of each frame are:

  • FrameHeader - the DRX frame header object and
  • FrameData - the DRX frame data object.

Combined, these two objects contain all of the information found in the original DRX frame.

ObservingBlock
object that stores a collection of Frames for all beams/tunings/ polarizations for a particular time.
The functions defined in this module fall into two class:
  1. convert a frame in a file to a Frame object and
  2. describe the format of the data in the file.

For reading in data, use the readFrame function. It takes a python file- handle as an input and returns a fully-filled Frame object. The readBlock function reads in a (user-defined) number of DRX frames and returns a ObservingBlock object.

For describing the format of data in the file, two function are provided:

getBeamCount
read in the first few frames of an open file handle and return how many beams are present in the file.
getFramesPerObs
read in the first several frames to see how many frames (tunings/polarizations) are associated with each beam.

Finally, there are also two experimental functions defined in this file for averaging DRX observations. averageObservations performs a straight channel- by-channel average of a collection of DRX frames, which averageObservations2 allows for both temporal and spatial averaging.

Changed in version 0.4.0: Switched over from pure Python readers to the new C-base Go Fast! readers.

class lsl.reader.drx.FrameHeader(frameCount=None, drxID=None, secondsCount=None, decimation=None, timeOffset=None)

Class that stores the information found in the header of a DRX frame. All six fields listed in the DP ICD version H are stored as well as the original binary header data.

getFilterCode()

Function to convert the sample rate in Hz to a filter code.

getSampleRate()

Return the sample rate of the data in samples/second.

parseID()

Parse the DRX ID into a tuple containing the beam (1 through 4), tunning (1 and 2), and polarization (0 and 1).

class lsl.reader.drx.FrameData(timeTag=None, tuningWord=None, flags=None, iq=None)

Class that stores the information found in the data section of a DRX frame. All three fields listed in the DP ICD version H are stored.

getCentralFreq()

Function to set the central frequency of the DRX data in Hz.

setGain(gain)

Function to set the gain of the DRX data.

class lsl.reader.drx.Frame(header=None, data=None)

Class that stores the information contained within a single DRX frame. It’s properties are FrameHeader and FrameData objects.

getCentralFreq()

Convenience wrapper for the Frame.FrameData.getCentralFreq function.

getFilterCode()

Convenience wrapper for the Frame.FrameHeader.getFilterCode function.

getSampleRate()

Convenience wrapper for the Frame.FrameHeader.getSampleRate function.

getTime()

Function to convert the time tag from samples since the UNIX epoch (UTC 1970-01-01 00:00:00) to seconds since the UNIX epoch.

parseID()

Convenience wrapper for the Frame.FrameHeader.parseID function.

setGain(gain)

Convenience wrapper for the Frame.FrameData.setGain function.

class lsl.reader.drx.ObservingBlock(x1=None, y1=None, x2=None, y2=None)

Class that stores all frames associates with a particular beam at a particular time.

getCentralFreq()

Convenience wrapper for the Frame.FrameData.getCentralFreq function.

Note

This returned a two-element tuple giving the frequncies for both tunings.

getFilterCode()

Convenience wrapper for the Frame.FrameData.getFilterCode function.

getTime()

Convenience wrapper for the Frame.FrameData.getTime function.

setGain(gain)

Convenience wrapper for the Frame.FrameData.setGain function.

lsl.reader.drx.readFrame(filehandle, Gain=None, Verbose=False)

Function to read in a single DRX frame (header+data) and store the contents as a Frame object. This function wraps readerHeader and readData.

lsl.reader.drx.readBlock(filehandle)

Function to read in a single DRX block (four frames) and store the contents as a ObservingBlock object. This function wraps readFrame.

lsl.reader.drx.getSampleRate(filehandle, nFrames=None, FilterCode=False)

Find out what the sampling rate/filter code is from a single observations. By default, the rate in Hz is returned. However, the corresponding filter code can be returned instead by setting the FilterCode keyword to true.

This function is included to make easier to write code for TBN analysis and modify it for DRX data.

lsl.reader.drx.getBeamCount(filehandle)

Find out how many beams are present by examining the first 16 DRX records. Return the number of beams found.

lsl.reader.drx.getFramesPerObs(filehandle)

Find out how many frames are present per beam by examining the first 16 DRX records. Return the number of frames per observations as a four- element tuple, one for each beam.

Low-Level DR Spectrometer

New in version 0.5.

Python module to read in DR spectrometer data. This module defines the following classes for storing the spectra found in a file:

Frame

object that contains all data associated with a particular spectrometer frame. The primary constituents of each frame are:

  • FrameHeader - the spectrometer frame header object and
  • FrameData - the spectral data object.

Combined, these two objects contain all of the information found in the original spectrometer frame.

The functions defined in this module fall into two class:
  1. convert a frame in a file to a Frame object and
  2. describe the format of the data in the file.

For reading in data, use the readFrame function. It takes a python file- handle as an input and returns a fully-filled Frame object For describing the format of data in the file, three function are provided:

  • getSampleRate - get the sample rate in the file
  • getFrameSize - get the total (header + data) frame size
  • getFFTsPerIntegration - get the number of FFT windows per integration
  • getTransformSize - get the FFT length
  • getIntegrationTime - get the integration time

Note

This reader works with the most current version of the DR spectrometer data format as specified in the version 1.7. To read data created with previous versions of the DR spectrometer, use LSL version 0.5.2.

Changed in version 1.0.1: Added in new functions to help better describe the contents of a DR spectrometer file.

class lsl.reader.drspec.FrameHeader(beam=0, format=0, decimation=None, timeOffset=None, nInts=None)

Class that stores the information found in the header of a DR spectrometer/DRX frame.

containsLinearData()

Return whether or not the frame contains linear polarization products or not.

New in version 0.6.0.

containsStokesData()

Return whether or not the frame contains Stokes polarization parameters or not.

New in version 0.6.0.

getDataProducts()

Return a list of data products contained in the file.

New in version 0.6.0.

getFFTsPerIntegration()

Return the number of FFT windows per integration.

New in version 1.0.1.

getFilterCode()

Function to convert the sample rate in Hz to a filter code.

getSampleRate()

Return the sample rate of the data in samples/second.

parseID()

Return the beam the frame corresponds to.

class lsl.reader.drspec.FrameData(timeTag=None, tuningWords=None, fills=None, errors=None, saturations=None)

Class that stores the information found in the data section of a DR spectrometer/ DRX frame.

Changed in version 0.5.3: Added the saturations field to keep up with saturation counts.

Changed in version 0.6.0: The attributes that store the data are not defined until a frame is read in order to account for the fact that spectrometer files can store either linear or Stokes data.

getCentralFreq(which=None)

Function to set the central frequency of the DRX data in Hz.

class lsl.reader.drspec.Frame(header=None, data=None)

Class that stores the information contained within a single DR spectrometer/ DRX frame. It’s properties are FrameHeader and FrameDataLinear/FrameDataStokes objects.

Changed in version 0.6.0: By default the data contained with in a frame is normalized by the number of fills (header.fills parameter). For data 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.

containsLinearData()

Convenience wrapper for the Frame.FrameHeder.containsLinearData function.

containsStokesData()

Convenience wrapper for the Frame.FrameHeder.containsStokesData function.

getCentralFreq(which=None)

Convenience wrapper for the Frame.FrameData.getCentralFreq function.

getDataProducts()

Convenience wrapper for the Frame.FrameHeder.getDataProducts function.

getFFTsPerIntegration()

Conveinence wrapper for the Frame.FrameHeader.getFFTsPerIntegration function.

New in version 1.0.1.

getFilterCode()

Convenience wrapper for the Frame.FrameHeader.getFilterCode function.

getIntegrationTime()

Return the integration time for data in seconds.

New in version 1.0.1.

getSampleRate()

Convenience wrapper for the Frame.FrameHeader.getSampleRate function.

getTime()

Function to convert the time tag from samples since the UNIX epoch (UTC 1970-01-01 00:00:00) to seconds since the UNIX epoch.

getTransformSize()

Find out what the transform size is.

New in version 1.0.1.

parseID()

Convenience wrapper for the Frame.FrameHeader.parseID function.

setGain(gain)

Convenience wrapper for the Frame.FrameData.setGain function.

lsl.reader.drspec.readFrame(filehandle, Gain=None, Verbose=False)

Function to read in a single DR spectrometer/DRX frame (header+data) and store the contents as a Frame object.

lsl.reader.drspec.getDataProducts(filehandle)

Find out the data products contained in the file by looking at a frame.

lsl.reader.drspec.containsLinearData(filehandle)

Find out if the file contains linear polarization products or not.

lsl.reader.drspec.containsStokesData(filehandle)

Find out if the file contains Stokes parameters or not.

lsl.reader.drspec.getSampleRate(filehandle, nFrames=None, FilterCode=False)

Find out what the sampling rate/filter code is from a single observations. By default, the rate in Hz is returned. However, the corresponding filter code can be returned instead by setting the FilterCode keyword to true.

lsl.reader.drspec.getFrameSize(filehandle)

Find out what the frame size in a file is at the current file location. Returns the frame size in bytes.

lsl.reader.drspec.getFFTsPerIntegration(filehandle)

Find out what the number of FFT windows per integration is at the current file location.

New in version 1.0.1.

lsl.reader.drspec.getTransformSize(filehandle)

Find out what the transform size in a file is at the current file location.

lsl.reader.drspec.getIntegrationTime(filehandle)

Find out what the integration time is at the current file location.

Reader Error Codes

Module that contains the error classes for the DRX, TBN, and TBW readers. These errors are currently meant to deal with file I/O problems.

exception lsl.reader.errors.baseReaderError(strerror, errno='-1')

Base class for file I/O problem during numpy.fromfile calls and out-of- sync Mark5C headers.

exception lsl.reader.errors.eofError

Extension to the base class for dealing with EOF errors. The error code is 1.

exception lsl.reader.errors.numpyError

Extension to the base class for dealing with errors that occur when numpy.fromfile tried to read more data can exists. This is a specialized form of EOF error. The error code is 2.

exception lsl.reader.errors.syncError(sync1=None, sync2=None, sync3=None, sync4=None)

Extension to the base class for dealing with Mark 5C header sync word problems. If the sync word doesn’t match what is expected. The error code is 3.

exception lsl.reader.errors.notTBNError

Extenstion to the base class for dealing with trying to read in TBW data with a TBN reader. The error code is 4.

exception lsl.reader.errors.notTBWError

Extenstion to the base class for dealing with trying to read in TBN data with a TBW reader. The error code is 5.

lsl.reader.errors.listErrorCodes(errno=None)

Function to provide a list of errors defined in this file. It alternatively takes an error code using the ‘errno’ keyword and returns its description.

Reader Ring Buffer

Buffer for dealing with out-of-order/missing frames.

Changed in version 0.5: Removed support for DRX FrameBuffers since they shouldn’t be needed.

Changed in version 0.6: Removed support for TBW FrameBuffers since they didn’t really work.

Changed in version 1.0.0: Added back in the DRX FrameBuffers since they might be useful. Dropped TBW support from within the FrameBuffer class.

class lsl.reader.buffer.FrameBuffer(mode='TBN', stands=[], beams=[], tunes=[], pols=[], nSegments=6, ReorderFrames=False)

Bases: object

Frame buffer for re-ordering TBN and DRX frames in time order. This class is filled with frames and a returns a frame list when the ‘nSegments’ starts filling. In that case, the oldest segment is returned.

The buffer also keeps track of what has already been read out so that tardy frames are just dropped. For buffers that are read out, missing frames are replaced with frames filled with zeros.

Note

Due to the nature of the buffer, it is possible that there will still be ‘nSegments’-1 segements in the buffer that are either full or partially full. This can be retrieved using the buffer’s ‘flush()’ function.

append(frames)

Append a new frame to the buffer with the appropriate time tag. True is returned if the frame was added to the buffer and False if the frame was dropped because it belongs to a buffer that has already been returned.

calcFrames()

Calculate the maximum number of frames that we expect from the setup of the observations and a list of tuples that describes all of the possible stand/pol combination.

This will be overridden by sub-classes of FrameBuffer.

createFill(key, frameParameters)

Create a ‘fill’ frame of zeros using an existing good packet as a template.

This will be overridden by sub-classes of FrameBuffer.

figureOfMerit(frame)

Figure of merit for storing/sorting frames in the ring buffer.

This will be overridden by sub-classes of FrameBuffer.

flush()

Return a list of lists containing all remaining frames in the buffer from buffers that are considered ‘full’. Afterwards, delete all buffers. This is useful for emptying the buffer after reading in all of the data.

Note

It is possible for this function to return list of packets that are mostly invalid.

get(keyToReturn=None)

Return a list of frames that consitute a ‘full’ buffer. Afterwards, delete that buffer and mark it as closed so that any missing frames that are recieved late are dropped. If none of the buffers are ready to be dumped, None is returned.

status()

Print out the status of the buffer. This contains information about: 1. The current buffer fill level 2. The numer of full and partial buffer dumps preformed 3. The number of missing frames that fill packets needed to be created

for
  1. The number of frames that arrived too late to be incorporated into one of the ring buffers
class lsl.reader.buffer.TBNFrameBuffer(stands=[], pols=[0, 1], nSegments=20, ReorderFrames=False)

Bases: lsl.reader.buffer.FrameBuffer

A sub-type of FrameBuffer specifically for dealing with TBN frames. See lsl.reader.buffer.FrameBuffer for a description of how the buffering is implemented.

Keywords: stands

list of stand to expect packets for
pols
list of polarizations to expect packets for
nSegments
number of ring segments to use for the buffer (default is 20)
ReorderFrames
whether or not to reorder frames returned by get() or flush() by stand/polarization (default is False)

The number of segements in the ring can be converted to a buffer time in seconds:

Segments TBN Filter Code
1 2 3 4 5 6 7
10 5.1 1.6 0.8 0.4 0.2 0.1 0.05
20 10.2 3.3 1.6 0.8 0.4 0.2 0.10
30 15.4 4.9 2.5 1.2 0.6 0.3 0.15
40 20.5 6.6 3.3 1.6 0.8 0.4 0.20
50 25.6 8.2 4.1 2.0 1.0 0.5 0.26
100 51.2 16.4 8.2 4.1 2.0 1.0 0.51
calcFrames()

Calculate the maximum number of frames that we expect from the setup of the observations and a list of tuples that describes all of the possible stand/pol combination.

createFill(key, frameParameters)

Create a ‘fill’ frame of zeros using an existing good packet as a template.

figureOfMerit(frame)

Figure of merit for sorting frames. For TBN it is: <frame timetag in ticks>

class lsl.reader.buffer.DRXFrameBuffer(beams=[], tunes=[1, 2], pols=[0, 1], nSegments=10, ReorderFrames=False)

Bases: lsl.reader.buffer.FrameBuffer

A sub-type of FrameBuffer specifically for dealing with DRX frames. See lsl.reader.buffer.FrameBuffer for a description of how the buffering is implemented.

Keywords: beams

list of beam to expect packets for
tunes
list of tunings to expect packets for
pols
list of polarizations to expect packets for
nSegments
number of ring segments to use for the buffer (default is 10)
ReorderFrames
whether or not to reorder frames returned by get() or flush() by stand/polarization (default is False)

The number of segements in the ring can be converted to a buffer time in seconds:

Segments DRX Filter Code
1 2 3 4 5 6 7
10 0.16 0.08 0.04 0.02 0.01 0.004 0.002
20 0.33 0.16 0.08 0.04 0.02 0.008 0.004
30 0.49 0.25 0.12 0.06 0.03 0.013 0.006
40 0.66 0.33 0.16 0.08 0.03 0.017 0.008
50 0.82 0.41 0.20 0.10 0.04 0.021 0.010
100 1.64 0.82 0.41 0.20 0.08 0.042 0.021
calcFrames()

Calculate the maximum number of frames that we expect from the setup of the observations and a list of tuples that describes all of the possible stand/pol combination.

createFill(key, frameParameters)

Create a ‘fill’ frame of zeros using an existing good packet as a template.

figureOfMerit(frame)

Figure of merit for sorting frames. For DRX it is: <frame timetag in ticks>

Table Of Contents

Previous topic

Session and Observation Specification

Next topic

Data Writers

This Page