Flatten structure of metadata in scans
This commit is contained in:
parent
a6f97f59e8
commit
983e0dab42
@ -99,7 +99,7 @@ def create():
|
||||
scan_list = [s["idx"] for s in det_data]
|
||||
file_list = []
|
||||
for scan_id in scan_list:
|
||||
_, f_name = os.path.split(det_data[scan_id]["meta"]["original_filename"])
|
||||
_, f_name = os.path.split(det_data[scan_id]["original_filename"])
|
||||
file_list.append(f_name)
|
||||
|
||||
scan_table_source.data.update(
|
||||
|
@ -155,10 +155,7 @@ def parse_1D(fileobj, data_type):
|
||||
counts.extend(map(float, next(fileobj).split()))
|
||||
s["Counts"] = np.array(counts)
|
||||
|
||||
# add metadata to each scan
|
||||
s["meta"] = metadata
|
||||
|
||||
scan.append(s)
|
||||
scan.append({**metadata, **s})
|
||||
|
||||
elif data_type == ".dat":
|
||||
# skip the first 2 rows, the third row contans the column names
|
||||
@ -195,10 +192,7 @@ def parse_1D(fileobj, data_type):
|
||||
|
||||
s["idx"] = 1
|
||||
|
||||
# add metadata to the scan
|
||||
s["meta"] = metadata
|
||||
|
||||
scan.append(dict(s))
|
||||
scan.append({**metadata, **s})
|
||||
|
||||
else:
|
||||
print("Unknown file extention")
|
||||
@ -219,7 +213,7 @@ def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precis
|
||||
Scans with integer/real hkl values are saved in .comm/.incomm files correspondingly. If no scans
|
||||
are present for a particular output format, that file won't be created.
|
||||
"""
|
||||
zebra_mode = data[0]["meta"]["zebra_mode"]
|
||||
zebra_mode = data[0]["zebra_mode"]
|
||||
file_content = {".comm": [], ".incomm": []}
|
||||
|
||||
for scan in data:
|
||||
|
@ -77,11 +77,11 @@ def merge(scan1, scan2):
|
||||
|
||||
|
||||
def check_UB(dict1, dict2, precision=0.01):
|
||||
return np.max(np.abs(dict1[0]["meta"]["ub"] - dict2[0]["meta"]["ub"])) < precision
|
||||
return np.max(np.abs(dict1[0]["ub"] - dict2[0]["ub"])) < precision
|
||||
|
||||
|
||||
def check_zebramode(dict1, dict2):
|
||||
if dict1[0]["meta"]["zebra_mode"] == dict2[0]["meta"]["zebra_mode"]:
|
||||
if dict1[0]["zebra_mode"] == dict2[0]["zebra_mode"]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -128,12 +128,12 @@ def check_temp_mag(scan1, scan2):
|
||||
|
||||
def merge_dups(dictionary):
|
||||
|
||||
if dictionary[0]["meta"]["data_type"] == "dat":
|
||||
if dictionary[0]["data_type"] == "dat":
|
||||
return
|
||||
|
||||
if dictionary[0]["meta"]["zebra_mode"] == "bi":
|
||||
if dictionary[0]["zebra_mode"] == "bi":
|
||||
angles = ["twotheta", "omega", "chi", "phi"]
|
||||
elif dictionary[0]["meta"]["zebra_mode"] == "nb":
|
||||
elif dictionary[0]["zebra_mode"] == "nb":
|
||||
angles = ["gamma", "omega", "nu"]
|
||||
|
||||
precision = {
|
||||
@ -220,9 +220,9 @@ def unified_merge(dict1, dict2):
|
||||
return
|
||||
|
||||
# decide angles
|
||||
if dict1[0]["meta"]["zebra_mode"] == "bi":
|
||||
if dict1[0]["zebra_mode"] == "bi":
|
||||
angles = ["twotheta", "omega", "chi", "phi"]
|
||||
elif dict1[0]["meta"]["zebra_mode"] == "nb":
|
||||
elif dict1[0]["zebra_mode"] == "nb":
|
||||
angles = ["gamma", "omega", "nu"]
|
||||
|
||||
# precision of angles to check
|
||||
@ -234,7 +234,7 @@ def unified_merge(dict1, dict2):
|
||||
"omega": 5,
|
||||
"gamma": 0.1,
|
||||
}
|
||||
if (dict1[0]["meta"]["data_type"] == "ccl") and (dict2[0]["meta"]["data_type"] == "ccl"):
|
||||
if (dict1[0]["data_type"] == "ccl") and (dict2[0]["data_type"] == "ccl"):
|
||||
precision["omega"] = 0.05
|
||||
|
||||
process(dict1, dict2, angles, precision)
|
||||
@ -249,7 +249,7 @@ def add_dict(dict1, dict2):
|
||||
Note: dict1 must be made from ccl, otherwise we would have to change the structure of loaded
|
||||
dat file"""
|
||||
try:
|
||||
if dict1[0]["meta"]["zebra_mode"] != dict2[0]["meta"]["zebra_mode"]:
|
||||
if dict1[0]["zebra_mode"] != dict2[0]["zebra_mode"]:
|
||||
print("You are trying to add scans measured with different zebra modes")
|
||||
return
|
||||
# this is for the qscan case
|
||||
@ -263,6 +263,6 @@ def add_dict(dict1, dict2):
|
||||
else:
|
||||
print(
|
||||
"The file %s has alredy been added to %s"
|
||||
% (dict2[0]["meta"]["original_filename"], dict1[0]["meta"]["original_filename"])
|
||||
% (dict2[0]["original_filename"], dict1[0]["original_filename"])
|
||||
)
|
||||
return dict1
|
||||
|
@ -79,7 +79,7 @@ def create_dataframe(dict1, variables):
|
||||
|
||||
# populate the dict
|
||||
for keys in range(len(dict1)):
|
||||
pull_dict["filenames"].append(dict1[0]["meta"]["original_filename"].split("/")[-1])
|
||||
pull_dict["filenames"].append(dict1[0]["original_filename"].split("/")[-1])
|
||||
|
||||
pull_dict["fit_area"].append(dict1[keys]["fit"]["fit_area"])
|
||||
pull_dict["int_area"].append(dict1[keys]["fit"]["int_area"])
|
||||
@ -306,9 +306,9 @@ def scan_dict(dict, precision=0.5):
|
||||
note: can be checked by "not d", true if empty
|
||||
"""
|
||||
|
||||
if dict[0]["meta"]["zebra_mode"] == "bi":
|
||||
if dict[0]["zebra_mode"] == "bi":
|
||||
angles = ["twotheta", "omega", "chi", "phi"]
|
||||
elif dict[0]["meta"]["zebra_mode"] == "nb":
|
||||
elif dict[0]["zebra_mode"] == "nb":
|
||||
angles = ["gamma", "omega", "nu"]
|
||||
else:
|
||||
print("Unknown zebra mode")
|
||||
|
Loading…
x
Reference in New Issue
Block a user