Consolidate hkl and ub
This commit is contained in:
parent
e09538eaeb
commit
20527e8d2b
@ -88,7 +88,7 @@ def create():
|
||||
|
||||
def _init_datatable():
|
||||
scan_list = [s["idx"] for s in det_data["scan"]]
|
||||
hkl = [f'{s["h_index"]} {s["k_index"]} {s["l_index"]}' for s in det_data["scan"]]
|
||||
hkl = [f'{s["h"]} {s["k"]} {s["l"]}' for s in det_data["scan"]]
|
||||
scan_table_source.data.update(
|
||||
scan=scan_list,
|
||||
hkl=hkl,
|
||||
|
@ -618,7 +618,7 @@ def calculate_hkl(det_data, index):
|
||||
gammad = det_data["gamma"][index]
|
||||
om = det_data["omega"][index]
|
||||
nud = det_data["nu"]
|
||||
ub = det_data["UB"]
|
||||
ub = det_data["ub"]
|
||||
geometry = det_data["zebra_mode"]
|
||||
|
||||
if geometry == "bi":
|
||||
|
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
import numpy as np
|
||||
@ -58,12 +57,7 @@ META_VARS_FLOAT = (
|
||||
|
||||
META_UB_MATRIX = ("ub1j", "ub2j", "ub3j")
|
||||
|
||||
CCL_FIRST_LINE = (
|
||||
("idx", int),
|
||||
("h_index", float),
|
||||
("k_index", float),
|
||||
("l_index", float),
|
||||
)
|
||||
CCL_FIRST_LINE = (("idx", int), ("h", float), ("k", float), ("l", float))
|
||||
|
||||
CCL_ANGLES = {
|
||||
"bi": (("twotheta", float), ("omega", float), ("chi", float), ("phi", float)),
|
||||
@ -111,14 +105,20 @@ def parse_1D(fileobj, data_type):
|
||||
variable, value = line.split("=")
|
||||
variable = variable.strip()
|
||||
value = value.strip()
|
||||
if variable in META_VARS_FLOAT:
|
||||
|
||||
if variable in META_VARS_STR:
|
||||
metadata[variable] = value
|
||||
|
||||
elif variable in META_VARS_FLOAT:
|
||||
if variable == "2-theta": # fix that angle name not to be an expression
|
||||
variable = "twotheta"
|
||||
metadata[variable] = float(value)
|
||||
elif variable in META_VARS_STR:
|
||||
metadata[variable] = value
|
||||
|
||||
elif variable in META_UB_MATRIX:
|
||||
metadata[variable] = re.findall(r"[-+]?\d*\.\d+|\d+", value)
|
||||
if "ub" not in metadata:
|
||||
metadata["ub"] = np.zeros((3, 3))
|
||||
row = int(variable[-2]) - 1
|
||||
metadata["ub"][row, :] = list(map(float, value.split()))
|
||||
|
||||
if "#data" in line:
|
||||
# this is the end of metadata and the start of data section
|
||||
@ -172,10 +172,9 @@ def parse_1D(fileobj, data_type):
|
||||
s[name].append(float(val))
|
||||
|
||||
try:
|
||||
s["h_index"] = float(metadata["title"].split()[-3])
|
||||
s["k_index"] = float(metadata["title"].split()[-2])
|
||||
s["l_index"] = float(metadata["title"].split()[-1])
|
||||
s["h"], s["k"], s["l"] = map(float, metadata["title"].split()[-3:])
|
||||
except (ValueError, IndexError):
|
||||
s["h"] = s["k"] = s["l"] = float("nan")
|
||||
print("seems hkl is not in title")
|
||||
|
||||
s["om"] = np.array(s["om"])
|
||||
@ -201,10 +200,8 @@ def parse_1D(fileobj, data_type):
|
||||
print("Unknown file extention")
|
||||
|
||||
for s in scan:
|
||||
if s["h_index"].is_integer() and s["k_index"].is_integer() and s["l_index"].is_integer():
|
||||
s["h_index"] = int(s["h_index"])
|
||||
s["k_index"] = int(s["k_index"])
|
||||
s["l_index"] = int(s["l_index"])
|
||||
if s["h"].is_integer() and s["k"].is_integer() and s["l"].is_integer():
|
||||
s["h"], s["k"], s["l"] = map(int, (s["h"], s["k"], s["l"]))
|
||||
s["indices"] = "hkl"
|
||||
else:
|
||||
s["indices"] = "real"
|
||||
@ -229,7 +226,7 @@ def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precis
|
||||
|
||||
idx_str = f"{scan['idx']:6}"
|
||||
|
||||
h, k, l = scan["h_index"], scan["k_index"], scan["l_index"]
|
||||
h, k, l = scan["h"], scan["k"], scan["l"]
|
||||
if scan["indices"] == "hkl":
|
||||
hkl_str = f"{h:6}{k:6}{l:6}"
|
||||
else: # scan["indices"] == "real"
|
||||
|
@ -69,7 +69,7 @@ def read_detector_data(filepath):
|
||||
det_data["wave"] = h5f["/entry1/ZEBRA/monochromator/wavelength"][:]
|
||||
det_data["chi"] = h5f["/entry1/sample/chi"][:] # ch
|
||||
det_data["phi"] = h5f["/entry1/sample/phi"][:] # ph
|
||||
det_data["UB"] = h5f["/entry1/sample/UB"][:].reshape(3, 3)
|
||||
det_data["ub"] = h5f["/entry1/sample/UB"][:].reshape(3, 3)
|
||||
|
||||
for var in ("omega", "gamma", "nu", "chi", "phi"):
|
||||
if abs(det_data[var][0] - det_data[var][-1]) > 0.1:
|
||||
|
@ -77,20 +77,7 @@ def merge(scan1, scan2):
|
||||
|
||||
|
||||
def check_UB(dict1, dict2, precision=0.01):
|
||||
truth_list = list()
|
||||
for i in ["ub1j", "ub2j", "ub3j"]:
|
||||
for j in range(3):
|
||||
if abs(abs(float(dict1["meta"][i][j])) - abs(float(dict2["meta"][i][j]))) < precision:
|
||||
|
||||
truth_list.append(True)
|
||||
else:
|
||||
truth_list.append(False)
|
||||
|
||||
# print(truth_list)
|
||||
if all(truth_list):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return np.max(np.abs(dict1["meta"]["ub"] - dict2["meta"]["ub"])) < precision
|
||||
|
||||
|
||||
def check_zebramode(dict1, dict2):
|
||||
|
@ -416,9 +416,9 @@ def variables(dictionary):
|
||||
"Monitor1",
|
||||
"Monitor2",
|
||||
"Monitor3",
|
||||
"h_index",
|
||||
"l_index",
|
||||
"k_index",
|
||||
"h",
|
||||
"k",
|
||||
"l",
|
||||
"n_points",
|
||||
"monitor",
|
||||
"Time",
|
||||
|
Loading…
x
Reference in New Issue
Block a user