feat: 波长偏移修正 + 项目架构文档

- BandMathCalculator 支持 wavelength_offset 参数,公式波长统一加减偏移后匹配传感器波段
- WaterQualityIndexCalculator 全链传递偏移量 (band_math → calculate_one → calculate_many)
- WaterIndexCsvProcessor / Step7Handler / DataPreparationStep 传播偏移参数
- Step7/Step10 面板新增 QDoubleSpinBox 波长偏移控件 (±200nm, 默认0)
- 偏移控件去除单位后缀,避免编辑时需手动移动光标
- 新增 ARCHITECTURE.md 完整项目架构文档
This commit is contained in:
duxin
2026-06-30 13:13:38 +08:00
parent 8ff5b08190
commit 9e433395f4
8 changed files with 537 additions and 15 deletions

View File

@ -114,6 +114,7 @@ class WaterIndexCsvProcessor:
output_dir: str,
selected_formulas: Optional[List[str]] = None,
progress_callback: Optional[Callable[[str, float], None]] = None,
wavelength_offset: float = 0.0,
) -> Dict[str, str]:
"""
散点 CSV → 按指数拆分的多个 CSV。
@ -128,6 +129,8 @@ class WaterIndexCsvProcessor:
要计算的公式名列表;None 或空列表 = 全部公式
progress_callback : callable, optional
进度回调 ``(msg: str, pct: float)``
wavelength_offset : float
波长偏移修正量(nm),公式波长统一加上此值后再匹配波段
Returns
-------
@ -192,7 +195,7 @@ class WaterIndexCsvProcessor:
notify(f"开始逐行计算 {len(targets)} 个公式…", 25)
spectra_df = df[wl_cols]
try:
results_df = calc.calculate_many(targets, spectra_df)
results_df = calc.calculate_many(targets, spectra_df, wavelength_offset=wavelength_offset)
except Exception as e:
raise RuntimeError(f"公式计算失败: {e}")

View File

@ -38,6 +38,7 @@ class Step7CalcIndicesHandler(BaseStepHandler):
output_file=config.get('output_file'),
enabled=config.get('enabled', True),
output_dir=str(context.indices_dir),
wavelength_offset=float(config.get('wavelength_offset', 0)),
)
context.indices_path = result

View File

@ -133,6 +133,7 @@ class DataPreparationStep:
enabled: bool = True,
output_dir: Union[str, Path] = "./7_Water_Quality_Indices",
callback: Optional[Callable] = None,
wavelength_offset: float = 0.0,
) -> Optional[str]:
"""根据训练光谱计算水质光谱指数(使用 band_math 方法)"""
output_dir = Path(output_dir)
@ -170,7 +171,7 @@ class DataPreparationStep:
from src.utils.band_math import BandMathCalculator
calculator = BandMathCalculator(training_csv_path)
calculator = BandMathCalculator(training_csv_path, wavelength_offset=wavelength_offset)
result_df = calculator.process_formulas_from_csv(
formula_csv_file=formula_csv_file,
formula_names=formula_names,