Enables time info for XTCReader

This commit is contained in:
Niels Mueller
2019-10-08 15:03:40 +02:00
parent 025cf3fe6f
commit b0d373c9cb

8
pygmx/xtcio.pyx Normal file → Executable file
View File

@@ -152,7 +152,12 @@ cdef class XTCReader:
size = xtc_stat.st_size size = xtc_stat.st_size
with open(indexfile, 'rb') as fd: with open(indexfile, 'rb') as fd:
unpacker = Unpacker(SubscriptableReader(fd)) unpacker = Unpacker(fd.read())
# first 4 * 8 bytes are used for checks, followed by N * (8 + 4) bytes of data
length = int((len(unpacker.get_buffer()) - 32) / 12)
if length < 0:
raise InvalidIndexException
if unpacker.unpack_hyper() != INDEX_MAGIC: if unpacker.unpack_hyper() != INDEX_MAGIC:
raise InvalidMagicException raise InvalidMagicException
@@ -173,6 +178,7 @@ cdef class XTCReader:
except EOFError: except EOFError:
pass pass
self.has_cache = True self.has_cache = True
self.has_times = True
def __cinit__(self): def __cinit__(self):
self.has_cache = False self.has_cache = False