Skip to content

striqt.analysis.testing

Synthetic IQ generators with known spectra for tests and examples.

circular_awgn

circular_awgn(
    duration: float | None,
    sample_rate: float,
    *,
    power: float = 1.0,
    ports: int = 1,
    start_index: int = 0,
    count: int | None = None,
    seed: int = 0,
    xp: ModuleType = np,
    dtype: DTypeLike = 'complex64',
) -> Array

generate circularly-symmetric complex gaussian noise of total power power.

The real and imaginary parts are independent, each with variance power / 2. The mean of |iq|**2 is power. Each port is an independent draw. White noise with power spectral density noise_psd mW/Hz over the full sample rate has total power noise_psd * sample_rate mW.

Samples at indices i >= 0 are the stream from RandomState(seed), interleaved across ports within each sample. Samples at negative indices are drawn from a second stream seeded seed + 2**31, independent of the first stream and of the same power, with index -1 the first draw. A window at any start_index is the matching slice of any longer window.

Parameters:

  • duration (float | None) –

    capture duration, in s, used only when count is None

  • sample_rate (float) –

    IQ sample rate, in Hz, read only to convert duration to a sample count

  • power (float, default: 1.0 ) –

    total power of each port, in linear units

  • ports (int, default: 1 ) –

    number of receive ports, with independent noise on each port

  • start_index (int, default: 0 ) –

    absolute index of the first returned sample

  • count (int | None, default: None ) –

    number of samples, or None for duration less start_index

  • seed (int, default: 0 ) –

    seed of the noise generator, in [0, 2**31)

  • xp (ModuleType, default: np ) –

    the array namespace of the returned array

  • dtype (DTypeLike, default: 'complex64' ) –

    the returned complex dtype

Returns:

  • Array –

    an array of shape (ports, count) and dtype dtype in the namespace xp

Raises:

  • ValueError –

    when ports is below 1, when duration and count are both None, when the resolved count is negative, when seed is outside [0, 2**32), or when start_index is negative and seed is at or above 2**31

dirac_delta

dirac_delta(
    duration: float | None,
    sample_rate: float,
    *,
    time: float = 0.0,
    power: float = 0.0,
    ports: int = 1,
    start_index: int = 0,
    count: int | None = None,
    xp: ModuleType = np,
    dtype: DTypeLike = 'complex64',
) -> Array

generate a single impulse at time in a field of zeros.

The impulse is real with an amplitude of power dB relative to 1, at the absolute sample index nearest time s from the start of the capture. The returned array is all zeros when that index is outside the returned window. Every port has the same samples.

Parameters:

  • duration (float | None) –

    capture duration, in s, used only when count is None

  • sample_rate (float) –

    IQ sample rate, in Hz

  • time (float, default: 0.0 ) –

    time of the impulse, in s from the start of the capture

  • power (float, default: 0.0 ) –

    the impulse amplitude, in dB relative to 1

  • ports (int, default: 1 ) –

    number of receive ports

  • start_index (int, default: 0 ) –

    absolute index of the first returned sample

  • count (int | None, default: None ) –

    number of samples, or None for duration less start_index

  • xp (ModuleType, default: np ) –

    the array namespace of the returned array

  • dtype (DTypeLike, default: 'complex64' ) –

    the returned complex dtype

Returns:

  • Array –

    an array of shape (ports, count) and dtype dtype in the namespace xp

Raises:

  • ValueError –

    when ports is below 1, when duration and count are both None, or when the resolved count is negative

sawtooth

sawtooth(
    duration: float | None,
    sample_rate: float,
    *,
    period: float = 0.01,
    power: float = 0.0,
    ports: int = 1,
    start_index: int = 0,
    count: int | None = None,
    xp: ModuleType = np,
    dtype: DTypeLike = 'complex64',
) -> Array

generate a real-valued sawtooth ramp that repeats every period s.

Each ramp rises linearly from 0 toward a peak amplitude of power dB relative to 1. Ramps reset at absolute sample index 0 and at every multiple of period s before and after that index. The peak is never reached. The imaginary part is 0. Every port has the same samples.

