carputils.carpio.igb.IGBFile

class carputils.carpio.igb.IGBFile(filename, mode='r')

IGB format file IO class.

Direct read/write to gzipped files is possible. The class automatically determines if the file is gzipped by its extension.

close()

Close the file object.

data()

Return a numpy array of the file contents.

The data is returned as a flat array. It is up to the user to use the header information to determine how to reshape the array, if desired.

Returns:
(numpy.ndarray) A numpy array with the file contents
dtype()

Get a numpy-friendly data type for this file.

Returns:
(numpy.dtype) The numpy data type corresponding to the file contents
header()

Read the IGB file header and return as python dictionary.

Returns:
(dict) The contents of the file header
write(data, header={})

Write a numpy array to the IGB file.

Some header fields are automatically determined from the numpy array. Others must be specified as additional keyword arguments.

Not all IGB output formats are currently supported. For that reason, the input numpy array data type must be single.

Args:
data: (numpy.ndarray) The array to be written to the IGB file
Kwargs:
header: (dict) Fields to be included in the IGB header