# Path: molmod/units.py
# def parse_unit(expression):
# 
# Path: molmod/io/common.py
# class SlicedReader(object):
#     """Base class for readers that can read a slice of all the frames"""
# 
#     def __init__(self, f, sub=slice(None)):
#         """
#            Argument:
#             | ``f``  --  a filename or a file-like object
# 
#            Optional argument:
#             | ``sub``  --  a slice indicating which frames to read/skip
# 
#         """
#         if isinstance(f, basestring):
#             self._auto_close = True
#             self._f = open(f)
#         else:
#             self._auto_close = False
#             self._f = f
#         self._sub = sub
#         self._counter = 0
# 
#     def __del__(self):
#         """Clean up the open file"""
#         if self._auto_close:
#             self._f.close()
# 
#     def _read_frame(self):
#         """Read a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def _skip_frame(self):
#         """Skip a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self):
#         """Get the next frame from the file, taking into account the slice
# 
#            This method is part of the iterator protocol.
#         """
#         # skip frames as requested
#         while not slice_match(self._sub, self._counter):
#             self._skip_frame()
#             self._counter += 1
# 
#         result = self._read_frame()
#         self._counter += 1
#         return result
# 
# class FileFormatError(Exception):
#     """Is raised when unexpected data is encountered while reading a file"""
#     pass


from builtins import range
from molmod.units import picosecond, amu, angstrom, atm, deg
from molmod.io.common import SlicedReader, FileFormatError
import numpy as np
                frc[i] = read_three(frc_msg)
        pos *= self.pos_unit # convert to au
        if self.keytrj > 0:
            vel *= self.vel_unit # convert to au
        if self.keytrj > 1:
            frc *= self.frc_unit # convert to au
        return frame

    def _skip_frame(self):
        """Skip a single frame from the trajectory"""
        for i in range(self._frame_size):
            next(self._f)


class DLPolyOutputReader(SlicedReader):
    """A Reader for DLPoly output files.

       Use this object as an iterator::

         >>> outr = OutputReader("somefile.txt")
         >>> for row in outr:
         ...     print row[5]

       The variable row in the example above is a concatenation of all the
       values that belong to one time frame. (line after line)
    """

    _marker = " " + "-"*130

    def __init__(self, f, sub=slice(None), skip_equi_period=True,

# Path: molmod/units.py
# def parse_unit(expression):
# 
# Path: molmod/io/common.py
# class SlicedReader(object):
#     """Base class for readers that can read a slice of all the frames"""
# 
#     def __init__(self, f, sub=slice(None)):
#         """
#            Argument:
#             | ``f``  --  a filename or a file-like object
# 
#            Optional argument:
#             | ``sub``  --  a slice indicating which frames to read/skip
# 
#         """
#         if isinstance(f, basestring):
#             self._auto_close = True
#             self._f = open(f)
#         else:
#             self._auto_close = False
#             self._f = f
#         self._sub = sub
#         self._counter = 0
# 
#     def __del__(self):
#         """Clean up the open file"""
#         if self._auto_close:
#             self._f.close()
# 
#     def _read_frame(self):
#         """Read a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def _skip_frame(self):
#         """Skip a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self):
#         """Get the next frame from the file, taking into account the slice
# 
#            This method is part of the iterator protocol.
#         """
#         # skip frames as requested
#         while not slice_match(self._sub, self._counter):
#             self._skip_frame()
#             self._counter += 1
# 
#         result = self._read_frame()
#         self._counter += 1
#         return result
# 
# class FileFormatError(Exception):
#     """Is raised when unexpected data is encountered while reading a file"""
#     pass


# Path: molmod/io/dlpoly.py
from builtins import range
from molmod.units import picosecond, amu, angstrom, atm, deg
from molmod.io.common import SlicedReader, FileFormatError
import numpy as np

                frc[i] = read_three(frc_msg)
        pos *= self.pos_unit # convert to au
        if self.keytrj > 0:
            vel *= self.vel_unit # convert to au
        if self.keytrj > 1:
            frc *= self.frc_unit # convert to au
        return frame

    def _skip_frame(self):
        """Skip a single frame from the trajectory"""
        for i in range(self._frame_size):
            next(self._f)


class DLPolyOutputReader(SlicedReader):
    """A Reader for DLPoly output files.

       Use this object as an iterator::

         >>> outr = OutputReader("somefile.txt")
         >>> for row in outr:
         ...     print row[5]

       The variable row in the example above is a concatenation of all the
       values that belong to one time frame. (line after line)
    """

    _marker = " " + "-"*130

    def __init__(self, f, sub=slice(None), skip_equi_period=True,

        pos_unit=angstrom, time_unit=picosecond, angle_unit=deg,