Skip to content

Binout

There is a youtube tutorial available for this class:

This class is meant to read binouts from LS-Dyna

Parameters:

Name Type Description Default
filepath str

Path to the binout to read. May contain * (glob) for selecting multiple files.

required

Attributes:

Name Type Description
filelist List[str]

List of files which are opened. lsda: Lsda The underlying LS-Dyna binout reader instance from code from LSTC. lsda_root: Symbol Root lsda symbol which is like a root directory to traverse the content of the binout file.

Notes

This class is only a utility wrapper for Lsda from LSTC.

Examples:

>>> binout = Binout("path/to/binout")

__init__(filepath)

Constructor for a binout

Parameters:

Name Type Description Default
filepath str

path to the binout or pattern

required

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']

as_df(*args)

read data and convert to pandas dataframe if possible

Parameters:

Name Type Description Default
*args

internal path in the folder structure of the binout

()

Returns:

Name Type Description
df pandas.DataFrame

data converted to pandas dataframe

Raises:

Type Description
ValueError

if the data cannot be converted to a pandas dataframe

Examples:

>>> from lasso.dyna import Binout
>>> binout = Binout('path/to/binout')

Read a time-dependent array.

>>> binout.as_df('glstat', 'eroded_kinetic_energy')
time
0.00000        0.000000
0.19971        0.000000
0.39942        0.000000
0.59976        0.000000
0.79947        0.000000
                ...
119.19978    105.220786
119.39949    105.220786
119.59983    105.220786
119.79954    105.220786
119.99988    105.220786
Name: eroded_kinetic_energy, Length: 601, dtype: float64

Read a time and id-dependent array.

>>> binout.as_df('secforc', 'x_force')
                      1             2             3  ...            33            34
time                                                 .
0.00063    2.168547e-16  2.275245e-15 -3.118639e-14  ... -5.126108e-13  4.592941e-16
0.20034    3.514243e-04  3.797908e-04 -1.701294e-03  ...  2.530416e-11  2.755493e-07
0.40005    3.052490e-03  3.242951e-02 -2.699926e-02  ...  6.755315e-06 -2.608923e-03
0.60039   -1.299816e-02  4.930999e-02 -1.632376e-02  ...  8.941705e-05 -2.203455e-02
0.80010    1.178485e-02  4.904512e-02 -9.740204e-03  ...  5.648263e-05 -6.999854e-02
...                 ...           ...           ...  ...           ...           ...
119.00007  9.737679e-01 -8.833702e+00  1.298964e+01  ... -9.977377e-02  7.883521e+00
119.20041  7.421170e-01 -8.849411e+00  1.253505e+01  ... -1.845916e-01  7.791409e+00
119.40012  9.946615e-01 -8.541475e+00  1.188757e+01  ... -3.662228e-02  7.675800e+00
119.60046  9.677638e-01 -8.566695e+00  1.130774e+01  ...  5.144208e-02  7.273052e+00
119.80017  1.035165e+00 -8.040828e+00  1.124044e+01  ... -1.213450e-02  7.188395e+00

read(*path)

Read all data from Binout (top to low level)

Parameters:

Name Type Description Default
path

internal path in the folder structure of the binout

()

Returns:

Name Type Description
ret Union[List[str], str, np.ndarray]

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 data

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

Examples:

>>> from lasso.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(filepath, compression='gzip')

Save a binout as HDF5

Parameters:

Name Type Description Default
filepath

path where the HDF5 shall be saved

required
compression

compression technique (see h5py docs)

'gzip'

Examples:

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