diff --git a/pyzebra/ccl_io.py b/pyzebra/ccl_io.py index 12e8a91..f03802e 100644 --- a/pyzebra/ccl_io.py +++ b/pyzebra/ccl_io.py @@ -1,4 +1,5 @@ import os +import re from collections import defaultdict import numpy as np @@ -72,7 +73,7 @@ CCL_SECOND_LINE = ( ("mf", float), ("date", str), ("time", str), - ("scan_type", str), + ("variable_name", str), ) AREA_METHODS = ("fit_area", "int_area") @@ -158,12 +159,18 @@ def parse_1D(fileobj, data_type): scan.append({**metadata, **s}) elif data_type == ".dat": - # skip the first 2 rows, the third row contans the column names - next(fileobj) - next(fileobj) - col_names = next(fileobj).split() s = defaultdict(list) + match = re.search('Scanning Variables: (.*), Steps: (.*)', next(fileobj)) + s["variable_name"] = match.group(1) + + match = re.search('(.*) Points, Mode: (.*), Preset (.*)', next(fileobj)) + if match.group(2) != "Monitor": + raise Exception("Unknown mode in dat file.") + s["monitor"] = float(match.group(3)) + + col_names = next(fileobj).split() + for line in fileobj: if "END-OF-DATA" in line: # this is the end of data @@ -177,15 +184,10 @@ def parse_1D(fileobj, data_type): s["h"] = s["k"] = s["l"] = float("nan") - s["om"] = np.array(s["om"]) - for param in ("mf", "temp"): if param not in metadata: s[param] = 0 - s["n_points"] = len(s["om"]) - s["monitor"] = s["Monitor1"][0] - s["idx"] = 1 scan.append({**metadata, **s})