player:--calibration 默认自动解析到 calibration_exports/<录制>_f####
旧默认指向已删除的 Programs/wavelength_calibration/,不指定就直接报错。 现在先按录制名 + 帧号找,找不到再唯一匹配,仍找不到才提示传 --calibration。
This commit is contained in:
1 parent
31e41f6519
commit
a85bffa316
1 file changed
+21
-1
+21
-1
@@ -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/<recording>_f0001/calibration.json)')
|
||||
calibration = SavedCalibration(extra.calibration)
|
||||
source = hq.RecordingSource(args.input)
|
||||
calibration.validate_geometry(source)
|
||||
|
||||
Reference in new issue
Block a user