diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 50e11e8..8522e27 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -7,7 +7,6 @@ from bokeh.layouts import column, row from bokeh.models import ( BasicTicker, Button, - CheckboxGroup, Circle, ColumnDataSource, CustomJS, @@ -20,6 +19,7 @@ from bokeh.models import ( LinearAxis, Panel, Plot, + RadioButtonGroup, Select, Spacer, Spinner, @@ -128,11 +128,6 @@ def create(): fit = meas.get("fit") if fit is not None: - if meas["fit"]["export_fit"]: - export_fit_checkbox.active = [0] - else: - export_fit_checkbox.active = [] - plot_gauss_source.data.update(x=x, y=meas["fit"]["comps"]["gaussian"]) plot_bkg_source.data.update(x=x, y=meas["fit"]["comps"]["background"]) params = fit["result"].params @@ -419,13 +414,13 @@ def create(): fit_button = Button(label="Fit Current", default_size=145) fit_button.on_click(fit_button_callback) - def export_fit_checkbox_callback(_attr, _old, new): - sel_ind = meas_table_source.selected.indices[-1] - meas = meas_table_source.data["measurement"][sel_ind] - det_data["Measurements"][meas]["fit"]["export_fit"] = bool(new) + def area_method_radiobutton_callback(_attr, _old, new): + det_data["meta"]["area_method"] = ("fit", "integ")[new] - export_fit_checkbox = CheckboxGroup(labels=["Export fit"], width=100) - export_fit_checkbox.on_change("active", export_fit_checkbox_callback) + area_method_radiobutton = RadioButtonGroup( + labels=["Fit", "Integral"], active=0, default_size=145 + ) + area_method_radiobutton.on_change("active", area_method_radiobutton_callback) preview_output_textinput = TextAreaInput(title="Export file preview:", width=450, height=400) @@ -503,7 +498,7 @@ def create(): Spacer(width=20), column( row(integ_from, integ_to), - row(fitparam_reset_button, column(Spacer(height=5), export_fit_checkbox)), + row(fitparam_reset_button, area_method_radiobutton), row(fit_button, fit_all_button), ), ) diff --git a/pyzebra/comm_export.py b/pyzebra/comm_export.py index 8211dac..cb70126 100644 --- a/pyzebra/comm_export.py +++ b/pyzebra/comm_export.py @@ -38,12 +38,12 @@ def export_comm(data, path, lorentz=False): h_str = f'{int(meas["h_index"]):{padding[1]}}' k_str = f'{int(meas["k_index"]):{padding[1]}}' l_str = f'{int(meas["l_index"]):{padding[1]}}' - if meas["fit"]["export_fit"] is True: + if data["meta"]["area_method"] == "fit": area = float(meas["fit"]["fit_area"].n) sigma_str = ( f'{"{:8.2f}".format(float(meas["fit"]["fit_area"].s)):{align}{padding[2]}}' ) - else: + elif data["meta"]["area_method"] == "integ": area = float(meas["fit"]["int_area"].n) sigma_str = ( f'{"{:8.2f}".format(float(meas["fit"]["int_area"].s)):{align}{padding[2]}}' diff --git a/pyzebra/fit2.py b/pyzebra/fit2.py index ff8166d..0b92550 100644 --- a/pyzebra/fit2.py +++ b/pyzebra/fit2.py @@ -216,8 +216,7 @@ def fitccl( print(result.fit_report()) print((result.params["g_amp"].value - int_area.n) / result.params["g_amp"].value) - d["export_fit"] = False - # ["export_fit"] = False if user wants num. int. value in comm/incomm, otherwise true + d["ratio"] = (result.params["g_amp"].value - int_area.n) / result.params["g_amp"].value d["int_area"] = int_area d["fit_area"] = u.ufloat(result.params["g_amp"].value, result.params["g_amp"].stderr) diff --git a/pyzebra/load_1D.py b/pyzebra/load_1D.py index a2fbed9..7bac265 100644 --- a/pyzebra/load_1D.py +++ b/pyzebra/load_1D.py @@ -97,7 +97,6 @@ def parse_1D(fileobj, data_type): # read data if data_type == ".ccl": - metadata["data_type"] = data_type measurements = {} decimal = list() data = fileobj.readlines() @@ -162,7 +161,6 @@ def parse_1D(fileobj, data_type): elif data_type == ".dat": # skip the first 2 rows, the third row contans the column names - metadata["data_type"] = data_type next(fileobj) next(fileobj) col_names = next(fileobj).split() @@ -181,4 +179,8 @@ def parse_1D(fileobj, data_type): else: print("Unknown file extention") + # utility information + metadata["data_type"] = data_type + metadata["area_method"] = "fit" + return {"meta": metadata, "Measurements": measurements}