sigpyproc.Utils¶
-
class
sigpyproc.Utils.File(filename, mode, nbits=8)[source]¶ Bases:
_io.FileIOA class to handle writing of arbitrary bit size data to file.
- Parameters
filename (
str()) – name of file to openmode (
str()) – file access mode, can be either “r”, “r+”, “w” or “a”.nbits – the bit size of units to be read from or written to file
Note
The File class handles all packing and unpacking of sub-byte size data under the hood, so all calls can be made requesting numbers of units rather than numbers of bits or bytes.
-
cread(nunits)[source]¶ Read nunits of data from the file.
- Parameters
nunits (int) – number of units to be read from file
- Returns
an array containing the read data
- Return type
-
cwrite(ar)[source]¶ Write an array to file.
- Parameters
ar (
numpy.ndarray) – a numpy array
Note
Regardless of the dtype of the array argument, the data will be packed with a bitsize determined by the nbits attribute of the File instance. To change this attribute, use the _setNbits methods. It is the responsibility of the user to ensure that values in the array do not go beyond the maximum and minimum values allowed by the nbits attribute.
-
sigpyproc.Utils.editInplace(inst, key, value)[source]¶ Edit a sigproc style header in place
- Parameters
inst (
Header) – a header instance with a.filenameattributekey (
str()) – name of parameter to change (must be a valid sigproc key)value – new value to enter into header
Note
It is up to the user to be responsible with this function, as it will directly change the file on which it is being operated. The only fail contition of editInplace comes when the new header to be written to file is longer or shorter than the header that was previously in the file.