Skip to content
Snippets Groups Projects
Commit 38694412 authored by Emmanuel Branlard's avatar Emmanuel Branlard
Browse files

Some fast out files have a different number of header lines

parent 8e10d70d
No related branches found
No related tags found
No related merge requests found
Pipeline #5518 failed
......@@ -49,17 +49,38 @@ def load_ascii_output(filename):
with open(filename) as f:
info = {}
info['name'] = os.path.splitext(os.path.basename(filename))[0]
try:
header = [f.readline() for _ in range(8)]
info['description'] = header[4].strip()
info['attribute_names'] = header[6].split()
info['attribute_units'] = [unit[1:-1] for unit in header[7].split()] #removing "()"
data = np.array([line.split() for line in f.readlines()]).astype(np.float)
return data, info
except (ValueError, AssertionError):
raise
# Header is whatever is before the keyword `time`
in_header = True
header = []
while in_header:
l = f.readline()
if not l:
raise Exception('Error finding the end of FAST out file header. Keyword Time missing.')
in_header= (l+' dummy').lower().split()[0] != 'time'
if in_header:
header.append(l)
else:
info['description'] = header
info['attribute_names'] = l.split()
info['attribute_units'] = [unit[1:-1] for unit in f.readline().split()]
# Data, up to end of file or empty line (potential comment line at the end)
split_lines=[]
while True:
l = f.readline().strip()
if not l or len(l)==0:
break
split_lines.append(l.split())
data = np.array(split_lines).astype(np.float)
# Harcoded 8 line header and
#header = [f.readline() for _ in range(8)]
#info['description'] = header[4].strip()
#info['attribute_names'] = header[6].split()
#info['attribute_units'] = [unit[1:-1] for unit in header[7].split()] #removing "()"
#data = np.array([line.split() for line in f.readlines() if len(line)]).astype(np.float)
return data, info
def load_binary_output(filename):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment