Skip to content

Commit 7e6e1ee

Browse files
committed
fix: mark selected BET window as one heatmap cell
1 parent 3b7f4a2 commit 7e6e1ee

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

app_bet.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,19 @@ def _plot_bet_heatmap(heatmap_result, best_window) -> plt.Figure:
293293
origin="lower", interpolation="nearest")
294294

295295
if best_window is not None:
296-
p_lo = np.searchsorted(p, best_window.p_min)
297-
p_hi = np.searchsorted(p, best_window.p_max)
298-
if p_hi > p_lo:
299-
rect = plt.Rectangle((p_lo, p_lo), p_hi - p_lo, p_hi - p_lo,
300-
linewidth=2, edgecolor="blue",
301-
facecolor="none", linestyle="--")
302-
ax.add_patch(rect)
296+
start_idx = int(np.argmin(np.abs(p - best_window.p_min)))
297+
end_idx = int(np.argmin(np.abs(p - best_window.p_max)))
298+
299+
rect = plt.Rectangle(
300+
(end_idx - 0.5, start_idx - 0.5),
301+
1.0,
302+
1.0,
303+
linewidth=2.2,
304+
edgecolor="blue",
305+
facecolor="none",
306+
linestyle="--",
307+
)
308+
ax.add_patch(rect)
303309

304310
tick_step = max(1, N // 8)
305311
tick_pos = np.arange(0, N, tick_step)
@@ -693,6 +699,12 @@ def _match_instrument_window_by_pressure(p_ads, n_ads, bet_pts,
693699
fig_hm = _plot_bet_heatmap(heatmap_result, best)
694700
st.pyplot(fig_hm, use_container_width=True)
695701
plt.close(fig_hm)
702+
if heatmap_result["valid"].sum() <= 1:
703+
st.info(
704+
"Only one Rouquerol-valid window was found. "
705+
"The heatmap confirms a unique fit, but range sensitivity "
706+
"cannot be assessed from multiple valid windows."
707+
)
696708

697709

698710
if instrument_window is not None:

0 commit comments

Comments
 (0)