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]
|
scan_list = [s["idx"] for s in det_data]
|
||||||
file_list = []
|
file_list = []
|
||||||
for scan_id in scan_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)
|
file_list.append(f_name)
|
||||||
|
|
||||||
scan_table_source.data.update(
|
scan_table_source.data.update(
|
||||||
|
@ -155,10 +155,7 @@ def parse_1D(fileobj, data_type):
|
|||||||
counts.extend(map(float, next(fileobj).split()))
|
counts.extend(map(float, next(fileobj).split()))
|
||||||
s["Counts"] = np.array(counts)
|
s["Counts"] = np.array(counts)
|
||||||
|
|
||||||
# add metadata to each scan
|
scan.append({**metadata, **s})
|
||||||
s["meta"] = metadata
|
|
||||||
|
|
||||||
scan.append(s)
|
|
||||||
|
|
||||||
elif data_type == ".dat":
|
elif data_type == ".dat":
|
||||||
# skip the first 2 rows, the third row contans the column names
|
# 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
|
s["idx"] = 1
|
||||||
|
|
||||||
# add metadata to the scan
|
scan.append({**metadata, **s})
|
||||||
s["meta"] = metadata
|
|
||||||
|
|
||||||
scan.append(dict(s))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Unknown file extention")
|
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
|
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.
|
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": []}
|
file_content = {".comm": [], ".incomm": []}
|
||||||
|
|
||||||
for scan in data:
|
for scan in data:
|
||||||
|
@ -77,11 +77,11 @@ def merge(scan1, scan2):
|
|||||||
|
|
||||||
|
|
||||||
def check_UB(dict1, dict2, precision=0.01):
|
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):
|
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
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -128,12 +128,12 @@ def check_temp_mag(scan1, scan2):
|
|||||||
|
|
||||||
def merge_dups(dictionary):
|
def merge_dups(dictionary):
|
||||||
|
|
||||||
if dictionary[0]["meta"]["data_type"] == "dat":
|
if dictionary[0]["data_type"] == "dat":
|
||||||
return
|
return
|
||||||
|
|
||||||
if dictionary[0]["meta"]["zebra_mode"] == "bi":
|
if dictionary[0]["zebra_mode"] == "bi":
|
||||||
angles = ["twotheta", "omega", "chi", "phi"]
|
angles = ["twotheta", "omega", "chi", "phi"]
|
||||||
elif dictionary[0]["meta"]["zebra_mode"] == "nb":
|
elif dictionary[0]["zebra_mode"] == "nb":
|
||||||
angles = ["gamma", "omega", "nu"]
|
angles = ["gamma", "omega", "nu"]
|
||||||
|
|
||||||
precision = {
|
precision = {
|
||||||
@ -220,9 +220,9 @@ def unified_merge(dict1, dict2):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# decide angles
|
# decide angles
|
||||||
if dict1[0]["meta"]["zebra_mode"] == "bi":
|
if dict1[0]["zebra_mode"] == "bi":
|
||||||
angles = ["twotheta", "omega", "chi", "phi"]
|
angles = ["twotheta", "omega", "chi", "phi"]
|
||||||
elif dict1[0]["meta"]["zebra_mode"] == "nb":
|
elif dict1[0]["zebra_mode"] == "nb":
|
||||||
angles = ["gamma", "omega", "nu"]
|
angles = ["gamma", "omega", "nu"]
|
||||||
|
|
||||||
# precision of angles to check
|
# precision of angles to check
|
||||||
@ -234,7 +234,7 @@ def unified_merge(dict1, dict2):
|
|||||||
"omega": 5,
|
"omega": 5,
|
||||||
"gamma": 0.1,
|
"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
|
precision["omega"] = 0.05
|
||||||
|
|
||||||
process(dict1, dict2, angles, precision)
|
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
|
Note: dict1 must be made from ccl, otherwise we would have to change the structure of loaded
|
||||||
dat file"""
|
dat file"""
|
||||||
try:
|
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")
|
print("You are trying to add scans measured with different zebra modes")
|
||||||
return
|
return
|
||||||
# this is for the qscan case
|
# this is for the qscan case
|
||||||
@ -263,6 +263,6 @@ def add_dict(dict1, dict2):
|
|||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
"The file %s has alredy been added to %s"
|
"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
|
return dict1
|
||||||
|
@ -79,7 +79,7 @@ def create_dataframe(dict1, variables):
|
|||||||
|
|
||||||
# populate the dict
|
# populate the dict
|
||||||
for keys in range(len(dict1)):
|
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["fit_area"].append(dict1[keys]["fit"]["fit_area"])
|
||||||
pull_dict["int_area"].append(dict1[keys]["fit"]["int_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
|
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"]
|
angles = ["twotheta", "omega", "chi", "phi"]
|
||||||
elif dict[0]["meta"]["zebra_mode"] == "nb":
|
elif dict[0]["zebra_mode"] == "nb":
|
||||||
angles = ["gamma", "omega", "nu"]
|
angles = ["gamma", "omega", "nu"]
|
||||||
else:
|
else:
|
||||||
print("Unknown zebra mode")
|
print("Unknown zebra mode")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user