Bamboost

bamboost.core.simulation.series

Module for handling time series data in HDF5 files. The notion of time is used to describe Series, but it can be used for any data that changes with a single parameter.

The default time series is stored at /data in the HDF5 file. You can create additional series' with Simulation.create_series.

This module provides classes for managing time series data stored in HDF5 files:

  • Series: Main class for managing a series, including fields and global values
  • FieldData: Handles a particular field (e.g., nodal or element data) and its timesteps
  • GlobalData: Manages the global data that varies with time. This refers to data that is not tied to a mesh.
  • StepWriter: Helper class for writing data at specific timesteps

The data is organized hierarchically in the HDF5 file with separate sections for field data and global/scalar data. Fields typically represent spatial data like displacements or stresses, while globals are used for scalar quantities like energy or convergence metrics.

Attributes

  • log=BAMBOOST_LOGGER.getChild(__name__)

Classes

NotASeriesError

NotASeriesError(self, path)
Arguments:
  • path:str

Series

Series(self, simulation, path=PATH_DATA)
Arguments:
  • simulation:_Simulation[bamboost._typing._MT]
  • path:str=bamboost.constants.PATH_DATA
Attributes:
  • _obj:h5py.h5py.Group
  • _field_instances:[str, bamboost.core.simulation.series.FieldData[bamboost._typing._MT]]={}
  • last_step:typing.Union[int, None]
  • globals:GlobalData[bamboost._typing._MT]
  • values:numpy.numpy.ndarray

    Return the values of the series. In the default time series, this returns the time values of the steps.

Arguments:
  • key
Series.__len__(self) -> int
Series.get_field_names(self) -> list[HDF5Path]

Return all the name of the fields in the series.

Series.get_field(self, name) -> FieldData[_MT]

Get a field by name.

Arguments:
  • name:str

    The name of the field.

Series.get_fields(self, *glob) -> list[FieldData[_MT]]

Get multiple fields by name or glob pattern. If no arguments are given, all fields are returned.

Arguments:
  • glob:str=()

    A list of glob patterns to filter the field names.

Series.require_step(self, value=np.nan, step=None) -> StepWriter

Create a new step in the series. If the step is not given, we append one.

Arguments:
  • value:float=numpy.numpy.nan

    The value of the step. This is typically the time value.

  • step:typing.Optional[int]=None

    The step number. If not given, a step is appended after the last one.

Series._ipython_key_completions_(self) -> list[HDF5Path]

Repr showing the content of the group.

Series._values(self) -> Dataset[_MT]
Series._store_value(self, step, time) -> None
Arguments:
  • step:int
  • time:float

StepWriter

StepWriter(self, series, step)

A class to write data for a specific step in a series.

Arguments:
  • series:Series[bamboost._typing.Mutable]
  • step:int
Attributes:
  • _series=bamboost.core.simulation.series.StepWriter(series)

    The series to which the step belongs.

  • _step=bamboost.core.simulation.series.StepWriter(step)

    The step number.

StepWriter.add_field(self, name, data, *, mesh_name=DEFAULT_MESH_NAME, field_type=FieldType.NODE) -> None

Add a field to the step.

Arguments:
  • name:str

    The name of the field.

  • The data for the field.

  • mesh_name:str=bamboost.constants.DEFAULT_MESH_NAME

    The name of the mesh to which the field belongs.

  • field_type:FieldType=bamboost.core.simulation.FieldType.bamboost.core.simulation.FieldType.NODE

    The type of the field (default: FieldType.NODE). This is only relevant for XDMF writing.

StepWriter.add_fields(self, fields, mesh_name=DEFAULT_MESH_NAME, field_type=FieldType.NODE) -> None

Add multiple fields to the step.

Arguments:
  • fields:[str, bamboost._typing.ArrayLike]

    A dictionary of field names and their data.

  • mesh_name:str=bamboost.constants.DEFAULT_MESH_NAME

    The name of the mesh to which the fields belong.

  • field_type:FieldType=bamboost.core.simulation.FieldType.bamboost.core.simulation.FieldType.NODE

    The type of the fields (default: FieldType.NODE). This is only relevant for XDMF writing.

StepWriter.add_scalar(self, name, data) -> None

Add a scalar to the step. Scalar data is typically a single value or a small array. The shape must be consistent across all steps.

Arguments:
  • name:str

    The name of the scalar.

  • data:typing.Union[int, float, typing.Iterable]

    The data for the scalar.

StepWriter.add_scalars(self, scalars) -> None

Add multiple scalars to the step. See add_scalar for more information.

Arguments:
  • scalars:[str, typing.Union[int, float, typing.Iterable]]

    A dictionary of scalar names and their data.

FieldData

FieldData(self, series, name)
Arguments:
  • series:Series[bamboost._typing._MT]
  • name:str
Attributes:
  • _parent:Series[bamboost._typing._MT]=bamboost.core.simulation.series.FieldData(series)
  • name:str=bamboost.core.simulation.series.FieldData(name)
FieldData.__getitem__(self, key) -> np.ndarray

Get data of the field for a specific step or steps using standard slice notation. First index is the step number.

Arguments:
  • key:typing.Union[int, slice, tuple[slice | int, ...]]
FieldData.at(self, step) -> Dataset[_MT]

Get the dataset for a specific step without reading the data itself.

Arguments:
  • step:int

    The step number.

Arguments:
  • index:int
FieldData._slice_step(self, step) -> list[str]
Arguments:
  • step:slice

GlobalData

GlobalData(self, series)
Arguments:
  • series:Series[bamboost._typing._MT]
Attributes:
  • _series=bamboost.core.simulation.series.GlobalData(series)
  • df:pandas.pandas.DataFrame
GlobalData.__getitem__(self, key) -> Dataset[_MT]
Arguments:
  • key:str
GlobalData.get(self, *glob) -> tuple[tuple[np.ndarray, ...], tuple[str, ...]]

Get the data for many scalars by name or glob pattern. If no arguments are given, all scalars are read and returned.

Arguments:
  • glob:str=()

    A list of glob patterns to filter the scalar names.