| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "markdown", |
| 5 |
"metadata": {}, |
| 6 |
"source": [ |
| 7 |
"# TwoPortOnePath, EnhancedResponse, and FakeFlip" |
| 8 |
] |
| 9 |
}, |
| 10 |
{ |
| 11 |
"cell_type": "markdown", |
| 12 |
"metadata": {}, |
| 13 |
"source": [ |
| 14 |
"## Intro" |
| 15 |
] |
| 16 |
}, |
| 17 |
{ |
| 18 |
"cell_type": "markdown", |
| 19 |
"metadata": {}, |
| 20 |
"source": [ |
| 21 |
"This example demonstrates a macgyver-ish shortcut you can take if you are measuring a device that is ** reciprocal** and **symmetric** on a switch-less three-receiver system. For more information about error correction this type of architecture, see [Calibration With Three Receivers](Calibration With Three Receivers.ipynb).\n", |
| 22 |
"\n", |
| 23 |
"In general, full error correction of a 2-port network on a switchless three-receiver architecture requires each DUT to measured in two orientations. However, if the DUT is known to be reciprocal ($S_{21}=S_{12}$) and symmetric ($S_{11}=S_{22}$), then measurements in both orientations produce the same response, and therefore are unnecessary.\n", |
| 24 |
"\n", |
| 25 |
"The following worked example compares the corrected response of a 10dB attenuator at WR-12 as corrected using full error correction and pseudo-full error correction using:\n", |
| 26 |
"\n", |
| 27 |
"1. Full Correction\n", |
| 28 |
"2. Pseudo-Full Correction (FakeFlip)\n", |
| 29 |
"3. Partial (EnhancedResponse)\n", |
| 30 |
"\n", |
| 31 |
"\n" |
| 32 |
] |
| 33 |
}, |
| 34 |
{ |
| 35 |
"cell_type": "code", |
| 36 |
"execution_count": null, |
| 37 |
"metadata": {}, |
| 38 |
"outputs": [], |
| 39 |
"source": [ |
| 40 |
"from IPython.display import Image\n", |
| 41 |
"\n", |
| 42 |
"Image('three_receiver_cal/pics/macgyver.jpg', width='50%')" |
| 43 |
] |
| 44 |
}, |
| 45 |
{ |
| 46 |
"cell_type": "markdown", |
| 47 |
"metadata": {}, |
| 48 |
"source": [ |
| 49 |
"## Example" |
| 50 |
] |
| 51 |
}, |
| 52 |
{ |
| 53 |
"cell_type": "markdown", |
| 54 |
"metadata": {}, |
| 55 |
"source": [ |
| 56 |
"These measurements where taken on a Agilent PNAX with a set of VDI WR-12 TXRX-RX Frequency Extender heads. The measurements of the calibration standards and DUT's were downloaded from the VNA by saving touchstone files of the raw s-parameter data to disk. \n", |
| 57 |
"\n", |
| 58 |
"In the code that follows a TwoPortOnePath calibration is created from corresponding measured and ideal responses of the calibration standards. The measured networks are read from disk, while their corresponding ideal responses are generated using scikit-rf. More information about using scikit-rf to do offline calibrations can be found [here](../../tutorials/Calibration.ipynb). " |
| 59 |
] |
| 60 |
}, |
| 61 |
{ |
| 62 |
"cell_type": "code", |
| 63 |
"execution_count": null, |
| 64 |
"metadata": {}, |
| 65 |
"outputs": [], |
| 66 |
"source": [ |
| 67 |
"import matplotlib.pyplot as plt\n", |
| 68 |
"\n", |
| 69 |
"import skrf as rf\n", |
| 70 |
"\n", |
| 71 |
"%matplotlib inline\n", |
| 72 |
"\n", |
| 73 |
"from skrf import mil\n", |
| 74 |
"from skrf import two_port_reflect as tpr\n", |
| 75 |
"from skrf.calibration import TwoPortOnePath\n", |
| 76 |
"from skrf.media import RectangularWaveguide\n", |
| 77 |
"\n", |
| 78 |
"rf.stylely()\n", |
| 79 |
"\n", |
| 80 |
"raw = rf.read_all_networks('three_receiver_cal/data/')\n", |
| 81 |
"\n", |
| 82 |
"\n", |
| 83 |
"\n", |
| 84 |
"# pull frequency information from measurements\n", |
| 85 |
"frequency = raw['short'].frequency\n", |
| 86 |
"\n", |
| 87 |
"# the media object\n", |
| 88 |
"wg = RectangularWaveguide(frequency=frequency, a=120*mil, z0_override=50)\n", |
| 89 |
"\n", |
| 90 |
"# list of 'ideal' responses of the calibration standards\n", |
| 91 |
"ideals = [wg.short(nports=2),\n", |
| 92 |
" tpr(wg.delay_short( 90,'deg'), wg.match()),\n", |
| 93 |
" wg.match(nports=2),\n", |
| 94 |
" wg.thru()]\n", |
| 95 |
"\n", |
| 96 |
"# corresponding measurements to the 'ideals'\n", |
| 97 |
"measured = [raw['short'],\n", |
| 98 |
" raw['quarter wave delay short'],\n", |
| 99 |
" raw['load'],\n", |
| 100 |
" raw['thru']]\n", |
| 101 |
"\n", |
| 102 |
"# the Calibration object\n", |
| 103 |
"cal = TwoPortOnePath(measured = measured, ideals = ideals )" |
| 104 |
] |
| 105 |
}, |
| 106 |
{ |
| 107 |
"cell_type": "markdown", |
| 108 |
"metadata": {}, |
| 109 |
"source": [ |
| 110 |
"## Correction Options" |
| 111 |
] |
| 112 |
}, |
| 113 |
{ |
| 114 |
"cell_type": "markdown", |
| 115 |
"metadata": {}, |
| 116 |
"source": [ |
| 117 |
"With the calibration created above, we compare the corrected response of WR-12 10dB attenuator using **Full**, **Pseudo-Full**, and **Partial** Correction. Each correction algorithm is described below. \n" |
| 118 |
] |
| 119 |
}, |
| 120 |
{ |
| 121 |
"cell_type": "code", |
| 122 |
"execution_count": null, |
| 123 |
"metadata": {}, |
| 124 |
"outputs": [], |
| 125 |
"source": [ |
| 126 |
"Image('three_receiver_cal/pics/symmetric DUT.jpg', width='75%')" |
| 127 |
] |
| 128 |
}, |
| 129 |
{ |
| 130 |
"cell_type": "markdown", |
| 131 |
"metadata": {}, |
| 132 |
"source": [ |
| 133 |
"### Full Correction (TwoPortOnePath)" |
| 134 |
] |
| 135 |
}, |
| 136 |
{ |
| 137 |
"cell_type": "markdown", |
| 138 |
"metadata": {}, |
| 139 |
"source": [ |
| 140 |
"Full correction on this type of architecture has been called *TwoPortOnePath*. In `scikit-rf` using this correction algorithm requires the device to be measured in both orientations, **forward** and **reverse**, and passing them both to the `apply_cal()` function as a `tuple`. Neglecting the connector uncertainty, this type of correction is identical to full two-port **SOLT** calibration." |
| 141 |
] |
| 142 |
}, |
| 143 |
{ |
| 144 |
"cell_type": "markdown", |
| 145 |
"metadata": {}, |
| 146 |
"source": [ |
| 147 |
"### Pseudo-full Correction ( FakeFlip)" |
| 148 |
] |
| 149 |
}, |
| 150 |
{ |
| 151 |
"cell_type": "markdown", |
| 152 |
"metadata": {}, |
| 153 |
"source": [ |
| 154 |
"If we assume the DUT is **reciprocal** and **symmetric**, then measuring the device in both orientations will produce the same result. Therefore, the reverse orientation measurement may be replaced by a copy of the forward orientation measurement. We refer to this technique as the *Fake Flip*. " |
| 155 |
] |
| 156 |
}, |
| 157 |
{ |
| 158 |
"cell_type": "markdown", |
| 159 |
"metadata": {}, |
| 160 |
"source": [ |
| 161 |
"<div class=\"alert \">\n", |
| 162 |
"**Warning**: \n", |
| 163 |
"Be sure that you understand the assumptions of reciprocity and symmetry before using this macgyver technique, incorrect usage can lead to nonsense results.\n", |
| 164 |
"</div>\n" |
| 165 |
] |
| 166 |
}, |
| 167 |
{ |
| 168 |
"cell_type": "markdown", |
| 169 |
"metadata": {}, |
| 170 |
"source": [ |
| 171 |
"### Partial Correction (EnhancedResponse)" |
| 172 |
] |
| 173 |
}, |
| 174 |
{ |
| 175 |
"cell_type": "markdown", |
| 176 |
"metadata": {}, |
| 177 |
"source": [ |
| 178 |
"If you pass a single measurement to the `apply_cal()` function, then the calibration will employ partial correction. This type of correction is known as `EnhancedResponse`. While the *Fake Flip* technique assumes the device is reciprocal and symmetric, the `EnhancedResponse` algorithm *implicitly* assumes that the port 2 of the device is perfectly matched. The accuracy of the corrected result produced with either of these algorithms depends on accuracy of the assumptions. " |
| 179 |
] |
| 180 |
}, |
| 181 |
{ |
| 182 |
"cell_type": "markdown", |
| 183 |
"metadata": {}, |
| 184 |
"source": [ |
| 185 |
"## Comparison" |
| 186 |
] |
| 187 |
}, |
| 188 |
{ |
| 189 |
"cell_type": "code", |
| 190 |
"execution_count": null, |
| 191 |
"metadata": {}, |
| 192 |
"outputs": [], |
| 193 |
"source": [ |
| 194 |
"dutf = raw['attenuator (forward)']\n", |
| 195 |
"dutr = raw['attenuator (reverse)']\n", |
| 196 |
"\n", |
| 197 |
"\n", |
| 198 |
"# note the correction algorithm is different depending on what is passed to\n", |
| 199 |
"# apply_cal\n", |
| 200 |
"corrected_full = cal.apply_cal((dutf, dutr))\n", |
| 201 |
"corrected_fakeflip = cal.apply_cal((dutf,dutf))\n", |
| 202 |
"corrected_partial = cal.apply_cal(dutf)\n", |
| 203 |
"\n", |
| 204 |
"\n", |
| 205 |
"\n", |
| 206 |
"f, ax = plt.subplots(2,2, figsize=(8,8))\n", |
| 207 |
"\n", |
| 208 |
"for m in [0,1]:\n", |
| 209 |
" for n in [0,1]:\n", |
| 210 |
" ax_ = ax[m,n]\n", |
| 211 |
" ax_.set_title('$S_{%i%i}$'%(m+1,n+1))\n", |
| 212 |
" corrected_full.plot_s_db(m,n, label='Full Correction',ax=ax_ )\n", |
| 213 |
" corrected_fakeflip.plot_s_db(m,n, label='Pseudo-full Correction', ax=ax_)\n", |
| 214 |
" if n==0:\n", |
| 215 |
" corrected_partial.plot_s_db(m,n, label='Partial Correction', ax=ax_)\n", |
| 216 |
"\n", |
| 217 |
"\n", |
| 218 |
"plt.tight_layout()" |
| 219 |
] |
| 220 |
}, |
| 221 |
{ |
| 222 |
"cell_type": "code", |
| 223 |
"execution_count": null, |
| 224 |
"metadata": {}, |
| 225 |
"outputs": [], |
| 226 |
"source": [] |
| 227 |
} |
| 228 |
], |
| 229 |
"metadata": { |
| 230 |
"anaconda-cloud": {}, |
| 231 |
"kernelspec": { |
| 232 |
"display_name": "Python 3 (ipykernel)", |
| 233 |
"language": "python", |
| 234 |
"name": "python3" |
| 235 |
}, |
| 236 |
"language_info": { |
| 237 |
"codemirror_mode": { |
| 238 |
"name": "ipython", |
| 239 |
"version": 3 |
| 240 |
}, |
| 241 |
"file_extension": ".py", |
| 242 |
"mimetype": "text/x-python", |
| 243 |
"name": "python", |
| 244 |
"nbconvert_exporter": "python", |
| 245 |
"pygments_lexer": "ipython3", |
| 246 |
"version": "3.8.10" |
| 247 |
} |
| 248 |
}, |
| 249 |
"nbformat": 4, |
| 250 |
"nbformat_minor": 1 |
| 251 |
} |