Top-level functions¶
- open_frames(path)¶
Opens a NetCDF4 file saved by shnitsel-tools, specially interpreting certain attributes.
- Parameters:
path – The path of the file to open.
- Return type:
An
xarray.Dataset
with any MultiIndex restored.- Raises:
FileNotFoundError – If there is is nothing at
path
, orpath
is not a file.ValueError (or other exception) – Raised by the underlying h5netcdf engine if the file is corrupted.
- read_ase(db_path, kind)¶
Reads an ASE DB containing data in the SPaiNN or SchNet format
- Parameters:
- Return type:
An xr.Dataset of frames
- Raises:
ValueError – If kind is not one of ‘spainn’ or ‘schnet’
FileNotFoundError – If db_path is not a file
- read_trajs(path, kind, pattern='TRAJ*', format='frames', parallel=True, errors='log')¶
Read all trajectories from a folder of trajectory folders
- Parameters:
path (str) – The path to the folder of folders
kind (Literal['sharc', 'nx', 'pyrai2md']) – The kind of trajectory, i.e. whether it was produced by SHARC, Newton-X or PyRAI2MD
pattern (str) – The search pattern to append to the path (the whole thing will be read by
glob.glob()
), by default ‘TRAJ*’format (Literal['frames', 'layers']) – Whether to return the trajectories concatenated along the time axis (‘frames’) using a
xarray.indexes.PandasMultiIndex
or along a new axis (‘layers’), by default ‘frames’parallel (bool) – Whether to read multiple trajectories at the same time (which, in the current implementation, is only faster on storage that allows non-sequential reads), by default False
errors (Literal['log', 'raise'])
- Return type:
An
xarray.Dataset
containing the data of the trajectories- Raises:
FileNotFoundError – If the search (
= path + pattern
) doesn’t match any paths according toglob.glob()
ValueError – If an invalid value for
format
is passed.