parent
e9d3fcc41a
commit
16966b6e3e
@ -102,7 +102,7 @@ def create():
|
||||
def _init_datatable():
|
||||
scan_list = [s["idx"] for s in det_data]
|
||||
hkl = [f'{s["h"]} {s["k"]} {s["l"]}' for s in det_data]
|
||||
export = [s.get("active", True) for s in det_data]
|
||||
export = [s["export"] for s in det_data]
|
||||
scan_table_source.data.update(
|
||||
scan=scan_list, hkl=hkl, fit=[0] * len(scan_list), export=export,
|
||||
)
|
||||
@ -200,7 +200,7 @@ def create():
|
||||
|
||||
def _update_datatable():
|
||||
fit_ok = [(1 if "fit" in scan else 0) for scan in det_data]
|
||||
export = [scan.get("active", True) for scan in det_data]
|
||||
export = [scan["export"] for scan in det_data]
|
||||
scan_table_source.data.update(fit=fit_ok, export=export)
|
||||
|
||||
def _update_plot():
|
||||
@ -317,7 +317,11 @@ def create():
|
||||
|
||||
_update_plot()
|
||||
|
||||
def scan_table_source_callback(_attr, _old, _new):
|
||||
def scan_table_source_callback(_attr, _old, new):
|
||||
# unfortunately, we don't know if the change comes from data update or user input
|
||||
# also `old` and `new` are the same for non-scalars
|
||||
for scan, export in zip(det_data, new["export"]):
|
||||
scan["export"] = export
|
||||
_update_preview()
|
||||
|
||||
scan_table_source = ColumnDataSource(dict(scan=[], hkl=[], fit=[], export=[]))
|
||||
@ -486,8 +490,8 @@ def create():
|
||||
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
||||
|
||||
def proc_all_button_callback():
|
||||
for scan, export in zip(det_data, scan_table_source.data["export"]):
|
||||
if export:
|
||||
for scan in det_data:
|
||||
if scan["export"]:
|
||||
pyzebra.fit_scan(
|
||||
scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value
|
||||
)
|
||||
@ -531,9 +535,9 @@ def create():
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_file = temp_dir + "/temp"
|
||||
export_data = []
|
||||
for s, export in zip(det_data, scan_table_source.data["export"]):
|
||||
if export:
|
||||
export_data.append(s)
|
||||
for scan in det_data:
|
||||
if scan["export"]:
|
||||
export_data.append(scan)
|
||||
|
||||
pyzebra.export_1D(
|
||||
export_data,
|
||||
|
@ -111,6 +111,7 @@ def create():
|
||||
|
||||
def _init_datatable():
|
||||
scan_list = [s["idx"] for s in det_data]
|
||||
export = [s["export"] for s in det_data]
|
||||
file_list = []
|
||||
for scan in det_data:
|
||||
file_list.append(os.path.basename(scan["original_filename"]))
|
||||
@ -120,7 +121,7 @@ def create():
|
||||
scan=scan_list,
|
||||
param=[None] * len(scan_list),
|
||||
fit=[0] * len(scan_list),
|
||||
export=[True] * len(scan_list),
|
||||
export=export,
|
||||
)
|
||||
scan_table_source.selected.indices = []
|
||||
scan_table_source.selected.indices = [0]
|
||||
@ -485,7 +486,11 @@ def create():
|
||||
|
||||
_update_plot()
|
||||
|
||||
def scan_table_source_callback(_attr, _old, _new):
|
||||
def scan_table_source_callback(_attr, _old, new):
|
||||
# unfortunately, we don't know if the change comes from data update or user input
|
||||
# also `old` and `new` are the same for non-scalars
|
||||
for scan, export in zip(det_data, new["export"]):
|
||||
scan["export"] = export
|
||||
_update_preview()
|
||||
|
||||
scan_table_source = ColumnDataSource(dict(file=[], scan=[], param=[], fit=[], export=[]))
|
||||
@ -646,8 +651,8 @@ def create():
|
||||
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
||||
|
||||
def proc_all_button_callback():
|
||||
for scan, export in zip(det_data, scan_table_source.data["export"]):
|
||||
if export:
|
||||
for scan in det_data:
|
||||
if scan["export"]:
|
||||
pyzebra.fit_scan(
|
||||
scan, fit_params, fit_from=fit_from_spinner.value, fit_to=fit_to_spinner.value
|
||||
)
|
||||
@ -708,12 +713,10 @@ def create():
|
||||
temp_file = temp_dir + "/temp"
|
||||
export_data = []
|
||||
param_data = []
|
||||
for s, p, export in zip(
|
||||
det_data, scan_table_source.data["param"], scan_table_source.data["export"]
|
||||
):
|
||||
if export:
|
||||
export_data.append(s)
|
||||
param_data.append(p)
|
||||
for scan, param in zip(det_data, scan_table_source.data["param"]):
|
||||
if scan["export"]:
|
||||
export_data.append(scan)
|
||||
param_data.append(param)
|
||||
|
||||
pyzebra.export_param_study(export_data, param_data, temp_file)
|
||||
|
||||
|
@ -144,6 +144,7 @@ def parse_1D(fileobj, data_type):
|
||||
continue
|
||||
|
||||
s = {}
|
||||
s["export"] = True
|
||||
|
||||
# first line
|
||||
for param, (param_name, param_type) in zip(line.split(), ccl_first_line):
|
||||
@ -182,6 +183,7 @@ def parse_1D(fileobj, data_type):
|
||||
metadata["gamma"] = metadata["twotheta"]
|
||||
|
||||
s = defaultdict(list)
|
||||
s["export"] = True
|
||||
|
||||
match = re.search("Scanning Variables: (.*), Steps: (.*)", next(fileobj))
|
||||
motors = [motor.lower() for motor in match.group(1).split(", ")]
|
||||
|
@ -117,7 +117,7 @@ def merge_scans(scan_into, scan_from):
|
||||
scan_into["counts"] = counts[index]
|
||||
scan_into["counts_err"] = counts_err[index]
|
||||
|
||||
scan_from["active"] = False
|
||||
scan_from["export"] = False
|
||||
|
||||
fname1 = os.path.basename(scan_into["original_filename"])
|
||||
fname2 = os.path.basename(scan_from["original_filename"])
|
||||
@ -127,7 +127,7 @@ def merge_scans(scan_into, scan_from):
|
||||
def restore_scan(scan):
|
||||
if "merged_scans" in scan:
|
||||
for merged_scan in scan["merged_scans"]:
|
||||
merged_scan["active"] = True
|
||||
merged_scan["export"] = True
|
||||
|
||||
if "init_scan" in scan:
|
||||
tmp = scan["init_scan"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user