Track the original scan index

This commit is contained in:
usov_i 2021-02-04 17:41:18 +01:00
parent e38993e69d
commit 7e6df95c49
5 changed files with 14 additions and 16 deletions

View File

@ -87,8 +87,8 @@ def create():
proposal_textinput.on_change("value", proposal_textinput_callback) proposal_textinput.on_change("value", proposal_textinput_callback)
def _init_datatable(): def _init_datatable():
scan_list = list(range(len(det_data["scan"]))) scan_list = [s["idx"] for s in det_data["scan"]]
hkl = [f'{m["h_index"]} {m["k_index"]} {m["l_index"]}' for m in det_data["scan"]] hkl = [f'{s["h_index"]} {s["k_index"]} {s["l_index"]}' for s in det_data["scan"]]
scan_table_source.data.update( scan_table_source.data.update(
scan=scan_list, scan=scan_list,
hkl=hkl, hkl=hkl,
@ -290,14 +290,13 @@ def create():
scan_table = DataTable( scan_table = DataTable(
source=scan_table_source, source=scan_table_source,
columns=[ columns=[
TableColumn(field="scan", title="scan"), TableColumn(field="scan", title="Scan"),
TableColumn(field="hkl", title="hkl"), TableColumn(field="hkl", title="hkl"),
TableColumn(field="peaks", title="Peaks"), TableColumn(field="peaks", title="Peaks"),
TableColumn(field="fit", title="Fit"), TableColumn(field="fit", title="Fit"),
TableColumn(field="export", title="Export", editor=CheckboxEditor()), TableColumn(field="export", title="Export", editor=CheckboxEditor()),
], ],
width=250, width=250,
index_position=None,
editable=True, editable=True,
) )

View File

@ -96,7 +96,7 @@ def create():
proposal_textinput.on_change("value", proposal_textinput_callback) proposal_textinput.on_change("value", proposal_textinput_callback)
def _init_datatable(): def _init_datatable():
scan_list = list(range(len(det_data["scan"]))) scan_list = [s["idx"] for s in det_data["scan"]]
file_list = [] file_list = []
extra_meta = det_data.get("extra_meta", {}) extra_meta = det_data.get("extra_meta", {})
for scan_id in scan_list: for scan_id in scan_list:
@ -398,7 +398,6 @@ def create():
TableColumn(field="export", title="Export", editor=CheckboxEditor(), width=50), TableColumn(field="export", title="Export", editor=CheckboxEditor(), width=50),
], ],
width=400, width=400,
index_position=None,
editable=True, editable=True,
fit_columns=False, fit_columns=False,
) )

View File

@ -59,7 +59,7 @@ META_VARS_FLOAT = (
META_UB_MATRIX = ("ub1j", "ub2j", "ub3j") META_UB_MATRIX = ("ub1j", "ub2j", "ub3j")
CCL_FIRST_LINE = ( CCL_FIRST_LINE = (
("scan_number", int), ("idx", int),
("h_index", float), ("h_index", float),
("k_index", float), ("k_index", float),
("l_index", float), ("l_index", float),
@ -202,7 +202,7 @@ def parse_1D(fileobj, data_type):
s["phi_angle"] = metadata["phi"] s["phi_angle"] = metadata["phi"]
s["nu_angle"] = metadata["nu"] s["nu_angle"] = metadata["nu"]
s["scan_number"] = 1 s["idx"] = 1
scan.append(dict(s)) scan.append(dict(s))
else: else:
@ -231,11 +231,11 @@ def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precis
zebra_mode = data["meta"]["zebra_mode"] zebra_mode = data["meta"]["zebra_mode"]
file_content = {".comm": [], ".incomm": []} file_content = {".comm": [], ".incomm": []}
for ind, scan in enumerate(data["scan"]): for scan in data["scan"]:
if "fit" not in scan: if "fit" not in scan:
continue continue
ind_str = f"{ind:6}" idx_str = f"{scan['idx']:6}"
h, k, l = scan["h_index"], scan["k_index"], scan["l_index"] h, k, l = scan["h_index"], scan["k_index"], scan["l_index"]
if scan["indices"] == "hkl": if scan["indices"] == "hkl":
@ -266,7 +266,7 @@ def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precis
ang_str = ang_str + f"{scan[angle]:8}" ang_str = ang_str + f"{scan[angle]:8}"
ref = file_content[".comm"] if scan["indices"] == "hkl" else file_content[".incomm"] ref = file_content[".comm"] if scan["indices"] == "hkl" else file_content[".incomm"]
ref.append(ind_str + hkl_str + area_str + ang_str + "\n") ref.append(idx_str + hkl_str + area_str + ang_str + "\n")
for ext, content in file_content.items(): for ext, content in file_content.items():
if content: if content:

View File

@ -132,7 +132,7 @@ def fitccl(
try: try:
result = mod.fit(y, params, weights=weights, x=x, calc_covar=True) result = mod.fit(y, params, weights=weights, x=x, calc_covar=True)
except ValueError: except ValueError:
print(f"Couldn't fit scan {scan['scan_number']}") print(f"Couldn't fit scan {scan['idx']}")
return return
if result.params["g_amp"].stderr is None: if result.params["g_amp"].stderr is None:
@ -217,7 +217,7 @@ def fitccl(
for pars in result.params: for pars in result.params:
d[str(pars)] = (result.params[str(pars)].value, result.params[str(pars)].vary) d[str(pars)] = (result.params[str(pars)].value, result.params[str(pars)].vary)
print("Scan", scan["scan_number"]) print("Scan", scan["idx"])
print(result.fit_report()) print(result.fit_report())
d["ratio"] = (result.params["g_amp"].value - int_area.n) / result.params["g_amp"].value d["ratio"] = (result.params["g_amp"].value - int_area.n) / result.params["g_amp"].value

View File

@ -71,9 +71,9 @@ def merge(scan1, scan2):
scan1["Counts"] = Counts scan1["Counts"] = Counts
scan1["sigma"] = sigma scan1["sigma"] = sigma
if "history" not in scan1: if "history" not in scan1:
scan1["history"] = str("Merged with scan %d" % scan2["scan_number"]) scan1["history"] = str("Merged with scan %d" % scan2["idx"])
else: else:
scan1["history"] = scan1["history"] + str(", merged with scan %d" % scan2["scan_number"]) scan1["history"] = scan1["history"] + str(", merged with scan %d" % scan2["idx"])
print("merging done") print("merging done")