9. raw

This module is used to read/write raw binary data.

9.1. Overview

load_raw(fn[, size, dtype]) Load a raw binary file.
save_raw(fn, x[, append_info, compress]) Write a raw binary file.

9.2. Example Usage

fn = ilpm.raw.dump_raw('test', my_array)
print "Saved to: %s"

loaded_array = iplm.raw.open_raw(fn)
print "Loaded from: %s" % fn

9.3. Functions

ilpm.raw.load_raw(fn, size=None, dtype=None)[source]

Load a raw binary file. The size and data type of the array will be determined automatically if specified correctly in the name of the file, for example: my_array.float64.100x100x200.bin, which corresponds to an 100x100x200 array of double precision floats. Note that the index ordering is “C” style; the fast axis is last.

Optionally, the binary file may be zipped, in which case the extension should be ".zip".

Parameters:

size : tuple (optional)

dtype : string (optional)

The size and data type (numpy format). Should be specified if the file name is not in the required format.

Returns:

array : numpy array

ilpm.raw.save_raw(fn, x, append_info=True, compress=False)[source]

Write a raw binary file.

Parameters:

fn : string

The filename base. If append_info is False, it is recommended not to include an extension.

array : numpy array

The data to save.

append_info : bool (default: True)

If true, appends the shape, data type, and ".bin" to the file name.

compress : bool (default: False)

Puts the resulting file in a zip archive. Not recommended unless data is exptected to compress well (e.g., a sparse array). Appends ".zip" to the final file name.

Returns:

filename : string

The complete file name, including added info.