Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
evg-mar committed Jul 24, 2024
1 parent 5fbd4e2 commit ce95d6c
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/pages/load_or_create_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def load_calibration_spectrum_neon():
# meta_dct = target_spe.meta
st.session_state["cache_dicts"]["spectra_x"]["neon"] = neon_spe

st.session_state["cache_strings"]["x_calibration"] = \
"uploaded_neon_calib_spectra_btn"
# st.session_state["cache_strings"]["x_calibration"] = \
# "uploaded_neon_calib_spectra_btn"


def load_calibration_spectrum_si():
Expand All @@ -217,9 +217,9 @@ def load_calibration_spectrum_si():
# meta_dct = target_spe.meta
st.session_state["cache_dicts"]["spectra_x"]["si"] = si_spe

st.session_state["cache_strings"][
"x_calibration"
] = "uploaded_si_calib_spectra_btn"
# st.session_state["cache_strings"][
# "x_calibration"
# ] = "uploaded_si_calib_spectra_btn"


def page_call_STD1_X_Calibration():
Expand Down Expand Up @@ -377,9 +377,9 @@ def process_x_calibration_neon_creation():
]
)

if "neon" in st.session_state["cache_dicts"]["spectrum_settings"]:
state_settings = st.session_state["cache_dicts"]["spectrum_settings"]["neon"]
else:
if "neon" not in st.session_state["cache_dicts"]["spectrum_settings"]:
# state_settings = st.session_state["cache_dicts"]["spectrum_settings"]["neon"]
# else:
st.session_state["cache_dicts"]["spectrum_settings"]["neon"] = default_state_neon

state_settings = st.session_state["cache_dicts"]["spectrum_settings"]["neon"]
Expand All @@ -389,6 +389,7 @@ def process_x_calibration_neon_creation():
print('------ END ------')

with load_tn:

load_calibration_spectrum_neon()

if "neon" in st.session_state["cache_dicts"]["spectra_x"]:
Expand Down Expand Up @@ -1101,6 +1102,7 @@ def __process_x_calibration_si_creation():
# else min(spe.x)
# print('Min val: ', min_val)
baseline_current = settings_baseline.baseline_corr_type

if set_default_btn:
callback_change_value(
'select_baseline_si', baseline_current)
Expand All @@ -1127,6 +1129,12 @@ def __process_x_calibration_si_creation():

st.write("")
with st.expander(label="Baseline correction settings"):
if set_default_btn:
keys = [k for k in st.session_state.keys(
) if 'Baseline correction settings']
for key in keys:
del st.session_state[key]

input_data = sp.pydantic_input(
"Baseline correction settings", baseline_corr_class)

Expand All @@ -1137,6 +1145,12 @@ def __process_x_calibration_si_creation():
# st.write(args)
# st.write(type(input_data))

print('sessions state...')
print(st.session_state.keys())
print('----------------------')
print(st.session_state)
print('=======================')

if submit_si_baseline_btn or use_baseline:
if baseline_corr == 'SNIP':
si_spe_baseline = si_spe_current
Expand Down Expand Up @@ -2053,15 +2067,15 @@ def update_x_calibraiton_val():
# fig.set_size_inches(40, 25)
# st.pyplot(fig)

elif x_calib_btn == "uploaded_si_calib_spectra_btn":
# st.write("Show the Si spe...")
si_spe = st.session_state["cache_dicts"]["spectra_x"]["si"]
# elif x_calib_btn == "uploaded_si_calib_spectra_btn":
# # st.write("Show the Si spe...")
# si_spe = st.session_state["cache_dicts"]["spectra_x"]["si"]

st.session_state["cache_dicts"]["spectra_x_current"]["si"] = si_spe
spe_units = si_spe.meta["units"]
simple_plot_spe(
spe=si_spe, label="Si", xlabel=r"Raman shift [{}]".format(spe_units)
)
# st.session_state["cache_dicts"]["spectra_x_current"]["si"] = si_spe
# spe_units = si_spe.meta["units"]
# simple_plot_spe(
# spe=si_spe, label="Si", xlabel=r"Raman shift [{}]".format(spe_units)
# )

elif x_calib_btn == "submitted_std1_btn":
# st.write(' in elif x_calib_btn std1')
Expand Down

0 comments on commit ce95d6c

Please sign in to comment.