magnelio.signals#
Signal components — time series and excitation waveforms.
- class magnelio.signals.Signal1D(t, values, dt, label='')#
Immutable time-domain signal.
- Parameters:
t (np.ndarray) – Time axis [s], shape (N,).
values (np.ndarray) – Signal values, shape (N,).
dt (float) – Time step [s].
label (str) – Optional label for identification.
- at_frequencies(f_target)#
Evaluate spectrum at arbitrary frequency points.
Two paths:
Direct DFT (default for small
Nf · N): evaluatesΣ_n x_n · e^{-2π j f t_n} · dtexactly at every requested frequency. Cost:O(Nf · N). Equivalent in scale tonp.fft.rfft(rfftreturnsΣ_n x_n · e^{-2π j k n / N}without adtfactor; the direct DFT here returns the same magnitude after dividing the Riemann-sum form bydt, i.e. cancels the explicitdtfactor).Zero-padded rFFT + linear interp (fallback for large
Nf · N): the historical path; pads so the FFT bin spacing is at mostdf_target / 2and linear-interpolatesreal/imag. Faster for very densef_target, but introduces a 1–3 % magnitude error when the inter-bin phase rotates significantly (~30° per bin) — manifests as a spurious|S|² < 1floor in the modal-port S-parameter pipeline. Switching to the direct DFT for smallNf · Neliminates that floor down to floating-point precision.
- Parameters:
f_target (np.ndarray) – Target frequencies [Hz].
- Returns:
Complex spectrum values at
f_target.- Return type:
np.ndarray
- magnelio.signals.gaussian(t, f_max)#
Plain Gaussian pulse, peak = 1 at t0 = 4/f_max.
Suitable for TEM modes (DC-inclusive).
- Parameters:
t (float or np.ndarray) – Time [s].
f_max (float) – Bandwidth [Hz].
- Return type:
float | ndarray
- magnelio.signals.modulated_gaussian(t, f_max, f_min)#
Gaussian envelope modulated at the band centre (f_min + f_max) / 2.
The envelope sigma scales with the passband bandwidth
f_max - f_minrather thanf_maxalone, so the spectrum is tightly confined to [f_min, f_max] and almost nothing leaks below f_min. This is what one wants when the lower edge is constrained — by a waveguide cut-off frequency or by an explicit user-specified band.- Parameters:
t (float or np.ndarray) – Time [s].
f_max (float) – Upper passband edge [Hz].
f_min (float) – Lower passband edge [Hz]. Either an explicit user value or the mode’s cut-off frequency.
- Return type:
float | ndarray
- magnelio.signals.waveform_for_mode(f_max, omega_c=0.0, f_min=0.0)#
Factory: select Gaussian or modulated Gaussian based on band edges.
Picks a modulated Gaussian whenever a positive lower edge exists — either implicitly via the mode cut-off (
omega_c > 0, e.g. TE/TM waveguide modes) or explicitly viaf_min > 0(caller-specified bandpass even for TEM modes). The carrier sits at the midpoint of[max(f_cutoff, f_min), f_max]. Falls back to a plain DC-inclusive Gaussian when both edges are zero.- Parameters:
f_max (float) – Upper bandwidth [Hz].
omega_c (float, default 0.0) – Angular cut-off frequency [rad/s] of the mode (TE/TM > 0, TEM = 0).
f_min (float, default 0.0) – Caller-specified lower band edge [Hz]. Set this when you want a bandpass excitation on a TEM mode (e.g. WR-90 measurement band).
- Returns:
Waveform function
v(t) -> float.- Return type:
Callable[[float], float]