Previous topic

pycrtools.io.interfaces

Next topic

pycrtools.lora

This Page

pycrtools.io.tbb

IOInterface() Base class for data IO.
MultiTBBData(filenames[, blocksize, block]) This class provides an interface to single file Transient Buffer Board data.
TBBData(filename[, blocksize, block]) This class provides an interface to single file Transient Buffer Board data.
datetime datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
open(filename, *args, **kwargs) Open file with LOFAR TBB data.

This module implements the primary interface for reading LOFAR TBB data.

It contains one function open that is used to open an HDF5 file containing LOFAR TBB data and returns a TBBData file object.

Module author: Pim Schellart <P.Schellart@astro.ru.nl>

This module assumes that correct ICD specified values are set for the folowing attributes:

  • ANTENNA_SET
  • ANTENNA_POSITION
  • ANTENNA_POSITION_UNIT
  • NYQUIST_ZONE

If this is not true for your files use the fix_metadata.py script to fix this.

class pycrtools.io.tbb.MultiTBBData(filenames, blocksize=1024, block=0)

This class provides an interface to single file Transient Buffer Board data.

applyClockOffsets()

Get clock offsets from opened files; subtract off the smallest one; shift alignment offsets accordingly. No parameters.

empty(key)

Return empty array for keyword data. Known keywords are: “TIMESERIES_DATA”, “TIME_DATA”, “FREQUENCY_DATA”, “FFT_DATA”.

getFFTData(data, block=-1, hanning=True, hanning_fraction=1.0, datacheck=False)
Writes FFT data for selected antennas to data array.
Calls TBBData.getFFTData(...) per file and merges the output.

Required Arguments:

Parameter Description
data data array to write FFT data to.
block index of block to return data from.
hanning apply Hannnig filter to timeseries data before the FFT.

Output: a two dimensional array containing the FFT data of the specified block for each of the selected antennae and for the selected frequencies. So that if a is the returned array a[i] is an array of length (number of frequencies) of antenna i.

getTimeseriesData(data, block=-1, sample_offset=0)

Returns timeseries data for selected antennas.

Required Arguments:

Parameter Description
data data array to write timeseries data to.
block index of block to return data from. Use last set block if not provided or None

Output: a two dimensional array containing the timeseries data of the specified block for each of the selected antennae. So that if a is the returned array a[i] is an array of length blocksize of antenna i.

setAntennaSelection(selection)

Sets the antenna selection used in subsequent calls to getFFTData, getTimeseriesData, getItrfAntennaPosition, etc.

Required Arguments:

Parameter Description
selection Either Python list (or hArray, Vector) with index of the antenna as known to self (integers (e.g. [1, 5, 6])) Or list of IDs to specify a LOFAR dipole (e.g. ['142000005', '3001008']) or say odd or even to select odd or even antennas.

Output: This method does not return anything.

Raises: It raises a ValueError if antenna selection cannot be set to requested value (e.g. specified antenna not in file).

Example:
file[“SELECTED_DIPOLES”]=”odd”
shiftTimeseriesData(sample_offset)

Apply integer-sample shifts to all opened files to compensate clock offsets. A positive number k shifts forward through the data, i.e. the first k samples are skipped. Required Arguments:

Parameter Description
sample_offset List containing integer sample offset for each opened file.
class pycrtools.io.tbb.TBBData(filename, blocksize=1024, block=0)

This class provides an interface to single file Transient Buffer Board data.

close()

Closes file and sets the data attribute .closed to True. A closed object can no longer be used for I/O operations. close() may be called multiple times without error.

empty(key)

Return empty array for keyword data. Known keywords are: “TIMESERIES_DATA”, “TIME_DATA”, “FREQUENCY_DATA”, “FFT_DATA”.

getClockOffset()

Return clock offset.

getFFTData(data, block=-1, hanning=True, hanning_fraction=1.0, datacheck=False)

Writes FFT data for selected antennas to data array.

Required Arguments:

Parameter Description
data data array to write FFT data to.
block index of block to return data from.
hanning apply Hannnig filter to timeseries data before the FFT.
hanning_fraction fraction of the window to hanning filter at start and end
datacheck check for blocks of consecutive zeros indicating data loss

Output: a two dimensional array containing the FFT data of the specified block for each of the selected antennae and for the selected frequencies. So that if a is the returned array a[i] is an array of length (number of frequencies) of antenna i.

getFrequencies(block=-1)

Returns the frequencies that are applicable to the FFT data

Arguments: block = -1 - Is without function, just for compatibility.

Return value: This method returns a FloatVector with the selected frequencies in Hz.

getHeader()

Return a dict with keyword/content pairs for all header variables.

getItrfAntennaPosition()

Returns antenna positions for selected antennas, or all antennas if no selection was applied.

Output: a two dimensional array containing the Cartesian position of each antenna in meters in ITRF coordinates. So that if a is the returned array a[i] is an array of length 3 with positions (x,y,z) of antenna i.

getLofarCenterRelativeAntennaPosition()

Returns antenna positions relative to the LOFAR center (e.g. antenna 0 of station CS002) for selected antennas, or all antennas if no selection was applied.

Output: a two dimensional array containing the Cartesian position of each antenna in meters in local coordinates from the station center center. So that if a is the returned array a[i] is an array of length 3 with positions (x,y,z) of antenna i.

getStationCenterRelativeAntennaPosition()

Returns antenna positions relative to the station center for selected antennas, or all antennas if no selection was applied.

Output: a two dimensional array containing the Cartesian position of each antenna in meters in local coordinates from the station center center. So that if a is the returned array a[i] is an array of length 3 with positions (x,y,z) of antenna i.

getTimeData(data=None, block=-1)

Calculate time axis depending on sample frequency and blocksize (and later also time offset). Create a new array, if none is provided, otherwise put data into array.

getTimeseriesData(data, block=-1, sample_offset=0, datacheck=False)

Returns timeseries data for selected antennas.

Required Arguments:

Parameter Description
data data array to write timeseries data to.
block index of block to return data from. Use last set block if not provided or None

Output: a two dimensional array containing the timeseries data of the specified block for each of the selected antennae. So that if a is the returned array a[i] is an array of length blocksize of antenna i.

info(verbose=True, show=True)

Display some information about the file. Short and long versions (verbose=False/True)

items(excludedata=False)

Return list of keyword/content tuples of all header variables

keys(excludedata=False)

Returns list of valid keywords.

next(step=1)

Advance to next block. step = 1 - advance by ‘step’ blocks (optional)

read(key, data, *args, **kwargs)

Generic read function supporting keyword arguments.

Required Arguments:

Parameter Description
key Data type to read, one of: TIMESERIES_DATA FFT_DATA FREQUENCY_DATA TIME_DATA
data array to write data to.
setAntennaSelection(selection)

Sets the antenna selection used in subsequent calls to getAntennaPosition, getFFTData, getTimeseriesData.

Required Arguments:

Parameter Description
selection Either Python list (or hArray, Vector) with index of the antenna as known to self (integers (e.g. [1, 5, 6])) Or list of IDs to specify a LOFAR dipole (e.g. ['142000005', '3001008']) or say odd or even to select odd or even antennas.

Output: This method does not return anything.

Raises: It raises a ValueError if antenna selection cannot be set to requested value (e.g. specified antenna not in file).

Example:
file[“SELECTED_DIPOLES”]=”odd”
shiftTimeseriesData(sample_offset=0)

Shifts timeseries data for selected antennas.

Required Arguments:

Parameter Description
sample_offset Number of samples to offset timeseries data.
pycrtools.io.tbb.open(filename, *args, **kwargs)

Open file with LOFAR TBB data.