| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "raw", |
| 5 |
"metadata": { |
| 6 |
"raw_mimetype": "text/restructuredtext" |
| 7 |
}, |
| 8 |
"source": [ |
| 9 |
".. _introduction:\n", |
| 10 |
"\n", |
| 11 |
"|\n", |
| 12 |
"|\n", |
| 13 |
"\n", |
| 14 |
"Download This Notebook: :download:`Introduction.ipynb`" |
| 15 |
] |
| 16 |
}, |
| 17 |
{ |
| 18 |
"cell_type": "markdown", |
| 19 |
"metadata": {}, |
| 20 |
"source": [ |
| 21 |
"# Introduction" |
| 22 |
] |
| 23 |
}, |
| 24 |
{ |
| 25 |
"cell_type": "markdown", |
| 26 |
"metadata": {}, |
| 27 |
"source": [ |
| 28 |
"This is a brief introduction to **scikit-rf** (aka `skrf`). The intended audience are those who have a working python stack, and are somewhat familiar with python. If you are completely new to python, see scipy's [Getting Started](http://www.scipy.org/Getting_Started). First, import the scikit-rf module `skrf`, as `rf`" |
| 29 |
] |
| 30 |
}, |
| 31 |
{ |
| 32 |
"cell_type": "code", |
| 33 |
"execution_count": null, |
| 34 |
"metadata": {}, |
| 35 |
"outputs": [], |
| 36 |
"source": [ |
| 37 |
"import skrf as rf" |
| 38 |
] |
| 39 |
}, |
| 40 |
{ |
| 41 |
"cell_type": "markdown", |
| 42 |
"metadata": {}, |
| 43 |
"source": [ |
| 44 |
"If this produces an error, please see the [installation](Installation.ipynb) tutorial." |
| 45 |
] |
| 46 |
}, |
| 47 |
{ |
| 48 |
"cell_type": "markdown", |
| 49 |
"metadata": {}, |
| 50 |
"source": [ |
| 51 |
"## Networks" |
| 52 |
] |
| 53 |
}, |
| 54 |
{ |
| 55 |
"cell_type": "markdown", |
| 56 |
"metadata": {}, |
| 57 |
"source": [ |
| 58 |
"The central object in `skrf` is a N-port microwave [Network][Network] object. A [Network][Network] can be created in a number of ways, one way is from data stored in a touchstone file.\n", |
| 59 |
"\n", |
| 60 |
"[Network]: ../api/network.rst" |
| 61 |
] |
| 62 |
}, |
| 63 |
{ |
| 64 |
"cell_type": "code", |
| 65 |
"execution_count": null, |
| 66 |
"metadata": {}, |
| 67 |
"outputs": [], |
| 68 |
"source": [ |
| 69 |
"ring_slot = rf.Network('data/ring slot.s2p')" |
| 70 |
] |
| 71 |
}, |
| 72 |
{ |
| 73 |
"cell_type": "markdown", |
| 74 |
"metadata": {}, |
| 75 |
"source": [ |
| 76 |
"If you can't find `ring slot.s2p`, then just import it from the `skrf.data` module. \n" |
| 77 |
] |
| 78 |
}, |
| 79 |
{ |
| 80 |
"cell_type": "code", |
| 81 |
"execution_count": null, |
| 82 |
"metadata": {}, |
| 83 |
"outputs": [], |
| 84 |
"source": [ |
| 85 |
"from skrf.data import ring_slot # noqa: F811" |
| 86 |
] |
| 87 |
}, |
| 88 |
{ |
| 89 |
"cell_type": "markdown", |
| 90 |
"metadata": {}, |
| 91 |
"source": [ |
| 92 |
"A short description of the network will be printed out if entered onto the command line" |
| 93 |
] |
| 94 |
}, |
| 95 |
{ |
| 96 |
"cell_type": "code", |
| 97 |
"execution_count": null, |
| 98 |
"metadata": {}, |
| 99 |
"outputs": [], |
| 100 |
"source": [ |
| 101 |
"ring_slot" |
| 102 |
] |
| 103 |
}, |
| 104 |
{ |
| 105 |
"cell_type": "markdown", |
| 106 |
"metadata": {}, |
| 107 |
"source": [ |
| 108 |
"The basic attributes of a microwave [Network](../api/network.rst) are provided by the \n", |
| 109 |
"following properties,\n", |
| 110 |
"\n", |
| 111 |
"\n", |
| 112 |
"* `Network.s` : Scattering Parameter matrix. \n", |
| 113 |
"* `Network.z0` : Port Impedance matrix.\n", |
| 114 |
"* `Network.frequency` : Frequency Object. " |
| 115 |
] |
| 116 |
}, |
| 117 |
{ |
| 118 |
"cell_type": "markdown", |
| 119 |
"metadata": {}, |
| 120 |
"source": [ |
| 121 |
" The [Network](../api/network.rst) object has numerous other properties and methods which can found in it's docstring. If you are using IPython/Jupyter, then these properties and methods can be 'tabbed' out on the command line. \n", |
| 122 |
"\n", |
| 123 |
"\n", |
| 124 |
"\tIn [1]: ring_slot.s<TAB>\n", |
| 125 |
"\tring_slot.s ring_slot.s_arcl ring_slot.s_im\n", |
| 126 |
"\tring_slot.s11 ring_slot.s_arcl_unwrap ring_slot.s_mag\n", |
| 127 |
"\t..." |
| 128 |
] |
| 129 |
}, |
| 130 |
{ |
| 131 |
"cell_type": "markdown", |
| 132 |
"metadata": {}, |
| 133 |
"source": [ |
| 134 |
"Other way to build Network are detailed in the [tutorial on Networks](Networks.ipynb)." |
| 135 |
] |
| 136 |
}, |
| 137 |
{ |
| 138 |
"cell_type": "markdown", |
| 139 |
"metadata": {}, |
| 140 |
"source": [ |
| 141 |
"### Linear Operations " |
| 142 |
] |
| 143 |
}, |
| 144 |
{ |
| 145 |
"cell_type": "markdown", |
| 146 |
"metadata": {}, |
| 147 |
"source": [ |
| 148 |
"\t\n", |
| 149 |
"Element-wise mathematical operations on the s-parameters are accessible through overloaded operators. To illustrate, we load a couple `Networks` stored in the `skrf.data` module. " |
| 150 |
] |
| 151 |
}, |
| 152 |
{ |
| 153 |
"cell_type": "code", |
| 154 |
"execution_count": null, |
| 155 |
"metadata": {}, |
| 156 |
"outputs": [], |
| 157 |
"source": [ |
| 158 |
"short = rf.data.wr2p2_short\n", |
| 159 |
"delayshort = rf.data.wr2p2_delayshort" |
| 160 |
] |
| 161 |
}, |
| 162 |
{ |
| 163 |
"cell_type": "markdown", |
| 164 |
"metadata": {}, |
| 165 |
"source": [ |
| 166 |
"The complex difference between their s-parameters is computed with " |
| 167 |
] |
| 168 |
}, |
| 169 |
{ |
| 170 |
"cell_type": "code", |
| 171 |
"execution_count": null, |
| 172 |
"metadata": {}, |
| 173 |
"outputs": [], |
| 174 |
"source": [ |
| 175 |
"short - delayshort" |
| 176 |
] |
| 177 |
}, |
| 178 |
{ |
| 179 |
"cell_type": "markdown", |
| 180 |
"metadata": {}, |
| 181 |
"source": [ |
| 182 |
"This returns a new [Network](../api/network.rst). Other arithmetic operators are overloaded as well," |
| 183 |
] |
| 184 |
}, |
| 185 |
{ |
| 186 |
"cell_type": "code", |
| 187 |
"execution_count": null, |
| 188 |
"metadata": {}, |
| 189 |
"outputs": [], |
| 190 |
"source": [ |
| 191 |
"short/delayshort" |
| 192 |
] |
| 193 |
}, |
| 194 |
{ |
| 195 |
"cell_type": "markdown", |
| 196 |
"metadata": {}, |
| 197 |
"source": [ |
| 198 |
"### Cascading and De-embedding" |
| 199 |
] |
| 200 |
}, |
| 201 |
{ |
| 202 |
"cell_type": "markdown", |
| 203 |
"metadata": {}, |
| 204 |
"source": [ |
| 205 |
"Cascading and de-embeding 2-port Networks can also be done though operators. Cascading is done through the power operator, ``**``. " |
| 206 |
] |
| 207 |
}, |
| 208 |
{ |
| 209 |
"cell_type": "code", |
| 210 |
"execution_count": null, |
| 211 |
"metadata": {}, |
| 212 |
"outputs": [], |
| 213 |
"source": [ |
| 214 |
"short = rf.data.wr2p2_short\n", |
| 215 |
"line = rf.data.wr2p2_line\n", |
| 216 |
"\n", |
| 217 |
"delayshort = line ** short" |
| 218 |
] |
| 219 |
}, |
| 220 |
{ |
| 221 |
"cell_type": "markdown", |
| 222 |
"metadata": {}, |
| 223 |
"source": [ |
| 224 |
"De-embedding can be accomplished by cascading the *inverse* of a network. The inverse of a network is accessed through the property `Network.inv`. " |
| 225 |
] |
| 226 |
}, |
| 227 |
{ |
| 228 |
"cell_type": "code", |
| 229 |
"execution_count": null, |
| 230 |
"metadata": {}, |
| 231 |
"outputs": [], |
| 232 |
"source": [ |
| 233 |
"short = line.inv ** delayshort" |
| 234 |
] |
| 235 |
}, |
| 236 |
{ |
| 237 |
"cell_type": "markdown", |
| 238 |
"metadata": {}, |
| 239 |
"source": [ |
| 240 |
"For more information on the functionality provided by the [Network](../api/network.rst) object, such as interpolation, stitching, n-port connections, and IO support see the [Networks](Networks.ipynb) tutorial." |
| 241 |
] |
| 242 |
}, |
| 243 |
{ |
| 244 |
"cell_type": "markdown", |
| 245 |
"metadata": {}, |
| 246 |
"source": [ |
| 247 |
"### Finding minimum (or maximum) of a Network quantity\n", |
| 248 |
"Often, it is desirable to get the minimum (or maximum) value of a Network quantity (s-parameters, z-parameters, etc.) and the frequency at which this occurs. In `scikit-rf`, Network quantities are stored as [Numpy](https://numpy.org/) arrays of shape ($N_F$, $N_p$, $N_p$) where $N_F$ is the number of frequency points and $N_p$ is the number of ports of a Network:" |
| 249 |
] |
| 250 |
}, |
| 251 |
{ |
| 252 |
"cell_type": "code", |
| 253 |
"execution_count": null, |
| 254 |
"metadata": {}, |
| 255 |
"outputs": [], |
| 256 |
"source": [ |
| 257 |
"print(type(line.s)) # s-parameters are stored as a Numpy array" |
| 258 |
] |
| 259 |
}, |
| 260 |
{ |
| 261 |
"cell_type": "code", |
| 262 |
"execution_count": null, |
| 263 |
"metadata": {}, |
| 264 |
"outputs": [], |
| 265 |
"source": [ |
| 266 |
"print(line.s.shape) # line is a 2-port Network defined on 201 frequency points" |
| 267 |
] |
| 268 |
}, |
| 269 |
{ |
| 270 |
"cell_type": "markdown", |
| 271 |
"metadata": {}, |
| 272 |
"source": [ |
| 273 |
"The frequency points are defined in the `frequency` parameter of a Network:" |
| 274 |
] |
| 275 |
}, |
| 276 |
{ |
| 277 |
"cell_type": "code", |
| 278 |
"execution_count": null, |
| 279 |
"metadata": {}, |
| 280 |
"outputs": [], |
| 281 |
"source": [ |
| 282 |
"print(line.frequency) # returns a Frequency object" |
| 283 |
] |
| 284 |
}, |
| 285 |
{ |
| 286 |
"cell_type": "markdown", |
| 287 |
"metadata": {}, |
| 288 |
"source": [ |
| 289 |
"The frequency values are given by the `frequency.f` parameter, or simply `.f`:" |
| 290 |
] |
| 291 |
}, |
| 292 |
{ |
| 293 |
"cell_type": "code", |
| 294 |
"execution_count": null, |
| 295 |
"metadata": {}, |
| 296 |
"outputs": [], |
| 297 |
"source": [ |
| 298 |
"line.f[0:10] # the 10 first frequency points. Same than line.frequency.f[0:10]" |
| 299 |
] |
| 300 |
}, |
| 301 |
{ |
| 302 |
"cell_type": "markdown", |
| 303 |
"metadata": {}, |
| 304 |
"source": [ |
| 305 |
"Being a Numpy array, finding the minimum (or maximum) value of a the magnitude of the $S_{21}$ parameter can be performed using the `min()` (or `max()`) method:" |
| 306 |
] |
| 307 |
}, |
| 308 |
{ |
| 309 |
"cell_type": "code", |
| 310 |
"execution_count": null, |
| 311 |
"metadata": {}, |
| 312 |
"outputs": [], |
| 313 |
"source": [ |
| 314 |
"import numpy as np\n", |
| 315 |
"\n", |
| 316 |
"rs = rf.data.ring_slot # another 2-port example\n", |
| 317 |
"\n", |
| 318 |
"print(rs.s_mag[:,1,0].min()) # or .max() for maximum. Watch out that Python indexing starts at 0!" |
| 319 |
] |
| 320 |
}, |
| 321 |
{ |
| 322 |
"cell_type": "markdown", |
| 323 |
"metadata": {}, |
| 324 |
"source": [ |
| 325 |
"Finding the frequency at which the magnitude of the $S_{11}$ parameter is minimum can be performed using the Numpy function [`argmin`](https://numpy.org/doc/stable/reference/generated/numpy.argmin.html?highlight=argmin#numpy.argmin):" |
| 326 |
] |
| 327 |
}, |
| 328 |
{ |
| 329 |
"cell_type": "code", |
| 330 |
"execution_count": null, |
| 331 |
"metadata": {}, |
| 332 |
"outputs": [], |
| 333 |
"source": [ |
| 334 |
"f_match = rs.f[np.argmin(rs.s_mag[:,0,0])] # frequency for min(|S11|)\n", |
| 335 |
"print(f_match)" |
| 336 |
] |
| 337 |
}, |
| 338 |
{ |
| 339 |
"cell_type": "markdown", |
| 340 |
"metadata": {}, |
| 341 |
"source": [ |
| 342 |
"## Plotting " |
| 343 |
] |
| 344 |
}, |
| 345 |
{ |
| 346 |
"cell_type": "raw", |
| 347 |
"metadata": { |
| 348 |
"raw_mimetype": "text/restructuredtext" |
| 349 |
}, |
| 350 |
"source": [ |
| 351 |
".. note::\n", |
| 352 |
"\n", |
| 353 |
" The plotting infrastructure in skrf is under refactoring at the moment to allow for multiple backends, and headless setups. The following assumes you are using `matplotlib` with an interactive session." |
| 354 |
] |
| 355 |
}, |
| 356 |
{ |
| 357 |
"cell_type": "markdown", |
| 358 |
"metadata": {}, |
| 359 |
"source": [ |
| 360 |
"**skrf** has a function which updates your [matplotlib rcParams](http://matplotlib.org/users/customizing.html) so that plots appear like the ones shown in these tutorials. " |
| 361 |
] |
| 362 |
}, |
| 363 |
{ |
| 364 |
"cell_type": "code", |
| 365 |
"execution_count": null, |
| 366 |
"metadata": {}, |
| 367 |
"outputs": [], |
| 368 |
"source": [ |
| 369 |
"# display plots in notebook\n", |
| 370 |
"%matplotlib inline\n", |
| 371 |
"import matplotlib.pyplot as plt\n", |
| 372 |
"\n", |
| 373 |
"rf.stylely()" |
| 374 |
] |
| 375 |
}, |
| 376 |
{ |
| 377 |
"cell_type": "markdown", |
| 378 |
"metadata": {}, |
| 379 |
"source": [ |
| 380 |
"The methods of the [Network](../api/network.rst) class provide convenient ways to plot components of the network parameters,\n", |
| 381 |
"\n", |
| 382 |
"* `Network.plot_s_db()` : plot magnitude of s-parameters in log scale\n", |
| 383 |
"* `Network.plot_s_deg()` : plot phase of s-parameters in degrees\n", |
| 384 |
"* `Network.plot_s_smith()` : plot complex s-parameters on Smith Chart" |
| 385 |
] |
| 386 |
}, |
| 387 |
{ |
| 388 |
"cell_type": "markdown", |
| 389 |
"metadata": {}, |
| 390 |
"source": [ |
| 391 |
"To plot all four s-parameters of the ``ring_slot`` in Mag, Phase, and on the Smith Chart." |
| 392 |
] |
| 393 |
}, |
| 394 |
{ |
| 395 |
"cell_type": "code", |
| 396 |
"execution_count": null, |
| 397 |
"metadata": {}, |
| 398 |
"outputs": [], |
| 399 |
"source": [ |
| 400 |
"ring_slot.plot_s_db()" |
| 401 |
] |
| 402 |
}, |
| 403 |
{ |
| 404 |
"cell_type": "markdown", |
| 405 |
"metadata": {}, |
| 406 |
"source": [ |
| 407 |
"Or plot the phase of $S_{12}$" |
| 408 |
] |
| 409 |
}, |
| 410 |
{ |
| 411 |
"cell_type": "code", |
| 412 |
"execution_count": null, |
| 413 |
"metadata": {}, |
| 414 |
"outputs": [], |
| 415 |
"source": [ |
| 416 |
"ring_slot.plot_s_deg(m=0,n=1)" |
| 417 |
] |
| 418 |
}, |
| 419 |
{ |
| 420 |
"cell_type": "code", |
| 421 |
"execution_count": null, |
| 422 |
"metadata": {}, |
| 423 |
"outputs": [], |
| 424 |
"source": [ |
| 425 |
"ring_slot.plot_s_smith(lw=2)\n", |
| 426 |
"plt.title('Big ole Smith Chart')" |
| 427 |
] |
| 428 |
}, |
| 429 |
{ |
| 430 |
"cell_type": "markdown", |
| 431 |
"metadata": {}, |
| 432 |
"source": [ |
| 433 |
"For more detailed information about plotting see the [Plotting](Plotting.ipynb) tutorial" |
| 434 |
] |
| 435 |
}, |
| 436 |
{ |
| 437 |
"cell_type": "markdown", |
| 438 |
"metadata": {}, |
| 439 |
"source": [ |
| 440 |
"## NetworkSet " |
| 441 |
] |
| 442 |
}, |
| 443 |
{ |
| 444 |
"cell_type": "raw", |
| 445 |
"metadata": { |
| 446 |
"raw_mimetype": "text/restructuredtext" |
| 447 |
}, |
| 448 |
"source": [ |
| 449 |
".. currentmodule:: skrf.networkSet" |
| 450 |
] |
| 451 |
}, |
| 452 |
{ |
| 453 |
"cell_type": "markdown", |
| 454 |
"metadata": {}, |
| 455 |
"source": [ |
| 456 |
"The [NetworkSet](../api/networkSet.rst) object\n", |
| 457 |
"represents an unordered set of networks and provides methods for \n", |
| 458 |
"calculating statistical quantities and displaying uncertainty bounds.\n", |
| 459 |
"\n", |
| 460 |
"A [NetworkSet](../api/networkSet.rst) is created from a list or dict of \n", |
| 461 |
"[Networks](../api/network.rst)'s. This can be done quickly with \n", |
| 462 |
"`rf.read_all()` , which loads all skrf-readable objects\n", |
| 463 |
"in a directory. The argument ``contains`` is used to load only files \n", |
| 464 |
"which match a given substring. \n" |
| 465 |
] |
| 466 |
}, |
| 467 |
{ |
| 468 |
"cell_type": "code", |
| 469 |
"execution_count": null, |
| 470 |
"metadata": {}, |
| 471 |
"outputs": [], |
| 472 |
"source": [ |
| 473 |
"rf.read_all('data/', contains='ro')" |
| 474 |
] |
| 475 |
}, |
| 476 |
{ |
| 477 |
"cell_type": "markdown", |
| 478 |
"metadata": {}, |
| 479 |
"source": [ |
| 480 |
"This dictionary can be passed directly to the [NetworkSet](../api/networkSet.rst) constructor, " |
| 481 |
] |
| 482 |
}, |
| 483 |
{ |
| 484 |
"cell_type": "code", |
| 485 |
"execution_count": null, |
| 486 |
"metadata": {}, |
| 487 |
"outputs": [], |
| 488 |
"source": [ |
| 489 |
"from skrf import NetworkSet\n", |
| 490 |
"\n", |
| 491 |
"ro_dict = rf.read_all('data/', contains='ro')\n", |
| 492 |
"ro_ns = NetworkSet(ro_dict, name='ro set') # name is optional\n", |
| 493 |
"ro_ns" |
| 494 |
] |
| 495 |
}, |
| 496 |
{ |
| 497 |
"cell_type": "markdown", |
| 498 |
"metadata": {}, |
| 499 |
"source": [ |
| 500 |
"[NetworkSet](../api/networkSet.rst)'s are list-like. " |
| 501 |
] |
| 502 |
}, |
| 503 |
{ |
| 504 |
"cell_type": "markdown", |
| 505 |
"metadata": {}, |
| 506 |
"source": [ |
| 507 |
"### Statistical Properties" |
| 508 |
] |
| 509 |
}, |
| 510 |
{ |
| 511 |
"cell_type": "markdown", |
| 512 |
"metadata": {}, |
| 513 |
"source": [ |
| 514 |
"Statistical quantities can be calculated by accessing \n", |
| 515 |
"properties of the [NetworkSet](../api/networkSet.rst). For example, to calculate the complex \n", |
| 516 |
"average of the set, access the ``mean_s`` property" |
| 517 |
] |
| 518 |
}, |
| 519 |
{ |
| 520 |
"cell_type": "code", |
| 521 |
"execution_count": null, |
| 522 |
"metadata": {}, |
| 523 |
"outputs": [], |
| 524 |
"source": [ |
| 525 |
"ro_ns.mean_s" |
| 526 |
] |
| 527 |
}, |
| 528 |
{ |
| 529 |
"cell_type": "markdown", |
| 530 |
"metadata": {}, |
| 531 |
"source": [ |
| 532 |
"The returned results are stored in a [Network](../api/network.rst)s s-parameters, regardless of the type of the output. Similarly, to calculate the complex standard deviation of the set, " |
| 533 |
] |
| 534 |
}, |
| 535 |
{ |
| 536 |
"cell_type": "code", |
| 537 |
"execution_count": null, |
| 538 |
"metadata": {}, |
| 539 |
"outputs": [], |
| 540 |
"source": [ |
| 541 |
"ro_ns.std_s" |
| 542 |
] |
| 543 |
}, |
| 544 |
{ |
| 545 |
"cell_type": "markdown", |
| 546 |
"metadata": {}, |
| 547 |
"source": [ |
| 548 |
"Because these methods return a [Network](../api/network.rst) object the results can be \n", |
| 549 |
"saved or plotted in the same way as you would with a [Network](../api/network.rst). To plot the magnitude of the standard deviation of the set, " |
| 550 |
] |
| 551 |
}, |
| 552 |
{ |
| 553 |
"cell_type": "code", |
| 554 |
"execution_count": null, |
| 555 |
"metadata": {}, |
| 556 |
"outputs": [], |
| 557 |
"source": [ |
| 558 |
"ro_ns.std_s.plot_s_mag(label='S11')\n", |
| 559 |
"plt.ylabel('Standard Deviation')\n", |
| 560 |
"plt.title('Standard Deviation of RO')" |
| 561 |
] |
| 562 |
}, |
| 563 |
{ |
| 564 |
"cell_type": "markdown", |
| 565 |
"metadata": {}, |
| 566 |
"source": [ |
| 567 |
"### Plotting Uncertainty Bounds" |
| 568 |
] |
| 569 |
}, |
| 570 |
{ |
| 571 |
"cell_type": "markdown", |
| 572 |
"metadata": {}, |
| 573 |
"source": [ |
| 574 |
"Uncertainty bounds on any network parameter can be plotted through the methods " |
| 575 |
] |
| 576 |
}, |
| 577 |
{ |
| 578 |
"cell_type": "code", |
| 579 |
"execution_count": null, |
| 580 |
"metadata": {}, |
| 581 |
"outputs": [], |
| 582 |
"source": [ |
| 583 |
"ro_ns.plot_uncertainty_bounds_s_db(label='S11');" |
| 584 |
] |
| 585 |
}, |
| 586 |
{ |
| 587 |
"attachments": {}, |
| 588 |
"cell_type": "markdown", |
| 589 |
"metadata": {}, |
| 590 |
"source": [ |
| 591 |
"See the [networkset](NetworkSet.ipynb) tutorial for more information.\n" |
| 592 |
] |
| 593 |
}, |
| 594 |
{ |
| 595 |
"cell_type": "markdown", |
| 596 |
"metadata": {}, |
| 597 |
"source": [ |
| 598 |
"## Virtual Instruments" |
| 599 |
] |
| 600 |
}, |
| 601 |
{ |
| 602 |
"cell_type": "markdown", |
| 603 |
"metadata": {}, |
| 604 |
"source": [ |
| 605 |
"The [skrf.vi](../api/vi/index.rst) module provides classes to communicate with\n", |
| 606 |
"some instruments. At the moment, this is only VNAs, but more support may be\n", |
| 607 |
"added in the future. See the [Virtual Instrument](VirtualInstruments.ipynb)\n", |
| 608 |
"tutorial for more information." |
| 609 |
] |
| 610 |
}, |
| 611 |
{ |
| 612 |
"cell_type": "markdown", |
| 613 |
"metadata": {}, |
| 614 |
"source": [ |
| 615 |
"An example of using the `PNA` class to retrieve some s-parameter data and plot it" |
| 616 |
] |
| 617 |
}, |
| 618 |
{ |
| 619 |
"cell_type": "markdown", |
| 620 |
"metadata": {}, |
| 621 |
"source": [ |
| 622 |
" from skrf.vi.vna.keysight import PNA\n", |
| 623 |
" instr = PNA(address=\"TCPIP0::10.0.0.1::INSTR\") \n", |
| 624 |
"\n", |
| 625 |
" freq = Frequency(start=2.3e9, stop=2.6e9, npoints=401, unit='hz')\n", |
| 626 |
" instr.frequency = freq\n", |
| 627 |
"\n", |
| 628 |
" ntwk = instr.get_snp_network(ports=(1,2))\n", |
| 629 |
" ntwk.s21.plot_s_db()" |
| 630 |
] |
| 631 |
}, |
| 632 |
{ |
| 633 |
"cell_type": "markdown", |
| 634 |
"metadata": {}, |
| 635 |
"source": [ |
| 636 |
"## Calibration" |
| 637 |
] |
| 638 |
}, |
| 639 |
{ |
| 640 |
"cell_type": "markdown", |
| 641 |
"metadata": {}, |
| 642 |
"source": [ |
| 643 |
"Calibrations are performed through a [Calibration](../api/calibration/index.rst) class. In most cases, creating\n", |
| 644 |
"a [Calibration](../api/calibration/index.rst) object requires at least two pieces of information:\n", |
| 645 |
"\n", |
| 646 |
"* a list of measured [Network](../api/network.rst)'s\n", |
| 647 |
"* a list of ideal [Network](../api/network.rst)'s\n", |
| 648 |
"\n", |
| 649 |
"The [Network](../api/network.rst) elements in each list must all be similar (same #ports, frequency info, etc) and must be aligned to each other, meaning the first element of ideals list must correspond to the first element of measured list.\n", |
| 650 |
"\n", |
| 651 |
"Below is an example script illustrating how to create a [Calibration](../api/calibration/index.rst) .\n" |
| 652 |
] |
| 653 |
}, |
| 654 |
{ |
| 655 |
"cell_type": "markdown", |
| 656 |
"metadata": {}, |
| 657 |
"source": [ |
| 658 |
"### One Port Calibration" |
| 659 |
] |
| 660 |
}, |
| 661 |
{ |
| 662 |
"cell_type": "markdown", |
| 663 |
"metadata": {}, |
| 664 |
"source": [ |
| 665 |
" import skrf as rf\n", |
| 666 |
" from skrf.calibration import OnePort\n", |
| 667 |
" \n", |
| 668 |
" my_ideals = rf.read_all('ideals/')\n", |
| 669 |
" my_measured = rf.read_all('measured/')\n", |
| 670 |
" duts = rf.read_all('measured/')\n", |
| 671 |
" \n", |
| 672 |
" ## create a Calibration instance\n", |
| 673 |
" cal = rf.OnePort(\n", |
| 674 |
" ideals = [my_ideals[k] for k in ['short','open','load']],\n", |
| 675 |
" measured = [my_measured[k] for k in ['short','open','load']],\n", |
| 676 |
" )\n", |
| 677 |
" \n", |
| 678 |
" caled_duts = [cal.apply_cal(dut) for dut in duts.values()]\n", |
| 679 |
" \n", |
| 680 |
"See the [Calibration](Calibration.ipynb) tutorial for more details and examples. " |
| 681 |
] |
| 682 |
}, |
| 683 |
{ |
| 684 |
"cell_type": "markdown", |
| 685 |
"metadata": {}, |
| 686 |
"source": [ |
| 687 |
"## Transmission Line Media" |
| 688 |
] |
| 689 |
}, |
| 690 |
{ |
| 691 |
"cell_type": "raw", |
| 692 |
"metadata": { |
| 693 |
"raw_mimetype": "text/restructuredtext" |
| 694 |
}, |
| 695 |
"source": [ |
| 696 |
".. currentModule:: skrf.media" |
| 697 |
] |
| 698 |
}, |
| 699 |
{ |
| 700 |
"cell_type": "markdown", |
| 701 |
"metadata": {}, |
| 702 |
"source": [ |
| 703 |
"Simple transmission-line based networks can be created through methods of the [Media](../api/media/index.rst) class, which represents a transmission line object for a given medium. Once constructed, a [Media](../api/media/index.rst) object contains the necessary properties such as ``propagation constant`` and ``characteristic impedance``, that are needed to generate microwave circuits.\n", |
| 704 |
"\n", |
| 705 |
"The basic usage looks something like this, \n" |
| 706 |
] |
| 707 |
}, |
| 708 |
{ |
| 709 |
"cell_type": "markdown", |
| 710 |
"metadata": {}, |
| 711 |
"source": [ |
| 712 |
"### CPW\n" |
| 713 |
] |
| 714 |
}, |
| 715 |
{ |
| 716 |
"cell_type": "code", |
| 717 |
"execution_count": null, |
| 718 |
"metadata": {}, |
| 719 |
"outputs": [], |
| 720 |
"source": [ |
| 721 |
"from skrf import Frequency\n", |
| 722 |
"from skrf.media import CPW, Coaxial\n", |
| 723 |
"\n", |
| 724 |
"freq = Frequency(75, 110, 101, 'GHz')\n", |
| 725 |
"cpw = CPW(freq, w = 10e-6, s = 5e-6, ep_r = 10.6)\n", |
| 726 |
"cpw" |
| 727 |
] |
| 728 |
}, |
| 729 |
{ |
| 730 |
"cell_type": "code", |
| 731 |
"execution_count": null, |
| 732 |
"metadata": {}, |
| 733 |
"outputs": [], |
| 734 |
"source": [ |
| 735 |
"cpw.line(d=90,unit='deg', name='line')" |
| 736 |
] |
| 737 |
}, |
| 738 |
{ |
| 739 |
"cell_type": "markdown", |
| 740 |
"metadata": {}, |
| 741 |
"source": [ |
| 742 |
"### Coax" |
| 743 |
] |
| 744 |
}, |
| 745 |
{ |
| 746 |
"cell_type": "code", |
| 747 |
"execution_count": null, |
| 748 |
"metadata": {}, |
| 749 |
"outputs": [], |
| 750 |
"source": [ |
| 751 |
"freq = Frequency(1, 10, 101, 'GHz')\n", |
| 752 |
"coax = Coaxial(frequency = freq, Dint = 1e-3, Dout = 2e-3)\n", |
| 753 |
"coax" |
| 754 |
] |
| 755 |
}, |
| 756 |
{ |
| 757 |
"cell_type": "code", |
| 758 |
"execution_count": null, |
| 759 |
"metadata": {}, |
| 760 |
"outputs": [], |
| 761 |
"source": [] |
| 762 |
} |
| 763 |
], |
| 764 |
"metadata": { |
| 765 |
"anaconda-cloud": {}, |
| 766 |
"kernelspec": { |
| 767 |
"display_name": "Python 3.10.4 ('skrf')", |
| 768 |
"language": "python", |
| 769 |
"name": "python3" |
| 770 |
}, |
| 771 |
"language_info": { |
| 772 |
"codemirror_mode": { |
| 773 |
"name": "ipython", |
| 774 |
"version": 3 |
| 775 |
}, |
| 776 |
"file_extension": ".py", |
| 777 |
"mimetype": "text/x-python", |
| 778 |
"name": "python", |
| 779 |
"nbconvert_exporter": "python", |
| 780 |
"pygments_lexer": "ipython3", |
| 781 |
"version": "3.10.6" |
| 782 |
}, |
| 783 |
"vscode": { |
| 784 |
"interpreter": { |
| 785 |
"hash": "6e9ab46c0308d25f8ecf2297d605bcf30c0184a06f23fc8ad30aef47f26c08c0" |
| 786 |
} |
| 787 |
} |
| 788 |
}, |
| 789 |
"nbformat": 4, |
| 790 |
"nbformat_minor": 1 |
| 791 |
} |