Skip to content

Commit

Permalink
last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
evg-mar committed Sep 3, 2024
1 parent b5865db commit f7d5be2
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions src/pages/load_or_create_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def load_calibration_spectrum_neon():
)

if uploaded_neon_spec:
neon_spe = process_file_spe([uploaded_neon_spec], label="Neon", units=units)
neon_spe = process_file_spe(
[uploaded_neon_spec], label="Neon", units=units)
# meta_dct = target_spe.meta
st.session_state["cache_dicts"]["spectra_x"]["neon"] = neon_spe

Expand Down Expand Up @@ -523,7 +524,8 @@ def process_x_calibration_neon_creation():

with col1:
min_val = (
settings_crop.crop_min if settings_crop.crop_min else min(spe.x)
settings_crop.crop_min if settings_crop.crop_min else min(
spe.x)
)
print("Min val: ", min_val)

Expand All @@ -540,7 +542,8 @@ def process_x_calibration_neon_creation():
)
with col2:
max_val = (
settings_crop.crop_max if settings_crop.crop_max else max(spe.x)
settings_crop.crop_max if settings_crop.crop_max else max(
spe.x)
)
# print('Max val: ', max_val)

Expand Down Expand Up @@ -684,7 +687,8 @@ def process_x_calibration_neon_creation():

red_patch = mpatches.Patch(color="blue", label="Neon")

blue_patch = mpatches.Patch(color="red", label="Neon normalized")
blue_patch = mpatches.Patch(
color="red", label="Neon normalized")

ax2.legend(handles=[red_patch, blue_patch])

Expand Down Expand Up @@ -752,7 +756,8 @@ def process_x_calibration_neon_creation():
"window_length_neon", settings_peak_find.value_wlen
)

callback_change_value("width_neon", settings_peak_find.value_width)
callback_change_value(
"width_neon", settings_peak_find.value_width)
# callback_change_value(
# "hht_chain_neon", settings_peak_find.value_hht_chain
# )
Expand Down Expand Up @@ -848,17 +853,18 @@ def process_x_calibration_neon_creation():

options_strategy = [
"topo",
"bayesian_gaussian_mixture",
# "bayesian_gaussian_mixture",
"bgm",
"cwt",
# "cwt",
]

# st.write(value_strategy)
strategy = st.selectbox(
key="strategy_neon",
label="strategy",
options=options_strategy,
index=options_strategy.index(settings_peak_find.value_strategy),
index=options_strategy.index(
settings_peak_find.value_strategy),
# on_change=update_x_calibration_btn("submitted_std1_btn"),
)

Expand All @@ -877,7 +883,8 @@ def process_x_calibration_neon_creation():

# fig, ax = plt.subplots()

neon_peak_candidates.plot(ax=axs[1], fmt=":", label="Neon peaks")
neon_peak_candidates.plot(
ax=axs[1], fmt=":", label="Neon peaks")
axs[1].set_xlabel(xlabel)
fig = axs[1].get_figure()

Expand Down Expand Up @@ -1258,7 +1265,8 @@ def process_x_calibration_si_creation():
baseline_current = settings_baseline.baseline_corr_type

if set_default_btn:
callback_change_value("select_baseline_si", baseline_current)
callback_change_value(
"select_baseline_si", baseline_current)

# callback_change_value('min_crop_input', min_val)
options = [
Expand Down Expand Up @@ -1505,7 +1513,8 @@ def process_x_calibration_si_creation():
"window_length_si", settings_peak_find.value_wlen
)

callback_change_value("width_si", settings_peak_find.value_width)
callback_change_value(
"width_si", settings_peak_find.value_width)
# callback_change_value(
# "hht_chain_si", settings_peak_find.value_hht_chain
# )
Expand Down Expand Up @@ -1600,17 +1609,18 @@ def process_x_calibration_si_creation():

options_strategy = [
"topo",
"bayesian_gaussian_mixture",
# "bayesian_gaussian_mixture",
"bgm",
"cwt",
# "cwt",
]

# st.write(value_strategy)
strategy = st.selectbox(
key="strategy_si",
label="strategy",
options=options_strategy,
index=options_strategy.index(settings_peak_find.value_strategy),
index=options_strategy.index(
settings_peak_find.value_strategy),
# on_change=update_x_calibration_btn("submitted_std2_btn"),
)

Expand Down Expand Up @@ -1785,7 +1795,8 @@ def upload_y_calibration_ref_spe():
import time

print(
"BEFORE TABS SRM REF, --- time: {} ---------".format(time.strftime("%X %x %Z"))
"BEFORE TABS SRM REF, --- time: {} ---------".format(
time.strftime("%X %x %Z"))
)

with load_srm:
Expand Down Expand Up @@ -1816,7 +1827,8 @@ def upload_y_calibration_ref_spe():
srm_spe = st.session_state["cache_dicts"]["spectra_y_last"]["srm_ref"]
spe_units = srm_spe.meta["units"]

label, xlabel = "Reference spectrum", r"Raman shift [{}]".format(spe_units)
label, xlabel = "Reference spectrum", r"Raman shift [{}]".format(
spe_units)
ax = srm_spe.plot(label=label, linestyle="dashed", color="blue")
ax.set_xlabel(xlabel)

Expand Down Expand Up @@ -1875,7 +1887,8 @@ def upload_y_calibration_ref_spe():

with col1:
min_val = (
settings_crop.crop_min if settings_crop.crop_min else min(spe.x)
settings_crop.crop_min if settings_crop.crop_min else min(
spe.x)
)
print("Min val: ", min_val)

Expand All @@ -1892,7 +1905,8 @@ def upload_y_calibration_ref_spe():
)
with col2:
max_val = (
settings_crop.crop_max if settings_crop.crop_max else max(spe.x)
settings_crop.crop_max if settings_crop.crop_max else max(
spe.x)
)
# print('Max val: ', max_val)

Expand Down Expand Up @@ -1961,7 +1975,8 @@ def upload_y_calibration_ref_spe():
srm_spe = st.session_state["cache_dicts"]["spectra_y"]["srm_ref"]
spe_units = srm_spe.meta["units"]

label, xlabel = "Reference spectrum", r"Raman shift [{}]".format(spe_units)
label, xlabel = "Reference spectrum", r"Raman shift [{}]".format(
spe_units)
ax = srm_spe.plot(label=label, linestyle="dashed", color="blue")
ax.set_xlabel(xlabel)
# ax.set_ylabel("Si", color="blue")
Expand Down Expand Up @@ -2034,7 +2049,8 @@ def upload_y_calibration_ref_spe():
index_method = method_options.index(settings_smooth.method)

if set_default_btn:
index_method = method_options.index(settings_smooth.method)
index_method = method_options.index(
settings_smooth.method)
callback_change_value(
"select_box_srm_method", default_state_srm_ref.smooth.method
)
Expand Down Expand Up @@ -2090,7 +2106,8 @@ def upload_y_calibration_ref_spe():
color="red",
)

red_patch = mpatches.Patch(color="blue", label="Reference spectrum")
red_patch = mpatches.Patch(
color="blue", label="Reference spectrum")

blue_patch = mpatches.Patch(color="red", label="Ref smooth")

Expand Down Expand Up @@ -2397,7 +2414,8 @@ def update_x_calibraiton_val():
path = str(rpath / "data" / xcalibration_filename)
calmodel.save(path)

st.write("Saved X-calibration model in ", "./data/" + xcalibration_filename)
st.write("Saved X-calibration model in ",
"./data/" + xcalibration_filename)


elif x_calib_btn == "btn_save_material_certificate":
Expand Down

0 comments on commit f7d5be2

Please sign in to comment.