GSBTimeStampIO

class baseband.gsb.base.GSBTimeStampIO(fh_raw)[source] [edit on github]

Bases: FileBase

Simple reader/writer for GSB time stamp files.

Wraps a binary filehandle, providing methods read_timestamp, write_timestamp, and get_frame_rate.

Parameters:
fh_rawfilehandle

Filehandle to the timestamp file, opened in binary mode.

Attributes Summary

fh_raw

info

Standardized information on a timestamp file reader.

Methods Summary

close()

get_frame_rate()

Determine the number of frames per second.

read_timestamp()

Read a single timestamp.

temporary_offset([offset, whence])

Context manager for temporarily seeking to another file position.

write_timestamp([header])

Write a single timestamp.

Attributes Documentation

fh_raw = None
info

Standardized information on a timestamp file reader.

The info descriptor has a number of standard attributes, which are determined from arguments passed in opening the file, from the first header (info.header0) and from possibly scanning the file to determine the duration of frames.

Methods Documentation

close() [edit on github]
get_frame_rate()[source] [edit on github]

Determine the number of frames per second.

The frame rate is inferred from the first two timestamps.

Returns:
frame_rateQuantity

Frames per second.

read_timestamp()[source] [edit on github]

Read a single timestamp.

Returns:
frameGSBHeader

With a .time property that returns the time encoded.

temporary_offset(offset=None, whence=0) [edit on github]

Context manager for temporarily seeking to another file position.

To be used as part of a with statement:

with fh_raw.temporary_offset() [as fh_raw]:
    with-block

On exiting the with-block, the file pointer is moved back to its original position. As a convenience, one can pass on the offset to seek to when entering the context manager. Parameters are as for io.IOBase.seek().

write_timestamp(header=None, **kwargs)[source] [edit on github]

Write a single timestamp.

Parameters:
headerGSBHeader, optional

Header holding time to be written to disk. Can instead give keyword arguments to construct a header.

**kwargs

If header is not given, these are used to initialize one.