OMXFile#

class caf.mat.omx.OMXFile(filename, mode='r', omx_version=None, shape=None, **kwargs)[source]#

Bases: File

Reading and writing data to OMX files, which use the HDF5 format.

This class wraps pytables File object and provides some helper methods and checks for working with OMX files specifically.

Parameters:
  • filename (str) – The name of the file (supports environment variable expansion). It is suggested that file names have any of the .h5, .hdf or .hdf5 extensions, although this is not mandatory.

  • mode (str, default 'r') –

    The mode to open the file. It can be one of the following:

    • ’r’: Read-only; no data can be modified.

    • ’w’: Write; a new file is created (an existing file

    with the same name would be deleted). * ‘a’: Append; an existing file is opened for reading and writing, and if the file does not exist it is created. * ‘r+’: It is similar to ‘a’, but the file must already exist.

  • omx_version (str, optional) – Version of the OMX file, this option is ignored unless mode = ‘w’, when it is mandatory. Expected OMX version is ‘0.2’.

  • shape (str, optional) – Shape of the matrices in the OMX file, this option is ignored unless mode = ‘w’, when it is mandatory.

  • kwargs (Keyword arguments, optional) – All other keyword arguments are passed to tables.File.

Raises:

ValueError – If a mode other than those defined above is provided or omx_version and shape aren’t provided in mode ‘w’.

Attributes

matrix_levels

Names of all the matrix levels in the OMX file.

omx_version

OMX version of the current file.

shape

Shape of the matrices in the current OMX file.

zones

Array of zone names for the current OMX file.

filename

The name of the opened file.

mode

The mode in which the file was opened.

format_version

The PyTables version number of this file.

isopen

True if the underlying file os open, False otherwise.

root

The root of the object tree hierarchy (a Group instance).

Methods

__init__(filename[, mode, omx_version, shape])

get_all()

Iterate through matrix levels as DataFrames.

get_matrix_array(name)

Return a single matrix level as an array.

get_matrix_level(name)

Return a single matrix level as an DataFrame.

set_matrix_level(name, matrix)

Set matrix level in OMX file to given array.

to_csvs(path[, format_, overwrite])

Export each matrix level to a CSV.

Attributes Documentation

matrix_levels#

Names of all the matrix levels in the OMX file.

omx_version#

OMX version of the current file.

shape#

Shape of the matrices in the current OMX file.

zones#

Array of zone names for the current OMX file.

filename[source]#

The name of the opened file.

mode[source]#

The mode in which the file was opened.

format_version[source]#

The PyTables version number of this file.

isopen[source]#

True if the underlying file os open, False otherwise.

root[source]#

The root of the object tree hierarchy (a Group instance).

Examples using caf.mat.omx.OMXFile#

CUBE .mat to CSV

CUBE .mat to CSV

Load CUBE .mat

Load CUBE .mat

Interacting with OMX Files

Interacting with OMX Files