Parameters:

  • duration (float | None) –

    capture duration, in s, used only when count is None

  • sample_rate (float) –

    IQ sample rate, in Hz

  • period (float, default: 0.01 ) –

    duration of one ramp, in s, positive

  • power (float, default: 0.0 ) –

    the peak amplitude of the ramp, in dB relative to 1

  • ports (int, default: 1 ) –

    number of receive ports

  • start_index (int, default: 0 ) –

    absolute index of the first returned sample

  • count (int | None, default: None ) –

    number of samples, or None for duration less start_index

  • xp (ModuleType, default: np ) –

    the array namespace of the returned array

  • dtype (DTypeLike, default: 'complex64' ) –

    the returned complex dtype

Returns:

  • Array –

    an array of shape (ports, count) and dtype dtype in the namespace xp

Raises:

  • ValueError –

    when period is not positive, when ports is below 1, when duration and count are both None, or when the resolved count is negative

single_tone

single_tone(
    duration: float | None,
    sample_rate: float,
    *,
    frequency_offset: float = 0.0,
    snr: float | None = None,
    lo_offset: float = 0.0,
    ports: int = 1,
    start_index: int = 0,
    count: int | None = None,
    seed: int = 0,
    xp: ModuleType = np,
    dtype: DTypeLike = 'complex64',
) -> Array

generate a unit-amplitude tone with an LO shift and optional additive noise.

The tone is tone at the sum of frequency_offset and lo_offset, with unit amplitude and zero phase at absolute sample index 0. When snr is set, circular_awgn is added at a total power snr dB below the tone mean power of 1. Every port has the same tone and independent noise.

Parameters:

  • duration (float | None) –

    capture duration, in s, used only when count is None

  • sample_rate (float) –

    IQ sample rate, in Hz

  • frequency_offset (float, default: 0.0 ) –

    tone frequency, in Hz relative to the center frequency

  • snr (float | None, default: None ) –

    ratio of the tone power to the noise power, in dB, or None for no noise

  • lo_offset (float, default: 0.0 ) –

    a second frequency shift, in Hz, added to frequency_offset

  • ports (int, default: 1 ) –

    number of receive ports

  • start_index (int, default: 0 ) –

    absolute index of the first returned sample

  • count (int | None, default: None ) –

    number of samples, or None for duration less start_index

  • seed (int, default: 0 ) –

    seed of the noise generator, in [0, 2**31)

  • xp (ModuleType, default: np ) –

    the array namespace of the returned array

  • dtype (DTypeLike, default: 'complex64' ) –

    the returned complex dtype

Returns:

  • Array –

    an array of shape (ports, count) and dtype dtype in the namespace xp

Raises:

  • ValueError –

    when ports is below 1, when duration and count are both None, or when the resolved count is negative

tone

tone(
    duration: float | None,
    sample_rate: float,
    *,
    frequency: float = 0.0,
    ports: int = 1,
    start_index: int = 0,
    count: int | None = None,
    xp: ModuleType = np,
    dtype: DTypeLike = 'complex64',
) -> Array

generate a unit-amplitude complex tone at frequency.

The phase is zero at absolute sample index 0 regardless of start_index, and advances frequency cycles per second. The mean power is 1.

Parameters:

  • duration (float | None) –

    capture duration, in s, used only when count is None

  • sample_rate (float) –

    IQ sample rate, in Hz

  • frequency (float, default: 0.0 ) –

    tone frequency, in Hz relative to the center frequency

  • ports (int, default: 1 ) –

    number of receive ports, with the same samples on every port

  • start_index (int, default: 0 ) –

    absolute index of the first returned sample

  • count (int | None, default: None ) –

    number of samples, or None for duration less start_index

  • xp (ModuleType, default: np ) –

    the array namespace of the returned array

  • dtype (DTypeLike, default: 'complex64' ) –

    the returned complex dtype

Returns:

  • Array –

    an array of shape (ports, count) and dtype dtype in the namespace xp

Raises:

  • ValueError –

    when ports is below 1, when duration and count are both None, or when the resolved count is negative