3.13.2. horton.scripts.common – Code shared by several scripts

horton.scripts.common.iter_elements(elements_str)

Interpret a string as a list of elements

elements_str
A string with comma-separated element numbers. One may add ranges with the format ‘N-M’ where M>N.
horton.scripts.common.reduce_ugrid(ugrid, stride, chop)

Reduce the uniform grid

Arguments:

ugrid
The uniform integration grid.
stride
The reduction factor.
chop
The number of slices to chop of the grid in each direction.

Returns: a reduced ugrid object

horton.scripts.common.reduce_data(cube_data, ugrid, stride, chop)

Reduce the uniform grid data according to stride and chop arguments

Arguments:

fn_cube
The cube file with the electron density.
ugrid
The uniform integration grid.
stride
The reduction factor.
chop
The number of slices to chop of the grid in each direction.

Returns: a new array and an updated grid object

horton.scripts.common.parse_h5(arg_h5, name, path_optional=True)

Parse an HDF5 command line argument of the form file.h5:group or file.h5:dataset

Arguments:

arg_h5
The command line argument that consists of two parts, the HDF5 filename and a path, separated by a colon. If the path is optional, the default value is the root group.
name
The name of the argument to be used in error messages.

Optional arguments:

path_optional
Set this to False when a path in the HDF5 is not optional

Returns: the filename and the group

horton.scripts.common.check_output(fn_h5, grp_name, overwrite)

Check if the output is already present in print a warning if –overwrite is not used

Arguments:

fn_h5
The output HDF5 file
grp_name
The HDF5 group in which the output is stored.
overwrite
Whether the user wants to overwrite contents that were already present.
horton.scripts.common.parse_ewald_args(args)
horton.scripts.common.parse_pbc(spbc)
horton.scripts.common.store_args(args, grp)

Convert the command line arguments to hdf5 attributes

horton.scripts.common.write_part_output(fn_h5, grp_name, part, keys, args)

Write the output of horton-wpart.py or horton-cpart.py

Arguments:

fn_h5
The filename for the HDF5 output file.
grp_name
the destination group
part
The partitioning object (instance of subclass of horton.part.base.Part)
keys
The keys of the cached items that must go in the HDF5 outut file.
args
The results of the command line parser. All arguments are stored as attributes in the HDF5 output file.
horton.scripts.common.write_script_output(fn_h5, grp_name, results, args)

Store the output of a script in an open HDF5 file

Arguments:

fn_h5
The HDF5 filename
grp_name
The name of the group where the results will be stored.
results
A dictionary with results.
args
The results of the command line parser. All arguments are stored as attributes in the HDF5 output file.