itof_unwrap_multifreq — OPTICS itof op

• Data kinds: table → table

• Call: import fullseye as fs; fs.ledger.itof_unwrap_multifreq(phase, frequencies_hz=None, weights=None, max_range_m=None, method='ml') (to call the implementation directly, import itof; itof.itof_unwrap_multifreq(phase, frequencies_hz=None, weights=None, max_range_m=None, method='ml'); from the registry, opsoptics.get("itof_unwrap_multifreq"))

Usage

Phases at several frequencies → depth (multi-frequency unwrapping). Returns a table.

> The detailed description below is the original text — the summary and the headings are translated.

周波数 f_i の位相 φ_i は距離を周期 p_i = c/(2 f_i) の剰余 r_i = φ_i p_i / (2π) で教える。周期の最小公倍数 U = c / (2·gcd f) までが一意(非曖昧距離)。

• method="ml"(既定)—— 最も高い周波数(距離の誤差が最も小さい帯)の剰余を錨にして、その次数の仮説 v = r_hi + k p_hi(k = 0 … U/p_hi)を全部、フェーザの一致 Σ w_i cos(2π(v − r_i)/p_i) で採点し、最良の仮説を逆分散の重み平均で精密化する(仮説を全部試す最尤の復号。位相雑音が帯ごとに同じなら、錨の誤差が最も小さい)。

• method="crt" —— residue.residue_crt(重みつきの頑健な中国剰余定理)にそのまま渡す。★residue_crt は Wang–Xia(2010)の錨の選び方 —— 雑音の分散 p²/w が最小の帯、同分散なら剰余 mod Γ が円上の最小二乗の共通剰余に最も近い帯 —— で錨を選ぶので、位相雑音が帯ごとに同じ iToF でも "ml" と同等になる(PoC の合成 0.1161 対 0.1160、実データ 0.131 対 0.131。以前の、常に最も長い周期を錨にする実装は 0.556 / 0.293 と大きく誤った)。保証(itof_unwrap_error_rate の guaranteed_phase_rad)の外の画素があると residue.ResidueBoundWarning を出す(値は返す)。

• method="beat" —— 2 周波だけ。うなりの位相 φ_1 − φ_2 で粗い距離(周期 c/(2|f_1 − f_2|))を出し、各周波数の次数をそれに最も近く丸めて重み平均する(教科書の古典的な方法)。

*weights* の既定は、itof_phase_amplitude の表なら A²/B(∝ 1/σ_φ²)、配列なら全帯 1。*max_range_m* で探す範囲 [0, max_range_m) を狭められる(非曖昧距離より広くは拒否)。

返す dict: depth、order (F, ...)(各周波数で何周目か)、margin(最良と次点の採点の差。小さい = 次数が際どい)、score、residual (F, ...) [m]、unambiguous_range、periods、method。

Raises ValueError: 周波数・位相の形が合わない / 周期が通約できない(非曖昧距離が有限でない)/ max_range_m が非曖昧距離より広い / beat で 2 周波でない / method が不正 / 仮説 × 画素が上限を超える。

Family-wide input contract (fail-closed)

Every optics op validates its input before computing (nothing slips through silently):

• Units are baked into the argument name — _mm / _um / _deg / _mrad. Confusing mm with µm does not crash; it yields a plausible-looking wrong answer, so the name prevents it. Nothing here guesses the unit from the magnitude.

• Strings raise ValueError — float('50') succeeds, so an unparsed configuration value would slip through as a length (measured: thin_lens('50', '200') returned a plausible 66.667 mm). bool is refused too, as the implicit promotion True == 1.

• complex / masked arrays raise ValueError (real-valued slots only; silently dropping the imaginary part or peeling off the mask is refused). NaN/Inf raises ValueError on every input.

• Division by zero and its relatives are refused by name: focal length 0, radius of curvature 0, refractive index <= 0, a fully opaque aperture (all zeros, so the normalisation is 0/0), a PSF whose sum is <= 0, a Stokes vector with S0 = 0, and an object sitting at the front focal point (the image is at infinity).

• Only two ops return a non-finite value, and both state it as a contract: depth_of_field returns far_mm = inf beyond the hyperfocal distance (that is what the hyperfocal distance means), and gaussian_beam returns wavefront_radius_mm = inf at the waist (the radius of curvature of a plane wavefront). Both also return a finite companion (far_is_infinite / curvature_per_mm). Any other silent NaN/Inf is detected internally and raises ValueError — "float64 overflowed" and "the answer is infinite" are different claims, so the first is never returned wearing the face of the second.

• Size caps: generated grids are capped by optics.MAX_GRID (4096); supplied fields/PSFs/apertures by optics.MAX_FIELD_ELEMENTS (2^24); ABCD element chains by optics.MAX_SYSTEM_ELEMENTS (1024); Zernike by MAX_ZERNIKE_TERMS (512) / MAX_ZERNIKE_ORDER (40) / MAX_ZERNIKE_BASIS (2^25). This closes, fail-closed, the paths where a small argument triggers a huge internal allocation (measured: n_max=40 × 4096² needs 108 GB).

• Physically impossible states are refused too: a Stokes vector with degree of polarisation > 1, negative transmittance, negative intensity, and invalid Zernike indices such as n-|m| odd.

Detailed usage guide

• optics_imaging family guide

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Runnable examples (verified samples that actually call this op)

• poc_itof_multifreq — py -3.11 examples/poc_itof_multifreq.py

Ops the type connects to (they accept table as input)

abcd_matrix · wavefront_stats · sfr_from_edge · paraxial_trace · seidel_coefficients · spot_stats · tolerance_analysis · wavefront_from_opd

Same category (itof)

itof_capture · itof_phase_amplitude · itof_noise_budget · itof_unwrap_error_rate · itof_multipath_separate · itof_flying_pixel_mask · itof_wiggling_correct


*Provenance: itof.py — OPTICS operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.