open, mode='rs', format=None, **kwargs)[source] [edit on github]

Open a baseband file (or sequence of files) for reading or writing.

Opened as a binary file, one gets a wrapped filehandle that adds methods to read/write a frame. Opened as a stream, the handle is wrapped further, and reading and writing to the file is done as if the file were a stream of samples.

namestr or filehandle, or sequence of str

File name, filehandle, or sequence of file names. A sequence may be a list or str of ordered filenames, or an instance of FileNameSequencer.

mode{‘rb’, ‘wb’, ‘rs’, or ‘ws’}, optional

Whether to open for reading or writing, and as a regular binary file or as a stream. Default: ‘rs’, for reading a stream.

formatstr or tuple of str

The format the file is in. For reading, if a tuple of possible formats, all will be tried in turn. By default, all supported formats are tried. For writing, an explicit format must be passed in.


Additional arguments needed for opening the file as a stream. For most formats, trying without these will raise an exception that tells which arguments are needed. Opening will not succeed if any arguments are passed in that are inconsistent with the file, or are irrelevant for opening the file.