Skip to content

Commit

Permalink
Merge pull request #15 from MaginnGroup/pullrequest
Browse files Browse the repository at this point in the history
remove dependancy on numpy genfromtxt in viscosity calculation
  • Loading branch information
mike5603 authored Apr 28, 2021
2 parents 9925e83 + cb4ad27 commit 7b0cc2e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/viscio.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,28 @@ def from_file(cls, filename):
if format:
data_format = format.group().split()[2:]

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

header += 1
#time.sleep(5)

#note: we are starting from the "break" above
raw_data = []
for line in logfile:
if line == '\n':
footer_blank_line += 1
if all(isinstance(x, float) for x in list(_list2float(line.split()))) and len(line)>=3:
raw_data.append(line.split())
else:
break
#if line == '\n':
#footer_blank_line += 1
#print int(md_step/log_save_freq)

if total_lines >= header + md_step/log_save_freq:
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)

else:
rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=1)
#if total_lines >= header + md_step/log_save_freq:
#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)

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

Expand Down

0 comments on commit 7b0cc2e

Please sign in to comment.