Break metadata and data reads
* fix decimal issue * add unkwn_angle
This commit is contained in:
parent
ab002be606
commit
8b3f1b568f
@ -68,6 +68,7 @@ def load_1D(filepath):
|
||||
"""
|
||||
det_variables = {"file_type": str(filepath)[-3:], "meta": {}}
|
||||
with open(filepath, "r") as infile:
|
||||
# read metadata
|
||||
for line in infile:
|
||||
det_variables["Measurements"] = {}
|
||||
if "=" in line:
|
||||
@ -80,7 +81,11 @@ def load_1D(filepath):
|
||||
elif variable in META_UB_MATRIX:
|
||||
det_variables["meta"][variable] = re.findall(r"[-+]?\d*\.\d+|\d+", str(value))
|
||||
|
||||
elif "#data" in line:
|
||||
if "#data" in line:
|
||||
# this is the end of metadata and the start of data section
|
||||
break
|
||||
|
||||
# read data
|
||||
if det_variables["file_type"] == "ccl":
|
||||
decimal = list()
|
||||
data = infile.readlines()
|
||||
@ -111,6 +116,7 @@ def load_1D(filepath):
|
||||
d["gamma_angle"] = float(lines.split()[4]) # gamma
|
||||
d["omega_angle"] = float(lines.split()[5]) # omega
|
||||
d["nu_angle"] = float(lines.split()[6]) # nu
|
||||
d["unkwn_angle"] = float(lines.split()[7])
|
||||
|
||||
next_line = data[position + 1]
|
||||
d["number_of_measurements"] = int(next_line.split()[0])
|
||||
@ -122,8 +128,7 @@ def load_1D(filepath):
|
||||
d["time"] = str(next_line.split()[6])
|
||||
d["scan_type"] = str(next_line.split()[7])
|
||||
for i in range(
|
||||
int(int(next_line.split()[0]) / 10)
|
||||
+ (int(next_line.split()[0]) % 10 > 0)
|
||||
int(int(next_line.split()[0]) / 10) + (int(next_line.split()[0]) % 10 > 0)
|
||||
):
|
||||
fileline = data[position + 2 + i].split()
|
||||
numbers = [int(w) for w in fileline]
|
||||
@ -138,6 +143,11 @@ def load_1D(filepath):
|
||||
d["counts"] = counts
|
||||
det_variables["Measurements"][str("M" + str(measurement_number))] = d
|
||||
|
||||
if all(decimal):
|
||||
det_variables["meta"]["indices"] = "hkl"
|
||||
else:
|
||||
det_variables["meta"]["indices"] = "real"
|
||||
|
||||
elif det_variables["file_type"] == "dat":
|
||||
data = infile.readlines()
|
||||
num_of_points = int(data[1].split()[0])
|
||||
@ -162,9 +172,5 @@ def load_1D(filepath):
|
||||
det_variables["Measurements"]["time"] = time
|
||||
else:
|
||||
print("Unknown file extention")
|
||||
if all(decimal):
|
||||
det_variables["meta"]["indices"] = "hkl"
|
||||
else:
|
||||
det_variables["meta"]["indices"] = "real"
|
||||
|
||||
return det_variables
|
||||
|
Loading…
x
Reference in New Issue
Block a user