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

View File

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

View File

@ -59,7 +59,7 @@ META_VARS_FLOAT = (
META_UB_MATRIX = ("ub1j", "ub2j", "ub3j")
CCL_FIRST_LINE = (
("scan_number", int),
("idx", int),
("h_index", float),
("k_index", float),
("l_index", float),
@ -202,7 +202,7 @@ def parse_1D(fileobj, data_type):
s["phi_angle"] = metadata["phi"]
s["nu_angle"] = metadata["nu"]
s["scan_number"] = 1
s["idx"] = 1
scan.append(dict(s))
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"]
file_content = {".comm": [], ".incomm": []}
for ind, scan in enumerate(data["scan"]):
for scan in data["scan"]:
if "fit" not in scan:
continue
ind_str = f"{ind:6}"
idx_str = f"{scan['idx']:6}"
h, k, l = scan["h_index"], scan["k_index"], scan["l_index"]
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}"
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():
if content:

View File

@ -132,7 +132,7 @@ def fitccl(
try:
result = mod.fit(y, params, weights=weights, x=x, calc_covar=True)
except ValueError:
print(f"Couldn't fit scan {scan['scan_number']}")
print(f"Couldn't fit scan {scan['idx']}")
return
if result.params["g_amp"].stderr is None:
@ -192,7 +192,7 @@ def fitccl(
print("Maximal integration value lower than minimal")
else:
pass
count_errors = create_uncertanities(y, y_err)
# create error vector for numerical integration propagation
@ -217,7 +217,7 @@ def fitccl(
for pars in result.params:
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())
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["sigma"] = sigma
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:
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")