Binout

There is a YOUTUBE TUTORIAL for this class available:

class qd.cae.dyna.Binout(filepath)

Constructor for a binout

Parameters
filepathstr

path to the binout or pattern

Notes

The class loads the file given in the filepath. By giving a search pattern such as: “binout*”, all files with that pattern will be loaded.

Examples

>>> # reads a single binout
>>> binout = Binout("path/to/binout0000")
>>> binout.filelist
['path/to/binout0000']
>>> # reads multiple files
>>> binout = Binout("path/to/binout*")
>>> binout.filelist
['path/to/binout0000','path/to/binout0001']

Methods

read(…)

Read all data from Binout (top to low level)

save_hdf5(self, filepath[, compression])

Save a binout as HDF5

__init__(self, filepath)

Constructor for a binout

Parameters
filepathstr

path to the binout or pattern

Notes

The class loads the file given in the filepath. By giving a search pattern such as: “binout*”, all files with that pattern will be loaded.

Examples

>>> # reads a single binout
>>> binout = Binout("path/to/binout0000")
>>> binout.filelist
['path/to/binout0000']
>>> # reads multiple files
>>> binout = Binout("path/to/binout*")
>>> binout.filelist
['path/to/binout0000','path/to/binout0001']
read(path) Read all data from Binout (top to low level)

Read all data from Binout (top to low level)

Parameters
pathlist(str) or str

internal path in the folder structure of the binout

Returns
retlist(str), np.ndarray or str

list of subdata within the folder or data itself (array or string)

Notes

This function is used to read any data from the binout. It has been used to make the access to the data more comfortable. The return type depends on the given path:

  • binout.read() : list(str) names of directories (in binout)

  • binout.read(dir) : list(str) names of variables or subdirs

  • binout.read(dir1, …, variable) : np.array(float/int) data

If you have multiple outputs with different ids (e.g. in nodout for multiple nodes) then don’t forget to read the ids array for identification or id-labels.

Examples

>>> from qd.cae.dyna import Binout
>>> binout = Binout("test/binout")
>>> # get top dirs
>>> binout.read()
['swforc']
>>> binout.read("swforc")
['title', 'failure', 'ids', 'failure_time', ...]
>>> binout.read("swforc","shear").shape
(321L, 26L)
>>> binout.read("swforc","ids").shape
(26L,)
>>> binout.read("swforc","ids")
array([52890, 52891, 52892, ...])
>>> # read a string value
>>> binout.read("swforc","date")
'11/05/2013'
save_hdf5(self, filepath, compression='gzip')

Save a binout as HDF5

Parameters
filepathstr

path where the HDF5 shall be saved

compressionstr

compression technique (see h5py docs)

Examples

>>> binout = Binout("path/to/binout")
>>> binout.save_hdf5("path/to/binout.h5")