Remove area_method from metadata

This commit is contained in:
usov_i 2021-01-07 13:36:59 +01:00
parent 315b025341
commit ba6a99b912
3 changed files with 15 additions and 13 deletions

View File

@ -495,13 +495,9 @@ def create():
fit_button = Button(label="Fit Current", default_size=145) fit_button = Button(label="Fit Current", default_size=145)
fit_button.on_click(fit_button_callback) fit_button.on_click(fit_button_callback)
def area_method_radiobutton_callback(_attr, _old, new):
det_data["meta"]["area_method"] = AREA_METHODS[new]
area_method_radiobutton = RadioButtonGroup( area_method_radiobutton = RadioButtonGroup(
labels=["Fit area", "Int area"], active=0, default_size=145 labels=["Fit area", "Int area"], active=0, default_size=145
) )
area_method_radiobutton.on_change("active", area_method_radiobutton_callback)
bin_size_spinner = Spinner(title="Bin size:", value=1, low=1, step=1, default_size=145) bin_size_spinner = Spinner(title="Bin size:", value=1, low=1, step=1, default_size=145)
@ -520,6 +516,7 @@ def create():
pyzebra.export_1D( pyzebra.export_1D(
export_data, export_data,
temp_file, temp_file,
area_method=AREA_METHODS[int(area_method_radiobutton.active)],
lorentz=lorentz_toggle.active, lorentz=lorentz_toggle.active,
hkl_precision=int(hkl_precision_select.value), hkl_precision=int(hkl_precision_select.value),
) )
@ -551,6 +548,7 @@ def create():
pyzebra.export_1D( pyzebra.export_1D(
export_data, export_data,
temp_file, temp_file,
area_method=AREA_METHODS[int(area_method_radiobutton.active)],
lorentz=lorentz_toggle.active, lorentz=lorentz_toggle.active,
hkl_precision=int(hkl_precision_select.value), hkl_precision=int(hkl_precision_select.value),
) )

View File

@ -601,13 +601,9 @@ def create():
fit_button = Button(label="Fit Current", default_size=145) fit_button = Button(label="Fit Current", default_size=145)
fit_button.on_click(fit_button_callback) fit_button.on_click(fit_button_callback)
def area_method_radiobutton_callback(_attr, _old, new):
det_data["meta"]["area_method"] = AREA_METHODS[new]
area_method_radiobutton = RadioButtonGroup( area_method_radiobutton = RadioButtonGroup(
labels=["Fit area", "Int area"], active=0, default_size=145, labels=["Fit area", "Int area"], active=0, default_size=145,
) )
area_method_radiobutton.on_change("active", area_method_radiobutton_callback)
bin_size_spinner = Spinner(title="Bin size:", value=1, low=1, step=1, default_size=145) bin_size_spinner = Spinner(title="Bin size:", value=1, low=1, step=1, default_size=145)
@ -623,7 +619,12 @@ def create():
if not export: if not export:
del export_data["scan"][s] del export_data["scan"][s]
pyzebra.export_1D(export_data, temp_file, lorentz=lorentz_toggle.active) pyzebra.export_1D(
export_data,
temp_file,
area_method=AREA_METHODS[int(area_method_radiobutton.active)],
lorentz=lorentz_toggle.active,
)
exported_content = "" exported_content = ""
for ext in (".comm", ".incomm"): for ext in (".comm", ".incomm"):
@ -645,7 +646,12 @@ def create():
if not export: if not export:
del export_data["scan"][s] del export_data["scan"][s]
pyzebra.export_1D(export_data, temp_file, lorentz=lorentz_toggle.active) pyzebra.export_1D(
export_data,
temp_file,
area_method=AREA_METHODS[int(area_method_radiobutton.active)],
lorentz=lorentz_toggle.active,
)
for ext in (".comm", ".incomm"): for ext in (".comm", ".incomm"):
fname = temp_file + ext fname = temp_file + ext

View File

@ -218,12 +218,11 @@ def parse_1D(fileobj, data_type):
s["indices"] = "real" s["indices"] = "real"
metadata["data_type"] = data_type metadata["data_type"] = data_type
metadata["area_method"] = AREA_METHODS[0]
return {"meta": metadata, "scan": scan} return {"meta": metadata, "scan": scan}
def export_1D(data, path, lorentz=False, hkl_precision=2): def export_1D(data, path, area_method=AREA_METHODS[0], lorentz=False, hkl_precision=2):
"""Exports data in the .comm/.incomm format """Exports data in the .comm/.incomm format
Scans with integer/real hkl values are saved in .comm/.incomm files correspondingly. If no scans Scans with integer/real hkl values are saved in .comm/.incomm files correspondingly. If no scans
@ -245,7 +244,6 @@ def export_1D(data, path, lorentz=False, hkl_precision=2):
else: # scan["indices"] == "real" else: # scan["indices"] == "real"
hkl_str = f"{h:8.{hkl_precision}f}{k:8.{hkl_precision}f}{l:8.{hkl_precision}f}" hkl_str = f"{h:8.{hkl_precision}f}{k:8.{hkl_precision}f}{l:8.{hkl_precision}f}"
area_method = data["meta"]["area_method"]
area_n = scan["fit"][area_method].n area_n = scan["fit"][area_method].n
area_s = scan["fit"][area_method].s area_s = scan["fit"][area_method].s