carputils
Doxygen code documentation for the python framework controlling openCARP
|
IGB format file IO class. More...
Public Member Functions | |
def | __init__ (self, filename, mode='r') |
def | close (self) |
Close the file object. More... | |
def | header (self) |
Read the IGB file header and return as python dictionary. More... | |
def | dtype (self) |
Get a numpy-friendly data type for this file. More... | |
def | data (self) |
Return a numpy array of the file contents. More... | |
def | write (self, data, header={}) |
Write a numpy array to the IGB file. More... | |
![]() | |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_val, exc_tb) |
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.
def carputils.carpio.igb.IGBFile.__init__ | ( | self, | |
filename, | |||
mode = 'r' |
|||
) |
filename | (str) the filename to open. |
mode | (str, optional) 'r' for read mode (default) 'w' for write mode |
def carputils.carpio.igb.IGBFile.close | ( | self | ) |
Close the file object.
def carputils.carpio.igb.IGBFile.data | ( | self | ) |
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.
def carputils.carpio.igb.IGBFile.dtype | ( | self | ) |
Get a numpy-friendly data type for this file.
def carputils.carpio.igb.IGBFile.header | ( | self | ) |
Read the IGB file header and return as python dictionary.
def carputils.carpio.igb.IGBFile.write | ( | self, | |
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.
data | (numpy.ndarray) The array to be written to the IGB file |
header | (dict) Fields to be included in the IGB header |