MDMC.readers package

Subpackages

Submodules

MDMC.readers.H5MD_reader module

Module for reading in H5MD files.

MDMC.readers.H5MD_reader.particles_file_path(file: File) Group[source]

Returns the path in the H5MD file where the particle data is stored.

Parameters:

file (h5py.File) – The H5MD file being read from.

Returns:

Particle data group.

Return type:

h5py.Group

MDMC.readers.H5MD_reader.read_all_data(filename: str) dict[source]

Read all data from an H5MD file and return it as a dictionary.

Parameters:

file (str) – The name of file being read from.

Returns:

A dictionary storing all data in the H5MD file.

Return type:

dict

MDMC.readers.H5MD_reader.read_box_property(file: File, property_name: str) ndarray[source]

Reads box properties from H5MD file.

Parameters:
  • file (h5py.File) – The H5MD file being read from

  • property_name (str) – The name of the box property being read

Returns:

An array returning the property read

Return type:

numpy.ndaray

Notes

This box is equivalent to what MDMC calls a Universe internally.

MDMC.readers.H5MD_reader.read_dataset(file: File, dataset_name: str) ndarray[source]

Read a dataset within an H5MD file.

Parameters:
  • file (h5py.File) – The H5MD file being read from

  • dataset_name (str) – The dataset attempting to be read

Returns:

Returns an array of the whole dataset

Return type:

numpy.ndarray

Raises:

KeyError – If the dataset is not found in the file.

MDMC.readers.H5MD_reader.read_number_steps(file: File) int[source]

Calculate the total number of simulation frames stored in an H5MD file.

Parameters:

file (h5py.File) – The H5MD file being read from

Returns:

Number of steps stored in H5MD file

Return type:

int

MDMC.readers.H5MD_reader.read_times(file: File, step: int) float[source]

Read the time of a specified step from an H5MD file.

Parameters:
  • file (h5py.File) – The H5MD file being read from

  • step (int) – The time step the H5MD file is calculating the time

Returns:

Simulation time at simulation step

Return type:

float

MDMC.readers.H5MD_reader.read_units(file: File, data_name: str) str[source]

Read the SI units of the data stored in an H5MD file.

Parameters:
  • file (h5py.File) – The H5MD file being read from

  • data_name (str) – The name of the data the unit is to be read from

Returns:

String abbreviation of the units.

Return type:

str

MDMC.readers.reader module

Module for reader abstract class

class MDMC.readers.reader.Reader(file_name: str)[source]

Bases: ABC

Abstract class that defines methods common to all readers

Parameters:

file_name (str) – name of file to read

abstract parse(**settings: dict) None[source]

Parses the file data so that it is in a format expected by the class calling the data reader

For readers which are not specific to one data type, the calling class must be determined so that the file data can be parsed into the appropriate data type.

Parameters:

**settings (dict) – dictionary of settings for reader

MDMC.readers.reader_factory module

Factory class for generating readers

class MDMC.readers.reader_factory.ReaderFactory[source]

Bases: ABC

Provides a abstract base class for methods and properties common to all reader factories

abstract static base_class()[source]

This should be implemented to return the base class of objects returned by the ReaderFactory

classmethod create_reader(module_name: str, file_name: str) Reader[source]

Creates a reader object from a module name

The reader object must be the first class in the module. The base class which the reader must inherit is defined by cls.base_class

Parameters:
  • module_name (str) – The name of the module where the reader is the first class

  • file_name (str) – The name of the file that the Reader will read

Returns:

A Reader object

Return type:

Reader

Module contents

Readers for both atomic configurations and experimental observables

Contents

configurations observables reader_factory reader