From 31e41f651988835e632d11465a76261290aac773 Mon Sep 17 00:00:00 2001 From: StarCells Date: Sat, 14 Nov 2026 15:37:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=A8=E9=80=9A=E9=81=93=E8=81=9A=E7=B1=BB?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=8B=9F=E5=90=88=E4=B8=AD=E5=BF=83=EF=BC=9A?= =?UTF-8?q?=E9=80=9A=E9=81=93=E9=97=B4=E5=81=8F=E5=B7=AE=E8=B6=85=E8=BF=87?= =?UTF-8?q?=20--group-tol=20=E5=B0=B1=E5=88=86=E6=88=90=E4=B8=A4=E6=9D=A1?= =?UTF-8?q?=E5=B3=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 检测位置只差 1 px、但 R/G 拟合中心差了 6 px 的那种线,以前会被合成一条; 现在按拟合中心聚类,分开后可在 pick 里按 m 手动合并。 --- spectro_core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spectro_core.py b/spectro_core.py index 4b73b07..f9dc564 100644 --- a/spectro_core.py +++ b/spectro_core.py @@ -801,10 +801,10 @@ def group_channels(peaks: dict[str, list[dict]], tolerance_px: float, merge_tolerance_px: float = 1.5) -> list[dict]: """Merge per-channel peaks that belong to the same spectral line.""" - # Cluster on the detected local maxima, not on the fitted centres: a single - # peak fit inside a blend is pulled towards its neighbour and would wrongly - # merge two resolved lines. - flat = [(item["sensor_x_px"], channel, item) + # Cluster on the fitted centres: if two channels put the line more than + # `tolerance_px` apart they are not the same feature, and the user can still + # join them by hand in the picker (m). + flat = [(item.get("center_px", item["sensor_x_px"]), channel, item) for channel, items in peaks.items() for item in items] flat.sort(key=lambda row: row[0]) groups: list[list[tuple[float, str, dict]]] = []