def getCoordsets(self, indices=None): """Returns coordinate sets at given *indices*. *indices* may be an integer, a list of integers or ``None``. ``None`` returns all coordinate sets.""" if self._closed: raise ValueError('I/O operation on closed file') if (self._indices is None and (indices is None or indices == slice(None))): nfi = self._nfi self.reset() n_floats = self._n_floats + self._unitcell * 14 n_atoms = self._n_atoms n_csets = self._n_csets data = np.fromfile(self._file, self._dtype, n_floats * n_csets) if len(data) > n_floats * n_csets: n_csets = len(data)/n_floats data = data[:n_csets] LOGGER.warning('DCD is corrupt, {0:d} out of {1:d} frames ' 'were parsed.'.format(n_csets, self._n_csets)) data = data.reshape((n_csets, n_floats)) if self._unitcell: data = data[:, 14:] data = data.reshape((n_csets, 3, n_atoms+2)) data = data[:, :, 1:-1] data = data.transpose(0, 2, 1) self.goto(nfi) if self._astype is not None and self._astype != data.dtype: data = data.astype(self._astype) return data else: return TrajFile.getCoordsets(self, indices)
def __init__(self, filename, mode='r', **kwargs): TrajFile.__init__(self, filename, mode) self._astype = kwargs.get('astype', None) if self._mode != 'w': self._parseHeader()
def __init__(self, filename, mode='r'): TrajFile.__init__(self, filename, mode) if self._mode != 'w': self._parseHeader()