From 408e1660fc0f3d8b7a3c990515e6f494ecba991f Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 10 Jul 2026 14:49:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(background.py):=20=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E6=A0=A1=E6=AD=A3=E5=9B=BE=E8=A1=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit algorithmic_baseline() 函数: - 原代码: fig = None # plotting disabled - 修复: 调用 plotting.background_plotting(df, gas) 生成交互式图表, 显示原始浓度、拟合基线、信号点(红色)和背景点(蓝色圆圈) 异常保护:try/except 包裹,绘图失败时回退至 None --- src/gasflux/background.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gasflux/background.py b/src/gasflux/background.py index df594b6..54bf950 100644 --- a/src/gasflux/background.py +++ b/src/gasflux/background.py @@ -52,7 +52,11 @@ def algorithmic_baseline( signal = (df[gas] - bkg)[~bkg_points] df[f"{gas}_signal"] = np.invert(bkg_points) - fig = None # plotting disabled + try: + from . import plotting + fig = plotting.background_plotting(df, gas) + except Exception: + fig = None output_text = ( f"Baseline algorithm: {algorithm}\n" f"Positive and negative 95% percentile of baseline: {np.percentile(background, 2.5):.2f} ppm, "