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} · dt exactly at every requested frequency. Cost: O(Nf · N). Equivalent in scale to np.fft.rfft (rfft returns Σ_n x_n · e^{-2π j k n / N} without a dt factor; the direct DFT here returns the same magnitude after dividing the Riemann-sum form by dt, i.e. cancels the explicit dt factor).

  • Zero-padded rFFT + linear interp (fallback for large Nf · N): the historical path; pads so the FFT bin spacing is at most df_target / 2 and linear-interpolates real / imag. Faster for very dense f_target, but introduces a 1–3 % magnitude error when the inter-bin phase rotates significantly (~30° per bin) — manifests as a spurious |S|² < 1 floor in the modal-port S-parameter pipeline. Switching to the direct DFT for small Nf · N eliminates 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

property f: ndarray#

Frequency axis [Hz].

property spectrum: ndarray#

Complex FFT spectrum (cached).

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_min rather than f_max alone, 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 via f_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]