H5MD Reader

This module provides a file reader for the H5MD format.

http://nongnu.org/h5md/

class halmd.io.readers.h5md(args)

Construct H5MD reader.

Parameters:
  • args (table) – keyword arguments
  • args.path (string) – pathname of input file
reader(self, args)

Construct a group reader.

Parameters:
  • args (table) – keyword arguments
  • args.location (table) – sequence with group’s path
  • args.mode (string) – read mode (“append” or “truncate”)
Returns:

instance of group reader

close(self)

Close file.

root

HDF5 root group of the file.

path

Filename of the file.

version

H5MD major and minor version of file.

creator

Name of the program that created the file.

creator_version

Version of the program that created the file.

creation_time

Creation time of the file in seconds since the Unix epoch.

This time stamp may be converted to a human-readable time using os.date:

halmd.log.info(("file created at %s"):format(os.date("%c", file.creation_time)))
author

Name of author of the file.

halmd.io.readers.h5md.check(path)

Check whether file is H5MD file.

Parameters:path – filename
Returns:true if file is H5MD file, false if not, or nil if file does not exist

This function is useful to validate a command-line argument:

local parser = halmd.utility.program_options.argument_parser()

parser:add_argument("trajectory", {
    help = "trajectory file name"
  , type = "string"
  , required = true
  , action = function(args, key, value)
        if not halmd.io.readers.h5md.check(value) then
            error(("not an H5MD file: %s"):format(value), 0)
        end
        args[key] = value
    end
})