Skip to content

Commit 7b0cc2e

Browse files
authored
Merge pull request #15 from MaginnGroup/pullrequest
remove dependancy on numpy genfromtxt in viscosity calculation
2 parents 9925e83 + cb4ad27 commit 7b0cc2e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/viscio.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,28 @@ def from_file(cls, filename):
104104
if format:
105105
data_format = format.group().split()[2:]
106106

107-
if all(isinstance(x, float) for x in list(_list2float(line.split()))) and md == 1: break
107+
if all(isinstance(x, float) for x in list(_list2float(line.split()))) and md == 1 and len(line)>=3: break
108108

109109
header += 1
110+
#time.sleep(5)
110111

111112
#note: we are starting from the "break" above
113+
raw_data = []
112114
for line in logfile:
113-
if line == '\n':
114-
footer_blank_line += 1
115+
if all(isinstance(x, float) for x in list(_list2float(line.split()))) and len(line)>=3:
116+
raw_data.append(line.split())
117+
else:
118+
break
119+
#if line == '\n':
120+
#footer_blank_line += 1
115121
#print int(md_step/log_save_freq)
116122

117-
if total_lines >= header + md_step/log_save_freq:
118-
rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=int(total_lines-header-md_step/log_save_freq-1 )-footer_blank_line)
119-
120-
else:
121-
rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=1)
123+
#if total_lines >= header + md_step/log_save_freq:
124+
#rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=int(total_lines-header-md_step/log_save_freq-1 )-footer_blank_line)
122125

126+
#else:
127+
#rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=1)
128+
rawdata = np.array(raw_data,np.float)
123129
for column, property in enumerate(data_format):
124130
llog[property] = rawdata[:, column]
125131

0 commit comments

Comments
 (0)