kicad2ems.core.causality

Causality of band-limited S-parameters (R-E2): the generalised dispersion
relations with subtractions (Triverio, Grivet-Talocia, "Robust causality
characterization via generalized dispersion relations", IEEE T-ADVP 2008).

A causal response (exp(+jwt): analytic in the lower half of the w plane) is its
own Hilbert transform. With n subtraction points w_k in the band, P the
polynomial through H(w_k) and Pi(w) = prod (w - w_k), the function (H - P) / Pi
is causal too and falls off as 1/w, so

    H(w) = P(w) + Pi(w) / (j pi) PV int H(w') / (Pi(w') (w - w')) dw'
        (over the whole line)

Only the band B = [fmin, fmax] (and its mirror, H(-w) = H(w)*) is known. Its
part is computed (the P / Pi share in closed form, the smooth rest by quadrature
with the singularity at w taken out), and the rest is bounded with |H| <= 1 (a
passive S): the truncation bound

    T(w) = |Pi(w)| / pi int_{not B} dw' / (|Pi(w')| |w - w'|)

which the subtractions make small inside the band (the kernel falls off as 1 /
w'^(n+1)). The data are causal to within the evidence where |H - H_r| <= T + the
quadrature's own error (from the same reconstruction of a causal test function
on the same samples); a larger miss is a causality violation: a reference plane
past the true one (a delay removed that was not there), a time-reversed or badly
interpolated response.

    r = check(freq, S)  # dict: worst (|H - H_r| - bound) over the terms, at
                        # which f and term, ...
kicad2ems.core.causality.check(freq, S, ns=range(2, 9))[source]
Each S term's causality on the inner 80 % of the band (at its edges the
unknown data just past them decide it): dict(worst, f, term, n, terms).
worst is the largest miss beyond the bound, max(|H - H_r| - T - e_n), over
the terms and over n subtractions: each n is a test of its own (few: large
bounds but the data's own shape decides; many: small bounds, but the
interpolating polynomial absorbs a violation), so a miss at any one is
evidence. e_n: the reconstruction's own error on these samples (a causal
test response's). 0: causal within the evidence. Every term at once, a
few products of _operator's matrices with them for each n (a term at a
time it had been 46 s of a 92-port Thor window's 107).
kicad2ems.core.causality.reconstruct(f, h, n)[source]
(H_r, T) on the samples f (Hz, ascending, from fmin > 0) of one term h,
with n subtractions (_operator's, applied).