diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 50b0c77..a70b480 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -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, ) diff --git a/pyzebra/app/panel_param_study.py b/pyzebra/app/panel_param_study.py index 36e1157..5158242 100644 --- a/pyzebra/app/panel_param_study.py +++ b/pyzebra/app/panel_param_study.py @@ -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, ) diff --git a/pyzebra/ccl_io.py b/pyzebra/ccl_io.py index 5762923..63ed0be 100644 --- a/pyzebra/ccl_io.py +++ b/pyzebra/ccl_io.py @@ -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: diff --git a/pyzebra/fit2.py b/pyzebra/fit2.py index 86519e3..5bfb0ad 100644 --- a/pyzebra/fit2.py +++ b/pyzebra/fit2.py @@ -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 diff --git a/pyzebra/merge_function.py b/pyzebra/merge_function.py index 4f8342c..f82927e 100644 --- a/pyzebra/merge_function.py +++ b/pyzebra/merge_function.py @@ -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")