<?xml version="1.0"?>
<!--
###################################################
##IQ Imbalance Generator
###################################################
 -->
<block>
  <name>IQ Imbalance Generator</name>
  <key>channels_iqbal_gen</key>
  <import>from gnuradio import channels</import>
  <make>channels.iqbal_gen($mag, $phase, $mode)</make>
  <callback>set_magnitude($mag)</callback>
  <callback>set_phase($phase)</callback>
  <param>
    <name>Magnitude</name>
    <key>mag</key>
    <value>0</value>
    <type>float</type>
  </param>
  <param>
    <name>Phase</name>
    <key>phase</key>
    <value>0</value>
    <type>float</type>
  </param>
  <param>
    <name>Origin</name>
    <key>mode</key>
    <value>0</value>
    <type>enum</type>
		<option>
			<name>Reciever</name>
			<key>1</key>
		</option>
		<option>
			<name>Transmitter</name>
			<key>0</key>
		</option>
  </param>
  <sink>
    <name>in</name>
    <type>complex</type>
  </sink>
  <source>
    <name>out</name>
    <type>complex</type>
  </source>
  <doc>
This block implements the single branch IQ imbalance
transmitter and receiver models.

Developed from source (2014):
"In-Phase and Quadrature Imbalance: Modeling, Estimation, and Compensation"

    TX Impairment:
                                      
                                                        {R}--|Multiply: 10**(mag/20)|--+--|Multiply: cos(pi*degree/180)|--X1
Input ---|Complex2Float|---|                                                               |--|Multiply: sin(pi*degree/180)|--X2
                                                        {I}--|   Adder  |
                                                       X2--|       (+)      |--X3

                          X1--{R}--| Float 2     |--- Output
                          X3---{I}--| Complex |

    RX Impairment:
                                      
                                                        {R}--|Multiply: cos(pi*degree/180)|-------|               |
Input ---|Complex2Float|---|                                                                                  | Adder |--X1
                                                         {I}--+--|Multiply: sin(pi*degree/180)|----|     (+)      |
                                                                 |
                                                                 +--X2

                        X1--|Multply: 10**(mag/20)|--{R}--| Float 2     |--- Output
                        X2--------------------------------------------{I}--| Complex |

    (ASCII ART adjusted for GRC viewing)

  </doc>
</block>
