carputils
Doxygen code documentation for the python framework controlling openCARP
Public Member Functions | List of all members
carputils.carpio.igb.IGBFile Class Reference

IGB format file IO class. More...

Inheritance diagram for carputils.carpio.igb.IGBFile:
carputils.carpio.filelike.FileLikeMixin

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...
 
- Public Member Functions inherited from carputils.carpio.filelike.FileLikeMixin
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def carputils.carpio.igb.IGBFile.__init__ (   self,
  filename,
  mode = 'r' 
)
Parameters
filename(str) the filename to open.
mode(str, optional)
'r' for read mode (default)
'w' for write mode

Member Function Documentation

◆ close()

def carputils.carpio.igb.IGBFile.close (   self)

Close the file object.

◆ data()

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.

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

◆ dtype()

def carputils.carpio.igb.IGBFile.dtype (   self)

Get a numpy-friendly data type for this file.

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

◆ header()

def carputils.carpio.igb.IGBFile.header (   self)

Read the IGB file header and return as python dictionary.

Returns
(dict) The contents of the file header

◆ write()

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.

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

The documentation for this class was generated from the following file: