Display filename in the scan table

This commit is contained in:
2020-11-24 16:14:43 +01:00
parent 9507339c2a
commit 216de442a5
2 changed files with 24 additions and 9 deletions

View File

@ -84,9 +84,20 @@ def create():
def _init_datatable(): def _init_datatable():
scan_list = list(det_data["scan"].keys()) scan_list = list(det_data["scan"].keys())
file_list = []
extra_meta = det_data.get("extra_meta", {})
for scan_id in scan_list:
if scan_id in extra_meta:
f_path = extra_meta[scan_id]["original_filename"]
else:
f_path = det_data["meta"]["original_filename"]
_, f_name = os.path.split(f_path)
file_list.append(f_name)
scan_table_source.data.update( scan_table_source.data.update(
# file=list(det_data.keys()), file=file_list,
file=scan_list, scan=scan_list,
param=[""] * len(scan_list), param=[""] * len(scan_list),
peaks=[0] * len(scan_list), peaks=[0] * len(scan_list),
fit=[0] * len(scan_list), fit=[0] * len(scan_list),
@ -261,19 +272,20 @@ def create():
# skip unnecessary update caused by selection drop # skip unnecessary update caused by selection drop
return return
_update_plot(det_data["scan"][scan_table_source.data["file"][new[0]]]) _update_plot(det_data["scan"][scan_table_source.data["scan"][new[0]]])
scan_table_source = ColumnDataSource(dict(file=[], param=[], peaks=[], fit=[], export=[])) scan_table_source = ColumnDataSource(dict(file=[], scan=[], param=[], peaks=[], fit=[], export=[]))
scan_table = DataTable( scan_table = DataTable(
source=scan_table_source, source=scan_table_source,
columns=[ columns=[
TableColumn(field="file", title="file", width=150), TableColumn(field="file", title="file", width=150),
TableColumn(field="scan", title="scan", width=50),
TableColumn(field="param", title="param", width=50), TableColumn(field="param", title="param", width=50),
TableColumn(field="peaks", title="Peaks", width=50), TableColumn(field="peaks", title="Peaks", width=50),
TableColumn(field="fit", title="Fit", width=50), TableColumn(field="fit", title="Fit", width=50),
TableColumn(field="export", title="Export", editor=CheckboxEditor(), width=50), TableColumn(field="export", title="Export", editor=CheckboxEditor(), width=50),
], ],
width=350, width=400,
index_position=None, index_position=None,
editable=True, editable=True,
fit_columns=False, fit_columns=False,
@ -283,7 +295,7 @@ def create():
def _get_selected_scan(): def _get_selected_scan():
selected_index = scan_table_source.selected.indices[0] selected_index = scan_table_source.selected.indices[0]
selected_scan_id = scan_table_source.data["file"][selected_index] selected_scan_id = scan_table_source.data["scan"][selected_index]
return det_data["scan"][selected_scan_id] return det_data["scan"][selected_scan_id]
def peak_pos_textinput_callback(_attr, _old, new): def peak_pos_textinput_callback(_attr, _old, new):
@ -499,7 +511,7 @@ def create():
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_file = temp_dir + "/temp" temp_file = temp_dir + "/temp"
export_data = deepcopy(det_data) export_data = deepcopy(det_data)
for s, export in zip(scan_table_source.data["file"], scan_table_source.data["export"]): for s, export in zip(scan_table_source.data["scan"], scan_table_source.data["export"]):
if not export: if not export:
del export_data["scan"][s] del export_data["scan"][s]
pyzebra.export_comm(export_data, temp_file, lorentz=lorentz_toggle.active) pyzebra.export_comm(export_data, temp_file, lorentz=lorentz_toggle.active)
@ -519,7 +531,7 @@ def create():
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_file = temp_dir + "/temp" temp_file = temp_dir + "/temp"
export_data = deepcopy(det_data) export_data = deepcopy(det_data)
for s, export in zip(scan_table_source.data["file"], scan_table_source.data["export"]): for s, export in zip(scan_table_source.data["scan"], scan_table_source.data["export"]):
if not export: if not export:
del export_data["scan"][s] del export_data["scan"][s]
pyzebra.export_comm(export_data, temp_file, lorentz=lorentz_toggle.active) pyzebra.export_comm(export_data, temp_file, lorentz=lorentz_toggle.active)

View File

@ -175,6 +175,9 @@ def merge_dups(dictionary, angles):
def add_scan(dict1, dict2, scan_to_add): def add_scan(dict1, dict2, scan_to_add):
max_scan = np.max(list(dict1["scan"])) max_scan = np.max(list(dict1["scan"]))
dict1["scan"][max_scan + 1] = dict2["scan"][scan_to_add] dict1["scan"][max_scan + 1] = dict2["scan"][scan_to_add]
if dict1.get("extra_meta") is None:
dict1["extra_meta"] = {}
dict1["extra_meta"][max_scan + 1] = dict2["meta"]
del dict2["scan"][scan_to_add] del dict2["scan"][scan_to_add]
@ -220,7 +223,7 @@ def process(dict1, dict2, angles, precision):
""" """
1. check for bisecting or normal beam geometry in data files; select stt, om, chi, phi for bisecting; select stt, om, nu for normal beam 1. check for bisecting or normal beam geometry in data files; select stt, om, chi, phi for bisecting; select stt, om, nu for normal beam
2. in the ccl files, check for identical stt, chi and nu within 0.1 degree, and, at the same time, for identical om and phi within 0.05 degree; 2. in the ccl files, check for identical stt, chi and nu within 0.1 degree, and, at the same time, for identical om and phi within 0.05 degree;
3. in the dat files, check for identical stt, chi and nu within 0.1 degree, and, at the same time, 3. in the dat files, check for identical stt, chi and nu within 0.1 degree, and, at the same time,
for identical phi within 0.05 degree, and, at the same time, for identical om within 5 degree.""" for identical phi within 0.05 degree, and, at the same time, for identical om within 5 degree."""