From a85bffa316a13a1948323f9f3790b19f8f3ed1e4 Mon Sep 17 00:00:00 2001 From: StarCells Date: Sat, 14 Nov 2026 15:53:10 +0800 Subject: [PATCH] =?UTF-8?q?player=EF=BC=9A--calibration=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=87=AA=E5=8A=A8=E8=A7=A3=E6=9E=90=E5=88=B0=20calibr?= =?UTF-8?q?ation=5Fexports/<=E5=BD=95=E5=88=B6>=5Ff####?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧默认指向已删除的 Programs/wavelength_calibration/,不指定就直接报错。 现在先按录制名 + 帧号找,找不到再唯一匹配,仍找不到才提示传 --calibration。 --- wavelength_player.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/wavelength_player.py b/wavelength_player.py index d53e80e..d34c9a7 100644 --- a/wavelength_player.py +++ b/wavelength_player.py @@ -84,10 +84,24 @@ def install_hooks(hq, calibration): hq.make_calibration = lambda args: calibration +def default_calibration(input_dir, frame: int = 0): + """Look for the calibration peak_finder/wavelength_calibration just wrote.""" + + root = Path.cwd() / 'calibration_exports' + if not root.is_dir(): + return None + stem = Path(input_dir).name + exact = root / f'{stem}_f{frame:04d}' / 'calibration.json' + if exact.is_file(): + return str(exact) + matches = sorted(root.glob(f'{stem}_f*/calibration.json')) + return str(matches[0]) if len(matches) == 1 else None + + def main(argv=None): argv = sys.argv[1:] if argv is None else list(argv) options = argparse.ArgumentParser(add_help=False, allow_abbrev=False) - options.add_argument('--calibration', default=str(Path(__file__).with_name('wavelength_calibration') / 'calibration.json')) + options.add_argument('--calibration', default=None) extra, rest = options.parse_known_args(argv) try: hq = load_player() @@ -111,6 +125,12 @@ def main(argv=None): raise ValueError('use --input REC_DIR and --calibration JSON; live/demo/--calibrate are unsupported') if args.smooth != 1: raise ValueError('this player preserves unsmoothed signal; --smooth must be 1') + if extra.calibration is None: + extra.calibration = default_calibration(args.input, getattr(args, 'frame', 0) or 0) + if extra.calibration is None: + raise ValueError( + 'no calibration given; pass --calibration PATH ' + '(e.g. calibration_exports/_f0001/calibration.json)') calibration = SavedCalibration(extra.calibration) source = hq.RecordingSource(args.input) calibration.validate_geometry(source)