Binary Files

class oskar.Binary(filename, mode='r')

This class provides a Python interface to an OSKAR binary data file.

The oskar.Binary class provides a low-level interface to allow binary data files written by OSKAR to be read from Python using its read() method.

See the binary file documentation for details on the binary file format used by OSKAR if you need it. To read visibility data into Python, it is recommended to use the (much) more convenient oskar.VisBlock.read() method instead, and this page can be safely ignored!

__init__(filename, mode='r')

Constructs a handle to a binary data file.

Parameters:
  • filename (str) – Path of the file to open.
  • mode (Optional[char]) – Open mode: ‘r’ for read, ‘w’ for write.
read(group, tag, user_index=0, data_type=None)

Returns data for the specified chunk in the file.

The returned data will be either an array, a single value, or a string, depending on the contents of the data block.

Parameters:
  • group (int or str) – The chunk group ID to match.
  • tag (int or str) – The chunk tag ID to match within the group.
  • user_index (Optional[int]) – The user-specified index to read. Defaults to 0.
  • data_type (Optional[int]) – The enumerated OSKAR data type to read. If not given, the first type found matching the other filters is returned.
set_query_search_start(start)

Sets the tag index at which to start the search query.

Parameters:start (int) – Index at which to start search query.
num_tags

Returns the number of data tags in the file.