Signal Processing¶
- genalyzer.downsample(a, ratio, interleaved=False)¶
Decimate a waveform by keeping every Nth sample.
Keeps every ratio-th sample from the input. If interleaved is True, the input is treated as interleaved I/Q pairs and decimation preserves pair alignment.
- Args:
a(ndarray) : Input array of typecomplex128,float64,int16,int32, orint64ratio(int) : Decimation ratio (keep every Nth sample)interleaved(bool) : If True, treataas interleaved I/Q data- Returns:
out(ndarray) : Downsampled waveform with same dtype as input
- genalyzer.fshift(a, *args)¶
Perform frequency shift
- Args:
a(ndarray) : Input array of typecomplex128,float64,int16,int32, orint64args(list)Additional argumentsIf
ais of typecomplex128orfloat64, then perform frequency shift of interleaved normalized samples with the following interpretation.fs(double) : Sample ratefshift_(double) : Shift frequencyIn this case, if
ais not complex, then a is interpreted to contain interleaved I/Q samples.If
ais of typefloat64, then perform frequency shift of split normalized samples.q(float64) : Quadrature componentfs(double) : Sample ratefshift_(double) : Shift frequencyIn this case,
ais interpreted to be the In-phase component.If
ais of typeint16,int32, orint64, then perform frequency shift of interleaved quantized samples with the following interpretation.n(int) : Resolution (Bitwidth of a)fs(double) : Sample ratefshift_(double) : Shift frequencyfmt(CodeFormat): Code formatIn this case,
ais interpreted to contain interleaved quantized samples.If
ais of typeint16,int32, orint64, then perform frequency shift of split quantized samples with the following interpretation.q(int16,int32, orint64) : Quadrature componentn(int) : Resolution (Bitwidth ofa)fs(double) : Sample ratefshift_(double) : Shift frequencyfmt(CodeFormat): Code formatIn this case,
ais interpreted to to be the In-phase component.
- Returns:
out(ndarray) : Frequency-shifted input waveform. The output datatype is the same as the input datatype.
- genalyzer.normalize(a, n, fmt=CodeFormat.TWOS_COMPLEMENT)¶
Convert quantized integer samples to normalized floating-point values in [-1, 1).
For two’s complement, scales by 2/2^n. For offset binary, subtracts the midpoint offset before scaling.
- Args:
a(ndarray) : Input array of typeint16,int32, orint64n(int) : ADC resolution in bitsfmt(CodeFormat) : Binary code format (default: TWOS_COMPLEMENT)- Returns:
out(ndarray) :float64array of normalized values in [-1, 1)
- genalyzer.polyval(a, c)¶
Evaluate a polynomial at each element of the input array using Horner’s method.
Coefficients are ordered as [c0, c1, c2, …] where y = c0 + c1*x + c2*x^2 + … Commonly used to model nonlinear transfer function distortion.
- Args:
a(ndarray) : Input array of typefloat64c(ndarrayorlist) : Polynomial coefficients [c0, c1, c2, …] of typefloat64- Returns:
out(ndarray) :float64array of polynomial evaluation results
- genalyzer.quantize16(a, fsr, n, noise=0.0, fmt=CodeFormat.TWOS_COMPLEMENT)¶
Quantize floating-point samples to 16-bit integer codes.
The full-scale range determines the LSB size: LSB = fsr / 2^n. Samples are mapped to codes by floor(sample/LSB), clamped to the valid code range. Optional Gaussian noise can be added before quantization to model thermal noise.
- Args:
a(ndarray) : Input array of typefloat64fsr(float) : Full-scale range of the waveformn(int) : ADC resolution in bitsnoise(float) : RMS level of Gaussian noise to add before quantization (default: 0.0)fmt(CodeFormat) : Binary code format (default: TWOS_COMPLEMENT)- Returns:
out(ndarray) :int16array of quantized codes
- genalyzer.quantize32(a, fsr, n, noise=0.0, fmt=CodeFormat.TWOS_COMPLEMENT)¶
Quantize floating-point samples to 32-bit integer codes.
The full-scale range determines the LSB size: LSB = fsr / 2^n. Samples are mapped to codes by floor(sample/LSB), clamped to the valid code range. Optional Gaussian noise can be added before quantization to model thermal noise.
- Args:
a(ndarray) : Input array of typefloat64fsr(float) : Full-scale range of the waveformn(int) : ADC resolution in bitsnoise(float) : RMS level of Gaussian noise to add before quantization (default: 0.0)fmt(CodeFormat) : Binary code format (default: TWOS_COMPLEMENT)- Returns:
out(ndarray) :int32array of quantized codes
- genalyzer.quantize64(a, fsr, n, noise=0.0, fmt=CodeFormat.TWOS_COMPLEMENT)¶
Quantize floating-point samples to 64-bit integer codes.
The full-scale range determines the LSB size: LSB = fsr / 2^n. Samples are mapped to codes by floor(sample/LSB), clamped to the valid code range. Optional Gaussian noise can be added before quantization to model thermal noise.
- Args:
a(ndarray) : Input array of typefloat64fsr(float) : Full-scale range of the waveformn(int) : ADC resolution in bitsnoise(float) : RMS level of Gaussian noise to add before quantization (default: 0.0)fmt(CodeFormat) : Binary code format (default: TWOS_COMPLEMENT)- Returns:
out(ndarray) :int64array of quantized codes
- genalyzer.quantize(a, fsr, n, noise=0.0, fmt=CodeFormat.TWOS_COMPLEMENT)¶
Quantize floating-point samples to integer codes with automatic bit-width selection.
Selects
int16output if n <= 16 (two’s complement) or n < 16 (offset binary), andint32otherwise. Seequantize16andquantize32for details.- Args:
a(ndarray) : Input array of typefloat64fsr(float) : Full-scale range of the waveformn(int) : ADC resolution in bitsnoise(float) : RMS level of Gaussian noise to add before quantization (default: 0.0)fmt(CodeFormat) : Binary code format (default: TWOS_COMPLEMENT)- Returns:
out(ndarray) :int16orint32array of quantized codes