VDIFStreamWriter

class baseband.vdif.base.VDIFStreamWriter(fh_raw, header0=None, sample_rate=None, nthread=1, squeeze=True, **kwargs)[source] [edit on github]

Bases: baseband.vdif.base.VDIFStreamBase, baseband.vlbi_base.base.VLBIStreamWriterBase

VLBI VDIF format writer.

Encodes and writes sequences of samples to file.

Parameters
fh_rawfilehandle

Which will write filled sets of frames to storage.

header0VDIFHeader

Header for the first frame, holding time information, etc. Can instead give keyword arguments to construct a header (see **kwargs).

sample_rateQuantity

Number of complete samples per second, i.e. the rate at which each channel in each thread is sampled. For EDV 1 and 3, can alternatively set sample_rate within the header.

nthreadint, optional

Number of threads (e.g., 2 for 2 polarisations). Default: 1.

squeezebool, optional

If True (default), write accepts squeezed arrays as input, and adds any dimensions of length unity.

**kwargs

If no header is given, an attempt is made to construct one from these. For a standard header, this would include the following.

— Header keywords(see fromvalues())
timeTime

Start time of the file. Can instead pass on ref_epoch and seconds.

nchanint, optional

Number of channels (default: 1). Note: different numbers of channels per thread is not supported.

complex_databool, optional

Whether data are complex. Default: False.

bpsint, optional

Bits per elementary sample, i.e. per real or imaginary component for complex data. Default: 1.

samples_per_frameint

Number of complete samples per frame. Can alternatively use frame_length, the number of 8-byte words for header plus payload. For some EDV, this number is fixed (e.g., frame_length=629 for edv=3, which corresponds to 20000 real 2-bit samples per frame).

station2 characters, optional

Station ID. Can also be an unsigned 2-byte integer. Default: 0.

edv{False, 0, 1, 2, 3, 4, 0xab}

Extended Data Version.

Attributes Summary

bps

Bits per elementary sample.

complex_data

Whether the data are complex.

header0

First header of the file.

sample_rate

Number of complete samples per second.

sample_shape

Shape of a complete sample (possibly subset or squeezed).

samples_per_frame

Number of complete samples per frame.

squeeze

Whether data arrays have dimensions with length unity removed.

start_time

Start time of the file.

subset

Specific components of the complete sample to decode.

time

Time of the sample pointer’s current offset in file.

verify

Whether to do consistency checks on frames being read.

Methods Summary

close(self)

tell(self[, unit])

Current offset in the file.

write(self, data[, valid])

Write data, buffering by frames as needed.

Attributes Documentation

bps

Bits per elementary sample.

complex_data

Whether the data are complex.

header0

First header of the file.

sample_rate

Number of complete samples per second.

sample_shape

Shape of a complete sample (possibly subset or squeezed).

samples_per_frame

Number of complete samples per frame.

squeeze

Whether data arrays have dimensions with length unity removed.

If True, data read out has such dimensions removed, and data passed in for writing has them inserted.

start_time

Start time of the file.

See also time for the time of the sample pointer’s current offset.

subset

Specific components of the complete sample to decode.

The order of dimensions is the same as for sample_shape. Set by the class initializer.

time

Time of the sample pointer’s current offset in file.

See also start_time for the start time of the file.

verify

Whether to do consistency checks on frames being read.

Methods Documentation

close(self) [edit on github]
tell(self, unit=None) [edit on github]

Current offset in the file.

Parameters
unitUnit or str, optional

Time unit the offset should be returned in. By default, no unit is used, i.e., an integer enumerating samples is returned. For the special string ‘time’, the absolute time is calculated.

Returns
offsetint, Quantity, or Time

Offset in current file (or time at current position).

write(self, data, valid=True) [edit on github]

Write data, buffering by frames as needed.

Parameters
datandarray

Piece of data to be written, with sample dimensions as given by sample_shape. This should be properly scaled to make best use of the dynamic range delivered by the encoding.

validbool, optional

Whether the current data are valid. Default: True.