In order to be able to use this module import it like this:

#or assign it to a shorter name
import as dat


class, index, dataslice=None)

Bases: object

Standardized interface for reading Mpacts save files stored with DataSaveCommand

  • fname (str) – file name of data save file that needs to be read (will be opened in read-only mode)
  • index (int) – Assign an index to this data frame
In most instances, a DataReader should be used to automatically handle multiple data frames.
DataFrameReader(name, parent, **kwargs)


class, folder='.')

Bases: object

Standardized interface for reading collections of Mpacts save files stored with DataSaveCommand

  • simname (str) – Name of the root node of the simulation, specifying the ‘base name’ of a list of mpactsd save files
  • folder (str) – Optional folder in which the DataReader should read save files

Example usage:

import as ds
reader = ds.DataReader("simulation", folder='./')

#Last saved frame of a simulation:
dr = reader[-1]

#Access to regular arrays
x = dr('spheres/x')
v = dr('spheres/v')

#Access to arrays in complex data structures:
vil = dr('box/RigidQuads/vertexIndices')
xctrl = dr('box/controlPoints/x')

#Access to any property in a 'tree':
g = dr('simulation/loop_cmds/body_force_cmds/GravityCmd/g')

#Access to Variables:
E = dr('simulation/params/E')
The example above directly extracts data from a simulation. For advanced post-processing, it is often useful to organize data access and processing over multiple frames using postprocessing operators. See: DEMutilities.postprocessing.operators.operators.
DataReader(name, parent, **kwargs)