Data Writers
Time-Series FITS
Modules to take TBW/TBN time series data and write it to a FITS file composed
of binary tables. The format of TSFITS files is:
PRIMARY HDU
- Keywords:
- OBJECT - object being observed in this data set, e.g., ‘zenith’
- TELESCOP - telescope used for the observations, e.g., ‘LWA-1’
- OBSMODE - observation mode used for the data. Options are TBW or TBN.
- NSTANDS - number of stands found in the file
- TBWBITS optional - how many bits are used by the TBW data (4 or 12)
- FILTER optional - TBN filter code used to acquire the data
- GAIN optional - TBN gain setting used to acquire the data
- FREQ optional - central frequency in Hz for the TBN observations
TIME SERIES HDU
Binary table that stores the actual observations. There is one TIME SERIES
extension per stand (TBW/TBN) or beam/tuning pair (DRX) in the data.
- Keywords:
- EXTNAME - extension name of ‘TIME SERIES’
- EXTVER - extension version equal to the order in which the data was
added to the FITS file
- STAND - stand number associated with this data
- DATE-OBS - date of observation for the first sample of the first data
row
- Data:
- DATA - column storing the observations. For TBW data this consists of
400 (12-bit) or 1200 (4-bit) elements per row stored as 16-bit integers.
For TBN data this consists of 512 elements per row stored as 32-bit
complex numbers. For DRX data this consists of 4096 elements per row
stored as 32-bit complex numbers.
- POL - column storing the polarization associated with the DATA column.
‘x’ polarization is stored as 0 and ‘y’ polarization is stored as 1.
The values is stored as a 16-bit integer.
- TIME - number of samples at f_S (196 MSamples/s) since DATE-OBS for the
first sample in the row. This is stored as a 64-bit integer.
-
class lsl.writer.tsfits.UTC
tzinfo object for UTC time.
-
fromutc
- datetime in UTC -> datetime in local time.
-
class lsl.writer.tsfits.TSFITS(filename, mode, Overwrite=False, UseQueue=True, verbose=False)
Class that holds TSFITS data until it is ready to be written to disk.
-
addStandData(frame)
- Add a frame object to the TSFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits, TBN filter code, etc.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
-
class lsl.writer.tsfits.TBW(filename, Overwrite=False, UseQueue=True, verbose=False)
Sub-class of TSFITS for dealing with TBW data in particular.
-
addStandData(frame)
- Add a frame object to the TSFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits, TBN filter code, etc.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
-
class lsl.writer.tsfits.TBN(filename, Overwrite=False, UseQueue=True, verbose=False)
Sub-class of TSFITS for dealing with TBN data in particular.
-
addStandData(frame)
- Add a frame object to the TSFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits, TBN filter code, etc.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
Single-Dish FITS
SDFITS Standard
Modules to take DRX/TBW/TBN data and write it to a SDFITS file.
Warning
The FITS files created by this module to not strictly conform to the
SDFITS convention.
-
class lsl.writer.sdfits.SDFITS(filename, mode, LFFT=128, Overwrite=False, UseQueue=True, verbose=False)
Class that holds TSFITS data until it is ready to be writen to disk.
-
addStandData(frame)
- Add a frame object to the SDFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setCentralFrequency(centralFreq)
- Set the central frequency in Hz of the data for TBN and DRX
observations.
-
setSampleRate(sampleRate)
- Set the sample rate in Hz of the data for TBN and DRX observations.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
-
class lsl.writer.sdfits.TBW(filename, LFFT=128, Overwrite=False, UseQueue=True, verbose=False)
Sub-class of SDFITS for dealing with TBW data in particular.
-
addStandData(frame)
- Add a frame object to the SDFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setCentralFrequency(centralFreq)
- Set the central frequency in Hz of the data for TBN and DRX
observations.
-
setSampleRate(sampleRate)
- Set the sample rate in Hz of the data for TBN and DRX observations.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
-
class lsl.writer.sdfits.TBN(filename, LFFT=128, Overwrite=False, UseQueue=True, verbose=False)
Sub-class of SDFITS for dealing with TBN data in particular.
-
addStandData(frame)
- Add a frame object to the SDFITS file. This function takes care of
figuring out which extension the data goes to and how it should be formated.
This function also updates the primary HDU with information about the data,
i.e., TBW data bits.
-
close()
- Empty the data queue (if it exists) and write all changes to disk
using flush.
-
flush()
- Short-cut to the pyfits.flush() function on an opened FITS file.
-
getStandData(stand)
Retrieve a dictionary of all data stored for a particular stand. The
dictionary keys are:
- data - numpy array of data
- pol - numpy array of polarizations
- time - numpy array of times in samples at f_S since DATE-OBS
-
info()
- Short-cut to the pyfits.info() function on an opened FITS file.
-
setCentralFrequency(centralFreq)
- Set the central frequency in Hz of the data for TBN and DRX
observations.
-
setSampleRate(sampleRate)
- Set the sample rate in Hz of the data for TBN and DRX observations.
-
setSite(site)
- Set the TELESCOP keyword in the primary HDU using an lsl.common.stations
object.
FITS IDI
FITS IDI Standard
Module for writing correlator output to a FITS IDI file. The classes and
functions defined in this module are based heavily off the lwda_fits library.
Note
Some software that deal with FITS IDI files, e.g. AIPS, does not support
FITS IDI files with more than 99 antennas. See the lsl.writer.fitsidi.aips
class for a FITS IDI writer that respects this limit.
-
class lsl.writer.fitsidi.IDI(filename, refTime=0.0, verbose=False)
Class for storing visibility data and writing the data, along with array
geometry, frequency setup, etc., to a FITS IDI file that can be read into
AIPS via the FITLD task.
-
addDataSet(obsTime, intTime, baselines, visibilities, pol='XX')
Create a UVData object to store a collection of visibilities.
Changed in version 0.4.0: Switched over to passing in Antenna instances generated by the
lsl.common.stations module instead of a list of stand ID
as part of the baselines.
-
close()
- Close out the file.
-
parseRefTime(refTime)
- Given a time as either a integer, float, string, or datetime object,
convert it to a string in the formation ‘YYYY-MM-DDTHH:MM:SS’.
-
readArrayGeometry()
- Return a tuple with the array geodetic position and the local
positions for all antennas defined in the ARRAY_GEOMETRY table.
-
readArrayMapper()
- Return a tuple with the array NOSTA mapper and inverse mapper (both
dictionaries. If the stand IDs have not been mapped, return None for
both.
-
refTime2AstroDate()
- Convert a reference time string to an lsl.astro.date object.
-
setFrequency(freq)
- Given a numpy array of frequencies, set the relevant common observation
parameters and add an entry to the self.freq list.
-
setGeometry(site, antennas, bits=8)
Given a station and an array of stands, set the relevant common observation
parameters and add entries to the self.array list.
Changed in version 0.4.0: Switched over to passing in Antenna instances generated by the
lsl.common.stations module instead of a list of stand ID
numbers.
-
setStokes(polList)
- Given a list of Stokes parameters, update the object’s parameters.
-
write()
- Fill in the FITS-IDI file will all of the tables in the
correct order.
-
class lsl.writer.fitsidi.AIPS(filename, refTime=0.0, verbose=False)
Sub-class of the FITS IDI writer for making files that should work
with AIPS nicely. AIPS imposes a limit on antenna number of two digits
(1-99). This sub-class overwrite the setGeometry() function with one that
enforces the two digit limit and maps accordingly. It also sets the FITS
LWATYPE keyword in the primary HDU to a value of IDI-AIPS-ZA to
distinguish files written by this writer from the standard IDI writer.
-
setGeometry(site, antennas, bits=8)
Given a station and an array of stands, set the relevant common observation
parameters and add entries to the self.array list.
Changed in version 0.4.0: Switched over to passing in Antenna instances generated by the
lsl.common.stations module instead of a list of stand ID
numbers.
VDIF
VDIF Standard (PDF)
Module to write VDIF frames. The implementation of this module is similar
to that of lsl.sim.tbw in that the primary element defined in this module is
a Frame object which as attribute functions that can create a numpy
representation of the raw frame and write that raw frame to an open file-
handle.
-
class lsl.writer.vdif.Frame(stand=0, time=0, bits=16, data=None, sampleRate=196000000.0)
Object to create and write a VDIF (VLBI Data Interchange Format)
frame (version 1, June 26, 2009).
-
createRawFrame()
- Using the data and information stored in the object, create a
numpy array on unsigned 1-byte integers that represents the frame.
-
writeRawFrame(fh)
- Create a numpy representation of the VDIF frame and then write
it to the specified file handle.