diff --git a/tools/python/pizza/dump.py b/tools/python/pizza/dump.py index 214a9d87b5..92df8fde6e 100644 --- a/tools/python/pizza/dump.py +++ b/tools/python/pizza/dump.py @@ -357,7 +357,21 @@ class dump: def read_snapshot(self,f): try: snap = Snap() - item = f.readline() + snap.units = 'unknown' + snap.stime = -1.0 + # read until hitting next "TIMESTEP" item + while True: + try: + item = f.readline().split() + if item[0] == 'ITEM:' and item[1] == 'UNITS': + snap.units = f.readline().split()[0] + if item[0] == 'ITEM:' and item[1] == 'TIME': + snap.time = f.readline().split()[0] + if item[0] == 'ITEM:' and item[1] == 'TIMESTEP': + break + except: + return + snap.time = int(f.readline().split()[0]) # just grab 1st field item = f.readline() snap.natoms = int(f.readline()) @@ -391,7 +405,7 @@ class dump: for i in range(1,snap.natoms): words += f.readline().split() floats = map(float,words) - atom_data = np.array(list(floats),np.float) + atom_data = np.array(list(floats),float) snap.atoms = atom_data.reshape((snap.natoms, ncol)) else: diff --git a/tools/python/pizza/log.py b/tools/python/pizza/log.py index df35b64cde..874b70cca1 100644 --- a/tools/python/pizza/log.py +++ b/tools/python/pizza/log.py @@ -318,9 +318,9 @@ class log: last = 1 # entire read is a chunk s1 = 0 if self.style == 1: - s2 = txt.rfind("\n--".encode('utf-8'),s1) + 1 + s2 = txt.rfind("\n--",s1) + 1 else: - s2 = txt.rfind("\n".encode('utf-8'),s1) + 1 + s2 = txt.rfind("\n",s1) + 1 eof -= len(txt) - s2 if s1 == s2: break