Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iq_imbalance: dc offset is not calculated properly #229

Open
nalexandros opened this issue Feb 20, 2024 · 0 comments
Open

iq_imbalance: dc offset is not calculated properly #229

nalexandros opened this issue Feb 20, 2024 · 0 comments
Assignees

Comments

@nalexandros
Copy link

Describe the bug
IQ Imbalance considers that the hardware has non-idealities and that the in-phase and quadrature are not perfectly
aligned. As a result, the IQ data will have slightly different amplitude, phase and dc-offset.

Problem description:
By setting to zero the amplitude_imbalance_db and the phase_imbalance we can isolate the effect of the dc_offset_db.
The expectation is that the constellation diagram will be moved to a different location, while keeping the scaling,
rotation and shape. However, this is not the case as is shown in iq_imbalance.png. Instead the data are scaled in
a similar manner as with amplitude imbalance.

Solution:
The function iq_imbalance_fixed modifies a couple of lines. The resulting plot (iq_imbalance.png) shows that the
IQ data have been shifted as expected.

To Reproduce
to_torchsig_debug_iq_imbalance.zip

Use the Python code and the *.npy file to reproduce the bug and get the bugfix.

Expected behavior
The IQ data must be shifted, not scaled, as seen in the picture.

def iq_imbalance_fixed(
    iq: np.ndarray,
    amplitude_imbalance_db: float,
    phase_imbalance: float,
    dc_offset_db: float,
) -> np.ndarray:
    amplitude_imbalance_linear = 10 ** (amplitude_imbalance_db / 10.0)
    iq_transformed = (amplitude_imbalance_linear * iq.real + 1j * amplitude_imbalance_linear * iq.imag)

    iq_transformed = (np.exp(-1j * phase_imbalance / 2.0) * iq_transformed.real +
                      np.exp(1j * (np.pi / 2.0 + phase_imbalance / 2.0)) * iq_transformed.imag)

    dc_offset_linear = 10 ** (dc_offset_db / 10.0)
    dc_offset_linear_complex = dc_offset_linear + 1j * dc_offset_linear
    iq_transformed += dc_offset_linear_complex
    return iq_transformed
@TorchDSP TorchDSP self-assigned this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants