| 1 |
""" |
| 2 |
.. module:: skrf.calibration.deembedding |
| 3 |
|
| 4 |
==================================================== |
| 5 |
deembedding (:mod:`skrf.calibration.deembedding`) |
| 6 |
==================================================== |
| 7 |
|
| 8 |
De-embedding is the procedure of removing effects of the |
| 9 |
test fixture that is often present in the measurement of a device |
| 10 |
or circuit. It is based on a lumped element approximation of the |
| 11 |
test fixture which needs removal from the raw data, and its |
| 12 |
equivalent circuit often needs to be known a-priori. This is often |
| 13 |
required since implementation of calibration methods such as |
| 14 |
Thru-Reflect-Line (TRL) becomes too expensive for implementation |
| 15 |
in on-wafer measurement environments where space is limited, or |
| 16 |
insufficiently accurate as in the case of Short-Open-Load-Thru |
| 17 |
(SOLT) calibration where the load cannot be manufactured accurately. |
| 18 |
De-embedding is often performed as a second step, after a |
| 19 |
SOLT, TRL or similar calibration to the end of a known reference |
| 20 |
plane, like the probe-tips in on-wafer measurements. |
| 21 |
|
| 22 |
This module provides objects to implement commonly used de-embedding |
| 23 |
method in on-wafer applications. |
| 24 |
Each de-embedding method inherits from the common abstract base |
| 25 |
class :class:`Deembedding`. |
| 26 |
|
| 27 |
Base Class |
| 28 |
---------- |
| 29 |
|
| 30 |
.. autosummary:: |
| 31 |
:toctree: generated/ |
| 32 |
|
| 33 |
Deembedding |
| 34 |
|
| 35 |
De-embedding Methods |
| 36 |
-------------------- |
| 37 |
|
| 38 |
.. autosummary:: |
| 39 |
:toctree: generated/ |
| 40 |
|
| 41 |
OpenShort |
| 42 |
Open |
| 43 |
ShortOpen |
| 44 |
Short |
| 45 |
SplitPi |
| 46 |
SplitTee |
| 47 |
AdmittanceCancel |
| 48 |
ImpedanceCancel |
| 49 |
IEEEP370 |
| 50 |
IEEEP370_SE_NZC_2xThru |
| 51 |
IEEEP370_MM_NZC_2xThru |
| 52 |
IEEEP370_SE_ZC_2xThru |
| 53 |
IEEEP370_MM_ZC_2xThru |
| 54 |
|
| 55 |
""" |
| 56 |
|
| 57 |
from __future__ import annotations |
| 58 |
|
| 59 |
import warnings |
| 60 |
from abc import ABC, abstractmethod |
| 61 |
from collections.abc import Sequence |
| 62 |
from typing import Literal |
| 63 |
|
| 64 |
import numpy as np |
| 65 |
from numpy import angle, concatenate, conj, exp, flip, imag, ndarray, real, unwrap, zeros |
| 66 |
from numpy.fft import fft, fftshift, ifftshift, irfft |
| 67 |
from numpy.linalg import norm |
| 68 |
from scipy.interpolate import interp1d |
| 69 |
|
| 70 |
from ..frequency import Frequency |
| 71 |
from ..network import Network, concat_ports, overlap_multi, subnetwork |
| 72 |
from ..util import Axes, Figure, figure, subplots |
| 73 |
|
| 74 |
PortOrderT = Literal["first", "second", "third"] |
| 75 |
|
| 76 |
class Deembedding(ABC): |
| 77 |
""" |
| 78 |
Abstract Base Class for all de-embedding objects. |
| 79 |
|
| 80 |
This class implements the common mechanisms for all de-embedding |
| 81 |
algorithms. Specific calibration algorithms should inherit this |
| 82 |
class and over-ride the methods: |
| 83 |
* :func:`Deembedding.deembed` |
| 84 |
|
| 85 |
""" |
| 86 |
|
| 87 |
def __init__(self, dummies, name=None, *args, **kwargs): |
| 88 |
r""" |
| 89 |
De-embedding Initializer |
| 90 |
|
| 91 |
Notes |
| 92 |
----- |
| 93 |
Each de-embedding algorithm may use a different number of |
| 94 |
dummy networks. We check that each of these dummy networks |
| 95 |
have matching frequencies to perform de-embedding. |
| 96 |
|
| 97 |
It should be known a-priori what the equivalent circuit |
| 98 |
of the parasitic network looks like. The proper de-embedding |
| 99 |
method should then be chosen accordingly. |
| 100 |
|
| 101 |
Parameters |
| 102 |
---------- |
| 103 |
dummies : list of :class:`~skrf.network.Network` objects |
| 104 |
Network info of all the dummy structures used in a |
| 105 |
given de-embedding algorithm. |
| 106 |
|
| 107 |
name : string |
| 108 |
Name of this de-embedding instance, like 'open-short-set1' |
| 109 |
This is for convenience of identification. |
| 110 |
|
| 111 |
\*args, \*\*kwargs : keyword arguments |
| 112 |
stored in self.args and self.kwargs, which may be used |
| 113 |
by sub-classes if needed. |
| 114 |
""" |
| 115 |
|
| 116 |
|
| 117 |
for dmyntwk in dummies: |
| 118 |
if dummies[0].frequency != dmyntwk.frequency: |
| 119 |
warnings.warn('Dummy Networks dont have matching frequencies, attempting overlap.', RuntimeWarning, |
| 120 |
stacklevel=2) |
| 121 |
dummies = overlap_multi(dummies) |
| 122 |
break |
| 123 |
|
| 124 |
self.frequency = dummies[0].frequency |
| 125 |
self.dummies = dummies |
| 126 |
self.args = args |
| 127 |
self.kwargs = kwargs |
| 128 |
self.name = name |
| 129 |
|
| 130 |
def __str__(self): |
| 131 |
if self.name is None: |
| 132 |
name = '' |
| 133 |
else: |
| 134 |
name = self.name |
| 135 |
|
| 136 |
output = (f'{self.__class__.__name__} Deembedding: {name}, {self.frequency}, ' |
| 137 |
f'{len(self.dummies)} dummy structures') |
| 138 |
|
| 139 |
return output |
| 140 |
|
| 141 |
def __repr_(self): |
| 142 |
return self.__str__() |
| 143 |
|
| 144 |
@abstractmethod |
| 145 |
def deembed(self, ntwk): |
| 146 |
""" |
| 147 |
Apply de-embedding correction to a Network |
| 148 |
""" |
| 149 |
pass |
| 150 |
|
| 151 |
|
| 152 |
class OpenShort(Deembedding): |
| 153 |
""" |
| 154 |
Remove open parasitics followed by short parasitics. |
| 155 |
|
| 156 |
This is a commonly used de-embedding method for on-wafer applications. |
| 157 |
|
| 158 |
A deembedding object is created with two dummy measurements: `dummy_open` |
| 159 |
and `dummy_short`. When :func:`Deembedding.deembed` is applied, |
| 160 |
Open de-embedding is applied to the short dummy |
| 161 |
because the measurement results for the short dummy contains parallel parasitics. |
| 162 |
Then the Y-parameters of the dummy_open are subtracted from the DUT measurement, |
| 163 |
followed by subtraction of Z-parameters of dummy-short which is previously de-embedded. |
| 164 |
|
| 165 |
This method is applicable only when there is a-priori knowledge of the |
| 166 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 167 |
where the series parasitics are closest to device under test, |
| 168 |
followed by the parallel parasitics. For more information, see [1]_ |
| 169 |
|
| 170 |
References |
| 171 |
------------ |
| 172 |
|
| 173 |
.. [1] M. C. A. M. Koolen, J. A. M. Geelen and M. P. J. G. Versleijen, "An improved |
| 174 |
de-embedding technique for on-wafer high frequency characterization", |
| 175 |
IEEE 1991 Bipolar Circuits and Technology Meeting, pp. 188-191, Sep. 1991. |
| 176 |
|
| 177 |
Example |
| 178 |
-------- |
| 179 |
>>> import skrf as rf |
| 180 |
>>> from skrf.calibration import OpenShort |
| 181 |
|
| 182 |
Create network objects for dummy structures and dut |
| 183 |
|
| 184 |
>>> op = rf.Network('open_ckt.s2p') |
| 185 |
>>> sh = rf.Network('short_ckt.s2p') |
| 186 |
>>> dut = rf.Network('full_ckt.s2p') |
| 187 |
|
| 188 |
Create de-embedding object |
| 189 |
|
| 190 |
>>> dm = OpenShort(dummy_open = op, dummy_short = sh, name = 'test_openshort') |
| 191 |
|
| 192 |
Remove parasitics to get the actual device network |
| 193 |
|
| 194 |
>>> realdut = dm.deembed(dut) |
| 195 |
|
| 196 |
""" |
| 197 |
|
| 198 |
def __init__(self, dummy_open, dummy_short, name=None, *args, **kwargs): |
| 199 |
""" |
| 200 |
Open-Short De-embedding Initializer |
| 201 |
|
| 202 |
Parameters |
| 203 |
----------- |
| 204 |
|
| 205 |
dummy_open : :class:`~skrf.network.Network` object |
| 206 |
Measurement of the dummy open structure |
| 207 |
|
| 208 |
dummy_short : :class:`~skrf.network.Network` object |
| 209 |
Measurement of the dummy short structure |
| 210 |
|
| 211 |
name : string |
| 212 |
Optional name of de-embedding object |
| 213 |
|
| 214 |
args, kwargs: |
| 215 |
Passed to :func:`Deembedding.__init__` |
| 216 |
|
| 217 |
See Also |
| 218 |
--------- |
| 219 |
:func:`Deembedding.__init__` |
| 220 |
|
| 221 |
""" |
| 222 |
self.open = dummy_open.copy() |
| 223 |
self.short = dummy_short.copy() |
| 224 |
dummies = [self.open, self.short] |
| 225 |
|
| 226 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 227 |
|
| 228 |
def deembed(self, ntwk): |
| 229 |
""" |
| 230 |
Perform the de-embedding calculation |
| 231 |
|
| 232 |
Parameters |
| 233 |
---------- |
| 234 |
ntwk : :class:`~skrf.network.Network` object |
| 235 |
Network data of device measurement from which |
| 236 |
parasitics needs to be removed via de-embedding |
| 237 |
|
| 238 |
|
| 239 |
Returns |
| 240 |
------- |
| 241 |
caled : :class:`~skrf.network.Network` object |
| 242 |
Network data of the device after de-embedding |
| 243 |
|
| 244 |
""" |
| 245 |
|
| 246 |
|
| 247 |
if ntwk.frequency != self.open.frequency: |
| 248 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', RuntimeWarning, |
| 249 |
stacklevel=2) |
| 250 |
caled, op, sh = overlap_multi([ntwk, self.open, self.short]) |
| 251 |
else: |
| 252 |
caled, op, sh = ntwk.copy(), self.open, self.short |
| 253 |
|
| 254 |
|
| 255 |
deembeded_short = sh.copy() |
| 256 |
deembeded_short.y = sh.y - op.y |
| 257 |
|
| 258 |
caled.y = caled.y - op.y |
| 259 |
|
| 260 |
caled.z = caled.z - deembeded_short.z |
| 261 |
|
| 262 |
return caled |
| 263 |
|
| 264 |
|
| 265 |
class Open(Deembedding): |
| 266 |
""" |
| 267 |
Remove open parasitics only. |
| 268 |
|
| 269 |
A deembedding object is created with just one open dummy measurement, |
| 270 |
`dummy_open`. When :func:`Deembedding.deembed` is applied, the |
| 271 |
Y-parameters of the open dummy are subtracted from the DUT measurement, |
| 272 |
|
| 273 |
This method is applicable only when there is a-priori knowledge of the |
| 274 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 275 |
where the series parasitics are assumed to be negligible, |
| 276 |
but parallel parasitics are unwanted. |
| 277 |
|
| 278 |
Example |
| 279 |
-------- |
| 280 |
>>> import skrf as rf |
| 281 |
>>> from skrf.calibration import Open |
| 282 |
|
| 283 |
Create network objects for dummy structure and dut |
| 284 |
|
| 285 |
>>> op = rf.Network('open_ckt.s2p') |
| 286 |
>>> dut = rf.Network('full_ckt.s2p') |
| 287 |
|
| 288 |
Create de-embedding object |
| 289 |
|
| 290 |
>>> dm = Open(dummy_open = op, name = 'test_open') |
| 291 |
|
| 292 |
Remove parasitics to get the actual device network |
| 293 |
|
| 294 |
>>> realdut = dm.deembed(dut) |
| 295 |
""" |
| 296 |
|
| 297 |
def __init__(self, dummy_open, name=None, *args, **kwargs): |
| 298 |
""" |
| 299 |
Open De-embedding Initializer |
| 300 |
|
| 301 |
Parameters |
| 302 |
----------- |
| 303 |
|
| 304 |
dummy_open : :class:`~skrf.network.Network` object |
| 305 |
Measurement of the dummy open structure |
| 306 |
|
| 307 |
name : string |
| 308 |
Optional name of de-embedding object |
| 309 |
|
| 310 |
args, kwargs: |
| 311 |
Passed to :func:`Deembedding.__init__` |
| 312 |
|
| 313 |
See Also |
| 314 |
--------- |
| 315 |
:func:`Deembedding.__init__` |
| 316 |
|
| 317 |
""" |
| 318 |
self.open = dummy_open.copy() |
| 319 |
dummies = [self.open] |
| 320 |
|
| 321 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 322 |
|
| 323 |
def deembed(self, ntwk): |
| 324 |
""" |
| 325 |
Perform the de-embedding calculation |
| 326 |
|
| 327 |
Parameters |
| 328 |
---------- |
| 329 |
ntwk : :class:`~skrf.network.Network` object |
| 330 |
Network data of device measurement from which |
| 331 |
parasitics needs to be removed via de-embedding |
| 332 |
|
| 333 |
Returns |
| 334 |
------- |
| 335 |
caled : :class:`~skrf.network.Network` object |
| 336 |
Network data of the device after de-embedding |
| 337 |
|
| 338 |
""" |
| 339 |
|
| 340 |
|
| 341 |
if ntwk.frequency != self.open.frequency: |
| 342 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', RuntimeWarning, |
| 343 |
stacklevel=2) |
| 344 |
ntwk, op = overlap_multi([ntwk, self.open]) |
| 345 |
else: |
| 346 |
op = self.open |
| 347 |
|
| 348 |
caled = ntwk.copy() |
| 349 |
|
| 350 |
caled.y = ntwk.y - op.y |
| 351 |
|
| 352 |
return caled |
| 353 |
|
| 354 |
|
| 355 |
class ShortOpen(Deembedding): |
| 356 |
""" |
| 357 |
Remove short parasitics followed by open parasitics. |
| 358 |
|
| 359 |
A deembedding object is created with two dummy measurements: `dummy_open` |
| 360 |
and `dummy_short`. When :func:`Deembedding.deembed` is applied, |
| 361 |
short de-embedding is applied to the open dummy |
| 362 |
because the measurement results for the open dummy contains series parasitics. |
| 363 |
the Z-parameters of the dummy_short are subtracted from the DUT measurement, |
| 364 |
followed by subtraction of Y-parameters of dummy_open which is previously de-embedded. |
| 365 |
|
| 366 |
This method is applicable only when there is a-priori knowledge of the |
| 367 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 368 |
where the parallel parasitics are closest to device under test, |
| 369 |
followed by the series parasitics. |
| 370 |
|
| 371 |
Example |
| 372 |
-------- |
| 373 |
>>> import skrf as rf |
| 374 |
>>> from skrf.calibration import ShortOpen |
| 375 |
|
| 376 |
Create network objects for dummy structures and dut |
| 377 |
|
| 378 |
>>> op = rf.Network('open_ckt.s2p') |
| 379 |
>>> sh = rf.Network('short_ckt.s2p') |
| 380 |
>>> dut = rf.Network('full_ckt.s2p') |
| 381 |
|
| 382 |
Create de-embedding object |
| 383 |
|
| 384 |
>>> dm = ShortOpen(dummy_short = sh, dummy_open = op, name = 'test_shortopen') |
| 385 |
|
| 386 |
Remove parasitics to get the actual device network |
| 387 |
|
| 388 |
>>> realdut = dm.deembed(dut) |
| 389 |
|
| 390 |
""" |
| 391 |
|
| 392 |
def __init__(self, dummy_short, dummy_open, name=None, *args, **kwargs): |
| 393 |
""" |
| 394 |
Short-Open De-embedding Initializer |
| 395 |
|
| 396 |
Parameters |
| 397 |
----------- |
| 398 |
|
| 399 |
dummy_short : :class:`~skrf.network.Network` object |
| 400 |
Measurement of the dummy short structure |
| 401 |
|
| 402 |
dummy_open : :class:`~skrf.network.Network` object |
| 403 |
Measurement of the dummy open structure |
| 404 |
|
| 405 |
name : string |
| 406 |
Optional name of de-embedding object |
| 407 |
|
| 408 |
args, kwargs: |
| 409 |
Passed to :func:`Deembedding.__init__` |
| 410 |
|
| 411 |
See Also |
| 412 |
--------- |
| 413 |
:func:`Deembedding.__init__` |
| 414 |
|
| 415 |
""" |
| 416 |
self.open = dummy_open.copy() |
| 417 |
self.short = dummy_short.copy() |
| 418 |
dummies = [self.open, self.short] |
| 419 |
|
| 420 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 421 |
|
| 422 |
def deembed(self, ntwk): |
| 423 |
""" |
| 424 |
Perform the de-embedding calculation |
| 425 |
|
| 426 |
Parameters |
| 427 |
---------- |
| 428 |
ntwk : :class:`~skrf.network.Network` object |
| 429 |
Network data of device measurement from which |
| 430 |
parasitics needs to be removed via de-embedding |
| 431 |
|
| 432 |
Returns |
| 433 |
------- |
| 434 |
caled : :class:`~skrf.network.Network` object |
| 435 |
Network data of the device after de-embedding |
| 436 |
|
| 437 |
""" |
| 438 |
|
| 439 |
|
| 440 |
if ntwk.frequency != self.open.frequency: |
| 441 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', RuntimeWarning, |
| 442 |
stacklevel=2) |
| 443 |
ntwk, op, sh = overlap_multi([ntwk, self.open, self.short]) |
| 444 |
else: |
| 445 |
op, sh = self.open, self.short |
| 446 |
|
| 447 |
caled = ntwk.copy() |
| 448 |
|
| 449 |
deembeded_open = op.copy() |
| 450 |
deembeded_open.z = op.z - sh.z |
| 451 |
|
| 452 |
caled.z = ntwk.z - sh.z |
| 453 |
|
| 454 |
caled.y = caled.y - deembeded_open.y |
| 455 |
|
| 456 |
return caled |
| 457 |
|
| 458 |
|
| 459 |
class Short(Deembedding): |
| 460 |
""" |
| 461 |
Remove short parasitics only. |
| 462 |
|
| 463 |
This is a useful method to remove pad contact resistances from measurement. |
| 464 |
|
| 465 |
A deembedding object is created with just one dummy measurement: `dummy_short`. |
| 466 |
When :func:`Deembedding.deembed` is applied, the |
| 467 |
Z-parameters of the dummy_short are subtracted from the DUT measurement, |
| 468 |
|
| 469 |
This method is applicable only when there is a-priori knowledge of the |
| 470 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 471 |
where only series parasitics are to be removed while retaining all others. |
| 472 |
|
| 473 |
Example |
| 474 |
-------- |
| 475 |
>>> import skrf as rf |
| 476 |
>>> from skrf.calibration import Short |
| 477 |
|
| 478 |
Create network objects for dummy structures and dut |
| 479 |
|
| 480 |
>>> sh = rf.Network('short_ckt.s2p') |
| 481 |
>>> dut = rf.Network('full_ckt.s2p') |
| 482 |
|
| 483 |
Create de-embedding object |
| 484 |
|
| 485 |
>>> dm = Short(dummy_short = sh, name = 'test_short') |
| 486 |
|
| 487 |
Remove parasitics to get the actual device network |
| 488 |
|
| 489 |
>>> realdut = dm.deembed(dut) |
| 490 |
|
| 491 |
""" |
| 492 |
|
| 493 |
def __init__(self, dummy_short, name=None, *args, **kwargs): |
| 494 |
""" |
| 495 |
Short De-embedding Initializer |
| 496 |
|
| 497 |
Parameters |
| 498 |
----------- |
| 499 |
|
| 500 |
dummy_short : :class:`~skrf.network.Network` object |
| 501 |
Measurement of the dummy short structure |
| 502 |
|
| 503 |
name : string |
| 504 |
Optional name of de-embedding object |
| 505 |
|
| 506 |
args, kwargs: |
| 507 |
Passed to :func:`Deembedding.__init__` |
| 508 |
|
| 509 |
See Also |
| 510 |
--------- |
| 511 |
:func:`Deembedding.__init__` |
| 512 |
|
| 513 |
""" |
| 514 |
self.short = dummy_short.copy() |
| 515 |
dummies = [self.short] |
| 516 |
|
| 517 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 518 |
|
| 519 |
def deembed(self, ntwk): |
| 520 |
""" |
| 521 |
Perform the de-embedding calculation |
| 522 |
|
| 523 |
Parameters |
| 524 |
---------- |
| 525 |
ntwk : :class:`~skrf.network.Network` object |
| 526 |
Network data of device measurement from which |
| 527 |
parasitics needs to be removed via de-embedding |
| 528 |
|
| 529 |
Returns |
| 530 |
------- |
| 531 |
caled : :class:`~skrf.network.Network` object |
| 532 |
Network data of the device after de-embedding |
| 533 |
|
| 534 |
""" |
| 535 |
|
| 536 |
|
| 537 |
if ntwk.frequency != self.short.frequency: |
| 538 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', RuntimeWarning, |
| 539 |
stacklevel=2) |
| 540 |
ntwk, sh = overlap_multi([ntwk, self.short]) |
| 541 |
else: |
| 542 |
sh = self.short |
| 543 |
|
| 544 |
caled = ntwk.copy() |
| 545 |
|
| 546 |
caled.z = ntwk.z - sh.z |
| 547 |
|
| 548 |
return caled |
| 549 |
|
| 550 |
|
| 551 |
class SplitPi(Deembedding): |
| 552 |
""" |
| 553 |
Remove shunt and series parasitics assuming pi-type embedding network. |
| 554 |
|
| 555 |
A deembedding object is created with just one thru dummy measurement `dummy_thru`. |
| 556 |
The thru dummy is, for example, a direct cascaded connection of the left and right test pads. |
| 557 |
|
| 558 |
When :func:`Deembedding.deembed` is applied, |
| 559 |
the shunt admittance and series impedance of the thru dummy are removed. |
| 560 |
|
| 561 |
This method is applicable only when there is a-priori knowledge of the |
| 562 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 563 |
where the series parasitics are closest to device under test, |
| 564 |
followed by the shunt parasitics. For more information, see [2]_ |
| 565 |
|
| 566 |
References |
| 567 |
------------ |
| 568 |
.. [2] L. Nan, K. Mouthaan, Y.-Z. Xiong, J. Shi, S. C. Rustagi, and B.-L. Ooi, |
| 569 |
“Experimental Characterization of the Effect of Metal Dummy Fills on Spiral Inductors,” |
| 570 |
in 2007 IEEE Radio Frequency Integrated Circuits (RFIC) Symposium, Jun. 2007, pp. 307–310. |
| 571 |
|
| 572 |
Example |
| 573 |
-------- |
| 574 |
>>> import skrf as rf |
| 575 |
>>> from skrf.calibration import SplitPi |
| 576 |
|
| 577 |
Create network objects for dummy structure and dut |
| 578 |
|
| 579 |
>>> th = rf.Network('thru_ckt.s2p') |
| 580 |
>>> dut = rf.Network('full_ckt.s2p') |
| 581 |
|
| 582 |
Create de-embedding object |
| 583 |
|
| 584 |
>>> dm = SplitPi(dummy_thru = th, name = 'test_thru') |
| 585 |
|
| 586 |
Remove parasitics to get the actual device network |
| 587 |
|
| 588 |
>>> realdut = dm.deembed(dut) |
| 589 |
""" |
| 590 |
|
| 591 |
def __init__(self, dummy_thru, name=None, *args, **kwargs): |
| 592 |
""" |
| 593 |
SplitPi De-embedding Initializer |
| 594 |
|
| 595 |
Parameters |
| 596 |
----------- |
| 597 |
dummy_thru : :class:`~skrf.network.Network` object |
| 598 |
Measurement of the dummy thru structure |
| 599 |
|
| 600 |
name : string |
| 601 |
Optional name of de-embedding object |
| 602 |
|
| 603 |
args, kwargs: |
| 604 |
Passed to :func:`Deembedding.__init__` |
| 605 |
|
| 606 |
See Also |
| 607 |
--------- |
| 608 |
:func:`Deembedding.__init__` |
| 609 |
""" |
| 610 |
self.thru = dummy_thru.copy() |
| 611 |
dummies = [self.thru] |
| 612 |
|
| 613 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 614 |
|
| 615 |
def deembed(self, ntwk): |
| 616 |
""" |
| 617 |
Perform the de-embedding calculation |
| 618 |
|
| 619 |
Parameters |
| 620 |
---------- |
| 621 |
ntwk : :class:`~skrf.network.Network` object |
| 622 |
Network data of device measurement from which |
| 623 |
parasitics needs to be removed via de-embedding |
| 624 |
|
| 625 |
Returns |
| 626 |
------- |
| 627 |
caled : :class:`~skrf.network.Network` object |
| 628 |
Network data of the device after de-embedding |
| 629 |
""" |
| 630 |
|
| 631 |
|
| 632 |
if ntwk.frequency != self.thru.frequency: |
| 633 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 634 |
RuntimeWarning, stacklevel=2) |
| 635 |
ntwk, thru = overlap_multi([ntwk, self.thru]) |
| 636 |
else: |
| 637 |
thru = self.thru |
| 638 |
|
| 639 |
left = thru.copy() |
| 640 |
left_y = left.y |
| 641 |
left_y[:,0,0] = (thru.y[:,0,0] - thru.y[:,1,0] + thru.y[:,1,1] - thru.y[:,0,1]) / 2 |
| 642 |
left_y[:,0,1] = thru.y[:,1,0] + thru.y[:,0,1] |
| 643 |
left_y[:,1,0] = thru.y[:,1,0] + thru.y[:,0,1] |
| 644 |
left_y[:,1,1] = - thru.y[:,1,0] - thru.y[:,0,1] |
| 645 |
left.y = left_y |
| 646 |
right = left.flipped() |
| 647 |
caled = left.inv ** ntwk ** right.inv |
| 648 |
|
| 649 |
return caled |
| 650 |
|
| 651 |
|
| 652 |
class SplitTee(Deembedding): |
| 653 |
""" |
| 654 |
Remove series and shunt parasitics assuming tee-type embedding network. |
| 655 |
|
| 656 |
A deembedding object is created with just one thru dummy measurement `dummy_thru`. |
| 657 |
The thru dummy is, for example, a direct cascaded connection of the left and right test pads. |
| 658 |
|
| 659 |
When :func:`Deembedding.deembed` is applied, |
| 660 |
the shunt admittance and series impedance of the thru dummy are removed. |
| 661 |
|
| 662 |
This method is applicable only when there is a-priori knowledge of the |
| 663 |
equivalent circuit model of the parasitic network to be de-embedded, |
| 664 |
where the shunt parasitics are closest to device under test, |
| 665 |
followed by the series parasitics. For more information, see [3]_ |
| 666 |
|
| 667 |
References |
| 668 |
------------ |
| 669 |
.. [3] M. J. Kobrinsky, S. Chakravarty, D. Jiao, M. C. Harmes, S. List, and M. Mazumder, |
| 670 |
“Experimental validation of crosstalk simulations for on-chip interconnects using S-parameters,” |
| 671 |
IEEE Transactions on Advanced Packaging, vol. 28, no. 1, pp. 57–62, Feb. 2005. |
| 672 |
|
| 673 |
Example |
| 674 |
-------- |
| 675 |
>>> import skrf as rf |
| 676 |
>>> from skrf.calibration import SplitTee |
| 677 |
|
| 678 |
Create network objects for dummy structure and dut |
| 679 |
|
| 680 |
>>> th = rf.Network('thru_ckt.s2p') |
| 681 |
>>> dut = rf.Network('full_ckt.s2p') |
| 682 |
|
| 683 |
Create de-embedding object |
| 684 |
|
| 685 |
>>> dm = SplitTee(dummy_thru = th, name = 'test_thru') |
| 686 |
|
| 687 |
Remove parasitics to get the actual device network |
| 688 |
|
| 689 |
>>> realdut = dm.deembed(dut) |
| 690 |
""" |
| 691 |
|
| 692 |
def __init__(self, dummy_thru, name=None, *args, **kwargs): |
| 693 |
""" |
| 694 |
SplitTee De-embedding Initializer |
| 695 |
|
| 696 |
Parameters |
| 697 |
----------- |
| 698 |
dummy_thru : :class:`~skrf.network.Network` object |
| 699 |
Measurement of the dummy thru structure |
| 700 |
|
| 701 |
name : string |
| 702 |
Optional name of de-embedding object |
| 703 |
|
| 704 |
args, kwargs: |
| 705 |
Passed to :func:`Deembedding.__init__` |
| 706 |
|
| 707 |
See Also |
| 708 |
--------- |
| 709 |
:func:`Deembedding.__init__` |
| 710 |
""" |
| 711 |
self.thru = dummy_thru.copy() |
| 712 |
dummies = [self.thru] |
| 713 |
|
| 714 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 715 |
|
| 716 |
def deembed(self, ntwk): |
| 717 |
""" |
| 718 |
Perform the de-embedding calculation |
| 719 |
|
| 720 |
Parameters |
| 721 |
---------- |
| 722 |
ntwk : :class:`~skrf.network.Network` object |
| 723 |
Network data of device measurement from which |
| 724 |
parasitics needs to be removed via de-embedding |
| 725 |
|
| 726 |
Returns |
| 727 |
------- |
| 728 |
caled : :class:`~skrf.network.Network` object |
| 729 |
Network data of the device after de-embedding |
| 730 |
""" |
| 731 |
|
| 732 |
|
| 733 |
if ntwk.frequency != self.thru.frequency: |
| 734 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 735 |
RuntimeWarning, stacklevel=2) |
| 736 |
ntwk, thru = overlap_multi([ntwk, self.thru]) |
| 737 |
else: |
| 738 |
thru = self.thru |
| 739 |
|
| 740 |
left = thru.copy() |
| 741 |
left_z = left.z |
| 742 |
left_z[:,0,0] = (thru.z[:,0,0] + thru.z[:,1,0] + thru.z[:,1,1] + thru.z[:,0,1]) / 2 |
| 743 |
left_z[:,0,1] = thru.z[:,1,0] + thru.z[:,0,1] |
| 744 |
left_z[:,1,0] = thru.z[:,1,0] + thru.z[:,0,1] |
| 745 |
left_z[:,1,1] = thru.z[:,1,0] + thru.z[:,0,1] |
| 746 |
left.z = left_z |
| 747 |
right = left.flipped() |
| 748 |
caled = left.inv ** ntwk ** right.inv |
| 749 |
|
| 750 |
return caled |
| 751 |
|
| 752 |
|
| 753 |
class AdmittanceCancel(Deembedding): |
| 754 |
""" |
| 755 |
Cancel shunt admittance by swapping (a.k.a Mangan's method). |
| 756 |
A deembedding object is created with just one thru dummy measurement `dummy_thru`. |
| 757 |
The thru dummy is, for example, a direct cascaded connection of the left and right test pads. |
| 758 |
|
| 759 |
When :func:`Deembedding.deembed` is applied, |
| 760 |
the shunt admittance of the thru dummy are canceled, |
| 761 |
from the DUT measurement by left-right mirroring operation. |
| 762 |
|
| 763 |
This method is applicable to only symmetric (i.e. S11=S22 and S12=S21) 2-port DUTs, |
| 764 |
but suitable for the characterization of transmission lines at mmW frequencies. |
| 765 |
For more information, see [4]_ |
| 766 |
|
| 767 |
References |
| 768 |
------------ |
| 769 |
.. [4] A. M. Mangan, S. P. Voinigescu, Ming-Ta Yang, and M. Tazlauanu, |
| 770 |
“De-embedding transmission line measurements for accurate modeling of IC designs,” |
| 771 |
IEEE Trans. Electron Devices, vol. 53, no. 2, pp. 235–241, Feb. 2006. |
| 772 |
|
| 773 |
Example |
| 774 |
-------- |
| 775 |
>>> import skrf as rf |
| 776 |
>>> from skrf.calibration import AdmittanceCancel |
| 777 |
|
| 778 |
Create network objects for dummy structure and dut |
| 779 |
|
| 780 |
>>> th = rf.Network('thru_ckt.s2p') |
| 781 |
>>> dut = rf.Network('full_ckt.s2p') |
| 782 |
|
| 783 |
Create de-embedding object |
| 784 |
|
| 785 |
>>> dm = AdmittanceCancel(dummy_thru = th, name = 'test_thru') |
| 786 |
|
| 787 |
Remove parasitics to get the actual device network |
| 788 |
|
| 789 |
>>> realdut = dm.deembed(dut) |
| 790 |
""" |
| 791 |
|
| 792 |
def __init__(self, dummy_thru, name=None, *args, **kwargs): |
| 793 |
""" |
| 794 |
AdmittanceCancel De-embedding Initializer |
| 795 |
|
| 796 |
Parameters |
| 797 |
----------- |
| 798 |
|
| 799 |
dummy_thru : :class:`~skrf.network.Network` object |
| 800 |
Measurement of the dummy thru structure |
| 801 |
|
| 802 |
name : string |
| 803 |
Optional name of de-embedding object |
| 804 |
|
| 805 |
args, kwargs: |
| 806 |
Passed to :func:`Deembedding.__init__` |
| 807 |
|
| 808 |
See Also |
| 809 |
--------- |
| 810 |
:func:`Deembedding.__init__` |
| 811 |
|
| 812 |
""" |
| 813 |
self.thru = dummy_thru.copy() |
| 814 |
dummies = [self.thru] |
| 815 |
|
| 816 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 817 |
|
| 818 |
def deembed(self, ntwk): |
| 819 |
""" |
| 820 |
Perform the de-embedding calculation |
| 821 |
|
| 822 |
Parameters |
| 823 |
---------- |
| 824 |
|
| 825 |
ntwk : :class:`~skrf.network.Network` object |
| 826 |
Network data of device measurement from which |
| 827 |
parasitics needs to be removed via de-embedding |
| 828 |
|
| 829 |
Returns |
| 830 |
------- |
| 831 |
|
| 832 |
caled : :class:`~skrf.network.Network` object |
| 833 |
Network data of the device after de-embedding |
| 834 |
""" |
| 835 |
|
| 836 |
|
| 837 |
if ntwk.frequency != self.thru.frequency: |
| 838 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 839 |
RuntimeWarning, stacklevel=2) |
| 840 |
ntwk, thru = overlap_multi([ntwk, self.thru]) |
| 841 |
else: |
| 842 |
thru = self.thru |
| 843 |
|
| 844 |
caled = ntwk.copy() |
| 845 |
h = ntwk ** thru.inv |
| 846 |
h_ = h.flipped() |
| 847 |
caled.y = (h.y + h_.y) / 2 |
| 848 |
|
| 849 |
return caled |
| 850 |
|
| 851 |
|
| 852 |
class ImpedanceCancel(Deembedding): |
| 853 |
""" |
| 854 |
Cancel series impedance by swapping. |
| 855 |
|
| 856 |
A deembedding object is created with just one thru dummy measurement `dummy_thru`. |
| 857 |
The thru dummy is, for example, a direct cascaded connection of the left and right test pads. |
| 858 |
|
| 859 |
When :func:`Deembedding.deembed` is applied, |
| 860 |
the series impedance of the thru dummy are canceled, |
| 861 |
from the DUT measurement by left-right mirroring operation. |
| 862 |
|
| 863 |
This method is applicable to only symmetric (i.e. S11=S22 and S12=S21) 2-port DUTs, |
| 864 |
but suitable for the characterization of transmission lines at mmW frequencies. |
| 865 |
For more information, see [5]_ |
| 866 |
|
| 867 |
References |
| 868 |
------------ |
| 869 |
.. [5] S. Amakawa, K. Katayama, K. Takano, T. Yoshida, and M. Fujishima, |
| 870 |
“Comparative analysis of on-chip transmission line de-embedding techniques,” |
| 871 |
in 2015 IEEE International Symposium on Radio-Frequency Integration Technology, |
| 872 |
Sendai, Japan, Aug. 2015, pp. 91–93. |
| 873 |
|
| 874 |
|
| 875 |
Example |
| 876 |
-------- |
| 877 |
>>> import skrf as rf |
| 878 |
>>> from skrf.calibration import ImpedanceCancel |
| 879 |
|
| 880 |
Create network objects for dummy structure and dut |
| 881 |
|
| 882 |
>>> th = rf.Network('thru_ckt.s2p') |
| 883 |
>>> dut = rf.Network('full_ckt.s2p') |
| 884 |
|
| 885 |
Create de-embedding object |
| 886 |
|
| 887 |
>>> dm = ImpedanceCancel(dummy_thru = th, name = 'test_thru') |
| 888 |
|
| 889 |
Remove parasitics to get the actual device network |
| 890 |
|
| 891 |
>>> realdut = dm.deembed(dut) |
| 892 |
""" |
| 893 |
|
| 894 |
def __init__(self, dummy_thru, name=None, *args, **kwargs): |
| 895 |
""" |
| 896 |
ImpedanceCancel De-embedding Initializer |
| 897 |
|
| 898 |
Parameters |
| 899 |
----------- |
| 900 |
|
| 901 |
dummy_thru : :class:`~skrf.network.Network` object |
| 902 |
Measurement of the dummy thru structure |
| 903 |
|
| 904 |
name : string |
| 905 |
Optional name of de-embedding object |
| 906 |
|
| 907 |
args, kwargs: |
| 908 |
Passed to :func:`Deembedding.__init__` |
| 909 |
|
| 910 |
See Also |
| 911 |
--------- |
| 912 |
|
| 913 |
:func:`Deembedding.__init__` |
| 914 |
""" |
| 915 |
self.thru = dummy_thru.copy() |
| 916 |
dummies = [self.thru] |
| 917 |
|
| 918 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 919 |
|
| 920 |
def deembed(self, ntwk): |
| 921 |
""" |
| 922 |
Perform the de-embedding calculation |
| 923 |
|
| 924 |
Parameters |
| 925 |
---------- |
| 926 |
|
| 927 |
ntwk : :class:`~skrf.network.Network` object |
| 928 |
Network data of device measurement from which |
| 929 |
parasitics needs to be removed via de-embedding |
| 930 |
|
| 931 |
Returns |
| 932 |
------- |
| 933 |
|
| 934 |
caled : :class:`~skrf.network.Network` object |
| 935 |
Network data of the device after de-embedding |
| 936 |
""" |
| 937 |
|
| 938 |
|
| 939 |
if ntwk.frequency != self.thru.frequency: |
| 940 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 941 |
RuntimeWarning, stacklevel=2) |
| 942 |
ntwk, thru = overlap_multi([ntwk, self.thru]) |
| 943 |
else: |
| 944 |
thru = self.thru |
| 945 |
|
| 946 |
caled = ntwk.copy() |
| 947 |
h = ntwk ** thru.inv |
| 948 |
h_ = h.flipped() |
| 949 |
caled.z = (h.z + h_.z) / 2 |
| 950 |
|
| 951 |
return caled |
| 952 |
|
| 953 |
|
| 954 |
class IEEEP370(Deembedding): |
| 955 |
""" |
| 956 |
Abstract Base Class for all IEEEP370 de-embedding class. |
| 957 |
|
| 958 |
This class implements the common mechanisms for all IEEEP370 de-embedding |
| 959 |
algorithms. Specific algorithms should inherit this |
| 960 |
class and override the methods: |
| 961 |
* :func:`IEEEP370.deembed` |
| 962 |
* :func:`IEEEP370.split2xthru` |
| 963 |
|
| 964 |
Based on [ElSA20]_, [I3E3701]_, [I3E3702]_, [I3E3703]_, [I3E3704]_, |
| 965 |
and [I3E3705]_. |
| 966 |
|
| 967 |
References |
| 968 |
---------- |
| 969 |
.. [ElSA20] Ellison J, Smith SB, Agili S., "Using a 2x-thru standard to achieve |
| 970 |
accurate de-embedding of measurements", Microwave Optical Technology |
| 971 |
Letter, 2020, https://doi.org/10.1002/mop.32098 |
| 972 |
.. [I3E3701] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP3702xThru.m, |
| 973 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 974 |
.. [I3E3702] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370mmZc2xthru.m |
| 975 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 976 |
.. [I3E3703] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370Zc2xThru.m |
| 977 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 978 |
.. [I3E3704] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370mmZc2xthru.m |
| 979 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 980 |
.. [I3E3705] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG3/qualityCheckFrequencyDomain.m |
| 981 |
commit 8b8f3a3b5e41aeb4ab16110bbfb683ec52e70206 |
| 982 |
""" |
| 983 |
def __init__(self, dummies: Sequence[Network], name: str = None, |
| 984 |
*args, **kwargs) -> None: |
| 985 |
r""" |
| 986 |
IEEEP370 de-embedding Initializer. |
| 987 |
|
| 988 |
Parameters |
| 989 |
---------- |
| 990 |
dummies : list of :class:`~skrf.network.Network` objects |
| 991 |
Network info of all the dummy structures used in a |
| 992 |
given de-embedding algorithm. |
| 993 |
|
| 994 |
name : string |
| 995 |
Name of this de-embedding instance, like 'open-short-set1' |
| 996 |
This is for convenience of identification. |
| 997 |
|
| 998 |
\*args, \*\*kwargs : keyword arguments |
| 999 |
stored in self.args and self.kwargs, which may be used |
| 1000 |
by sub-classes if needed. |
| 1001 |
""" |
| 1002 |
Deembedding.__init__(self, dummies, name, *args, **kwargs) |
| 1003 |
|
| 1004 |
@abstractmethod |
| 1005 |
def deembed(self, ntwk: Network) -> Network: |
| 1006 |
""" |
| 1007 |
Apply de-embedding correction to a Network |
| 1008 |
""" |
| 1009 |
pass |
| 1010 |
|
| 1011 |
@abstractmethod |
| 1012 |
def split2xthru(self): |
| 1013 |
""" |
| 1014 |
Determine fixtures models |
| 1015 |
""" |
| 1016 |
pass |
| 1017 |
|
| 1018 |
@staticmethod |
| 1019 |
def extrapolate_to_dc(ntwk: Network) -> Network: |
| 1020 |
""" |
| 1021 |
Extrapolate the network to DC using IEEE370 NZC algorithm. |
| 1022 |
This is useful to compare the fixtures and deembedded networks |
| 1023 |
to the input data in the same conditions used by NZC algorithm. |
| 1024 |
If the network already have a DC point, it will be replaced. |
| 1025 |
|
| 1026 |
Parameters |
| 1027 |
---------- |
| 1028 |
ntwk : :class:`~skrf.network.Network` object |
| 1029 |
Network to be extrapolated to DC |
| 1030 |
|
| 1031 |
Returns |
| 1032 |
------- |
| 1033 |
ntwk_dc : :class:`~skrf.network.Network` object |
| 1034 |
Network with DC point |
| 1035 |
|
| 1036 |
""" |
| 1037 |
name = ntwk.name |
| 1038 |
s = ntwk.s |
| 1039 |
f = ntwk.frequency.f |
| 1040 |
port_modes = ntwk.port_modes |
| 1041 |
|
| 1042 |
if(f[0] == 0): |
| 1043 |
warnings.warn( |
| 1044 |
"Existing DC point is replaced by extrapolated value.", |
| 1045 |
RuntimeWarning, stacklevel=2 |
| 1046 |
) |
| 1047 |
f = f[1:] |
| 1048 |
s = s[1:] |
| 1049 |
|
| 1050 |
df = f[1] - f[0] |
| 1051 |
tol = 0.1 |
| 1052 |
if(np.abs(f[0] - df) > tol): |
| 1053 |
warnings.warn( |
| 1054 |
"""Non-uniform frequency vector detected. Consider interpolation.""", |
| 1055 |
RuntimeWarning, stacklevel=2 |
| 1056 |
) |
| 1057 |
n_ports = ntwk.number_of_ports |
| 1058 |
z0 = ntwk.z0[0] |
| 1059 |
n = len(f) |
| 1060 |
snew = zeros((n + 1, n_ports, n_ports), dtype = complex) |
| 1061 |
snew[1:,:,:] = s |
| 1062 |
for i in range(n_ports): |
| 1063 |
for j in range(n_ports): |
| 1064 |
if i == j: |
| 1065 |
snew[0, i, j] = IEEEP370.DC(s[:, i, j], f) |
| 1066 |
else: |
| 1067 |
snew[0, i, j] = IEEEP370.dc_interp(s[:, i, j], f) |
| 1068 |
|
| 1069 |
f = concatenate(([0], f)) |
| 1070 |
ntwk_dc = Network(frequency = Frequency.from_f(f, 'Hz'), s = snew, |
| 1071 |
z0 = z0, name = name) |
| 1072 |
ntwk_dc.port_modes = port_modes |
| 1073 |
return ntwk_dc |
| 1074 |
|
| 1075 |
@staticmethod |
| 1076 |
def dc_interp(s: ndarray, f: ndarray) -> float: |
| 1077 |
""" |
| 1078 |
enforces symmetric upon the first 10 points and interpolates the DC |
| 1079 |
point. |
| 1080 |
""" |
| 1081 |
sp = s[0:9] |
| 1082 |
fp = f[0:9] |
| 1083 |
|
| 1084 |
snp = concatenate((conj(flip(sp)), sp)) |
| 1085 |
fnp = concatenate((-1*flip(fp), fp)) |
| 1086 |
|
| 1087 |
snew = interp1d(fnp, snp, axis=0, kind = 'cubic') |
| 1088 |
return real(snew(0)) |
| 1089 |
|
| 1090 |
@staticmethod |
| 1091 |
def COM_receiver_noise_filter(f: ndarray, fr: float) -> ndarray: |
| 1092 |
""" |
| 1093 |
receiver filter in COM defined by eq 93A-20 |
| 1094 |
As defined in 802.3-2022 - IEEE Standard for Ethernet annex 93A |
| 1095 |
""" |
| 1096 |
fdfr = f / fr |
| 1097 |
|
| 1098 |
return 1 / (1 - 3.414214 * fdfr**2 + fdfr**4 + 1j*2.613126*(fdfr - fdfr**3)) |
| 1099 |
|
| 1100 |
@staticmethod |
| 1101 |
def makeStep(impulse: ndarray) -> ndarray: |
| 1102 |
""" |
| 1103 |
Make a time-domain step response from an impulse response. |
| 1104 |
""" |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
return np.cumsum(impulse, axis=0) |
| 1109 |
|
| 1110 |
@staticmethod |
| 1111 |
def DC(s: ndarray, f: ndarray, allowedError: float = 1e-12) -> float: |
| 1112 |
""" |
| 1113 |
Advanced reflective DC point extrapolation. |
| 1114 |
""" |
| 1115 |
DCpoint = 0.002 |
| 1116 |
err = 1 |
| 1117 |
cnt = 0 |
| 1118 |
df = f[1] - f[0] |
| 1119 |
n = len(f) |
| 1120 |
t = np.linspace(-1/df,1/df,n*2+1) |
| 1121 |
ts = np.argmin(np.abs(t - (-3e-9))) |
| 1122 |
Hr = IEEEP370.COM_receiver_noise_filter(f, f[-1]/2) |
| 1123 |
while(err > allowedError): |
| 1124 |
h1 = IEEEP370.makeStep( |
| 1125 |
fftshift(irfft(concatenate(([DCpoint], Hr * s)), axis=0), axes=0)) |
| 1126 |
h2 = IEEEP370.makeStep( |
| 1127 |
fftshift(irfft(concatenate(([DCpoint + 0.001], Hr * s)), axis=0), axes=0)) |
| 1128 |
m = (h2[ts] - h1[ts]) / 0.001 |
| 1129 |
b = h1[ts] - m * DCpoint |
| 1130 |
DCpoint = (0 - b) / m |
| 1131 |
err = np.abs(h1[ts] - 0) |
| 1132 |
cnt += 1 |
| 1133 |
return DCpoint |
| 1134 |
|
| 1135 |
@staticmethod |
| 1136 |
def thru(ntwk: Network) -> Network: |
| 1137 |
""" |
| 1138 |
Create a perfect thru |
| 1139 |
|
| 1140 |
Parameters |
| 1141 |
---------- |
| 1142 |
ntwk : :class:`~skrf.network.Network` object |
| 1143 |
Network from which copy frequency, z0 and other parameters. |
| 1144 |
The S-parameters will be replaced by zero-length matched lossless |
| 1145 |
thru. |
| 1146 |
|
| 1147 |
Returns |
| 1148 |
------- |
| 1149 |
out : :class:`~skrf.network.Network` object |
| 1150 |
Network of the perfect thru |
| 1151 |
|
| 1152 |
""" |
| 1153 |
out = ntwk.copy() |
| 1154 |
out.s[:, 0, 0] = 0 |
| 1155 |
out.s[:, 1, 0] = 1 |
| 1156 |
out.s[:, 0, 1] = 1 |
| 1157 |
out.s[:, 1, 1] = 0 |
| 1158 |
return out |
| 1159 |
|
| 1160 |
@staticmethod |
| 1161 |
def add_dc(ntwk: Network) -> Network: |
| 1162 |
""" |
| 1163 |
Extrapolate a network to DC using interpolation for all S-parameters. |
| 1164 |
|
| 1165 |
Parameters |
| 1166 |
---------- |
| 1167 |
ntwk : :class:`~skrf.network.Network` object |
| 1168 |
Network to be extrapolated to DC |
| 1169 |
|
| 1170 |
Returns |
| 1171 |
------- |
| 1172 |
out : :class:`~skrf.network.Network` object |
| 1173 |
Network with DC point |
| 1174 |
|
| 1175 |
""" |
| 1176 |
s = ntwk.s |
| 1177 |
f = ntwk.frequency.f |
| 1178 |
z0 = ntwk.z0[0] |
| 1179 |
n = len(f) |
| 1180 |
snew = zeros((n + 1, 2,2), dtype = complex) |
| 1181 |
snew[1:,:,:] = s |
| 1182 |
snew[0, 0, 0] = IEEEP370.dc_interp(s[:, 0, 0], f) |
| 1183 |
snew[0, 0, 1] = IEEEP370.dc_interp(s[:, 0, 1], f) |
| 1184 |
snew[0, 1, 0] = IEEEP370.dc_interp(s[:, 1, 0], f) |
| 1185 |
snew[0, 1, 1] = IEEEP370.dc_interp(s[:, 1, 1], f) |
| 1186 |
|
| 1187 |
f = concatenate(([0], f)) |
| 1188 |
return Network(frequency = Frequency.from_f(f, 'Hz'), s = snew, z0 = z0) |
| 1189 |
|
| 1190 |
@staticmethod |
| 1191 |
def getz(s: ndarray, f: ndarray, z0: float) -> ndarray: |
| 1192 |
""" |
| 1193 |
Compute step response to get the time-domain impedance from S-parameters. |
| 1194 |
The S-parameters are DC extrapolated first. |
| 1195 |
|
| 1196 |
Parameters |
| 1197 |
---------- |
| 1198 |
s : :array-like |
| 1199 |
1-Port S-parameters array |
| 1200 |
f : :array-like |
| 1201 |
Frequency array for DC extrapolation |
| 1202 |
z0: :array-like |
| 1203 |
Reference impedance |
| 1204 |
|
| 1205 |
Returns |
| 1206 |
------- |
| 1207 |
z : :array-like |
| 1208 |
Time-domain impedance step response |
| 1209 |
|
| 1210 |
""" |
| 1211 |
DC11 = IEEEP370.DC(s, f, 1e-10) |
| 1212 |
t112x = irfft(concatenate(([DC11], s))) |
| 1213 |
|
| 1214 |
|
| 1215 |
t112xStep = IEEEP370.makeStep(fftshift(t112x)) |
| 1216 |
|
| 1217 |
z = -z0 * (t112xStep + 1) / (t112xStep - 1) |
| 1218 |
z = ifftshift(z) |
| 1219 |
return z |
| 1220 |
|
| 1221 |
@staticmethod |
| 1222 |
def makeTL(zline: float, z0: float, gamma: ndarray, l: float) -> ndarray: |
| 1223 |
""" |
| 1224 |
Compute the S-parameters of a transmission line. |
| 1225 |
|
| 1226 |
Parameters |
| 1227 |
---------- |
| 1228 |
zline : :number |
| 1229 |
Characteristic impedance |
| 1230 |
z0 : :number |
| 1231 |
Port impedance to renormalize into |
| 1232 |
gamma : :array-like |
| 1233 |
Frequency-dependent propagation constant |
| 1234 |
l : :number |
| 1235 |
Length in the same length unit as gamma |
| 1236 |
|
| 1237 |
Returns |
| 1238 |
------- |
| 1239 |
TL : :array-like |
| 1240 |
S_Parameters of the transmission line |
| 1241 |
""" |
| 1242 |
|
| 1243 |
n = len(gamma) |
| 1244 |
TL = np.zeros((n, 2, 2), dtype = complex) |
| 1245 |
TL[:, 0, 0] = (((zline**2 - z0**2) * np.sinh(gamma * l)) |
| 1246 |
/ ((zline**2 + z0**2) * np.sinh(gamma * l) + 2 * z0 * zline * np.cosh(gamma * l))) |
| 1247 |
TL[:, 1, 0] = (2 * z0 * zline) / ((zline**2 + z0**2) * np.sinh(gamma * l) + 2 * z0 * zline * np.cosh(gamma * l)) |
| 1248 |
TL[:, 0, 1] = (2 * z0 * zline) / ((zline**2 + z0**2) * np.sinh(gamma * l) + 2 * z0 * zline * np.cosh(gamma * l)) |
| 1249 |
TL[:, 1, 1] = (((zline**2 - z0**2) * np.sinh(gamma * l)) |
| 1250 |
/ ((zline**2 + z0**2) * np.sinh(gamma * l) + 2 * z0 * zline * np.cosh(gamma * l))) |
| 1251 |
return TL |
| 1252 |
|
| 1253 |
@staticmethod |
| 1254 |
def NRP(ntwk: Network, TD: ndarray = None, port: int = None) -> (Network, ndarray): |
| 1255 |
""" |
| 1256 |
Enforce the Nyquist Rate Point. |
| 1257 |
Force the length of the transmissive network to be an integer multiple |
| 1258 |
of the wavelength at the highest frequency. |
| 1259 |
If required, a proper delay is added to meet this condition. |
| 1260 |
The function can also be used to remove the delay. |
| 1261 |
|
| 1262 |
Parameters |
| 1263 |
---------- |
| 1264 |
ntwk : :class:`~skrf.network.Network` object |
| 1265 |
Network to be extrapolated to DC |
| 1266 |
TD : :array-like |
| 1267 |
If None, the delay will be computed and added. |
| 1268 |
Else, the delay will be removed (to reset the original length). |
| 1269 |
(default: None) |
| 1270 |
port: :Number |
| 1271 |
Specify to apply NRP only on a single port of the network (default: None) |
| 1272 |
|
| 1273 |
Returns |
| 1274 |
------- |
| 1275 |
TL : :array-like |
| 1276 |
S_Parameters of the transmission line |
| 1277 |
""" |
| 1278 |
p = ntwk.s |
| 1279 |
f = ntwk.frequency.f |
| 1280 |
n = len(f) |
| 1281 |
X = ntwk.nports |
| 1282 |
fend = f[-1] |
| 1283 |
if TD is None: |
| 1284 |
TD = np.zeros(X) |
| 1285 |
for i in range(X): |
| 1286 |
theta0 = angle(p[-1, i, i]) |
| 1287 |
if theta0 < -np.pi/2: |
| 1288 |
theta = -np.pi - theta0 |
| 1289 |
elif theta0 > np.pi/2: |
| 1290 |
theta = np.pi - theta0 |
| 1291 |
else: |
| 1292 |
theta = -theta0 |
| 1293 |
|
| 1294 |
TD[i] = -theta / (2 * np.pi * fend) |
| 1295 |
pd = np.zeros((n, X, X), dtype = complex) |
| 1296 |
delay = exp(-1j * 2. * np.pi * f * TD[i] / 2.) |
| 1297 |
if i == 0: |
| 1298 |
pd[:, i + X//2, i] = delay |
| 1299 |
pd[:, i, i + X//2] = delay |
| 1300 |
spd = ntwk.copy() |
| 1301 |
spd.s = pd |
| 1302 |
out = spd ** ntwk |
| 1303 |
elif i < X//2: |
| 1304 |
pd[:, i + X//2, i] = delay |
| 1305 |
pd[:, i, i + X//2] = delay |
| 1306 |
spd = ntwk.copy() |
| 1307 |
spd.s = pd |
| 1308 |
out = spd ** out |
| 1309 |
else: |
| 1310 |
pd[:, i - X//2, i] = delay |
| 1311 |
pd[:, i, i - X//2] = delay |
| 1312 |
spd = ntwk.copy() |
| 1313 |
spd.s = pd |
| 1314 |
out = out ** spd |
| 1315 |
else: |
| 1316 |
pd = np.zeros((n, X, X), dtype = complex) |
| 1317 |
if port is not None: |
| 1318 |
i = port |
| 1319 |
delay = exp(1j * 2. * np.pi * f * TD[i] / 2.) |
| 1320 |
if i < X//2: |
| 1321 |
pd[:, i + X//2, i] = delay |
| 1322 |
pd[:, i, i + X//2] = delay |
| 1323 |
spd = ntwk.copy() |
| 1324 |
spd.s = pd |
| 1325 |
out = spd ** ntwk |
| 1326 |
else: |
| 1327 |
pd[:, i - X//2, i] = delay |
| 1328 |
pd[:, i, i - X//2] = delay |
| 1329 |
spd = ntwk.copy() |
| 1330 |
spd.s = pd |
| 1331 |
out = ntwk ** spd |
| 1332 |
else: |
| 1333 |
for i in range(X): |
| 1334 |
delay = exp(1j * 2. * np.pi * f * TD[i] / 2) |
| 1335 |
if i == 0: |
| 1336 |
pd[:, i + X//2, i] = delay |
| 1337 |
pd[:, i, i + X//2] = delay |
| 1338 |
spd = ntwk.copy() |
| 1339 |
spd.s = pd |
| 1340 |
out = spd ** ntwk |
| 1341 |
elif i < X//2: |
| 1342 |
pd[:, i + X//2, i] = delay |
| 1343 |
pd[:, i, i + X//2] = delay |
| 1344 |
spd = ntwk.copy() |
| 1345 |
spd.s = pd |
| 1346 |
out = spd ** out |
| 1347 |
else: |
| 1348 |
pd[:, i - X//2, i] = delay |
| 1349 |
pd[:, i, i - X//2] = delay |
| 1350 |
spd = ntwk.copy() |
| 1351 |
spd.s = pd |
| 1352 |
out = out ** spd |
| 1353 |
return out, TD |
| 1354 |
|
| 1355 |
@staticmethod |
| 1356 |
def shiftOnePort(ntwk: Network, N: int, port: int) -> Network: |
| 1357 |
""" |
| 1358 |
Shift one port of the network of N samples in time-domain. |
| 1359 |
This is achieved by cascading a delay. |
| 1360 |
|
| 1361 |
Parameters |
| 1362 |
---------- |
| 1363 |
ntwk: :class:`~skrf.network.Network` object |
| 1364 |
Network to be shifted |
| 1365 |
N : :number |
| 1366 |
Number of point to shift |
| 1367 |
port: :Number |
| 1368 |
Port to be shifted |
| 1369 |
|
| 1370 |
Returns |
| 1371 |
------- |
| 1372 |
out : :class:`~skrf.network.Network` object |
| 1373 |
Shifted network |
| 1374 |
""" |
| 1375 |
f = ntwk.frequency.f |
| 1376 |
n = len(f) |
| 1377 |
X = ntwk.nports |
| 1378 |
Omega0 = np.pi/n |
| 1379 |
Omega = np.arange(Omega0, np.pi + Omega0, Omega0) |
| 1380 |
delay = exp(-N * 1j * Omega/2) |
| 1381 |
pd = np.zeros((n, 2, 2), dtype = complex) |
| 1382 |
if port < X//2: |
| 1383 |
pd[:, port, port + X//2] = delay |
| 1384 |
pd[:, port + X//2, port] = delay |
| 1385 |
spd = ntwk.copy() |
| 1386 |
spd.s = pd |
| 1387 |
out = spd ** ntwk |
| 1388 |
else: |
| 1389 |
pd[:, port, port - X//2] = delay |
| 1390 |
pd[:, port - X//2, port] = delay |
| 1391 |
spd = ntwk.copy() |
| 1392 |
spd.s = pd |
| 1393 |
out = ntwk ** spd |
| 1394 |
return out |
| 1395 |
|
| 1396 |
@staticmethod |
| 1397 |
def shiftNPoints(ntwk: Network, N: int) -> Network: |
| 1398 |
""" |
| 1399 |
Shift the whole network of N samples in time-domain. |
| 1400 |
This is achieved by cascading a delay. |
| 1401 |
|
| 1402 |
Parameters |
| 1403 |
---------- |
| 1404 |
ntwk: :class:`~skrf.network.Network` object |
| 1405 |
Network to be shifted |
| 1406 |
N : :number |
| 1407 |
Number of point to shift |
| 1408 |
|
| 1409 |
Returns |
| 1410 |
------- |
| 1411 |
out : :class:`~skrf.network.Network` object |
| 1412 |
Shifted network |
| 1413 |
""" |
| 1414 |
f = ntwk.frequency.f |
| 1415 |
n = len(f) |
| 1416 |
X = ntwk.nports |
| 1417 |
Omega0 = np.pi/n |
| 1418 |
Omega = np.arange(Omega0, np.pi + Omega0, Omega0) |
| 1419 |
delay = exp(-N * 1j * Omega/2) |
| 1420 |
pd = np.zeros((n, 2, 2), dtype = complex) |
| 1421 |
for port in range(X): |
| 1422 |
if port < X//2: |
| 1423 |
pd[:, port, port + X//2] = delay |
| 1424 |
pd[:, port + X//2, port] = delay |
| 1425 |
spd = ntwk.copy() |
| 1426 |
spd.s = pd |
| 1427 |
p = spd ** ntwk |
| 1428 |
else: |
| 1429 |
pd[:, port, port - X//2] = delay |
| 1430 |
pd[:, port - X//2, port] = delay |
| 1431 |
spd = ntwk.copy() |
| 1432 |
spd.s = pd |
| 1433 |
out = p ** spd |
| 1434 |
return out |
| 1435 |
|
| 1436 |
@staticmethod |
| 1437 |
def peelNPointsLossless(ntwk: Network, N: int, z0: float) -> Network: |
| 1438 |
""" |
| 1439 |
Peel N points of the network on both side and return the corresponding |
| 1440 |
error boxes. |
| 1441 |
This is done in a lossless way without determination of the propagation |
| 1442 |
constant gamma. |
| 1443 |
|
| 1444 |
Parameters |
| 1445 |
---------- |
| 1446 |
ntwk: :class:`~skrf.network.Network` object |
| 1447 |
Network to be peeled |
| 1448 |
N : :number |
| 1449 |
Number of points to peel |
| 1450 |
z0 : :number |
| 1451 |
Reference impedance |
| 1452 |
gamma : :array-like |
| 1453 |
Frequency-dependent propagation constant |
| 1454 |
|
| 1455 |
Returns |
| 1456 |
------- |
| 1457 |
out : :class:`~skrf.network.Network` object |
| 1458 |
Peeled network |
| 1459 |
out : :class:`~skrf.network.Network` object |
| 1460 |
Error box side port 1 |
| 1461 |
out : :class:`~skrf.network.Network` object |
| 1462 |
Error box side port 2 |
| 1463 |
""" |
| 1464 |
f = ntwk.frequency.f |
| 1465 |
n = len(f) |
| 1466 |
out = ntwk.copy() |
| 1467 |
Omega0 = np.pi/n |
| 1468 |
Omega = np.arange(Omega0, np.pi + Omega0, Omega0) |
| 1469 |
betal = 1j * Omega/2 |
| 1470 |
for i in range(N): |
| 1471 |
p = out.s |
| 1472 |
|
| 1473 |
zline1 = IEEEP370.getz(p[:, 0, 0], f, z0)[0] |
| 1474 |
zline2 = IEEEP370.getz(p[:, 1, 1], f, z0)[0] |
| 1475 |
|
| 1476 |
TL1 = IEEEP370.makeTL(zline1, z0, betal, 1) |
| 1477 |
TL2 = IEEEP370.makeTL(zline2, z0, betal, 1) |
| 1478 |
sTL1 = ntwk.copy() |
| 1479 |
sTL1.s = TL1 |
| 1480 |
sTL2 = ntwk.copy() |
| 1481 |
sTL2.s = TL2 |
| 1482 |
|
| 1483 |
|
| 1484 |
out = sTL1.inv ** out ** sTL2.inv |
| 1485 |
|
| 1486 |
if i == 0: |
| 1487 |
eb1 = sTL1.copy() |
| 1488 |
eb2 = sTL2.copy() |
| 1489 |
else: |
| 1490 |
eb1 = eb1 ** sTL1 |
| 1491 |
eb2 = sTL2 ** eb2 |
| 1492 |
|
| 1493 |
return out, eb1, eb2 |
| 1494 |
|
| 1495 |
class IEEEP370_FER: |
| 1496 |
""" |
| 1497 |
IEEE 370 checking for fixture electrical requirements (FER) in the |
| 1498 |
frequency and in the time domains. |
| 1499 |
|
| 1500 |
Based on [IEEE370]_. |
| 1501 |
|
| 1502 |
References |
| 1503 |
---------- |
| 1504 |
.. [IEEE370] IEEE Standard for Electrical Characterization of Printed |
| 1505 |
Circuit Board and Related Interconnects at Frequencies up to 50 GHz", |
| 1506 |
IEEE 370-2020. |
| 1507 |
""" |
| 1508 |
def plot_constant_limit(self, frequency: Frequency, value: float, ax: Axes, |
| 1509 |
**kwargs) -> None: |
| 1510 |
""" |
| 1511 |
Plot a constant limit line. |
| 1512 |
""" |
| 1513 |
ax.plot([frequency.f[0], frequency.f[-1]], [value, value], **kwargs) |
| 1514 |
|
| 1515 |
def plot_relative_limit(self, x: ndarray, y: ndarray, value: float, ax: Axes, |
| 1516 |
**kwargs) -> None: |
| 1517 |
""" |
| 1518 |
Plot positive and negative relative limit line around a reference trace. |
| 1519 |
""" |
| 1520 |
ax.plot(x, y * (1.0 + value), **kwargs) |
| 1521 |
kwargs.pop('label', None) |
| 1522 |
ax.plot(x, y * (1.0 - value), label = '_nolabel_', **kwargs) |
| 1523 |
|
| 1524 |
def plot_limit_fer1(self, frequency: Frequency, ax: Axes) -> None: |
| 1525 |
""" |
| 1526 |
Plot fer 1 limit lines. |
| 1527 |
""" |
| 1528 |
self.plot_constant_limit(frequency, -10, ax, color = 'g', |
| 1529 |
linestyle = 'dashed', label = 'Minimum A') |
| 1530 |
self.plot_constant_limit(frequency, -15, ax, color = 'r', |
| 1531 |
linestyle = 'dashed', label = 'Minimum B, C') |
| 1532 |
|
| 1533 |
def plot_limit_fer2(self, frequency: Frequency, ax: Axes) -> None: |
| 1534 |
""" |
| 1535 |
Plot fer 2 limit lines. |
| 1536 |
""" |
| 1537 |
self.plot_constant_limit(frequency, -20, ax, color = 'g', |
| 1538 |
linestyle = 'dashed', label = 'Maximum A') |
| 1539 |
self.plot_constant_limit(frequency, -10, ax, color = 'b', |
| 1540 |
linestyle = 'dashed', label = 'Maximum B') |
| 1541 |
self.plot_constant_limit(frequency, -6, ax, color = 'r', |
| 1542 |
linestyle = 'dashed', label = 'Maximum C') |
| 1543 |
|
| 1544 |
def plot_limit_fer3(self, frequency: Frequency, ax: Axes) -> None: |
| 1545 |
""" |
| 1546 |
Plot fer 3 limit lines. |
| 1547 |
""" |
| 1548 |
self.plot_constant_limit(frequency, 5, ax, color = 'g', |
| 1549 |
linestyle = 'dashed', label = 'Minimum A') |
| 1550 |
self.plot_constant_limit(frequency, 0, ax, color = 'r', |
| 1551 |
linestyle = 'dashed', label = 'Minimum B, C') |
| 1552 |
|
| 1553 |
def plot_limit_fer5(self, x: ndarray, y: ndarray, ax: Axes) -> None: |
| 1554 |
""" |
| 1555 |
Plot fer 5 limit lines. |
| 1556 |
""" |
| 1557 |
self.plot_relative_limit(x, y, 0.025, ax, linestyle = 'dashed', color = 'g', |
| 1558 |
label = 'Limit A ±2.5%') |
| 1559 |
self.plot_relative_limit(x, y, 0.05, ax, linestyle = 'dashed', color = 'b', |
| 1560 |
label = 'Limit B ±5%') |
| 1561 |
self.plot_relative_limit(x, y, 0.1, ax, linestyle = 'dashed', color = 'r', |
| 1562 |
label = 'Limit C ±10%') |
| 1563 |
|
| 1564 |
def plot_limit_fer6(self, frequency: Frequency, ax: Axes) -> None: |
| 1565 |
""" |
| 1566 |
Plot fer 6 limit lines. |
| 1567 |
""" |
| 1568 |
self.plot_constant_limit(frequency, -15, ax, color = 'r', |
| 1569 |
linestyle = 'dashed', label = 'Maximum A, B, C') |
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
def plot_fd_se_fer(self, s2xthru: Network, fig: Figure = None) -> Figure: |
| 1574 |
""" |
| 1575 |
Plot fixture electrical requirements (FER) for s values |
| 1576 |
""" |
| 1577 |
if fig is None: |
| 1578 |
fig = figure(figsize=(8, 8)) |
| 1579 |
|
| 1580 |
fig.suptitle('Fixture electrical requirements (FER)') |
| 1581 |
|
| 1582 |
ax = fig.add_subplot(2, 2, 1) |
| 1583 |
ax.set_title('FER1 2x-Thru IL') |
| 1584 |
s2xthru.plot_s_db(1, 0, ax = ax, color = '0.5') |
| 1585 |
s2xthru.plot_s_db(0, 1, ax = ax, color = 'k') |
| 1586 |
self.plot_limit_fer1(s2xthru.frequency, ax) |
| 1587 |
ax.legend(loc = 'lower left') |
| 1588 |
|
| 1589 |
ax = fig.add_subplot(2, 2, 2) |
| 1590 |
ax.set_title('FER2 2x-Thru RL') |
| 1591 |
s2xthru.plot_s_db(0, 0, ax = ax, color = '0.5') |
| 1592 |
s2xthru.plot_s_db(1, 1, ax = ax, color = 'k') |
| 1593 |
self.plot_limit_fer2(s2xthru.frequency, ax) |
| 1594 |
ax.legend(loc = 'lower left') |
| 1595 |
|
| 1596 |
ax = fig.add_subplot(2, 1, 2) |
| 1597 |
ax.set_title('FER3 2x-Thru IL - RL') |
| 1598 |
s1 = s2xthru.s_db[:, 1, 0] - s2xthru.s_db[:, 0, 0] |
| 1599 |
s2 = s2xthru.s_db[:, 0, 1] - s2xthru.s_db[:, 1, 1] |
| 1600 |
ax.plot(s2xthru.frequency.f, s1, color = '0.5', label = 'S21 - S11') |
| 1601 |
ax.plot(s2xthru.frequency.f, s2, color = 'k', label = 'S21 - S22') |
| 1602 |
self.plot_limit_fer3(s2xthru.frequency, ax) |
| 1603 |
ax.set_xlabel(f'Frequency ({s2xthru.frequency.unit})') |
| 1604 |
ax.set_ylabel('Magnitude (dB)') |
| 1605 |
ax.legend(loc = 'upper right') |
| 1606 |
|
| 1607 |
fig.tight_layout() |
| 1608 |
return fig |
| 1609 |
|
| 1610 |
def plot_fd_mm_fer(self, s2xthru: Network, fig: Figure = None) -> Figure: |
| 1611 |
""" |
| 1612 |
Plot fixture electrical requirements (FER) for s values |
| 1613 |
""" |
| 1614 |
if fig is None: |
| 1615 |
fig = figure(figsize=(8, 8)) |
| 1616 |
|
| 1617 |
fig.suptitle('Fixture electrical requirements (FER)') |
| 1618 |
|
| 1619 |
mm_2xthru = s2xthru.copy() |
| 1620 |
mm_2xthru.se2gmm(p=2) |
| 1621 |
|
| 1622 |
ax = fig.add_subplot(2, 2, 1) |
| 1623 |
ax.set_title('FER1 2x-Thru IL') |
| 1624 |
mm_2xthru.plot_s_db(1, 0, ax = ax, color = '0.5') |
| 1625 |
mm_2xthru.plot_s_db(0, 1, ax = ax, color = 'k') |
| 1626 |
self.plot_limit_fer1(mm_2xthru.frequency, ax) |
| 1627 |
ax.legend(loc = 'lower left') |
| 1628 |
|
| 1629 |
ax = fig.add_subplot(2, 2, 2) |
| 1630 |
ax.set_title('FER2 2x-Thru RL') |
| 1631 |
mm_2xthru.plot_s_db(0, 0, ax = ax, color = '0.5') |
| 1632 |
mm_2xthru.plot_s_db(1, 1, ax = ax, color = 'k') |
| 1633 |
self.plot_limit_fer2(mm_2xthru.frequency, ax) |
| 1634 |
ax.legend(loc = 'lower left') |
| 1635 |
|
| 1636 |
ax = fig.add_subplot(2, 2, 3) |
| 1637 |
ax.set_title('FER3 2x-Thru IL - RL') |
| 1638 |
s1 = mm_2xthru.s_db[:, 1, 0] - mm_2xthru.s_db[:, 0, 0] |
| 1639 |
s2 = mm_2xthru.s_db[:, 0, 1] - mm_2xthru.s_db[:, 1, 1] |
| 1640 |
ax.plot(mm_2xthru.frequency.f, s1, color = '0.5', label = 'S21 - S11') |
| 1641 |
ax.plot(mm_2xthru.frequency.f, s2, color = 'k', label = 'S21 - S22') |
| 1642 |
self.plot_limit_fer3(mm_2xthru.frequency, ax) |
| 1643 |
ax.set_xlabel(f'Frequency ({mm_2xthru.frequency.unit})') |
| 1644 |
ax.set_ylabel('Magnitude (dB)') |
| 1645 |
ax.legend(loc = 'upper right') |
| 1646 |
|
| 1647 |
ax = fig.add_subplot(2, 2, 4) |
| 1648 |
ax.set_title('FER6 Differential to common CDL - IL') |
| 1649 |
s1 = mm_2xthru.s_db[:, 2, 0] - mm_2xthru.s_db[:, 1, 0] |
| 1650 |
s2 = mm_2xthru.s_db[:, 3, 1] - mm_2xthru.s_db[:, 0, 1] |
| 1651 |
ax.plot(mm_2xthru.frequency.f, s1, color = '0.5', label = 'SCD21 - S21') |
| 1652 |
ax.plot(mm_2xthru.frequency.f, s2, color = 'k', label = 'SCD42 - S12') |
| 1653 |
self.plot_limit_fer6(mm_2xthru.frequency, ax) |
| 1654 |
ax.legend(loc = 'upper right') |
| 1655 |
|
| 1656 |
fig.tight_layout() |
| 1657 |
return fig |
| 1658 |
|
| 1659 |
def plot_td_se_fer(self, s2xthru: Network, sfix_dut_fix: Network, |
| 1660 |
fig: Figure = None) -> Figure: |
| 1661 |
""" |
| 1662 |
Plot fixture electrical requirements (FER) for z values |
| 1663 |
""" |
| 1664 |
if fig is None: |
| 1665 |
fig = figure(figsize=(8, 8)) |
| 1666 |
|
| 1667 |
fig.suptitle('Fixture electrical requirements (FER)') |
| 1668 |
f = s2xthru.frequency.f |
| 1669 |
s2xthru_dc = IEEEP370.extrapolate_to_dc(s2xthru) |
| 1670 |
sfix_dut_fix_dc = IEEEP370.extrapolate_to_dc(sfix_dut_fix) |
| 1671 |
n = s2xthru.frequency.npoints * 2 - 1 |
| 1672 |
dt = 1e9 / (n * s2xthru.frequency.step) |
| 1673 |
s21 = s2xthru.s[:, 1, 0] |
| 1674 |
t21 = fftshift(irfft(s21, n = n)) |
| 1675 |
x_k = np.argmax(t21) - n//2 |
| 1676 |
x_t = x_k * dt |
| 1677 |
|
| 1678 |
ax = fig.add_subplot(2, 2, 1) |
| 1679 |
ax.set_title('FER5 TDR Z variation side 1') |
| 1680 |
sfix_dut_fix_dc.plot_z_time_step(0, 0, color = 'k', ax = ax) |
| 1681 |
s2xthru_dc.plot_z_time_step(0, 0, color = 'k', linestyle = 'dashed', ax = ax) |
| 1682 |
x = ax.lines[-1].get_xdata()[:(x_k + n//2 + 1)] |
| 1683 |
y = ax.lines[-1].get_ydata()[:(x_k + n//2 + 1)] |
| 1684 |
self.plot_limit_fer5(x, y, ax) |
| 1685 |
ax.legend(loc = 'lower right') |
| 1686 |
|
| 1687 |
ymax = np.max(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1688 |
1.1 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1689 |
ymin = np.min(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1690 |
0.9 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1691 |
ax.set_ylim((ymin - 5, ymax + 5)) |
| 1692 |
delay = 2 * x_t |
| 1693 |
ax.set_xlim((-0.5 * delay, 1.5 * delay)) |
| 1694 |
|
| 1695 |
ax = fig.add_subplot(2, 2, 2) |
| 1696 |
ax.set_title('FER5 TDR Z variation side 2') |
| 1697 |
sfix_dut_fix_dc.plot_z_time_step(1, 1, color = 'k', ax = ax) |
| 1698 |
s2xthru_dc.plot_z_time_step(1, 1, color = 'k', linestyle = 'dashed', ax = ax) |
| 1699 |
x = ax.lines[-1].get_xdata()[:(x_k + n//2 + 1)] |
| 1700 |
y = ax.lines[-1].get_ydata()[:(x_k + n//2 + 1)] |
| 1701 |
self.plot_limit_fer5(x, y, ax) |
| 1702 |
ax.legend(loc = 'lower right') |
| 1703 |
|
| 1704 |
ymax = np.max(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1705 |
1.1 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1706 |
ymin = np.min(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1707 |
0.9 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1708 |
ax.set_ylim((ymin - 5, ymax + 5)) |
| 1709 |
delay = 2 * x_t |
| 1710 |
ax.set_xlim((-0.5 * delay, 1.5 * delay)) |
| 1711 |
|
| 1712 |
ax = fig.add_subplot(2, 1, 2) |
| 1713 |
ax.set_title('FER8 TDT minimum length') |
| 1714 |
s2xthru_dc.plot_z_time_impulse(1, 0, color = '0.5', ax = ax) |
| 1715 |
s2xthru_dc.plot_z_time_impulse(1, 0, color = 'k', ax = ax) |
| 1716 |
y = ax.lines[-1].get_ydata() |
| 1717 |
y_lim = [np.min(y), np.max(y)] |
| 1718 |
t_lim = [3.0e9 / f[-1], 3.0e9 / f[-1]] |
| 1719 |
ax.plot([0, 0], y_lim, color = 'b', linestyle = 'dashed', label = 'Start') |
| 1720 |
ax.plot(t_lim, y_lim, color = 'r', linestyle = 'dashed', label = 'Minimum A, B, C') |
| 1721 |
ax.legend(loc = 'upper right') |
| 1722 |
ax.set_xlim((-1, x_t + 1)) |
| 1723 |
|
| 1724 |
fig.tight_layout() |
| 1725 |
return fig |
| 1726 |
|
| 1727 |
def plot_td_mm_fer(self, s2xthru: Network, sfix_dut_fix: Network, |
| 1728 |
fig: Figure = None) -> Figure: |
| 1729 |
""" |
| 1730 |
Plot fixture electrical requirements (FER) for z values |
| 1731 |
""" |
| 1732 |
if fig is None: |
| 1733 |
fig = figure(figsize=(8, 8)) |
| 1734 |
|
| 1735 |
mm_2xthru = s2xthru.copy() |
| 1736 |
mm_2xthru.se2gmm(p=2) |
| 1737 |
mm_fix_dut_fix = sfix_dut_fix.copy() |
| 1738 |
mm_fix_dut_fix.se2gmm(p=2) |
| 1739 |
|
| 1740 |
fig.suptitle('Fixture electrical requirements (FER)') |
| 1741 |
f = mm_2xthru.frequency.f |
| 1742 |
se_2xthru_dc = IEEEP370.extrapolate_to_dc(s2xthru) |
| 1743 |
mm_2xthru_dc = IEEEP370.extrapolate_to_dc(mm_2xthru) |
| 1744 |
mm_fix_dut_fix_dc = IEEEP370.extrapolate_to_dc(mm_fix_dut_fix) |
| 1745 |
n = mm_2xthru.frequency.npoints * 2 - 1 |
| 1746 |
dt = 1e9 / (n * mm_2xthru.frequency.step) |
| 1747 |
s21 = mm_2xthru.s[:, 1, 0] |
| 1748 |
t21 = fftshift(irfft(s21, n = n)) |
| 1749 |
x_k = np.argmax(t21) - n//2 |
| 1750 |
x_t = x_k * dt |
| 1751 |
|
| 1752 |
ax = fig.add_subplot(2, 2, 1) |
| 1753 |
ax.set_title('FER5 TDR Z variation side 1') |
| 1754 |
mm_fix_dut_fix_dc.plot_z_time_step(0, 0, color = 'k', ax = ax) |
| 1755 |
mm_2xthru_dc.plot_z_time_step(0, 0, color = 'k', linestyle = 'dashed', ax = ax) |
| 1756 |
x = ax.lines[-1].get_xdata()[:(x_k + n//2 + 1)] |
| 1757 |
y = ax.lines[-1].get_ydata()[:(x_k + n//2 + 1)] |
| 1758 |
self.plot_limit_fer5(x, y, ax) |
| 1759 |
ax.legend(loc = 'lower right') |
| 1760 |
|
| 1761 |
ymax = np.max(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1762 |
1.1 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1763 |
ymin = np.min(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1764 |
0.9 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1765 |
ax.set_ylim((ymin - 5, ymax + 5)) |
| 1766 |
delay = 2 * x_t |
| 1767 |
ax.set_xlim((-0.5 * delay, 1.5 * delay)) |
| 1768 |
|
| 1769 |
ax = fig.add_subplot(2, 2, 2) |
| 1770 |
ax.set_title('FER5 TDR Z variation side 2') |
| 1771 |
mm_fix_dut_fix_dc.plot_z_time_step(1, 1, color = 'k', ax = ax) |
| 1772 |
mm_2xthru_dc.plot_z_time_step(1, 1, color = 'k', linestyle = 'dashed', ax = ax) |
| 1773 |
x = ax.lines[-1].get_xdata()[:(x_k + n//2 + 1)] |
| 1774 |
y = ax.lines[-1].get_ydata()[:(x_k + n//2 + 1)] |
| 1775 |
self.plot_limit_fer5(x, y, ax) |
| 1776 |
ax.legend(loc = 'lower right') |
| 1777 |
|
| 1778 |
ymax = np.max(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1779 |
1.1 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1780 |
ymin = np.min(np.array([ax.lines[0].get_ydata()[(n // 2):(x_k + n // 2)], |
| 1781 |
0.9 * ax.lines[1].get_ydata()[(n // 2):(x_k + n // 2)]])) |
| 1782 |
ax.set_ylim((ymin - 5, ymax + 5)) |
| 1783 |
delay = 2 * x_t |
| 1784 |
ax.set_xlim((-0.5 * delay, 1.5 * delay)) |
| 1785 |
|
| 1786 |
ax = fig.add_subplot(2, 2, 3) |
| 1787 |
ax.set_title('FER7 TDT skew') |
| 1788 |
se_2xthru_dc.plot_z_time_impulse(2, 0, color = '0.5', ax = ax) |
| 1789 |
se_2xthru_dc.plot_z_time_impulse(3, 1, color = 'k', ax = ax) |
| 1790 |
ax.legend(loc = 'upper right') |
| 1791 |
ax.set_xlim((-1, x_t + 1)) |
| 1792 |
|
| 1793 |
ax = fig.add_subplot(2, 2, 4) |
| 1794 |
ax.set_title('FER8 TDT minimum length') |
| 1795 |
mm_2xthru_dc.plot_z_time_impulse(1, 0, color = '0.5', ax = ax) |
| 1796 |
mm_2xthru_dc.plot_z_time_impulse(1, 0, color = 'k', ax = ax) |
| 1797 |
y = ax.lines[-1].get_ydata() |
| 1798 |
y_lim = [np.min(y), np.max(y)] |
| 1799 |
t_lim = [3.0e9 / f[-1], 3.0e9 / f[-1]] |
| 1800 |
ax.plot([0, 0], y_lim, color = 'b', linestyle = 'dashed', label = 'Start') |
| 1801 |
ax.plot(t_lim, y_lim, color = 'r', linestyle = 'dashed', label = 'Minimum A, B, C') |
| 1802 |
ax.legend(loc = 'upper right') |
| 1803 |
ax.set_xlim((-1, x_t + 1)) |
| 1804 |
|
| 1805 |
fig.tight_layout() |
| 1806 |
return fig |
| 1807 |
|
| 1808 |
class IEEEP370_FD_QM: |
| 1809 |
def __init__(self, verbose: bool = False) -> None: |
| 1810 |
""" |
| 1811 |
IEEE 370 initial quality checking of raw data at the given frequency |
| 1812 |
samples. |
| 1813 |
|
| 1814 |
Initial passivity (PQMi), reciprocity (RQMi), and causality (CQMi) |
| 1815 |
checks are performed on the original S-parameters data in the frequency |
| 1816 |
domain. |
| 1817 |
|
| 1818 |
Based on [IEEE370]_. |
| 1819 |
|
| 1820 |
Parameters |
| 1821 |
---------- |
| 1822 |
verbose : :boolean |
| 1823 |
Plot internal causality, passivity, and reciprocity |
| 1824 |
figures (default False) |
| 1825 |
|
| 1826 |
References |
| 1827 |
---------- |
| 1828 |
.. [IEEE370] IEEE Standard for Electrical Characterization of Printed |
| 1829 |
Circuit Board and Related Interconnects at Frequencies up to 50 GHz", |
| 1830 |
IEEE 370-2020. |
| 1831 |
""" |
| 1832 |
self.verbose = verbose |
| 1833 |
|
| 1834 |
def check_causality(self, ntwk: Network) -> float: |
| 1835 |
""" |
| 1836 |
Initial Causality Quality Metric (CQMi): verify that the complex |
| 1837 |
S-parameters rotate clockwise in the complex plane. |
| 1838 |
|
| 1839 |
This is done by computing the normalized vector product on pairs of |
| 1840 |
consecutive vectors between two frequency points. |
| 1841 |
|
| 1842 |
Parameters |
| 1843 |
---------- |
| 1844 |
ntwk: :class:`~skrf.network.Network` object |
| 1845 |
Network to be checked |
| 1846 |
|
| 1847 |
Returns |
| 1848 |
------- |
| 1849 |
PQM : :class:`~skrf.network.Network` object |
| 1850 |
Causality quality metric in percents |
| 1851 |
""" |
| 1852 |
Nf = ntwk.frequency.npoints |
| 1853 |
CQM = zeros((ntwk.nports, ntwk.nports)) |
| 1854 |
for i in range(ntwk.nports): |
| 1855 |
for j in range(ntwk.nports): |
| 1856 |
if len(np.unique(ntwk.s[:, i, j])) == 1: |
| 1857 |
CQM[i, j] = 100. |
| 1858 |
else: |
| 1859 |
TotalR = 0 |
| 1860 |
PositiveR = 0 |
| 1861 |
for k in range(Nf - 2): |
| 1862 |
Vn = ntwk.s[k + 1, i, j] - ntwk.s[k, i, j] |
| 1863 |
Vn1 = ntwk.s[k + 2, i, j] - ntwk.s[k + 1, i, j] |
| 1864 |
R = real(Vn1) * imag(Vn) - imag(Vn1) * real(Vn) |
| 1865 |
if R > 0: |
| 1866 |
PositiveR = PositiveR + R |
| 1867 |
TotalR = TotalR + np.abs(R) |
| 1868 |
CQM[i, j] = np.nanmax((PositiveR / TotalR, 0)) * 100. |
| 1869 |
|
| 1870 |
return np.min(CQM) |
| 1871 |
|
| 1872 |
def check_passivity(self, ntwk: Network) -> float: |
| 1873 |
""" |
| 1874 |
Initial Passivity Quality Metric (PQMi): verify that the 2-Norm of |
| 1875 |
S-parameters is smaller or equal to 1 at each frequency. |
| 1876 |
|
| 1877 |
This is equivalent to checking the eigenvalues of the unity matrix |
| 1878 |
subtracted by complex conjugate transposed S time S is greater or |
| 1879 |
equal to zero. |
| 1880 |
|
| 1881 |
Parameters |
| 1882 |
---------- |
| 1883 |
ntwk: :class:`~skrf.network.Network` object |
| 1884 |
Network to be checked |
| 1885 |
|
| 1886 |
Returns |
| 1887 |
------- |
| 1888 |
PQM : :class:`~skrf.network.Network` object |
| 1889 |
Passivity quality metric in percents |
| 1890 |
""" |
| 1891 |
if ntwk.nports == 1: |
| 1892 |
raise (ValueError('Doesn\'t exist for one-ports')) |
| 1893 |
|
| 1894 |
Nf = ntwk.frequency.npoints |
| 1895 |
A = 1.00001 |
| 1896 |
B = 0.1 |
| 1897 |
self.PM = zeros(Nf) |
| 1898 |
PW = zeros(Nf) |
| 1899 |
for i in range(Nf): |
| 1900 |
|
| 1901 |
self.PM[i] = norm(ntwk.s[i, :, :], 2) |
| 1902 |
if self.PM[i] > A: |
| 1903 |
PW[i] = (self.PM[i] - A) / B |
| 1904 |
|
| 1905 |
return np.max([Nf - np.sum(PW), 0]) / Nf * 100. |
| 1906 |
|
| 1907 |
|
| 1908 |
def check_reciprocity(self, ntwk: Network) -> float: |
| 1909 |
""" |
| 1910 |
Initial Reciprocity Quality Metric (RQMi): |
| 1911 |
integrates the absolute difference between Sij and Sji at |
| 1912 |
each frequency point. Ideally, Sij should be equal to Sji. |
| 1913 |
|
| 1914 |
Parameters |
| 1915 |
---------- |
| 1916 |
ntwk: :class:`~skrf.network.Network` object |
| 1917 |
Network to be checked |
| 1918 |
|
| 1919 |
Returns |
| 1920 |
------- |
| 1921 |
PQM : :class:`~skrf.network.Network` object |
| 1922 |
Reciprocity quality metric in percents |
| 1923 |
""" |
| 1924 |
if ntwk.nports == 1: |
| 1925 |
raise (ValueError('Doesn\'t exist for one-ports')) |
| 1926 |
|
| 1927 |
Nf = ntwk.frequency.npoints |
| 1928 |
B = 0.1 |
| 1929 |
C = 1e-6 |
| 1930 |
self.RM = zeros(Nf) |
| 1931 |
RW = zeros(Nf) |
| 1932 |
for i in range(Nf): |
| 1933 |
self.RM[i] = 0 |
| 1934 |
for k in range(ntwk.nports): |
| 1935 |
for m in range(ntwk.nports): |
| 1936 |
self.RM[i] = self.RM[i] + np.abs(ntwk.s[i, k, m] - ntwk.s[i, m, k]) |
| 1937 |
self.RM[i] = self.RM[i] / (ntwk.nports * (ntwk.nports - 1)) |
| 1938 |
if self.RM[i] > C: |
| 1939 |
RW[i] = (self.RM[i] - C) / B |
| 1940 |
|
| 1941 |
return np.max([Nf - np.sum(RW), 0]) / Nf * 100. |
| 1942 |
|
| 1943 |
def check_se_quality(self, ntwk: Network, verbose: bool = False) -> dict: |
| 1944 |
""" |
| 1945 |
Single-ended passivity, reciprocity, and causality checks are |
| 1946 |
performed on the original S-parameters data in the frequency domain. |
| 1947 |
|
| 1948 |
Parameters |
| 1949 |
---------- |
| 1950 |
ntwk : :class:`~skrf.network.Network` object |
| 1951 |
Network to be checked |
| 1952 |
verbose: :boolean |
| 1953 |
Plot internal causality, passivity, and reciprocity |
| 1954 |
figures. When True, override class verbose parameter. |
| 1955 |
(default False). |
| 1956 |
|
| 1957 |
Returns |
| 1958 |
------- |
| 1959 |
QM : :class:`dict` object |
| 1960 |
Dictionary with quality metrics |
| 1961 |
""" |
| 1962 |
verbose = self.verbose or verbose |
| 1963 |
QM = {'causality': {'value': self.check_causality(ntwk), 'evaluation': ''}, |
| 1964 |
'passivity': {'value': self.check_passivity(ntwk), 'evaluation': ''}, |
| 1965 |
'reciprocity': {'value': self.check_reciprocity(ntwk), 'evaluation': ''}, |
| 1966 |
} |
| 1967 |
|
| 1968 |
|
| 1969 |
if QM['causality']['value'] <= 20.: |
| 1970 |
QM['causality']['evaluation'] = 'poor' |
| 1971 |
elif QM['causality']['value'] <= 50.: |
| 1972 |
QM['causality']['evaluation'] = 'inconclusive' |
| 1973 |
elif QM['causality']['value'] <= 80: |
| 1974 |
QM['causality']['evaluation'] = 'acceptable' |
| 1975 |
else: |
| 1976 |
QM['causality']['evaluation'] = 'good' |
| 1977 |
|
| 1978 |
if QM['passivity']['value'] <= 80.: |
| 1979 |
QM['passivity']['evaluation'] = 'poor' |
| 1980 |
elif QM['passivity']['value'] <= 99.: |
| 1981 |
QM['passivity']['evaluation'] = 'inconclusive' |
| 1982 |
elif QM['passivity']['value'] <= 99.9: |
| 1983 |
QM['passivity']['evaluation'] = 'acceptable' |
| 1984 |
else: |
| 1985 |
QM['passivity']['evaluation'] = 'good' |
| 1986 |
|
| 1987 |
if QM['reciprocity']['value'] <= 80.: |
| 1988 |
QM['reciprocity']['evaluation'] = 'poor' |
| 1989 |
elif QM['reciprocity']['value'] <= 99.: |
| 1990 |
QM['reciprocity']['evaluation'] = 'inconclusive' |
| 1991 |
elif QM['reciprocity']['value'] <= 99.9: |
| 1992 |
QM['reciprocity']['evaluation'] = 'acceptable' |
| 1993 |
else: |
| 1994 |
QM['reciprocity']['evaluation'] = 'good' |
| 1995 |
|
| 1996 |
|
| 1997 |
if verbose: |
| 1998 |
name = ntwk.name if ntwk.name else 'Network' |
| 1999 |
fig = figure(figsize = (12, 4.4)) |
| 2000 |
fig.suptitle('Initial checking in the frequency domain') |
| 2001 |
ax = fig.add_subplot(1, 3, 1, projection = 'polar') |
| 2002 |
ax.set_title('Causality') |
| 2003 |
ntwk.plot_s_polar(ax = ax) |
| 2004 |
ax.legend(loc = 'upper right') |
| 2005 |
ax = fig.add_subplot(1, 3, 2) |
| 2006 |
ax.set_title('Passivity') |
| 2007 |
ax.plot(ntwk.frequency.f_scaled, self.PM, color = 'k', label = name) |
| 2008 |
ax.plot([ntwk.frequency.f_scaled[0], ntwk.frequency.f_scaled[-1]], |
| 2009 |
[1., 1.], color = 'r', linestyle = 'dashed', label = 'Maximum') |
| 2010 |
ax.set_xlabel(f'Frequency ({ntwk.frequency.unit})') |
| 2011 |
ax.set_ylabel('2-Norm(S)') |
| 2012 |
ax.legend(loc = 'upper right') |
| 2013 |
ax = fig.add_subplot(1, 3, 3) |
| 2014 |
ax.set_title('Reciprocity') |
| 2015 |
ax.plot(ntwk.frequency.f_scaled, self.RM, color = 'k', label = name) |
| 2016 |
ax.set_xlabel(f'Frequency ({ntwk.frequency.unit})') |
| 2017 |
ax.set_ylabel('Sum of S-pairs differences') |
| 2018 |
ax.legend(loc = 'upper right') |
| 2019 |
fig.tight_layout() |
| 2020 |
|
| 2021 |
return QM |
| 2022 |
|
| 2023 |
def check_mm_quality(self, ntwk: Network, verbose: bool = False) -> dict: |
| 2024 |
""" |
| 2025 |
Mixed-mode passivity, reciprocity, and causality checks are |
| 2026 |
performed on the original S-parameters data in the frequency domain. |
| 2027 |
|
| 2028 |
The input networks should be 4-port single-ended and will be |
| 2029 |
transformed to mixed-mode representation. Only the differential and |
| 2030 |
the common modes are tested. |
| 2031 |
|
| 2032 |
Parameters |
| 2033 |
---------- |
| 2034 |
ntwk: :class:`~skrf.network.Network` object |
| 2035 |
Network to be checked |
| 2036 |
verbose: :bool |
| 2037 |
Plot internal causality, passivity, and reciprocity |
| 2038 |
figures. When True, override class verbose parameter. |
| 2039 |
(default False). |
| 2040 |
|
| 2041 |
Returns |
| 2042 |
------- |
| 2043 |
QM : :class:`dict` object |
| 2044 |
Dictionary with quality metrics |
| 2045 |
""" |
| 2046 |
mm = ntwk.copy() |
| 2047 |
mm.se2gmm(p = 2) |
| 2048 |
QM = {'dd': self.check_se_quality(mm.subnetwork([0, 1]), verbose), |
| 2049 |
'cc': self.check_se_quality(mm.subnetwork([2, 3]), verbose)} |
| 2050 |
|
| 2051 |
return QM |
| 2052 |
|
| 2053 |
def print_qm(self, QM: dict) -> dict: |
| 2054 |
""" |
| 2055 |
Print the quality metrics dictionary. |
| 2056 |
|
| 2057 |
Parameters |
| 2058 |
---------- |
| 2059 |
QM: :class:`dict` object |
| 2060 |
Dictionary with quality metrics to print |
| 2061 |
""" |
| 2062 |
if 'dd' in QM: |
| 2063 |
print('Differential mode') |
| 2064 |
for k in QM['dd'].keys(): |
| 2065 |
print(f"{k} is {QM['dd'][k]['evaluation']} ({QM['dd'][k]['value']:.2f}%)") |
| 2066 |
print('Common mode') |
| 2067 |
for k in QM['cc'].keys(): |
| 2068 |
print(f"{k} is {QM['cc'][k]['evaluation']} ({QM['cc'][k]['value']:.2f}%)") |
| 2069 |
else: |
| 2070 |
for k in QM.keys(): |
| 2071 |
print(f"{k} is {QM[k]['evaluation']} ({QM[k]['value']:.2f}%)") |
| 2072 |
|
| 2073 |
class IEEEP370_TD_QM: |
| 2074 |
def __init__(self, data_rate: float, sample_per_UI: int, |
| 2075 |
rise_time_per: float, pulse_shape: int = 1, |
| 2076 |
extrapolation: int = 2, verbose: bool = False) -> None: |
| 2077 |
""" |
| 2078 |
IEEEP370_TD_QM Application-based quality checking of in the time |
| 2079 |
domain using causality (CQMa), passivity (PQMa), and reciprocity (RQMa) |
| 2080 |
metrics. |
| 2081 |
|
| 2082 |
If necessary, the original S-parameters are extrapolated to a frequency |
| 2083 |
of three times the desired data rate. Causal, passive, and reciprocal |
| 2084 |
models are reconstructed and stimulated by a pulse. The difference |
| 2085 |
between the original extrapolated signal and the ideal responses |
| 2086 |
in the time domain are integrated to give metrics in millivolts. |
| 2087 |
|
| 2088 |
Based on [IEEE370]_. |
| 2089 |
|
| 2090 |
Parameters |
| 2091 |
----------- |
| 2092 |
data_rate : :float |
| 2093 |
Data rate (bps) |
| 2094 |
sample_per_UI: :number |
| 2095 |
Number of points of unit interval |
| 2096 |
rise_time_per: :float |
| 2097 |
Rise time from 20% to 80% divided by width |
| 2098 |
pulse_shape : :number |
| 2099 |
1 is Gaussian; 2 is rectangular with Butterworth filter; |
| 2100 |
3 is rectangular with Gaussian filter |
| 2101 |
extrapolation: :number |
| 2102 |
1 is constant extrapolation; 2 is zero padding |
| 2103 |
verbose : :boolean |
| 2104 |
Plot extrapolated frequency data, generated pulse and |
| 2105 |
the time domain comparison between the original and the |
| 2106 |
causality enforced responses |
| 2107 |
|
| 2108 |
References |
| 2109 |
---------- |
| 2110 |
.. [IEEE370] IEEE Standard for Electrical Characterization of Printed |
| 2111 |
Circuit Board and Related Interconnects at Frequencies up to 50 GHz", |
| 2112 |
IEEE 370-2020. |
| 2113 |
""" |
| 2114 |
self.data_rate = data_rate |
| 2115 |
self.sample_per_UI = sample_per_UI |
| 2116 |
self.rise_time_per = rise_time_per |
| 2117 |
self.pulse_shape = pulse_shape |
| 2118 |
self.extrapolation = extrapolation |
| 2119 |
self.verbose = verbose |
| 2120 |
|
| 2121 |
def add_conj(self, s_ij: ndarray): |
| 2122 |
""" |
| 2123 |
Add complex conjugates for ifft. |
| 2124 |
|
| 2125 |
Todo: Consider using irfft instead. |
| 2126 |
""" |
| 2127 |
N = len(s_ij) |
| 2128 |
s_ij_conj = zeros(2 * N - 1, dtype = complex) |
| 2129 |
s_ij_conj[:N] = s_ij |
| 2130 |
for k in range(N - 1): |
| 2131 |
s_ij_conj[k + N] = np.conj(s_ij_conj[N - k - 1]) |
| 2132 |
|
| 2133 |
return s_ij_conj |
| 2134 |
|
| 2135 |
def align_signals(self, x: ndarray, y: ndarray) -> ndarray: |
| 2136 |
""" |
| 2137 |
Compute the index shift between two identical shifted signals in the |
| 2138 |
time domain. |
| 2139 |
""" |
| 2140 |
y = y.T |
| 2141 |
x = x.T |
| 2142 |
n = len(x) |
| 2143 |
m = np.round(n * 0.1).astype(int) |
| 2144 |
mm = np.round(n * 0.01).astype(int) |
| 2145 |
xx = np.append(x[0:m], x[n - mm:n]) |
| 2146 |
yy = np.append(y[0:m], y[n - mm:n]) |
| 2147 |
x = xx |
| 2148 |
y = yy |
| 2149 |
yy = y[0:m] |
| 2150 |
Ix = np.argmax(x) |
| 2151 |
Iy = np.argmax(y) |
| 2152 |
index = Ix - Iy |
| 2153 |
yy = np.roll(y, index) |
| 2154 |
n = np.min([1000, m]).astype(int) |
| 2155 |
error = len(x) |
| 2156 |
error_ind = 0 |
| 2157 |
for k in range(-n + index, n + index): |
| 2158 |
yy = np.roll(y, k) |
| 2159 |
|
| 2160 |
cur_error = np.linalg.norm(yy - x, 2) |
| 2161 |
if error > cur_error: |
| 2162 |
error_ind = k |
| 2163 |
error = cur_error |
| 2164 |
y = np.roll(y, error_ind) |
| 2165 |
|
| 2166 |
return error_ind |
| 2167 |
|
| 2168 |
def create_causal(self, ntwk: Network, data_rate: float, |
| 2169 |
rise_time_per: float) -> (Network, ndarray): |
| 2170 |
""" |
| 2171 |
Create a causality-enforced network. |
| 2172 |
|
| 2173 |
Parameters |
| 2174 |
---------- |
| 2175 |
ntwk : :class:`~skrf.network.Network` object |
| 2176 |
Input network |
| 2177 |
data_rate : :float |
| 2178 |
Data rate (bps) |
| 2179 |
rise_time_per: :float |
| 2180 |
Rise time from 20% to 80% divided by width |
| 2181 |
|
| 2182 |
Returns |
| 2183 |
------- |
| 2184 |
causal: :class:`~skrf.network.Network` object |
| 2185 |
Causality-enforced network |
| 2186 |
delay : :class:`~skrf.network.Network` object |
| 2187 |
Alignment delay with original network for comparison sake |
| 2188 |
""" |
| 2189 |
causal = ntwk.copy() |
| 2190 |
nports = causal.nports |
| 2191 |
N = causal.frequency.npoints |
| 2192 |
f = causal.frequency.f |
| 2193 |
delay_matrix = zeros((nports, nports), dtype = int) |
| 2194 |
for i in range(nports): |
| 2195 |
for j in range(nports): |
| 2196 |
for k in range(N): |
| 2197 |
if np.abs(causal.s[k, i, j]) == 0: |
| 2198 |
causal.s[k, i, j] = 0.00001 |
| 2199 |
causal_ij, f, delay_ij = self.get_causal_model(f, causal.s[:, i, j], |
| 2200 |
data_rate, |
| 2201 |
rise_time_per) |
| 2202 |
causal.s[:, i, j] = causal_ij |
| 2203 |
delay_matrix[i, j] = delay_ij |
| 2204 |
|
| 2205 |
return (causal, delay_matrix) |
| 2206 |
|
| 2207 |
def create_passive(self, ntwk: Network) -> Network: |
| 2208 |
""" |
| 2209 |
Creat a passivity-enforced network. |
| 2210 |
|
| 2211 |
Parameters |
| 2212 |
---------- |
| 2213 |
ntwk: :class:`~skrf.network.Network` object |
| 2214 |
Input network |
| 2215 |
|
| 2216 |
Returns |
| 2217 |
------- |
| 2218 |
reciprocal : :class:`~skrf.network.Network` object |
| 2219 |
Passivity-enforced network |
| 2220 |
""" |
| 2221 |
passive = ntwk.copy() |
| 2222 |
for i in range(ntwk.frequency.npoints): |
| 2223 |
U, D, Vh = np.linalg.svd(ntwk.s[i, :, :]) |
| 2224 |
for k in range(ntwk.nports): |
| 2225 |
if D[k] > 1.: |
| 2226 |
D[k] = 1. |
| 2227 |
passive.s[i, :, :] = U @ np.diag(D) @ Vh |
| 2228 |
|
| 2229 |
return passive |
| 2230 |
|
| 2231 |
def create_reciprocal(self, ntwk: Network) -> Network: |
| 2232 |
""" |
| 2233 |
Creat a reciprocal network. |
| 2234 |
|
| 2235 |
The resulting network is the reciprocal of the input networks. The |
| 2236 |
reciprocity is not enforced, but the time domain response will still |
| 2237 |
gives metrics that is high if reciprocity is low. |
| 2238 |
|
| 2239 |
Parameters |
| 2240 |
---------- |
| 2241 |
ntwk: :class:`~skrf.network.Network` object |
| 2242 |
Input network |
| 2243 |
|
| 2244 |
Returns |
| 2245 |
------- |
| 2246 |
reciprocal : :class:`~skrf.network.Network` object |
| 2247 |
Reciprocal network |
| 2248 |
""" |
| 2249 |
reciprocal = ntwk.copy() |
| 2250 |
for i in range(ntwk.nports): |
| 2251 |
for j in range(ntwk.nports): |
| 2252 |
reciprocal.s[:, i, j] = ntwk.s[:, j, i] |
| 2253 |
|
| 2254 |
return reciprocal |
| 2255 |
|
| 2256 |
def extrapolate_to_dc(self, ntwk: Network) -> Network: |
| 2257 |
""" |
| 2258 |
Extrapolate to DC and interpolate to the harmonic frequency sweep. |
| 2259 |
|
| 2260 |
Passivity is enforced on the DC extrapolated points. The missing part |
| 2261 |
from dc to the first frequency sample should not exceed a phase change |
| 2262 |
of π/2. |
| 2263 |
|
| 2264 |
Parameters |
| 2265 |
---------- |
| 2266 |
ntwk: :class:`~skrf.network.Network` object |
| 2267 |
Input network |
| 2268 |
|
| 2269 |
Returns |
| 2270 |
------- |
| 2271 |
extrapolated : :class:`~skrf.network.Network` object |
| 2272 |
Extrapolated network |
| 2273 |
""" |
| 2274 |
f = ntwk.frequency.f |
| 2275 |
df = f[1] - f[0] |
| 2276 |
nports = ntwk.nports |
| 2277 |
f_0 = f[0] |
| 2278 |
|
| 2279 |
norm_0 = np.linalg.norm(ntwk.s[0, :, :], 2) |
| 2280 |
if f[0] == 0: |
| 2281 |
f_extra = f |
| 2282 |
else: |
| 2283 |
f_new = df * np.arange(0, np.ceil(f[0] / df)) |
| 2284 |
f_extra = np.append(f_new, f) |
| 2285 |
N_interp = np.floor(f_extra[-1]/df) |
| 2286 |
f_interp = df * np.arange(0, N_interp + 1) |
| 2287 |
s = zeros((len(f_extra), nports, nports), dtype = complex) |
| 2288 |
s_interp = zeros((len(f_interp), nports, nports), dtype = complex) |
| 2289 |
for i in range(nports): |
| 2290 |
for j in range(nports): |
| 2291 |
|
| 2292 |
if f[0] == 0: |
| 2293 |
s[:, i, j] = ntwk.s[:, i, j] |
| 2294 |
s[0] = np.real(s[0, i, j]) |
| 2295 |
else: |
| 2296 |
s[:, i, j] = self.extrapolate_to_dc_ij(f, f_new, |
| 2297 |
ntwk.s[:, i, j]) |
| 2298 |
|
| 2299 |
s_interp[:, i, j] = self.interpolate_ij(f_extra, f_interp, |
| 2300 |
s[:, i, j]) |
| 2301 |
|
| 2302 |
i = 0 |
| 2303 |
D_max = np.max(np.array([1., norm_0])) |
| 2304 |
while f_interp[i] < f_0: |
| 2305 |
U, D, Vh = np.linalg.svd(s_interp[i, :, :]) |
| 2306 |
for k in range(nports): |
| 2307 |
if D[k] > D_max: |
| 2308 |
D[k] = D_max |
| 2309 |
s_interp[i, :, :] = U @ np.diag(D) @ Vh |
| 2310 |
i += 1 |
| 2311 |
|
| 2312 |
return Network(frequency = f_interp, s = s_interp, name = ntwk.name, |
| 2313 |
z0 = ntwk.z0[0]) |
| 2314 |
|
| 2315 |
def extrapolate_to_dc_ij(self, f: ndarray, f_new: ndarray, s_ij: ndarray): |
| 2316 |
""" |
| 2317 |
Extrapolate single S-component to DC. |
| 2318 |
|
| 2319 |
The missing part from dc to the first frequency sample should not |
| 2320 |
exceed a phase change of π/2. |
| 2321 |
""" |
| 2322 |
|
| 2323 |
ph = -np.unwrap(np.angle(s_ij)) |
| 2324 |
delay = self.get_delay(f, ph) |
| 2325 |
|
| 2326 |
s_ij = s_ij * np.exp(1j * 2 * np.pi * f * delay) |
| 2327 |
|
| 2328 |
re = np.real(s_ij) |
| 2329 |
im = np.imag(s_ij) |
| 2330 |
|
| 2331 |
a = (re[1] - re[0]) / (f[1]**2 - f[0]**2) |
| 2332 |
b = re[0] - a * f[0]**2 |
| 2333 |
|
| 2334 |
re_new = a * f_new**2 + b |
| 2335 |
re = np.append(re_new, re) |
| 2336 |
|
| 2337 |
a = (im[1]/f[1] - im[0]/f[0])/(f[1]**2 - f[0]**2) |
| 2338 |
b = im[0]/f[0] - a * f[0]**2 |
| 2339 |
|
| 2340 |
im_new = a * f_new**3 + b * f_new |
| 2341 |
im = np.append(im_new, im) |
| 2342 |
f_extra = np.append(f_new, f) |
| 2343 |
|
| 2344 |
s_ij_extra = re + 1j * im |
| 2345 |
|
| 2346 |
s_ij_extra = s_ij_extra * \ |
| 2347 |
np.exp(-1j * 2 * np.pi * f_extra * delay) |
| 2348 |
|
| 2349 |
return s_ij_extra |
| 2350 |
|
| 2351 |
def extrapolate_to_fmax(self, ntwk: Network, data_rate: float, |
| 2352 |
sample_per_UI: int, extrapolation: int)-> Network: |
| 2353 |
""" |
| 2354 |
Extrapolate network max frequency if required by parameters. |
| 2355 |
|
| 2356 |
This is usually three times the data rate. |
| 2357 |
|
| 2358 |
Parameters |
| 2359 |
---------- |
| 2360 |
ntwk : :class:`~skrf.network.Network` object |
| 2361 |
Input network |
| 2362 |
data_rate : :float |
| 2363 |
Data rate (bps) |
| 2364 |
sample_per_UI: :number |
| 2365 |
Number of points of generated pulse signal |
| 2366 |
rise_time_per: :float |
| 2367 |
Rise time divided by high time ratio |
| 2368 |
extrapolation: :number |
| 2369 |
1 is constant extrapolation; 2 is zero padding |
| 2370 |
|
| 2371 |
Returns |
| 2372 |
------- |
| 2373 |
extrapolated : :class:`~skrf.network.Network` object |
| 2374 |
Extrapolated network |
| 2375 |
""" |
| 2376 |
f_max = 0.5 * data_rate * sample_per_UI |
| 2377 |
df = ntwk.frequency.f[1] - ntwk.frequency.f[0] |
| 2378 |
f_new = ntwk.frequency.f |
| 2379 |
while(f_new[-1] < f_max): |
| 2380 |
f_new = np.append(f_new, f_new[-1] + df) |
| 2381 |
N1 = ntwk.frequency.npoints |
| 2382 |
N = len(f_new) |
| 2383 |
s_new = zeros((N, ntwk.nports, ntwk.nports), dtype = complex) |
| 2384 |
for i in range(ntwk.nports): |
| 2385 |
for j in range(ntwk.nports): |
| 2386 |
s_new[:N1, i, j] = ntwk.s[:, i, j] |
| 2387 |
ph = np.unwrap(np.angle(s_new[:N1, i, j])) |
| 2388 |
dph = (ph[-1] - ph[0]) / (N1 - 1) |
| 2389 |
for k in range(N1, N): |
| 2390 |
if extrapolation == 1: |
| 2391 |
s_new[k, i, j] = s_new[k - 1, i, j] * np.exp(1j * dph) |
| 2392 |
else: |
| 2393 |
s_new[k, i, j] = 0 |
| 2394 |
|
| 2395 |
return Network(frequency = f_new, s = s_new, name = ntwk.name, |
| 2396 |
z0 = ntwk.z0[0]) |
| 2397 |
|
| 2398 |
|
| 2399 |
def get_causal_model(self, f: ndarray, s_ij: ndarray, data_rate, |
| 2400 |
rise_time_per) -> ndarray: |
| 2401 |
""" |
| 2402 |
Get causality-enforced model for a single S-parameter component Sij. |
| 2403 |
""" |
| 2404 |
df = f[1] - f[0] |
| 2405 |
dt = 1. / (2 * f[-1] + df) |
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
|
| 2410 |
|
| 2411 |
N = len(s_ij) |
| 2412 |
s_ij[0] = np.real(s_ij[0]) |
| 2413 |
s_ij_conj = self.add_conj(s_ij) |
| 2414 |
|
| 2415 |
s_ij_magn_conj = np.real(np.log(np.abs(s_ij_conj))) |
| 2416 |
|
| 2417 |
s_ij_magn_time = np.fft.ifft(s_ij_magn_conj) |
| 2418 |
|
| 2419 |
for i in range(N, 2 * N - 1): |
| 2420 |
s_ij_magn_time[i] = (-1.) * s_ij_magn_time[i] |
| 2421 |
s_ij_magn_time = 1j * s_ij_magn_time |
| 2422 |
|
| 2423 |
s_ij_phase_enforced = np.real(fft(s_ij_magn_time)) |
| 2424 |
|
| 2425 |
delay = self.get_delay_time(f, s_ij, s_ij_phase_enforced[0:N], |
| 2426 |
data_rate, rise_time_per) |
| 2427 |
delay = np.round(delay / dt) * dt |
| 2428 |
causal_ij = zeros(N, dtype = complex) |
| 2429 |
for i in range(N): |
| 2430 |
w = 2 * np.pi * f[i] |
| 2431 |
causal_ij[i] = np.exp(s_ij_magn_conj[i]) * \ |
| 2432 |
np.exp(-1j * s_ij_phase_enforced[i]) * np.exp(-1j * delay * w) |
| 2433 |
delay = np.round(delay / dt).astype(int) |
| 2434 |
return (causal_ij, f, delay) |
| 2435 |
|
| 2436 |
|
| 2437 |
def get_delay(self, freq: ndarray, phase: ndarray) -> float: |
| 2438 |
""" |
| 2439 |
Get the front delay from phase and frequency vectors. |
| 2440 |
|
| 2441 |
Parameters |
| 2442 |
---------- |
| 2443 |
freq: :ndarray |
| 2444 |
Frequency (Hz) |
| 2445 |
phase: :ndarray |
| 2446 |
Phase (rad) |
| 2447 |
|
| 2448 |
Returns |
| 2449 |
------- |
| 2450 |
delay: :float |
| 2451 |
Delay |
| 2452 |
|
| 2453 |
""" |
| 2454 |
N = len(freq) |
| 2455 |
delay = 1. |
| 2456 |
for i in range(N): |
| 2457 |
if freq[i] > 0: |
| 2458 |
delay_i = phase[i] / freq[i] / 2. / np.pi |
| 2459 |
if delay > delay_i: |
| 2460 |
delay = delay_i |
| 2461 |
return delay |
| 2462 |
|
| 2463 |
def get_delay_time(self, freq: ndarray, s_ij: ndarray, phase_causal: ndarray, |
| 2464 |
data_rate: float, rise_time_per: float) -> float: |
| 2465 |
""" |
| 2466 |
Get delay between original and causality enforced data in number of |
| 2467 |
time samples. |
| 2468 |
|
| 2469 |
Parameters |
| 2470 |
---------- |
| 2471 |
freq : :ndarray |
| 2472 |
Frequency (Hz) |
| 2473 |
s_ij : :ndarray |
| 2474 |
Original single S-component. |
| 2475 |
phase_causal : :ndarray |
| 2476 |
Causality enforced phase (rad) |
| 2477 |
data_rate : :float |
| 2478 |
Data rate (bps) |
| 2479 |
rise_time_per: :float |
| 2480 |
Rise time from 20% to 80% divided by width |
| 2481 |
|
| 2482 |
Returns |
| 2483 |
------- |
| 2484 |
delay: :float |
| 2485 |
Delay |
| 2486 |
""" |
| 2487 |
N = len(freq) |
| 2488 |
df = freq[1] - freq[0] |
| 2489 |
dt = 1. / (2 * freq[-1] + df) |
| 2490 |
|
| 2491 |
f_cut = 3. * data_rate / 2. |
| 2492 |
sigma = 1. / 2. / np.pi / f_cut |
| 2493 |
gaussian = np.exp(-2 * np.pi * np.pi * freq * freq * sigma * sigma) |
| 2494 |
original = s_ij * gaussian |
| 2495 |
causal = np.abs(original) * np.exp(-1j * phase_causal) |
| 2496 |
original_conj = self.add_conj(original) |
| 2497 |
causal_conj = self.add_conj(causal) |
| 2498 |
pulse = self.get_pulse_rect(dt, data_rate, 2 * N - 1, rise_time_per) |
| 2499 |
pulse_original = original_conj * pulse |
| 2500 |
pulse_causal = causal_conj * pulse |
| 2501 |
v_origin = np.fft.ifft(pulse_original) / 2. |
| 2502 |
v_causal = np.fft.ifft(pulse_causal) / 2. |
| 2503 |
shift_ind = -1 * self.align_signals(v_causal, v_origin) |
| 2504 |
return shift_ind * dt |
| 2505 |
|
| 2506 |
def get_pulse_gaussian(self, dt: float, data_rate: float, N: int, |
| 2507 |
rise_time_per: float, verbose = False) -> ndarray: |
| 2508 |
""" |
| 2509 |
Get the FFT of a gaussian pulse. The pulse is shifted in time according |
| 2510 |
to parameters. |
| 2511 |
|
| 2512 |
Parameters |
| 2513 |
---------- |
| 2514 |
dt : :float |
| 2515 |
Sample time (s) |
| 2516 |
data_rate : :float |
| 2517 |
Data rate (bps) |
| 2518 |
N : :number |
| 2519 |
Number of points of generated pulse signal |
| 2520 |
rise_time_per: :float |
| 2521 |
Rise time from 20% to 80% divided by width |
| 2522 |
verbose : :boolean |
| 2523 |
Plot reference and generated pulses in the time |
| 2524 |
domain |
| 2525 |
|
| 2526 |
Returns |
| 2527 |
------- |
| 2528 |
fft : :ndarray |
| 2529 |
FFT of the pulse signal |
| 2530 |
""" |
| 2531 |
n_samples = (N - 1) // 2 |
| 2532 |
self.t_pulse = np.arange(-n_samples, n_samples + 1) * dt |
| 2533 |
N = len(self.t_pulse) |
| 2534 |
sigma = rise_time_per / (data_rate * \ |
| 2535 |
(np.sqrt(-np.log(0.2))-np.sqrt(-np.log(0.8)))) |
| 2536 |
self.v_ref = np.exp(-self.t_pulse**2 / sigma**2) |
| 2537 |
k_middle = n_samples |
| 2538 |
k_start = np.round(1.5 / data_rate / dt) - 1 |
| 2539 |
self.v_pulse = zeros(self.t_pulse.shape) |
| 2540 |
for i in range(N): |
| 2541 |
self.v_pulse[i] = self.v_ref[np.mod(i + k_middle - k_start, N).astype(int)] |
| 2542 |
if verbose: |
| 2543 |
fig, ax = subplots(1, 1) |
| 2544 |
ax.plot(self.t_pulse, self.v_ref, color = 'r', label = 'Reference') |
| 2545 |
ax.plot(self.t_pulse, self.v_pulse, linestyle = 'dashed', label = 'Generated') |
| 2546 |
ax.legend(loc = 'upper right') |
| 2547 |
ax.set_ylabel('Amplitude (V)') |
| 2548 |
ax.set_xlabel('Time (s)') |
| 2549 |
ax.set_title('Gaussian Pulse') |
| 2550 |
|
| 2551 |
return fft(self.v_pulse) |
| 2552 |
|
| 2553 |
def get_pulse_rect(self, dt: float, data_rate: float, N: int, |
| 2554 |
rise_time_per: float, verbose = False)-> ndarray: |
| 2555 |
""" |
| 2556 |
Get the FFT of a rectangular pulse with defined rise time. |
| 2557 |
|
| 2558 |
Rise time and fall time are equals. |
| 2559 |
|
| 2560 |
Parameters |
| 2561 |
---------- |
| 2562 |
dt : :float |
| 2563 |
Sample time (s) |
| 2564 |
data_rate : :float |
| 2565 |
Data rate (bps) |
| 2566 |
N : :number |
| 2567 |
Number of points of generated pulse signal |
| 2568 |
rise_time_per: :float |
| 2569 |
Rise time from 20% to 80% divided by width |
| 2570 |
verbose : :boolean |
| 2571 |
Plot reference and interpolated pulses in the time |
| 2572 |
domain |
| 2573 |
|
| 2574 |
Returns |
| 2575 |
------- |
| 2576 |
fft : :ndarray |
| 2577 |
FFT of the pulse signal |
| 2578 |
""" |
| 2579 |
self.t_pulse = np.arange(0, N) * dt |
| 2580 |
k_high = np.round(1. / data_rate / dt) |
| 2581 |
k_rise = np.round(k_high * rise_time_per) |
| 2582 |
k_offset = np.array([0, k_rise, k_rise, k_rise, k_rise, 0]) |
| 2583 |
k_ref = np.array([0, 0, k_rise, k_high, k_high + k_rise, N - 1]) |
| 2584 |
self.t_ref = dt * (k_offset + k_ref) |
| 2585 |
self.v_ref = np.array([0, 0, 1, 1, 0, 0]) |
| 2586 |
|
| 2587 |
interp = interp1d(self.t_ref, self.v_ref) |
| 2588 |
self.v_pulse = interp(self.t_pulse) |
| 2589 |
|
| 2590 |
if verbose: |
| 2591 |
fig, ax = subplots(1, 1) |
| 2592 |
ax.plot(self.t_ref, self.v_ref, color = 'r', marker = 'o', |
| 2593 |
label = 'Reference') |
| 2594 |
ax.plot(self.t_pulse, self.v_pulse, linestyle = 'dashed', |
| 2595 |
label = 'Interpolated') |
| 2596 |
ax.legend(loc = 'upper right') |
| 2597 |
ax.set_ylabel('Amplitude (V)') |
| 2598 |
ax.set_xlabel('Time (s)') |
| 2599 |
ax.set_title('Rectangular Pulse') |
| 2600 |
|
| 2601 |
return fft(self.v_pulse) |
| 2602 |
|
| 2603 |
def get_time_domain(self, ntwk: Network, data_rate: float, |
| 2604 |
rise_time_per: float, |
| 2605 |
pulse_shape: int) -> (ndarray, ndarray): |
| 2606 |
""" |
| 2607 |
Get the impulse responses of the S-parameters. |
| 2608 |
|
| 2609 |
The pulse is defined as per application parameters. |
| 2610 |
|
| 2611 |
Parameters |
| 2612 |
---------- |
| 2613 |
ntwk : :class:`~skrf.network.Network` object |
| 2614 |
Input network |
| 2615 |
data_rate : :float |
| 2616 |
Data rate (bps) |
| 2617 |
rise_time_per: :float |
| 2618 |
Rise time from 20% to 80% divided by width |
| 2619 |
pulse_shape : :number |
| 2620 |
1 is Gaussian; 2 is rectangular with Butterworth filter; |
| 2621 |
3 is rectangular with Gaussian filter |
| 2622 |
|
| 2623 |
Returns |
| 2624 |
------- |
| 2625 |
v : :ndarray |
| 2626 |
Impulse response amplitude vector |
| 2627 |
t : :ndarray |
| 2628 |
Impulse response time vector |
| 2629 |
""" |
| 2630 |
N = ntwk.frequency.npoints |
| 2631 |
freq = ntwk.frequency.f |
| 2632 |
df = freq[1] - freq[0] |
| 2633 |
dt = 1 / (2 * freq[-1] + df) |
| 2634 |
nports = ntwk.nports |
| 2635 |
t = dt * np.arange(0, 2 * N - 1) |
| 2636 |
v = zeros((2 * N - 1, nports, nports)) |
| 2637 |
|
| 2638 |
f_cut = 3. * data_rate / 2. |
| 2639 |
sigma = 1. / 2. / np.pi / f_cut |
| 2640 |
rise_time = 1. / data_rate * 1000 * rise_time_per |
| 2641 |
f0 = 320 / rise_time |
| 2642 |
if pulse_shape == 1: |
| 2643 |
self.filter = np.ones(N, dtype = complex) |
| 2644 |
self.pulse = self.get_pulse_gaussian(dt, data_rate, 2 * N - 1, |
| 2645 |
rise_time_per) |
| 2646 |
elif pulse_shape == 2: |
| 2647 |
self.filter = 1. / (1 + 1j * freq / f0) |
| 2648 |
self.pulse = self.get_pulse_rect(dt, data_rate, 2 * N - 1, |
| 2649 |
1.4 * rise_time_per) |
| 2650 |
else: |
| 2651 |
self.filter = np.exp(-2 * np.pi * np.pi * freq * freq * sigma * sigma) |
| 2652 |
self.pulse = self.get_pulse_rect(dt, data_rate, 2 * N - 1, |
| 2653 |
1.4 * rise_time_per) |
| 2654 |
for i in range(nports): |
| 2655 |
for j in range(nports): |
| 2656 |
s_ij = ntwk.s[:, i, j] * self.filter |
| 2657 |
s_ij[0] = np.real(s_ij[0]) |
| 2658 |
s_ij_conj = self.add_conj(s_ij) |
| 2659 |
pulse_response_freq = self.pulse * s_ij_conj |
| 2660 |
v[:, i, j] = np.real(np.fft.ifft(pulse_response_freq)) |
| 2661 |
|
| 2662 |
return (v, t) |
| 2663 |
|
| 2664 |
def get_td_difference_mv(self, v1: ndarray, v2: ndarray, t: ndarray, |
| 2665 |
nports: int, |
| 2666 |
data_rate: float) -> (ndarray, ndarray): |
| 2667 |
""" |
| 2668 |
Integrate the difference between two signals on units intervals in the |
| 2669 |
time domain. The result has a physical estimation in millivolts of |
| 2670 |
the worst-case bit sequence based on peak distortion analysis. |
| 2671 |
""" |
| 2672 |
N = len(t) |
| 2673 |
dt = t[1] - t[0] |
| 2674 |
UI = 1. / data_rate / dt |
| 2675 |
max_bits = 31 |
| 2676 |
time_domain_difference_mv = zeros((nports, nports)) |
| 2677 |
N_UI = np.round(UI).astype(int) |
| 2678 |
delta = zeros(N_UI) |
| 2679 |
for i in range(nports): |
| 2680 |
for j in range(nports): |
| 2681 |
max_index = np.argmax(v1[:, i, j]) |
| 2682 |
last_index = max_index + max_bits * UI |
| 2683 |
lower_index = max_index - max_bits * UI |
| 2684 |
for k in range(N_UI): |
| 2685 |
delta[k] = 0 |
| 2686 |
for m in range(np.floor(N / UI).astype(int) - 1): |
| 2687 |
ind = k + np.floor(m * UI).astype(int) |
| 2688 |
if lower_index >= 0: |
| 2689 |
condition = (ind < last_index) and (ind > lower_index) |
| 2690 |
else: |
| 2691 |
condition = (ind < last_index) or (ind > N - lower_index - 1) |
| 2692 |
if condition: |
| 2693 |
delta[k] = delta[k] + np.abs(v2[ind, i, j] - v1[ind, i, j]) |
| 2694 |
time_domain_difference_mv[i, j] = np.max(delta) |
| 2695 |
|
| 2696 |
return time_domain_difference_mv |
| 2697 |
|
| 2698 |
def get_td_causality_difference_mv(self, v1: ndarray, v2: ndarray, t: ndarray, |
| 2699 |
nports: int, data_rate: float, |
| 2700 |
delay_matrix: ndarray) -> (ndarray, ndarray): |
| 2701 |
""" |
| 2702 |
Integrate the difference between two signals on units intervals in the |
| 2703 |
time domain. The result has a physical estimation in millivolts of |
| 2704 |
the worst-case bit sequence based on peak distortion analysis. |
| 2705 |
|
| 2706 |
Also accounts for the causality minimum delay. |
| 2707 |
""" |
| 2708 |
N = len(t) |
| 2709 |
dt = t[1] - t[0] |
| 2710 |
UI = 1. / data_rate / dt |
| 2711 |
max_bits = 31 |
| 2712 |
time_domain_difference_mv = zeros((nports, nports)) |
| 2713 |
N_UI = np.round(UI).astype(int) |
| 2714 |
delta = zeros(N_UI) |
| 2715 |
for i in range(nports): |
| 2716 |
for j in range(nports): |
| 2717 |
if i == j: |
| 2718 |
delay_num = 0 |
| 2719 |
else: |
| 2720 |
delay_num = delay_matrix[i, j] |
| 2721 |
for k in range(N_UI): |
| 2722 |
delta[k] = 0 |
| 2723 |
for m in range(max_bits): |
| 2724 |
ind = delay_num - k - np.floor(m * UI).astype(int) - 2 |
| 2725 |
if ind < 0: |
| 2726 |
ind = N + ind |
| 2727 |
delta[k] = delta[k] + np.abs(v2[ind, i, j] - v1[ind, i, j]) |
| 2728 |
time_domain_difference_mv[i, j] = np.max(delta) |
| 2729 |
|
| 2730 |
return time_domain_difference_mv |
| 2731 |
|
| 2732 |
def interpolate_ij(self, f: ndarray, f_new: ndarray, s_ij: ndarray): |
| 2733 |
""" |
| 2734 |
Interpolate single S-parameter component Sij. |
| 2735 |
""" |
| 2736 |
|
| 2737 |
delay = np.max([0, self.get_delay(f, -np.unwrap(np.angle(s_ij)))]) |
| 2738 |
|
| 2739 |
s_ij = s_ij * np.exp(1j * 2 * np.pi * f * delay) |
| 2740 |
|
| 2741 |
interp = interp1d(f, s_ij) |
| 2742 |
s_ij_interp = interp(f_new) |
| 2743 |
|
| 2744 |
s_ij_interp = s_ij_interp * \ |
| 2745 |
np.exp(-1j * 2 * np.pi * f_new * delay) |
| 2746 |
|
| 2747 |
return s_ij_interp |
| 2748 |
|
| 2749 |
def check_se_quality(self, ntwk: Network, verbose: bool = False) -> dict: |
| 2750 |
""" |
| 2751 |
Single-ended application-based quality checking in the time domain |
| 2752 |
using causality (CQMa), passivity (PQMa), and reciprocity (RQMa) |
| 2753 |
metrics. |
| 2754 |
|
| 2755 |
If necessary, the original S-parameters are extrapolated to a frequency |
| 2756 |
of three times the desired data rate. Causal, passive, and reciprocal |
| 2757 |
models are reconstructed and stimulated by a pulse. The difference |
| 2758 |
between the original extrapolated signal and the ideal responses |
| 2759 |
in the time domain are integrated to give metrics in millivolts. |
| 2760 |
|
| 2761 |
Parameters |
| 2762 |
---------- |
| 2763 |
ntwk : :class:`~skrf.network.Network` object |
| 2764 |
Network to be checked |
| 2765 |
verbose: :bool |
| 2766 |
Plot internal causality, passivity, and reciprocity |
| 2767 |
figures. When True, override class verbose parameter. |
| 2768 |
(default False). |
| 2769 |
|
| 2770 |
Returns |
| 2771 |
------- |
| 2772 |
QM : :class:`dict` object |
| 2773 |
Dictionary with quality metrics |
| 2774 |
""" |
| 2775 |
verbose = self.verbose or verbose |
| 2776 |
if (1.5 * self.data_rate) > ntwk.frequency.f[-1]: |
| 2777 |
warnings.warn('Maximum frequency is less then recommended frequency.', |
| 2778 |
RuntimeWarning, stacklevel=2) |
| 2779 |
|
| 2780 |
|
| 2781 |
self.ntwk_interpolated = self.extrapolate_to_fmax(ntwk, self.data_rate, |
| 2782 |
self.sample_per_UI, |
| 2783 |
self.extrapolation) |
| 2784 |
|
| 2785 |
|
| 2786 |
self.ntwk_interpolated = self.extrapolate_to_dc(self.ntwk_interpolated) |
| 2787 |
|
| 2788 |
if verbose: |
| 2789 |
fig, axs = subplots(2, 3, figsize = (12, 7)) |
| 2790 |
fig.suptitle('Application-based checking in the time domain') |
| 2791 |
ax = axs[0, 0] |
| 2792 |
ax.set_title('Extrapolation') |
| 2793 |
self.ntwk_interpolated.frequency.unit = ntwk.frequency.unit |
| 2794 |
|
| 2795 |
ntwk.plot_s_db(1, 0, color = 'r', ax = ax, label = 'Original, S21') |
| 2796 |
if self.extrapolation == 2: |
| 2797 |
nz_k = np.nonzero(self.ntwk_interpolated.s[:, 1, 0])[0] |
| 2798 |
self.ntwk_interpolated[:nz_k[-1]].plot_s_db(1, 0, color = 'b', |
| 2799 |
linestyle = 'dashed', ax = ax, |
| 2800 |
label = 'Extrapolated, S21') |
| 2801 |
else: |
| 2802 |
self.ntwk_interpolated.plot_s_db(1, 0, color = 'b', |
| 2803 |
linestyle = 'dashed', ax = ax, |
| 2804 |
label = 'Extrapolated, S21') |
| 2805 |
secax = ax.twinx() |
| 2806 |
ntwk.plot_s_deg(1, 0, color = 'm', ax = secax, label = 'Original, S21') |
| 2807 |
self.ntwk_interpolated.plot_s_deg(1, 0, color = 'c', |
| 2808 |
linestyle = 'dashed', ax = secax, |
| 2809 |
label = 'Extrapolated, S21') |
| 2810 |
ax.legend(loc = 'upper left') |
| 2811 |
secax.legend(loc = 'lower right') |
| 2812 |
fig.tight_layout() |
| 2813 |
|
| 2814 |
|
| 2815 |
self.causal, self.delay_matrix = self.create_causal(self.ntwk_interpolated, |
| 2816 |
self.data_rate, self.rise_time_per) |
| 2817 |
|
| 2818 |
self.passive = self.create_passive(self.ntwk_interpolated) |
| 2819 |
|
| 2820 |
self.reciprocal = self.create_reciprocal(self.ntwk_interpolated) |
| 2821 |
|
| 2822 |
|
| 2823 |
self.v_causal, self.t_causal = self.get_time_domain(self.causal, |
| 2824 |
self.data_rate, |
| 2825 |
self.rise_time_per, |
| 2826 |
self.pulse_shape) |
| 2827 |
self.v_passive, self.t_passive = self.get_time_domain(self.passive, |
| 2828 |
self.data_rate, |
| 2829 |
self.rise_time_per, |
| 2830 |
self.pulse_shape) |
| 2831 |
self.v_reciprocal, self.t_reciprocal = self.get_time_domain(self.reciprocal, |
| 2832 |
self.data_rate, |
| 2833 |
self.rise_time_per, |
| 2834 |
self.pulse_shape) |
| 2835 |
self.v_origin, self.t_origin = self.get_time_domain(self.ntwk_interpolated, |
| 2836 |
self.data_rate, |
| 2837 |
self.rise_time_per, |
| 2838 |
self.pulse_shape) |
| 2839 |
|
| 2840 |
|
| 2841 |
self.causality_difference_mv = self.get_td_causality_difference_mv( |
| 2842 |
self.v_causal, self.v_origin, self.t_origin, |
| 2843 |
2, self.data_rate, self.delay_matrix) |
| 2844 |
self.passivity_difference_mv = self.get_td_difference_mv( |
| 2845 |
self.v_passive, self.v_origin, self.t_origin, 2, self.data_rate) |
| 2846 |
self.reciprocity_difference_mv = self.get_td_difference_mv( |
| 2847 |
self.v_reciprocal, self.v_origin, self.t_origin, 2, self.data_rate) |
| 2848 |
|
| 2849 |
|
| 2850 |
causality_metric = np.round( |
| 2851 |
1000 * np.linalg.norm(self.causality_difference_mv, 2), 1) |
| 2852 |
passivity_metric = np.round( |
| 2853 |
1000 * np.linalg.norm(self.passivity_difference_mv, 2), 1) |
| 2854 |
reciprocity_metric = np.round( |
| 2855 |
1000 * np.linalg.norm(self.reciprocity_difference_mv, 2), 1) |
| 2856 |
|
| 2857 |
|
| 2858 |
if verbose: |
| 2859 |
|
| 2860 |
|
| 2861 |
filter = self.add_conj(self.filter) |
| 2862 |
pulse_response = self.pulse * filter |
| 2863 |
v_filtered = np.real(np.fft.ifft(pulse_response)) |
| 2864 |
ax = axs[1, 0] |
| 2865 |
if self.pulse_shape == 1: |
| 2866 |
ax.plot(self.t_pulse, self.v_ref, color = 'r', |
| 2867 |
label = 'Reference') |
| 2868 |
ax.plot(self.t_pulse, self.v_pulse, color = 'k', linestyle = 'dashed', |
| 2869 |
label = 'Generated') |
| 2870 |
ax.legend(loc = 'upper right') |
| 2871 |
ax.set_title('Gaussian Pulse') |
| 2872 |
else: |
| 2873 |
ax.plot(self.t_ref, self.v_ref, color = 'r', marker = 'o', |
| 2874 |
label = 'Reference') |
| 2875 |
ax.plot(self.t_pulse, self.v_pulse, color = 'k', linestyle = 'dashed', |
| 2876 |
label = 'Interpolated') |
| 2877 |
ax.plot(self.t_pulse, v_filtered, color = 'b', linestyle = 'dotted', |
| 2878 |
label = 'Filtered') |
| 2879 |
ax.set_title('Filtered Rectangular Pulse') |
| 2880 |
ax.legend(loc = 'upper right') |
| 2881 |
ax.set_ylabel('Amplitude (V)') |
| 2882 |
ax.set_xlabel('Time (s)') |
| 2883 |
|
| 2884 |
|
| 2885 |
|
| 2886 |
ax = axs[0, 1] |
| 2887 |
ax.set_title('TDR11') |
| 2888 |
ax.plot(self.t_causal * 1e9, self.v_causal[:, 0, 0] / 2., |
| 2889 |
label = 'causal', color = 'r') |
| 2890 |
ax.plot(self.t_origin * 1e9, self.v_origin[:, 0, 0] / 2., |
| 2891 |
label = 'original', color = 'k', linestyle = 'dashed') |
| 2892 |
ax = axs[0, 2] |
| 2893 |
ax.set_title('TDT21') |
| 2894 |
ax.plot(self.t_causal * 1e9, self.v_causal[:, 1, 0] / 2., |
| 2895 |
label = 'causal', color = 'r') |
| 2896 |
ax.plot(self.t_origin * 1e9, self.v_origin[:, 1, 0] / 2., |
| 2897 |
label = 'original', color = 'k', linestyle = 'dashed') |
| 2898 |
ax = axs[1, 1] |
| 2899 |
ax.set_title('TDT12') |
| 2900 |
ax.plot(self.t_causal * 1e9, self.v_causal[:, 0, 1] / 2., |
| 2901 |
label = 'causal', color = 'r') |
| 2902 |
ax.plot(self.t_origin * 1e9, self.v_origin[:, 0, 1] / 2., |
| 2903 |
label = 'original', color = 'k', linestyle = 'dashed') |
| 2904 |
ax = axs[1, 2] |
| 2905 |
ax.set_title('TDR22') |
| 2906 |
ax.plot(self.t_causal * 1e9, self.v_causal[:, 1, 1] / 2., |
| 2907 |
label = 'causal', color = 'r') |
| 2908 |
ax.plot(self.t_origin * 1e9, self.v_origin[:, 1, 1] / 2., |
| 2909 |
label = 'original', color = 'k', linestyle = 'dashed') |
| 2910 |
for ax in axs[:, 1:].reshape(-1): |
| 2911 |
ax.set_xlabel('Time (ns)') |
| 2912 |
ax.set_ylabel('Amplitude (V)') |
| 2913 |
ax.legend(loc = 'upper right') |
| 2914 |
fig.tight_layout() |
| 2915 |
|
| 2916 |
QM = {'causality': {'value': causality_metric / 2., 'unit': 'mV', |
| 2917 |
'evaluation': ''}, |
| 2918 |
'passivity': {'value': passivity_metric / 2., 'unit': 'mV', |
| 2919 |
'evaluation': ''}, |
| 2920 |
'reciprocity': {'value': reciprocity_metric / 2., 'unit': 'mV', |
| 2921 |
'evaluation': ''}, |
| 2922 |
} |
| 2923 |
|
| 2924 |
|
| 2925 |
CQM = QM['causality']['value'] |
| 2926 |
if CQM >= 15.: |
| 2927 |
QM['causality']['evaluation'] = 'poor' |
| 2928 |
elif CQM >= 10.: |
| 2929 |
QM['causality']['evaluation'] = 'inconclusive' |
| 2930 |
elif CQM >= 5.: |
| 2931 |
QM['causality']['evaluation'] = 'acceptable' |
| 2932 |
else: |
| 2933 |
QM['causality']['evaluation'] = 'good' |
| 2934 |
|
| 2935 |
PQM = QM['passivity']['value'] |
| 2936 |
if PQM >= 15.: |
| 2937 |
QM['passivity']['evaluation'] = 'poor' |
| 2938 |
elif PQM >= 10.: |
| 2939 |
QM['passivity']['evaluation'] = 'inconclusive' |
| 2940 |
elif PQM >= 5.: |
| 2941 |
QM['passivity']['evaluation'] = 'acceptable' |
| 2942 |
else: |
| 2943 |
QM['passivity']['evaluation'] = 'good' |
| 2944 |
|
| 2945 |
RQM = QM['reciprocity']['value'] |
| 2946 |
if RQM >= 15.: |
| 2947 |
QM['reciprocity']['evaluation'] = 'poor' |
| 2948 |
elif RQM >= 10.: |
| 2949 |
QM['reciprocity']['evaluation'] = 'inconclusive' |
| 2950 |
elif RQM >= 5.: |
| 2951 |
QM['reciprocity']['evaluation'] = 'acceptable' |
| 2952 |
else: |
| 2953 |
QM['reciprocity']['evaluation'] = 'good' |
| 2954 |
|
| 2955 |
return QM |
| 2956 |
|
| 2957 |
def check_mm_quality(self, ntwk: Network, verbose: bool = False) -> dict: |
| 2958 |
""" |
| 2959 |
Mixed-mode application-based quality checking of in the time domain. |
| 2960 |
|
| 2961 |
If necessary, the original S-parameters are extrapolated to a frequency |
| 2962 |
of three times the desired data rate. Causal, passive, and reciprocal |
| 2963 |
models are reconstructed and stimulated by a pulse. The difference |
| 2964 |
between the original extrapolated signal and the ideal responses |
| 2965 |
in the time domain are integrated to give metrics in millivolts. |
| 2966 |
|
| 2967 |
The input networks should be 4-port single-ended and will be |
| 2968 |
transformed to mixed-mode representation. Only the differential and |
| 2969 |
the common modes are tested. |
| 2970 |
|
| 2971 |
Parameters |
| 2972 |
---------- |
| 2973 |
ntwk: :class:`~skrf.network.Network` object |
| 2974 |
Network to be checked |
| 2975 |
verbose: :bool |
| 2976 |
Plot internal causality, passivity, and reciprocity |
| 2977 |
figures. When True, override class verbose parameter. |
| 2978 |
(default False). |
| 2979 |
|
| 2980 |
Returns |
| 2981 |
------- |
| 2982 |
QM : :class:`dict` object |
| 2983 |
Dictionary with quality metrics |
| 2984 |
""" |
| 2985 |
mm = ntwk.copy() |
| 2986 |
mm.se2gmm(p = 2) |
| 2987 |
QM = {'dd': self.check_se_quality(mm.subnetwork([0, 1]), verbose), |
| 2988 |
'cc': self.check_se_quality(mm.subnetwork([2, 3]), verbose)} |
| 2989 |
|
| 2990 |
return QM |
| 2991 |
|
| 2992 |
def print_qm(self, QM: dict) -> dict: |
| 2993 |
""" |
| 2994 |
Print the quality metrics dictionary. |
| 2995 |
|
| 2996 |
Parameters |
| 2997 |
---------- |
| 2998 |
QM: :class:`dict` object |
| 2999 |
Dictionary with quality metrics to print |
| 3000 |
""" |
| 3001 |
if 'dd' in QM: |
| 3002 |
print('Differential mode') |
| 3003 |
for k in QM['dd'].keys(): |
| 3004 |
print(f"{k} in the time domain is {QM['dd'][k]['evaluation']} " |
| 3005 |
f"({QM['dd'][k]['value']} {QM['dd'][k]['unit']})") |
| 3006 |
print('Common mode') |
| 3007 |
for k in QM['cc'].keys(): |
| 3008 |
print(f"{k} in the time domain is {QM['cc'][k]['evaluation']} " |
| 3009 |
f"({QM['cc'][k]['value']} {QM['cc'][k]['unit']})") |
| 3010 |
else: |
| 3011 |
for k in QM.keys(): |
| 3012 |
print(f"{k} in the time domain is {QM[k]['evaluation']} " |
| 3013 |
f"({QM[k]['value']} {QM[k]['unit']})") |
| 3014 |
|
| 3015 |
class IEEEP370_SE_NZC_2xThru(IEEEP370): |
| 3016 |
""" |
| 3017 |
Creates error boxes from a test fixture 2xThru network. |
| 3018 |
|
| 3019 |
Based on [ElSA20]_ and [I3E370]_. |
| 3020 |
|
| 3021 |
A deembedding object is created with a single 2xThru (FIX-FIX) network, |
| 3022 |
which is split into left (FIX-1) and right (FIX-2) fixtures with IEEEP370 |
| 3023 |
2xThru method. |
| 3024 |
|
| 3025 |
When :func:`Deembedding.deembed` is applied, the s-parameters of FIX-1 and |
| 3026 |
FIX-2 are deembedded from the FIX_DUT_FIX network. |
| 3027 |
|
| 3028 |
This method is applicable only when there is a 2x-Thru network. |
| 3029 |
|
| 3030 |
The S-parameters bisection is done by time gating S11 and S22, taking the |
| 3031 |
proper square root of the S21 corrected by return loss, and remixing the |
| 3032 |
parameters according to the fixture signal flow graph. This method gives |
| 3033 |
crude results but is robust. |
| 3034 |
|
| 3035 |
Example |
| 3036 |
-------- |
| 3037 |
>>> import skrf as rf |
| 3038 |
>>> from skrf.calibration import IEEEP370_SE_NZC_2xThru |
| 3039 |
|
| 3040 |
Create network objects for 2x-Thru and FIX_DUT_FIX |
| 3041 |
|
| 3042 |
>>> s2xthru = rf.Network('2xthru.s2p') |
| 3043 |
>>> fdf = rf.Network('f-dut-f.s2p') |
| 3044 |
|
| 3045 |
Create de-embedding object |
| 3046 |
|
| 3047 |
>>> dm = IEEEP370_SE_NZC_2xThru(dummy_2xthru = s2xthru, name = '2xthru') |
| 3048 |
|
| 3049 |
Apply deembedding to get the actual DUT network |
| 3050 |
|
| 3051 |
>>> dut = dm.deembed(fdf) |
| 3052 |
|
| 3053 |
Note |
| 3054 |
---- |
| 3055 |
numbering diagram:: |
| 3056 |
|
| 3057 |
FIX-1 DUT FIX-2 |
| 3058 |
+----+ +----+ +----+ |
| 3059 |
-|1 2|---|1 2|---|2 1|- |
| 3060 |
+----+ +----+ +----+ |
| 3061 |
|
| 3062 |
|
| 3063 |
Warning |
| 3064 |
------- |
| 3065 |
There are two differences compared to the original matlab implementation |
| 3066 |
[I3E370]: |
| 3067 |
- FIX-2 is flipped (see diagram above) |
| 3068 |
- A more robust root choice solution is used that avoids the apparition |
| 3069 |
of 180° phase jumps in the fixtures in certain circumstances |
| 3070 |
|
| 3071 |
References |
| 3072 |
---------- |
| 3073 |
.. [ElSA20] Ellison J, Smith SB, Agili S., "Using a 2x-thru standard to achieve |
| 3074 |
accurate de-embedding of measurements", Microwave Optical Technology |
| 3075 |
Letter, 2020, https://doi.org/10.1002/mop.32098 |
| 3076 |
.. [I3E370] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP3702xThru.m, |
| 3077 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 3078 |
""" |
| 3079 |
def __init__(self, dummy_2xthru: Network, name: str = None, |
| 3080 |
z0: float = 50, use_z_instead_ifft: bool = False, verbose: bool = False, |
| 3081 |
forced_z0_line: float = None, *args, **kwargs) -> None: |
| 3082 |
""" |
| 3083 |
IEEEP370_SE_NZC_2xThru De-embedding Initializer |
| 3084 |
|
| 3085 |
Parameters |
| 3086 |
----------- |
| 3087 |
|
| 3088 |
dummy_2xthru : :class:`~skrf.network.Network` object |
| 3089 |
2xThru (FIX-FIX) network. |
| 3090 |
|
| 3091 |
z0 : |
| 3092 |
reference impedance of the S-parameters (default: 50) |
| 3093 |
|
| 3094 |
name : string |
| 3095 |
optional name of de-embedding object |
| 3096 |
|
| 3097 |
use_z_instead_ifft: |
| 3098 |
use z-transform instead ifft. This method is not documented in |
| 3099 |
the paper but exists in the IEEE repo. It could be used if the |
| 3100 |
2x-Thru is so short that there is not enough points in time domain |
| 3101 |
to determine the length of half fixtures from the s21 impulse |
| 3102 |
response and the the impedance at split plane from the s11 step |
| 3103 |
response. |
| 3104 |
Parameter `verbose` could be used for diagnostic in |
| 3105 |
ifft mode. (default: False) |
| 3106 |
|
| 3107 |
forced_z0_line: |
| 3108 |
If specified, the value for the split plane impedance is forced to |
| 3109 |
`forced_z0_line`. |
| 3110 |
The IEEEP370 standard recommends the 2x-Thru being at least three |
| 3111 |
wavelengths at the highest measured frequency. This ensures that |
| 3112 |
the split plane impedance measured in the S11 step response is free |
| 3113 |
of reflections from the launches. |
| 3114 |
If the 2x-Thru is too short, any point in the s11 step response |
| 3115 |
contain reflections from the lanches and split plane impedance |
| 3116 |
cannot be determined accurately by this method. |
| 3117 |
In this case, setting the impedance manually can improve the |
| 3118 |
results. However, it should be noted that each fixture model will |
| 3119 |
still include some reflections from the opposite side launch |
| 3120 |
because there is not enough time resolution to separate them. |
| 3121 |
(Default: None) |
| 3122 |
|
| 3123 |
verbose : |
| 3124 |
view the process (default: False) |
| 3125 |
|
| 3126 |
args, kwargs: |
| 3127 |
passed to :func:`Deembedding.__init__` |
| 3128 |
|
| 3129 |
See Also |
| 3130 |
--------- |
| 3131 |
:func:`Deembedding.__init__` |
| 3132 |
|
| 3133 |
""" |
| 3134 |
self.s2xthru = dummy_2xthru.copy() |
| 3135 |
self.z0 = z0 |
| 3136 |
dummies = [self.s2xthru] |
| 3137 |
self.use_z_instead_ifft = use_z_instead_ifft |
| 3138 |
self.forced_z0_line = forced_z0_line |
| 3139 |
self.verbose = verbose |
| 3140 |
|
| 3141 |
self.x_end = None |
| 3142 |
self.z_x = None |
| 3143 |
|
| 3144 |
IEEEP370.__init__(self, dummies, name, *args, **kwargs) |
| 3145 |
self.s_side1, self.s_side2 = self.split2xthru(self.s2xthru) |
| 3146 |
|
| 3147 |
def deembed(self, ntwk: Network) -> Network: |
| 3148 |
""" |
| 3149 |
Perform the de-embedding calculation |
| 3150 |
|
| 3151 |
Parameters |
| 3152 |
---------- |
| 3153 |
ntwk : :class:`~skrf.network.Network` object |
| 3154 |
FIX-DUT-FIX network from which FIX-1 AND FIX-2 fixtures needs to be |
| 3155 |
removed via de-embedding |
| 3156 |
|
| 3157 |
Returns |
| 3158 |
------- |
| 3159 |
caled : :class:`~skrf.network.Network` object |
| 3160 |
Network data of the device after de-embedding |
| 3161 |
|
| 3162 |
""" |
| 3163 |
|
| 3164 |
|
| 3165 |
if ntwk.frequency != self.s2xthru.frequency: |
| 3166 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 3167 |
RuntimeWarning, stacklevel=2) |
| 3168 |
ntwk, s2xthru = overlap_multi([ntwk, self.s2xthru]) |
| 3169 |
s_side1, s_side2 = self.split2xthru(s2xthru) |
| 3170 |
else: |
| 3171 |
s_side1 = self.s_side1 |
| 3172 |
s_side2 = self.s_side2 |
| 3173 |
|
| 3174 |
return s_side1.inv ** ntwk ** s_side2.flipped().inv |
| 3175 |
|
| 3176 |
def split2xthru(self, s2xthru: Network) -> (Network, Network): |
| 3177 |
""" |
| 3178 |
Perform the fixtures extraction. |
| 3179 |
""" |
| 3180 |
f = s2xthru.frequency.f |
| 3181 |
s = s2xthru.s |
| 3182 |
|
| 3183 |
if not self.use_z_instead_ifft: |
| 3184 |
|
| 3185 |
if(f[0] == 0): |
| 3186 |
warnings.warn( |
| 3187 |
"DC point detected. An interpolated DC point will be included in the errorboxes.", |
| 3188 |
RuntimeWarning, stacklevel=2 |
| 3189 |
) |
| 3190 |
flag_DC = True |
| 3191 |
f = f[1:] |
| 3192 |
s = s[1:] |
| 3193 |
else: |
| 3194 |
flag_DC = False |
| 3195 |
|
| 3196 |
|
| 3197 |
if(f[1] - f[0] != f[0]): |
| 3198 |
warnings.warn( |
| 3199 |
"""Non-uniform frequency vector detected. An interpolated S-parameter matrix will be created for |
| 3200 |
this calculation. The output results will be re-interpolated to the original vector.""", |
| 3201 |
RuntimeWarning, stacklevel=2 |
| 3202 |
) |
| 3203 |
flag_df = True |
| 3204 |
f_original = f |
| 3205 |
projected_n = round(f[-1]/f[0]) |
| 3206 |
if(projected_n <= 10000): |
| 3207 |
fnew = f[0] * (np.arange(0, projected_n) + 1) |
| 3208 |
else: |
| 3209 |
dfnew = f[-1]/10000 |
| 3210 |
fnew = dfnew * (np.arange(0, 10000) + 1) |
| 3211 |
stemp = Network(frequency = Frequency.from_f(f, 'Hz'), s = s) |
| 3212 |
f_interp = Frequency.from_f(fnew, unit = 'Hz') |
| 3213 |
stemp.interpolate_self(f_interp, kind = 'cubic', |
| 3214 |
fill_value = 'extrapolate') |
| 3215 |
f = fnew |
| 3216 |
s = stemp.s |
| 3217 |
del stemp |
| 3218 |
|
| 3219 |
else: |
| 3220 |
flag_df = False |
| 3221 |
|
| 3222 |
n = len(f) |
| 3223 |
s11 = s[:, 0, 0] |
| 3224 |
|
| 3225 |
|
| 3226 |
|
| 3227 |
s21 = s[:, 1, 0] |
| 3228 |
dcs21 = IEEEP370.dc_interp(s21, f) |
| 3229 |
t21 = fftshift(irfft(concatenate(([dcs21], s21)), axis=0), axes=0) |
| 3230 |
x = np.argmax(t21) |
| 3231 |
self.x_end = x |
| 3232 |
|
| 3233 |
dcs11 = IEEEP370.DC(s11,f) |
| 3234 |
t11 = fftshift(irfft(concatenate(([dcs11], s11)), axis=0), axes=0) |
| 3235 |
step11 = IEEEP370.makeStep(t11) |
| 3236 |
z11 = -self.z0 * (step11 + 1) / (step11 - 1) |
| 3237 |
|
| 3238 |
if self.forced_z0_line: |
| 3239 |
z11x = self.forced_z0_line |
| 3240 |
else: |
| 3241 |
z11x = 0.5 * (z11[x-1] + z11[x]) |
| 3242 |
self.z_x = z11x |
| 3243 |
|
| 3244 |
if self.verbose: |
| 3245 |
fig, (ax1, ax2) = subplots(2,1, sharex = True) |
| 3246 |
fig.suptitle('Midpoint length and impedance determination') |
| 3247 |
ax1.plot(t21, label = 't21') |
| 3248 |
ax1.plot([x], [t21[x]], marker = 'o', linestyle = 'none', |
| 3249 |
label = 't21x') |
| 3250 |
ax1.grid() |
| 3251 |
ax1.legend() |
| 3252 |
ax2.plot(z11, label = 'z11') |
| 3253 |
ax2.plot([x], [z11x], marker = 'o', linestyle = 'none', |
| 3254 |
label = 'z11x') |
| 3255 |
ax2.set_xlabel('t-samples') |
| 3256 |
ax2.set_xlim((x - 50, x + 50)) |
| 3257 |
ax2.grid() |
| 3258 |
ax2.legend() |
| 3259 |
|
| 3260 |
temp = Network(frequency = Frequency.from_f(f, 'Hz'), s = s, z0 = self.z0) |
| 3261 |
temp.renormalize(z11x) |
| 3262 |
sr = temp.s |
| 3263 |
del temp |
| 3264 |
|
| 3265 |
s11r = sr[:, 0, 0] |
| 3266 |
s21r = sr[:, 1, 0] |
| 3267 |
s12r = sr[:, 0, 1] |
| 3268 |
s22r = sr[:, 1, 1] |
| 3269 |
|
| 3270 |
dcs11r = IEEEP370.DC(s11r, f) |
| 3271 |
|
| 3272 |
t11r = fftshift(irfft(concatenate(([dcs11r], s11r)), axis=0), axes=0) |
| 3273 |
t11r[x:] = 0 |
| 3274 |
e001 = fft(ifftshift(t11r)) |
| 3275 |
e001 = e001[1:n+1] |
| 3276 |
|
| 3277 |
dcs22r = IEEEP370.DC(s22r, f) |
| 3278 |
t22r = fftshift(irfft(concatenate(([dcs22r], s22r)), axis=0), axes=0) |
| 3279 |
t22r[x:] = 0 |
| 3280 |
e002 = fft(ifftshift(t22r)) |
| 3281 |
e002 = e002[1:n+1] |
| 3282 |
|
| 3283 |
|
| 3284 |
e111 = (s22r - e002) / s12r |
| 3285 |
e112 = (s11r - e001) / s21r |
| 3286 |
|
| 3287 |
|
| 3288 |
|
| 3289 |
|
| 3290 |
|
| 3291 |
|
| 3292 |
|
| 3293 |
|
| 3294 |
|
| 3295 |
|
| 3296 |
|
| 3297 |
|
| 3298 |
|
| 3299 |
|
| 3300 |
|
| 3301 |
|
| 3302 |
|
| 3303 |
|
| 3304 |
|
| 3305 |
|
| 3306 |
|
| 3307 |
|
| 3308 |
|
| 3309 |
|
| 3310 |
|
| 3311 |
|
| 3312 |
e01 = np.sqrt(s21r * (1 - e111 * e112)) |
| 3313 |
for i in range(n): |
| 3314 |
if i > 0: |
| 3315 |
if np.abs(-e01[i] - e01[i-1]) < np.abs(e01[i] - e01[i-1]): |
| 3316 |
e01[i] = - e01[i] |
| 3317 |
e10 = np.sqrt(s12r * (1 - e111 * e112)) |
| 3318 |
for i in range(n): |
| 3319 |
if i > 0: |
| 3320 |
if np.abs(-e10[i] - e10[i-1]) < np.abs(e10[i] - e10[i-1]): |
| 3321 |
e10[i] = - e10[i] |
| 3322 |
|
| 3323 |
|
| 3324 |
|
| 3325 |
if flag_df: |
| 3326 |
interp_e001 = interp1d(f, e001, kind = 'cubic', |
| 3327 |
fill_value = 'extrapolate', |
| 3328 |
assume_sorted = True) |
| 3329 |
e001 = interp_e001(f_original) |
| 3330 |
interp_e01 = interp1d(f, e01, kind = 'cubic', |
| 3331 |
fill_value = 'extrapolate', |
| 3332 |
assume_sorted = True) |
| 3333 |
e01 = interp_e01(f_original) |
| 3334 |
interp_e111 = interp1d(f, e111, kind = 'cubic', |
| 3335 |
fill_value = 'extrapolate', |
| 3336 |
assume_sorted = True) |
| 3337 |
e111 = interp_e111(f_original) |
| 3338 |
interp_e002 = interp1d(f, e002, kind = 'cubic', |
| 3339 |
fill_value = 'extrapolate', |
| 3340 |
assume_sorted = True) |
| 3341 |
e002 = interp_e002(f_original) |
| 3342 |
interp_e10 = interp1d(f, e10, kind = 'cubic', |
| 3343 |
fill_value = 'extrapolate', |
| 3344 |
assume_sorted = True) |
| 3345 |
e10 = interp_e10(f_original) |
| 3346 |
interp_e112 = interp1d(f, e112, kind = 'cubic', |
| 3347 |
fill_value = 'extrapolate', |
| 3348 |
assume_sorted = True) |
| 3349 |
e112 = interp_e112(f_original) |
| 3350 |
f = f_original |
| 3351 |
|
| 3352 |
|
| 3353 |
if flag_DC: |
| 3354 |
e001 = concatenate(([IEEEP370.dc_interp(e001, f)], e001)) |
| 3355 |
e01 = concatenate(([IEEEP370.dc_interp(e01, f)], e01)) |
| 3356 |
e111 = concatenate(([IEEEP370.dc_interp(e111, f)], e111)) |
| 3357 |
e002 = concatenate(([IEEEP370.dc_interp(e002, f)], e002)) |
| 3358 |
e10 = concatenate(([IEEEP370.dc_interp(e10, f)], e10)) |
| 3359 |
e112 = concatenate(([IEEEP370.dc_interp(e112, f)], e112)) |
| 3360 |
f = concatenate(([0], f)) |
| 3361 |
|
| 3362 |
|
| 3363 |
n = len(f) |
| 3364 |
fixture_model_1r = zeros((n, 2, 2), dtype = complex) |
| 3365 |
fixture_model_1r[:, 0, 0] = e001 |
| 3366 |
fixture_model_1r[:, 1, 0] = e01 |
| 3367 |
fixture_model_1r[:, 0, 1] = e01 |
| 3368 |
fixture_model_1r[:, 1, 1] = e111 |
| 3369 |
|
| 3370 |
fixture_model_2r = zeros((n, 2, 2), dtype = complex) |
| 3371 |
fixture_model_2r[:, 1, 1] = e002 |
| 3372 |
fixture_model_2r[:, 0, 1] = e10 |
| 3373 |
fixture_model_2r[:, 1, 0] = e10 |
| 3374 |
fixture_model_2r[:, 0, 0] = e112 |
| 3375 |
|
| 3376 |
|
| 3377 |
s_fixture_model_r1 = Network(frequency = Frequency.from_f(f, 'Hz'), s = fixture_model_1r, z0 = z11x) |
| 3378 |
s_fixture_model_r2 = Network(frequency = Frequency.from_f(f, 'Hz'), s = fixture_model_2r, z0 = z11x) |
| 3379 |
|
| 3380 |
|
| 3381 |
s_fixture_model_r1.renormalize(self.z0) |
| 3382 |
s_fixture_model_r2.renormalize(self.z0) |
| 3383 |
s_side1 = s_fixture_model_r1 |
| 3384 |
s_side2 = s_fixture_model_r2.flipped() |
| 3385 |
|
| 3386 |
else: |
| 3387 |
z = s2xthru.z |
| 3388 |
ZL = zeros(z.shape, dtype = complex) |
| 3389 |
ZR = zeros(z.shape, dtype = complex) |
| 3390 |
|
| 3391 |
for i in range(len(f)): |
| 3392 |
ZL[i, :, :] = [ |
| 3393 |
[z[i, 0, 0] + z[i, 1, 0], 2. * z[i, 1, 0]], |
| 3394 |
[2. * z[i, 1, 0], 2. * z[i, 1, 0]] |
| 3395 |
] |
| 3396 |
ZR[i, :, :] = [ |
| 3397 |
[2. * z[i, 0, 1], 2. * z[i, 0, 1]], |
| 3398 |
[2. * z[i, 0, 1], z[i, 1, 1] + z[i, 0, 1]] |
| 3399 |
] |
| 3400 |
|
| 3401 |
s_side1 = Network(frequency = s2xthru.frequency, z = ZL, z0 = self.z0) |
| 3402 |
s_side2 = Network(frequency = s2xthru.frequency, z = ZR, z0 = self.z0) |
| 3403 |
s_side2.flip() |
| 3404 |
|
| 3405 |
return (s_side1, s_side2) |
| 3406 |
|
| 3407 |
def plot_check_residuals(self, ax: Axes = None) -> (Figure, Axes): |
| 3408 |
res = self.deembed(self.s2xthru) |
| 3409 |
res.name = 'Residuals' |
| 3410 |
|
| 3411 |
if ax is None: |
| 3412 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 3413 |
else: |
| 3414 |
fig = ax.get_figure() |
| 3415 |
|
| 3416 |
fig.suptitle('Consistency test #1: Self de-embedding of 2X-Thru') |
| 3417 |
|
| 3418 |
ax[0].set_title('Magnitude residuals') |
| 3419 |
res.plot_s_db(1,0, ax = ax[0], color = '0.5') |
| 3420 |
res.plot_s_db(0,1, ax = ax[0], color = 'k') |
| 3421 |
ax[0].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3422 |
[0.1, 0.1], |
| 3423 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 3424 |
ax[0].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3425 |
[-0.1, -0.1], |
| 3426 |
linestyle = 'dashed', color = 'r') |
| 3427 |
ax[0].legend(loc = 'upper right') |
| 3428 |
|
| 3429 |
ax[1].set_title('Phase residuals') |
| 3430 |
res.plot_s_deg(1,0, ax = ax[1], color = '0.5') |
| 3431 |
res.plot_s_deg(0,1, ax = ax[1], color = 'k') |
| 3432 |
ax[1].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3433 |
[1, 1], |
| 3434 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 3435 |
ax[1].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3436 |
[-1, -1], |
| 3437 |
linestyle = 'dashed', color = 'r') |
| 3438 |
ax[1].legend(loc = 'upper right') |
| 3439 |
fig.tight_layout() |
| 3440 |
|
| 3441 |
return (fig, ax) |
| 3442 |
|
| 3443 |
def plot_check_impedance(self, fix_dut_fix: Network = None, ax: Axes = None, |
| 3444 |
window: str = 'hamming') -> (Figure, Axes): |
| 3445 |
|
| 3446 |
s2xthru = IEEEP370.extrapolate_to_dc(self.s2xthru) |
| 3447 |
fix1 = IEEEP370.extrapolate_to_dc(self.s_side1) |
| 3448 |
fix2 = IEEEP370.extrapolate_to_dc(self.s_side2) |
| 3449 |
if fix_dut_fix is not None: |
| 3450 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(fix_dut_fix) |
| 3451 |
n = s2xthru.frequency.npoints * 2 - 1 |
| 3452 |
dt = 1e9 / (n * s2xthru.frequency.step) |
| 3453 |
|
| 3454 |
if ax is None: |
| 3455 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 3456 |
else: |
| 3457 |
fig = ax.get_figure() |
| 3458 |
|
| 3459 |
fig.suptitle('Consistency test #2: Compare the TDR of the fixture model to the FIX-DUT-FIX') |
| 3460 |
ax[0].set_title('Side 1') |
| 3461 |
fix1.plot_z_time_step(0, 0, window = window, |
| 3462 |
ax = ax[0], color = 'k') |
| 3463 |
s2xthru.plot_z_time_step(0, 0, window = window, |
| 3464 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 3465 |
y = ax[0].lines[-1].get_ydata() |
| 3466 |
if fix_dut_fix is not None: |
| 3467 |
fix_dut_fix.plot_z_time_step(0, 0, window = window, |
| 3468 |
ax = ax[0], linestyle = 'dashed', color = 'm') |
| 3469 |
ax[0].plot([0], [y[n // 2]], marker = 's', color = 'k', label = 'start') |
| 3470 |
ax[0].plot([(self.x_end - (n // 2) - 1) * dt], [self.z_x], marker = 'o', |
| 3471 |
color = 'k', label = f'z_x = {self.z_x:0.1f} ohm') |
| 3472 |
|
| 3473 |
ymax = np.max(np.array([ax[0].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 3474 |
ax[0].lines[1].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 3475 |
ymin = np.min(np.array([ax[0].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 3476 |
ax[0].lines[1].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 3477 |
ax[0].set_ylim((ymin - 5, ymax + 5)) |
| 3478 |
ax[0].legend(loc = 'lower left') |
| 3479 |
|
| 3480 |
ax[1].set_title('Side 2') |
| 3481 |
fix2.plot_z_time_step(0, 0, window = window, |
| 3482 |
ax = ax[1], color = 'k') |
| 3483 |
s2xthru.plot_z_time_step(1, 1, window = window, |
| 3484 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 3485 |
y = ax[1].lines[-1].get_ydata() |
| 3486 |
if fix_dut_fix is not None: |
| 3487 |
fix_dut_fix.plot_z_time_step(1, 1, window = window, |
| 3488 |
ax = ax[1], linestyle = 'dashed', color = 'm') |
| 3489 |
ax[1].plot([0], [y[n // 2]], marker = 's', color = 'k', label = 'start') |
| 3490 |
ax[1].plot([(self.x_end - (n // 2) - 1) * dt], [self.z_x], marker = 'o', |
| 3491 |
color = 'k', label = f'z_x = {self.z_x:0.1f} ohm') |
| 3492 |
|
| 3493 |
ymax = np.max(np.array([ax[1].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 3494 |
ax[1].lines[1].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 3495 |
ymin = np.min(np.array([ax[1].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 3496 |
ax[1].lines[1].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 3497 |
ax[1].set_ylim((ymin - 5, ymax + 5)) |
| 3498 |
delay = 2 * (self.x_end - (n // 2)) * dt |
| 3499 |
ax[1].set_xlim((-0.5 * delay, 1.5 * delay)) |
| 3500 |
ax[1].legend(loc = 'lower left') |
| 3501 |
|
| 3502 |
fig.tight_layout() |
| 3503 |
|
| 3504 |
return (fig, ax) |
| 3505 |
|
| 3506 |
class IEEEP370_MM_NZC_2xThru(IEEEP370): |
| 3507 |
""" |
| 3508 |
Creates error boxes from a 4-port test fixture 2xThru. |
| 3509 |
|
| 3510 |
Based on [ElSA20]_ and [I3E370]_. |
| 3511 |
|
| 3512 |
A deembedding object is created with a single 2xThru (FIX-FIX) network, |
| 3513 |
which is split into left (FIX-1_2) and right (FIX-3_4) fixtures with |
| 3514 |
IEEEP370 2xThru method. |
| 3515 |
|
| 3516 |
When :func:`Deembedding.deembed` is applied, the s-parameters of FIX-1 and |
| 3517 |
FIX-2 are deembedded from the FIX_DUT_FIX network. |
| 3518 |
|
| 3519 |
This method is applicable only when there is a 2x-Thru measurement. |
| 3520 |
|
| 3521 |
The S-parameters bisection is done by time gating S11 and S22, taking the |
| 3522 |
proper square root of the S21 corrected by return loss, and remixing the |
| 3523 |
parameters according to the fixture signal flow graph. This method gives |
| 3524 |
crude results but is robust. |
| 3525 |
|
| 3526 |
Note |
| 3527 |
---- |
| 3528 |
The `port_order` ='first', means front-to-back also known as odd/even, |
| 3529 |
while `port_order`='second' means left-to-right also known as sequential. |
| 3530 |
`port_order`='third' means yet another numbering method. |
| 3531 |
Next figure show example of port numbering with 4-port networks. |
| 3532 |
|
| 3533 |
The `scikit-rf` cascade ** 2N-port operator use second scheme. This is very |
| 3534 |
convenient to write compact deembedding and other expressions. |
| 3535 |
|
| 3536 |
numbering diagram:: |
| 3537 |
|
| 3538 |
port_order = 'first' |
| 3539 |
+---------+ |
| 3540 |
-|0 1|- |
| 3541 |
-|2 3|- |
| 3542 |
+---------+ |
| 3543 |
|
| 3544 |
port_order = 'second' |
| 3545 |
+---------+ |
| 3546 |
-|0 2|- |
| 3547 |
-|1 3|- |
| 3548 |
+---------+ |
| 3549 |
|
| 3550 |
port_order = 'third' |
| 3551 |
+---------+ |
| 3552 |
-|0 3|- |
| 3553 |
-|1 2|- |
| 3554 |
+---------+ |
| 3555 |
|
| 3556 |
|
| 3557 |
use `Network.renumber` to change port ordering. |
| 3558 |
|
| 3559 |
Example |
| 3560 |
------- |
| 3561 |
>>> import skrf as rf |
| 3562 |
>>> from skrf.calibration import IEEEP370_MM_NZC_2xThru |
| 3563 |
|
| 3564 |
Create network objects for 2xThru and FIX-DUT-FIX |
| 3565 |
|
| 3566 |
>>> s2xthru = rf.Network('2xthru.s4p') |
| 3567 |
>>> fdf = rf.Network('f-dut-f.s4p') |
| 3568 |
|
| 3569 |
Create de-embedding object |
| 3570 |
|
| 3571 |
>>> dm = IEEEP370_MM_NZC_2xThru(dummy_2xthru = s2xthru, name = '2xthru') |
| 3572 |
|
| 3573 |
Apply deembedding to get the actual DUT network |
| 3574 |
|
| 3575 |
>>> dut = dm.deembed(fdf) |
| 3576 |
|
| 3577 |
Note |
| 3578 |
---- |
| 3579 |
numbering diagram:: |
| 3580 |
|
| 3581 |
FIX-1_2 DUT FIX-3_4 |
| 3582 |
+----+ +----+ +----+ |
| 3583 |
-|1 3|---|1 3|---|3 1|- |
| 3584 |
-|2 4|---|2 4|---|4 2|- |
| 3585 |
+----+ +----+ +----+ |
| 3586 |
|
| 3587 |
|
| 3588 |
Warning |
| 3589 |
------- |
| 3590 |
There are two differences compared to the original matlab implementation |
| 3591 |
[I3E370]_: |
| 3592 |
- FIX-2 is flipped (see diagram above) |
| 3593 |
- A more robust root choice solution is used that avoids the apparition |
| 3594 |
of 180° phase jumps in the fixtures in certain circumstances |
| 3595 |
|
| 3596 |
References |
| 3597 |
---------- |
| 3598 |
.. [ElSA20] Ellison J, Smith SB, Agili S., "Using a 2x-thru standard to achieve |
| 3599 |
accurate de-embedding of measurements", Microwave Optical Technology |
| 3600 |
Letter, 2020, https://doi.org/10.1002/mop.32098 |
| 3601 |
.. [I3E370] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370mmZc2xthru.m |
| 3602 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 3603 |
""" |
| 3604 |
def __init__(self, dummy_2xthru: Network, name: str = None, |
| 3605 |
z0: float = 50, port_order: PortOrderT = 'second', |
| 3606 |
use_z_instead_ifft: bool = False, verbose: bool = False, |
| 3607 |
forced_z0_line_dd: float = None, forced_z0_line_cc: float = None, |
| 3608 |
*args, **kwargs) -> None: |
| 3609 |
""" |
| 3610 |
IEEEP370_MM_NZC_2xThru De-embedding Initializer |
| 3611 |
|
| 3612 |
Parameters |
| 3613 |
----------- |
| 3614 |
|
| 3615 |
dummy_2xthru : :class:`~skrf.network.Network` object |
| 3616 |
2xThru (FIX-FIX) network. |
| 3617 |
|
| 3618 |
z0 : |
| 3619 |
reference impedance of the S-parameters (default: 50) |
| 3620 |
|
| 3621 |
port_order : ['first', 'second', 'third'] |
| 3622 |
specify what numbering scheme to use. See above. (default: second) |
| 3623 |
|
| 3624 |
name : string |
| 3625 |
optional name of de-embedding object |
| 3626 |
|
| 3627 |
use_z_instead_ifft: |
| 3628 |
use z-transform instead ifft. This method is not documented in |
| 3629 |
the paper but exists in the IEEE repo. It could be used if the |
| 3630 |
2x-Thru is so short that there is not enough points in time domain |
| 3631 |
to determine the length of half fixtures from the s21 impulse |
| 3632 |
response and the the impedance at split plane from the s11 step |
| 3633 |
response. |
| 3634 |
Parameter `verbose` could be used for diagnostic in |
| 3635 |
ifft mode. (default: False) |
| 3636 |
|
| 3637 |
forced_z0_line_dd: |
| 3638 |
If specified, the value for the split plane impedance is forced to |
| 3639 |
`forced_z0_line` for differential-mode. |
| 3640 |
The IEEEP370 standard recommends the 2x-Thru being at least three |
| 3641 |
wavelengths at the highest measured frequency. This ensures that |
| 3642 |
the split plane impedance measured in the S11 step response is free |
| 3643 |
of reflections from the launches. |
| 3644 |
If the 2x-Thru is too short, any point in the s11 step response |
| 3645 |
contain reflections from the lanches and split plane impedance |
| 3646 |
cannot be determined accurately by this method. |
| 3647 |
In this case, setting the impedance manually can improve the |
| 3648 |
results. However, it should be noted that each fixture model will |
| 3649 |
still include some reflections from the opposite side launch |
| 3650 |
because there is not enough time resolution to separate them. |
| 3651 |
(Default: None) |
| 3652 |
|
| 3653 |
forced_z0_line_cc: |
| 3654 |
Same behaviour as `forced_z0_line_dd`, but for the common-mode |
| 3655 |
split plane impedance. |
| 3656 |
(Default: None) |
| 3657 |
|
| 3658 |
verbose : |
| 3659 |
view the process (default: False) |
| 3660 |
|
| 3661 |
args, kwargs: |
| 3662 |
passed to :func:`Deembedding.__init__` |
| 3663 |
|
| 3664 |
See Also |
| 3665 |
--------- |
| 3666 |
:func:`Deembedding.__init__` |
| 3667 |
|
| 3668 |
""" |
| 3669 |
self.s2xthru = dummy_2xthru.copy() |
| 3670 |
self.z0 = z0 |
| 3671 |
self.port_order = port_order |
| 3672 |
dummies = [self.s2xthru] |
| 3673 |
self.use_z_instead_ifft = use_z_instead_ifft |
| 3674 |
self.verbose = verbose |
| 3675 |
self.forced_z0_line_dd = forced_z0_line_dd |
| 3676 |
self.forced_z0_line_cc = forced_z0_line_cc |
| 3677 |
|
| 3678 |
self.x_end_dd = None |
| 3679 |
self.z_x_dd = None |
| 3680 |
self.x_end_cc = None |
| 3681 |
self.z_x_cc = None |
| 3682 |
|
| 3683 |
IEEEP370.__init__(self, dummies, name, *args, **kwargs) |
| 3684 |
self.se_side1, self.se_side2 = self.split2xthru(self.s2xthru) |
| 3685 |
|
| 3686 |
def deembed(self, ntwk: Network) -> Network: |
| 3687 |
""" |
| 3688 |
Perform the de-embedding calculation |
| 3689 |
|
| 3690 |
Parameters |
| 3691 |
---------- |
| 3692 |
ntwk : :class:`~skrf.network.Network` object |
| 3693 |
FIX-DUT-FIX network from which FIX-1_2 and FIX-3_4 fixtures needs |
| 3694 |
to be removed via de-embedding |
| 3695 |
|
| 3696 |
Returns |
| 3697 |
------- |
| 3698 |
caled : :class:`~skrf.network.Network` object |
| 3699 |
Network data of the device after de-embedding |
| 3700 |
|
| 3701 |
""" |
| 3702 |
|
| 3703 |
|
| 3704 |
if ntwk.frequency != self.s2xthru.frequency: |
| 3705 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 3706 |
RuntimeWarning, stacklevel=2) |
| 3707 |
ntwk, s2xthru = overlap_multi([ntwk, self.s2xthru]) |
| 3708 |
se_side1, se_side2 = self.split2xthru(s2xthru) |
| 3709 |
else: |
| 3710 |
se_side1 = self.se_side1 |
| 3711 |
se_side2 = self.se_side2 |
| 3712 |
|
| 3713 |
|
| 3714 |
if ntwk.nports != 4: |
| 3715 |
raise(ValueError('2xthru has to be a 4-port network.')) |
| 3716 |
|
| 3717 |
if self.port_order == 'first': |
| 3718 |
N = ntwk.nports |
| 3719 |
old_order = list(range(N)) |
| 3720 |
new_order = list(range(0, N, 2)) + list(range(1, N, 2)) |
| 3721 |
ntwk.renumber(old_order, new_order) |
| 3722 |
elif self.port_order == 'third': |
| 3723 |
N = ntwk.nports |
| 3724 |
old_order = list(range(N)) |
| 3725 |
new_order = list(range(0, N//2)) + list(range(N-1, N//2-1, -1)) |
| 3726 |
ntwk.renumber(old_order, new_order) |
| 3727 |
|
| 3728 |
deembedded = se_side1.inv ** ntwk ** se_side2.flipped().inv |
| 3729 |
|
| 3730 |
if self.port_order != 'second': |
| 3731 |
deembedded.renumber(new_order, old_order) |
| 3732 |
return deembedded |
| 3733 |
|
| 3734 |
def split2xthru(self, se_2xthru: Network) -> (Network, Network): |
| 3735 |
""" |
| 3736 |
Perform the fixtures extraction. |
| 3737 |
""" |
| 3738 |
|
| 3739 |
if se_2xthru.nports != 4: |
| 3740 |
raise(ValueError('2xthru has to be a 4-port network.')) |
| 3741 |
|
| 3742 |
if self.port_order == 'first': |
| 3743 |
N = se_2xthru.nports |
| 3744 |
old_order = list(range(N)) |
| 3745 |
new_order = list(range(0, N, 2)) + list(range(1, N, 2)) |
| 3746 |
se_2xthru.renumber(old_order, new_order) |
| 3747 |
elif self.port_order == 'third': |
| 3748 |
N = se_2xthru.nports |
| 3749 |
old_order = list(range(N)) |
| 3750 |
new_order = list(range(0, N//2)) + list(range(N-1, N//2-1, -1)) |
| 3751 |
se_2xthru.renumber(old_order, new_order) |
| 3752 |
|
| 3753 |
|
| 3754 |
mm_2xthru = se_2xthru.copy() |
| 3755 |
mm_2xthru.se2gmm(p = 2) |
| 3756 |
|
| 3757 |
|
| 3758 |
sdd = subnetwork(mm_2xthru, [0, 1]) |
| 3759 |
scc = subnetwork(mm_2xthru, [2, 3]) |
| 3760 |
dm_dd = IEEEP370_SE_NZC_2xThru(dummy_2xthru = sdd, z0 = self.z0 * 2, |
| 3761 |
use_z_instead_ifft = self.use_z_instead_ifft, |
| 3762 |
verbose = self.verbose, |
| 3763 |
forced_z0_line = self.forced_z0_line_dd) |
| 3764 |
self.x_end_dd = dm_dd.x_end |
| 3765 |
self.z_x_dd = dm_dd.z_x |
| 3766 |
|
| 3767 |
dm_cc = IEEEP370_SE_NZC_2xThru(dummy_2xthru = scc, z0 = self.z0 / 2, |
| 3768 |
use_z_instead_ifft = self.use_z_instead_ifft, |
| 3769 |
verbose = self.verbose, |
| 3770 |
forced_z0_line = self.forced_z0_line_cc) |
| 3771 |
self.x_end_cc = dm_cc.x_end |
| 3772 |
self.z_x_cc = dm_cc.z_x |
| 3773 |
|
| 3774 |
|
| 3775 |
mm_side1 = concat_ports([dm_dd.s_side1, dm_cc.s_side1], port_order = 'first') |
| 3776 |
se_side1 = mm_side1.copy() |
| 3777 |
se_side1.gmm2se(p = 2) |
| 3778 |
mm_side2 = concat_ports([dm_dd.s_side2, dm_cc.s_side2], port_order = 'first') |
| 3779 |
se_side2 = mm_side2.copy() |
| 3780 |
se_side2.gmm2se(p = 2) |
| 3781 |
|
| 3782 |
return (se_side1, se_side2) |
| 3783 |
|
| 3784 |
def plot_check_residuals(self, ax: Axes = None) -> (Figure, Axes): |
| 3785 |
res = self.deembed(self.s2xthru) |
| 3786 |
res.name = 'Residuals' |
| 3787 |
res.se2gmm(p=2) |
| 3788 |
|
| 3789 |
if ax is None: |
| 3790 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 3791 |
else: |
| 3792 |
fig = ax.get_figure() |
| 3793 |
|
| 3794 |
fig.suptitle('Consistency test #1: Self de-embedding of 2X-Thru') |
| 3795 |
|
| 3796 |
ax[0].set_title('Magnitude residuals') |
| 3797 |
res.plot_s_db(1,0, ax = ax[0]) |
| 3798 |
res.plot_s_db(0,1, ax = ax[0]) |
| 3799 |
res.plot_s_db(3,2, ax = ax[0]) |
| 3800 |
res.plot_s_db(2,3, ax = ax[0]) |
| 3801 |
ax[0].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3802 |
[0.1, 0.1], |
| 3803 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 3804 |
ax[0].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3805 |
[-0.1, -0.1], |
| 3806 |
linestyle = 'dashed', color = 'r') |
| 3807 |
ax[0].legend(loc = 'upper right') |
| 3808 |
|
| 3809 |
ax[1].set_title('Phase residuals') |
| 3810 |
res.plot_s_deg(1,0, ax = ax[1]) |
| 3811 |
res.plot_s_deg(0,1, ax = ax[1]) |
| 3812 |
res.plot_s_deg(3,2, ax = ax[1]) |
| 3813 |
res.plot_s_deg(2,3, ax = ax[1]) |
| 3814 |
ax[1].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3815 |
[1, 1], |
| 3816 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 3817 |
ax[1].plot([res.frequency.f_scaled[0], res.frequency.f_scaled[-1]], |
| 3818 |
[-1, -1], |
| 3819 |
linestyle = 'dashed', color = 'r') |
| 3820 |
ax[1].legend(loc = 'upper right') |
| 3821 |
fig.tight_layout() |
| 3822 |
|
| 3823 |
return (fig, ax) |
| 3824 |
|
| 3825 |
def plot_check_impedance(self, fix_dut_fix: Network = None, ax: Axes = None, |
| 3826 |
window: str = 'hamming') -> (Figure, Axes): |
| 3827 |
|
| 3828 |
s2xthru = self.s2xthru.copy() |
| 3829 |
s2xthru.se2gmm(p=2) |
| 3830 |
s2xthru = IEEEP370.extrapolate_to_dc(s2xthru) |
| 3831 |
fix1 = self.se_side1.copy() |
| 3832 |
fix1.se2gmm(p=2) |
| 3833 |
fix1 = IEEEP370.extrapolate_to_dc(fix1) |
| 3834 |
fix2 = self.se_side2.copy() |
| 3835 |
fix2.se2gmm(p=2) |
| 3836 |
fix2 = IEEEP370.extrapolate_to_dc(fix2) |
| 3837 |
if fix_dut_fix is not None: |
| 3838 |
fix_dut_fix = fix_dut_fix.copy() |
| 3839 |
fix_dut_fix.se2gmm(p=2) |
| 3840 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(fix_dut_fix) |
| 3841 |
n = s2xthru.frequency.npoints * 2 - 1 |
| 3842 |
dt = 1e9 / (n * s2xthru.frequency.step) |
| 3843 |
|
| 3844 |
if ax is None: |
| 3845 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 3846 |
else: |
| 3847 |
fig = ax.get_figure() |
| 3848 |
|
| 3849 |
fig.suptitle('Consistency test #2: Compare the TDR of the fixture model to the FIX-DUT-FIX') |
| 3850 |
ax[0].set_title('Side 1') |
| 3851 |
fix1.plot_z_time_step(0, 0, window = window, |
| 3852 |
ax = ax[0], color = 'k') |
| 3853 |
s2xthru.plot_z_time_step(0, 0, window = window, |
| 3854 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 3855 |
y = ax[0].lines[-1].get_ydata() |
| 3856 |
if fix_dut_fix is not None: |
| 3857 |
fix_dut_fix.plot_z_time_step(0, 0, window = window, |
| 3858 |
ax = ax[0], linestyle = 'dashed', color = 'm') |
| 3859 |
ax[0].plot([0], [y[n // 2]], marker = 's', color = 'k', label = 'start') |
| 3860 |
ax[0].plot([(self.x_end_dd - (n // 2) - 1) * dt], [self.z_x_dd], marker = 'o', |
| 3861 |
color = 'k', label = f'z_x = {self.z_x_dd:0.1f} ohm') |
| 3862 |
fix1.plot_z_time_step(2, 2, window = window, |
| 3863 |
ax = ax[0], color = 'k') |
| 3864 |
s2xthru.plot_z_time_step(2, 2, window = window, |
| 3865 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 3866 |
if fix_dut_fix is not None: |
| 3867 |
fix_dut_fix.plot_z_time_step(2, 2, window = window, |
| 3868 |
ax = ax[0], linestyle = 'dashed', color = 'b') |
| 3869 |
ax[0].legend(loc = 'center left') |
| 3870 |
|
| 3871 |
ax[1].set_title('Side 2') |
| 3872 |
fix2.plot_z_time_step(0, 0, window = window, |
| 3873 |
ax = ax[1], color = 'k') |
| 3874 |
s2xthru.plot_z_time_step(1, 1, window = window, |
| 3875 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 3876 |
y = ax[1].lines[-1].get_ydata() |
| 3877 |
if fix_dut_fix is not None: |
| 3878 |
fix_dut_fix.plot_z_time_step(1, 1, window = window, |
| 3879 |
ax = ax[1], linestyle = 'dashed', color = 'm') |
| 3880 |
ax[1].plot([0], [y[n // 2]], marker = 's', color = 'k', label = 'start') |
| 3881 |
ax[1].plot([(self.x_end_dd - (n // 2) - 1) * dt], [self.z_x_dd], marker = 'o', |
| 3882 |
color = 'k', label = f'z_x = {self.z_x_dd:0.1f} ohm') |
| 3883 |
fix2.plot_z_time_step(2, 2, window = window, |
| 3884 |
ax = ax[1], color = 'k') |
| 3885 |
s2xthru.plot_z_time_step(3, 3, window = window, |
| 3886 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 3887 |
if fix_dut_fix is not None: |
| 3888 |
fix_dut_fix.plot_z_time_step(3, 3, window = window, |
| 3889 |
ax = ax[1], linestyle = 'dashed', color = 'b') |
| 3890 |
delay = 2 * (self.x_end_dd - (n // 2)) * dt |
| 3891 |
ax[1].set_xlim((-0.5 * delay, 1.5 * delay)) |
| 3892 |
ax[1].legend(loc = 'center left') |
| 3893 |
|
| 3894 |
fig.tight_layout() |
| 3895 |
|
| 3896 |
return (fig, ax) |
| 3897 |
|
| 3898 |
|
| 3899 |
class IEEEP370_SE_ZC_2xThru(IEEEP370): |
| 3900 |
""" |
| 3901 |
Creates error boxes from 2x-Thru and FIX-DUT-FIX networks. |
| 3902 |
|
| 3903 |
Based on [I3E370]_. |
| 3904 |
|
| 3905 |
A deembedding object is created with 2x-Thru (FIX-FIX) and FIX-DUT-FIX |
| 3906 |
measurements, which are split into left (FIX-1) and right (FIX-2) fixtures |
| 3907 |
with IEEEP370 Zc2xThru method. |
| 3908 |
|
| 3909 |
When :func:`Deembedding.deembed` is applied, the s-parameters of FIX-1 and |
| 3910 |
FIX-2 are deembedded from FIX_DUT_FIX network. |
| 3911 |
|
| 3912 |
This method is applicable only when there is 2xThru and FIX_DUT_FIX |
| 3913 |
networks. |
| 3914 |
|
| 3915 |
The possible difference of impedance between 2x-Thru and FIX-DUT-FIX |
| 3916 |
is corrected. |
| 3917 |
|
| 3918 |
The algorithm computes the length of the fixtures by halving the delay of |
| 3919 |
2x-Thru in time domain transmission. The propagation constant gamma is also |
| 3920 |
determined from the 2xThru. It then peels the FIX-DUT-FIX time domain |
| 3921 |
impedance profile iteratively in cycles of determining start impedance and |
| 3922 |
deembedding a single time sample long transmission line. |
| 3923 |
|
| 3924 |
Example |
| 3925 |
-------- |
| 3926 |
>>> import skrf as rf |
| 3927 |
>>> from skrf.calibration import IEEEP370_SE_ZC_2xThru |
| 3928 |
|
| 3929 |
Create network objects for 2xThru and FIX-DUT-FIX |
| 3930 |
|
| 3931 |
>>> s2xthru = rf.Network('2xthru.s2p') |
| 3932 |
>>> fdf = rf.Network('f-dut-f.s2p') |
| 3933 |
|
| 3934 |
Create de-embedding object |
| 3935 |
|
| 3936 |
>>> dm = IEEEP370_SE_ZC_2xThru(dummy_2xthru = s2xthru, dummy_fix_dut_fix = fdf, |
| 3937 |
bandwidth_limit = 10e9, |
| 3938 |
pullback1 = 0, pullback2 = 0, |
| 3939 |
leadin = 0, |
| 3940 |
name = 'zc2xthru') |
| 3941 |
|
| 3942 |
Apply deembedding to get the DUT |
| 3943 |
|
| 3944 |
>>> dut = dm.deembed(fdf) |
| 3945 |
|
| 3946 |
Note |
| 3947 |
---- |
| 3948 |
numbering diagram:: |
| 3949 |
|
| 3950 |
FIX-1 DUT FIX-2 |
| 3951 |
+----+ +----+ +----+ |
| 3952 |
-|1 2|---|1 2|---|2 1|- |
| 3953 |
+----+ +----+ +----+ |
| 3954 |
|
| 3955 |
|
| 3956 |
Warning |
| 3957 |
------- |
| 3958 |
There is one difference compared to the original matlab implementation |
| 3959 |
[I3E370]_: |
| 3960 |
- FIX-2 is flipped (see diagram above) |
| 3961 |
|
| 3962 |
References |
| 3963 |
---------- |
| 3964 |
.. [I3E370] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370Zc2xThru.m |
| 3965 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 3966 |
""" |
| 3967 |
def __init__(self, dummy_2xthru: Network, dummy_fix_dut_fix: Network, |
| 3968 |
name: str = None, |
| 3969 |
z0: float = 50, bandwidth_limit: float = 0, |
| 3970 |
pullback1: int = 0, pullback2: int = 0, |
| 3971 |
side1: bool = True, side2: bool = True, |
| 3972 |
NRP_enable: bool = True, leadin: int = 1, |
| 3973 |
verbose: bool = False, |
| 3974 |
*args, **kwargs) -> None: |
| 3975 |
""" |
| 3976 |
IEEEP370_SE_ZC_2xThru De-embedding Initializer |
| 3977 |
|
| 3978 |
Parameters |
| 3979 |
----------- |
| 3980 |
|
| 3981 |
dummy_2xthru : :class:`~skrf.network.Network` object |
| 3982 |
2xThru (FIX-FIX) network. |
| 3983 |
|
| 3984 |
name : string |
| 3985 |
optional name of de-embedding object |
| 3986 |
|
| 3987 |
z0 : |
| 3988 |
reference impedance of the S-parameters (default: 50) |
| 3989 |
|
| 3990 |
bandwidth_limit : |
| 3991 |
max frequency for a fitting function |
| 3992 |
(default: 0, use all s-parameters without fit) |
| 3993 |
|
| 3994 |
pullback1, pullback2 : |
| 3995 |
a number of discrete points to leave in the fixture on side 1 |
| 3996 |
respectively on side 2 (default: 0 leave all) |
| 3997 |
|
| 3998 |
side1, side2 : |
| 3999 |
set to de-embed the side1 resp. side2 errorbox (default: True) |
| 4000 |
|
| 4001 |
NRP_enable : |
| 4002 |
set to enforce the Nyquist Rate Point during de-embedding and to |
| 4003 |
add the appropriote delay to the errorboxes (default: True) |
| 4004 |
|
| 4005 |
leadin : |
| 4006 |
a number of discrete points before t = 0 that are non-zero from |
| 4007 |
calibration error (default: 1) |
| 4008 |
|
| 4009 |
verbose : |
| 4010 |
view the process (default: False) |
| 4011 |
|
| 4012 |
args, kwargs: |
| 4013 |
passed to :func:`Deembedding.__init__` |
| 4014 |
|
| 4015 |
See Also |
| 4016 |
--------- |
| 4017 |
:func:`Deembedding.__init__` |
| 4018 |
|
| 4019 |
""" |
| 4020 |
self.s2xthru = dummy_2xthru.copy() |
| 4021 |
self.sfix_dut_fix = dummy_fix_dut_fix.copy() |
| 4022 |
dummies = [self.s2xthru] |
| 4023 |
self.z0 = z0 |
| 4024 |
self.bandwidth_limit = bandwidth_limit |
| 4025 |
self.pullback1 = pullback1 |
| 4026 |
self.pullback2 = pullback2 |
| 4027 |
self.side1 = side1 |
| 4028 |
self.side2 = side2 |
| 4029 |
self.NRP_enable = NRP_enable |
| 4030 |
self.leadin = leadin |
| 4031 |
self.verbose = verbose |
| 4032 |
self.flag_DC = False |
| 4033 |
self.flag_df = False |
| 4034 |
|
| 4035 |
self.gamma = None |
| 4036 |
self.x_end = None |
| 4037 |
self.z_side1 = None |
| 4038 |
self.z_side2 = None |
| 4039 |
|
| 4040 |
IEEEP370.__init__(self, dummies, name, *args, **kwargs) |
| 4041 |
self.s_side1, self.s_side2 = self.split2xthru(self.s2xthru.copy(), |
| 4042 |
self.sfix_dut_fix) |
| 4043 |
|
| 4044 |
def deembed(self, ntwk: Network) -> Network: |
| 4045 |
""" |
| 4046 |
Perform the de-embedding calculation |
| 4047 |
|
| 4048 |
Parameters |
| 4049 |
---------- |
| 4050 |
ntwk : :class:`~skrf.network.Network` object |
| 4051 |
FIX-DUT-FIX network from which FIX-1 and FIX-2 fixtures needs to |
| 4052 |
be removed via de-embedding |
| 4053 |
|
| 4054 |
Returns |
| 4055 |
------- |
| 4056 |
caled : :class:`~skrf.network.Network` object |
| 4057 |
Network data of the device after de-embedding |
| 4058 |
|
| 4059 |
""" |
| 4060 |
|
| 4061 |
|
| 4062 |
if ntwk.frequency != self.s2xthru.frequency: |
| 4063 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 4064 |
RuntimeWarning, stacklevel=2) |
| 4065 |
ntwk, s2xthru = overlap_multi([ntwk, self.s2xthru]) |
| 4066 |
s_side1, s_side2 = self.split2xthru(s2xthru, |
| 4067 |
self.sfix_dut_fix) |
| 4068 |
else: |
| 4069 |
s_side1 = self.s_side1 |
| 4070 |
s_side2 = self.s_side2 |
| 4071 |
|
| 4072 |
return s_side1.inv ** ntwk ** s_side2.flipped().inv |
| 4073 |
|
| 4074 |
|
| 4075 |
def makeErrorBox_v7(self, s_dut: Network, s2x: Network, gamma: ndarray, |
| 4076 |
z0: float, pullback:int) -> (Network, Network): |
| 4077 |
""" |
| 4078 |
Extract the fixtures on both sides. |
| 4079 |
""" |
| 4080 |
f = s2x.frequency.f |
| 4081 |
n = len(f) |
| 4082 |
s212x = s2x.s[:, 1, 0] |
| 4083 |
DC21 = IEEEP370.dc_interp(s212x, f) |
| 4084 |
x = np.argmax(irfft(concatenate(([DC21], s212x)))) |
| 4085 |
self.x_end = x - pullback |
| 4086 |
|
| 4087 |
|
| 4088 |
l = 1. / (2 * (x + 1)) |
| 4089 |
|
| 4090 |
s11dut = s_dut.s[:, 0, 0] |
| 4091 |
s22dut = s_dut.s[:, 1, 1] |
| 4092 |
if self.verbose: |
| 4093 |
z1 = IEEEP370.getz(s11dut, f, z0) |
| 4094 |
z2 = IEEEP370.getz(s22dut, f, z0) |
| 4095 |
|
| 4096 |
|
| 4097 |
for i in range(self.x_end + 1): |
| 4098 |
zline1 = IEEEP370.getz(s11dut, f, z0)[0] |
| 4099 |
zline2 = IEEEP370.getz(s22dut, f, z0)[0] |
| 4100 |
TL1 = self.makeTL(zline1,z0,gamma,l) |
| 4101 |
TL2 = self.makeTL(zline2,z0,gamma,l) |
| 4102 |
sTL1 = s_dut.copy() |
| 4103 |
sTL1.s = TL1 |
| 4104 |
sTL2 = s_dut.copy() |
| 4105 |
sTL2.s = TL2 |
| 4106 |
if i == 0: |
| 4107 |
errorbox1 = sTL1 |
| 4108 |
errorbox2 = sTL2 |
| 4109 |
else: |
| 4110 |
errorbox1 = errorbox1 ** sTL1 |
| 4111 |
errorbox2 = errorbox2 ** sTL2 |
| 4112 |
|
| 4113 |
|
| 4114 |
s_dut = sTL1.inv ** s_dut ** sTL2.inv |
| 4115 |
|
| 4116 |
|
| 4117 |
|
| 4118 |
|
| 4119 |
|
| 4120 |
|
| 4121 |
|
| 4122 |
|
| 4123 |
|
| 4124 |
s11dut = s_dut.s[:, 0, 0] |
| 4125 |
s22dut = s_dut.s[:, 1, 1] |
| 4126 |
|
| 4127 |
if(i == self.x_end): |
| 4128 |
self.z_side1 = IEEEP370.getz(errorbox1.s[:, 0, 0], f, z0) |
| 4129 |
self.z_side2 = IEEEP370.getz(errorbox2.s[:, 0, 0], f, z0) |
| 4130 |
if self.verbose: |
| 4131 |
zdut1 = IEEEP370.getz(s11dut, f, z0) |
| 4132 |
zdut2 = IEEEP370.getz(s22dut, f, z0) |
| 4133 |
fig, axs = subplots(1, 2, sharex = True, figsize=(2*6.4, 4.8)) |
| 4134 |
axs[0].plot(ifftshift(zdut1), label = 'DUT') |
| 4135 |
axs[0].plot(ifftshift(self.z_side1), label = 'FIX-1') |
| 4136 |
axs[0].plot(ifftshift(z1), color = 'k', linestyle = 'dashed', label = 'FIX-DUT-FIX') |
| 4137 |
axs[0].set_xlim((n-50, n+x*2+50)) |
| 4138 |
axs[0].legend() |
| 4139 |
axs[0].set_title('Left') |
| 4140 |
axs[0].set_ylabel('Z (ohm)') |
| 4141 |
axs[1].plot(ifftshift(zdut2), label = 'DUT') |
| 4142 |
axs[1].plot(ifftshift(self.z_side2), label = 'FIX-2') |
| 4143 |
axs[1].plot(ifftshift(z2), color = 'k', linestyle = 'dashed', label = 'FIX-DUT-FIX') |
| 4144 |
axs[1].set_xlim((n-50, n+x*2+50)) |
| 4145 |
axs[1].legend() |
| 4146 |
axs[1].set_title('Right') |
| 4147 |
axs[1].set_ylabel('Z (ohm)') |
| 4148 |
return errorbox1, errorbox2.flipped() |
| 4149 |
|
| 4150 |
def makeErrorBox_v8(self, s_dut: Network, s2x: Network, gamma: ndarray, |
| 4151 |
z0: float, pullback: int) -> Network: |
| 4152 |
""" |
| 4153 |
Extract the fixture only on a single side. |
| 4154 |
""" |
| 4155 |
f = s2x.frequency.f |
| 4156 |
n = len(f) |
| 4157 |
s212x = s2x.s[:, 1, 0] |
| 4158 |
|
| 4159 |
DC21 = IEEEP370.dc_interp(s212x, f) |
| 4160 |
x = np.argmax(irfft(concatenate(([DC21], s212x)))) |
| 4161 |
self.x_end = x - pullback |
| 4162 |
|
| 4163 |
|
| 4164 |
l = 1. / (2 * (x + 1)) |
| 4165 |
|
| 4166 |
s11dut = s_dut.s[:, 0, 0] |
| 4167 |
if self.verbose: |
| 4168 |
z1 = IEEEP370.getz(s11dut, f, z0) |
| 4169 |
|
| 4170 |
|
| 4171 |
for i in range(self.x_end + 1): |
| 4172 |
zline1 = IEEEP370.getz(s11dut, f, z0)[0] |
| 4173 |
TL1 = self.makeTL(zline1,z0,gamma,l) |
| 4174 |
sTL1 = s_dut.copy() |
| 4175 |
sTL1.s = TL1 |
| 4176 |
if i == 0: |
| 4177 |
errorbox1 = sTL1 |
| 4178 |
else: |
| 4179 |
errorbox1 = errorbox1 ** sTL1 |
| 4180 |
|
| 4181 |
s_dut = sTL1.inv ** s_dut |
| 4182 |
s11dut = s_dut.s[:, 0, 0] |
| 4183 |
|
| 4184 |
if(i == self.x_end): |
| 4185 |
self.z_side1 = IEEEP370.getz(errorbox1.s[:, 0, 0], f, z0) |
| 4186 |
if self.verbose: |
| 4187 |
zdut1 = IEEEP370.getz(s11dut, f, z0) |
| 4188 |
fig, axs = subplots(1, 1, sharex = True, figsize=(6.4, 4.8)) |
| 4189 |
axs.plot(ifftshift(zdut1), label = 'DUT') |
| 4190 |
axs.plot(ifftshift(self.z_side1), label = 'FIX') |
| 4191 |
axs.plot(ifftshift(z1), color = 'k', linestyle = 'dashed', label = 'FIX-DUT-FIX') |
| 4192 |
axs.set_xlim((n-50, n+x*2+50)) |
| 4193 |
axs.legend() |
| 4194 |
axs.set_ylabel('Z (ohm)') |
| 4195 |
return errorbox1 |
| 4196 |
|
| 4197 |
|
| 4198 |
def split2xthru(self, s2xthru: Network, sfix_dut_fix: Network) -> (Network, Network): |
| 4199 |
""" |
| 4200 |
Perform the fixtures extraction. |
| 4201 |
""" |
| 4202 |
f = sfix_dut_fix.frequency.f |
| 4203 |
s = sfix_dut_fix.s |
| 4204 |
|
| 4205 |
|
| 4206 |
|
| 4207 |
if(f[0] == 0): |
| 4208 |
warnings.warn( |
| 4209 |
"DC point detected. The included DC point will not be used during extraction.", |
| 4210 |
RuntimeWarning, stacklevel=2 |
| 4211 |
) |
| 4212 |
self.flag_DC = True |
| 4213 |
f = f[1:] |
| 4214 |
s = s[1:] |
| 4215 |
sfix_dut_fix = Network(frequency = Frequency.from_f(f, 'Hz'), s = s) |
| 4216 |
s2xthru.interpolate_self(Frequency.from_f(f, 'Hz')) |
| 4217 |
|
| 4218 |
|
| 4219 |
df = f[1] - f[0] |
| 4220 |
tol = 0.1 |
| 4221 |
if(np.abs(f[0] - df) > tol): |
| 4222 |
warnings.warn( |
| 4223 |
"""Non-uniform frequency vector detected. An interpolated S-parameter matrix will be created for |
| 4224 |
this calculation. The output results will be re-interpolated to the original vector.""", |
| 4225 |
RuntimeWarning, stacklevel=2 |
| 4226 |
) |
| 4227 |
self.flag_df = True |
| 4228 |
f_original = f |
| 4229 |
projected_n = np.floor(f[-1]/f[0]) |
| 4230 |
fnew = f[0] * (np.arange(0, projected_n) + 1) |
| 4231 |
f_interp = Frequency.from_f(fnew, unit = 'Hz') |
| 4232 |
sfix_dut_fix.interpolate_self(f_interp, kind = 'cubic', |
| 4233 |
fill_value = 'extrapolate') |
| 4234 |
s2xthru.interpolate_self(f_interp, kind = 'cubic', |
| 4235 |
fill_value = 'extrapolate') |
| 4236 |
f = fnew |
| 4237 |
|
| 4238 |
|
| 4239 |
|
| 4240 |
if(not np.array_equal(sfix_dut_fix.frequency.f, s2xthru.frequency.f)): |
| 4241 |
s2xthru.interpolate(sfix_dut_fix.frequency, kind = 'cubic', |
| 4242 |
fill_value = 'extrapolate') |
| 4243 |
warnings.warn( |
| 4244 |
"""2x-thru does not have the same frequency vector as the fixture-dut-fixture. |
| 4245 |
Interpolating to fix problem.""", |
| 4246 |
RuntimeWarning, stacklevel=2 |
| 4247 |
) |
| 4248 |
|
| 4249 |
|
| 4250 |
if self.NRP_enable: |
| 4251 |
sfix_dut_fix, TD = IEEEP370.NRP(sfix_dut_fix) |
| 4252 |
s2xthru, _ = IEEEP370.NRP(s2xthru, -TD) |
| 4253 |
|
| 4254 |
|
| 4255 |
if self.leadin > 0: |
| 4256 |
_, temp1, temp2 = IEEEP370.peelNPointsLossless( |
| 4257 |
IEEEP370.shiftNPoints(sfix_dut_fix, self.leadin), self.leadin, |
| 4258 |
z0 = self.z0) |
| 4259 |
leadin1 = IEEEP370.shiftOnePort(temp1, -self.leadin, 0) |
| 4260 |
leadin2 = IEEEP370.shiftOnePort(temp2, -self.leadin, 1) |
| 4261 |
if self.verbose: |
| 4262 |
fig, axs = subplots(1, 2, sharex = True, figsize=(2*6.4, 4.8)) |
| 4263 |
n = len(f) |
| 4264 |
zfdf1 = IEEEP370.getz(sfix_dut_fix.s[:, 0, 0], f, self.z0) |
| 4265 |
zlead1 = IEEEP370.getz(leadin1.s[:, 0, 0], f, self.z0) |
| 4266 |
axs[0].plot(ifftshift(zfdf1), label = 'FDF') |
| 4267 |
axs[0].plot(ifftshift(zlead1), label = f'leadin ({self.leadin})') |
| 4268 |
axs[0].set_xlim((n-self.leadin-10, n+10)) |
| 4269 |
axs[0].legend() |
| 4270 |
axs[0].set_title('Left leadin') |
| 4271 |
axs[0].set_ylabel('Z (ohm)') |
| 4272 |
zfdf2 = IEEEP370.getz(sfix_dut_fix.s[:, 1, 1], f, self.z0) |
| 4273 |
zlead2 = IEEEP370.getz(leadin2.s[:, 1, 1], f, self.z0) |
| 4274 |
axs[1].plot(ifftshift(zfdf2), label = 'FDF') |
| 4275 |
axs[1].plot(ifftshift(zlead2), label = f'leadin ({self.leadin})') |
| 4276 |
axs[1].set_xlim((n-self.leadin-10, n+10)) |
| 4277 |
axs[1].legend() |
| 4278 |
axs[1].set_title('Right leadin') |
| 4279 |
axs[1].set_ylabel('Z (ohm)') |
| 4280 |
|
| 4281 |
|
| 4282 |
|
| 4283 |
s212x = s2xthru.s[:, 1, 0] |
| 4284 |
|
| 4285 |
beta_per_length = -unwrap(angle(s212x)) |
| 4286 |
|
| 4287 |
attenuation = np.abs(s2xthru.s[:,1,0])**2 / (1. - np.abs(s2xthru.s[:,0,0])**2) |
| 4288 |
alpha_per_length = (10.0 * np.log10(attenuation)) / -8.686 |
| 4289 |
if self.bandwidth_limit == 0: |
| 4290 |
|
| 4291 |
self.gamma = alpha_per_length + 1j * beta_per_length |
| 4292 |
else: |
| 4293 |
|
| 4294 |
bwl_x = np.argmin(np.abs(f - self.bandwidth_limit)) |
| 4295 |
X = np.array([np.sqrt(f[0:bwl_x+1]), f[0:bwl_x+1], f[0:bwl_x+1]**2]) |
| 4296 |
b = np.linalg.lstsq(X.conj().T, alpha_per_length[0:bwl_x+1], rcond=None)[0] |
| 4297 |
alpha_per_length_fit = b[0] * np.sqrt(f) + b[1] * f + b[2] * f**2 |
| 4298 |
|
| 4299 |
self.gamma = alpha_per_length_fit + 1j * beta_per_length |
| 4300 |
if self.verbose: |
| 4301 |
fig, axs = subplots(1, 2, figsize=(2*6.4, 4.8)) |
| 4302 |
fig.suptitle('Gamma determination') |
| 4303 |
axs[0].plot(s2xthru.frequency.f_scaled, alpha_per_length, label = 'alpha per length') |
| 4304 |
if self.bandwidth_limit != 0: |
| 4305 |
f_bw_hz = self.bandwidth_limit |
| 4306 |
f_bw = f_bw_hz / s2xthru.frequency.multiplier |
| 4307 |
unit = s2xthru.frequency.unit |
| 4308 |
alpha_bw = b[0] * np.sqrt(f_bw_hz) + b[1] * f_bw_hz + b[2] * f_bw_hz**2 |
| 4309 |
axs[0].plot(s2xthru.frequency.f_scaled, alpha_per_length_fit, |
| 4310 |
label = 'alpha per length fit') |
| 4311 |
axs[0].plot([f_bw], [alpha_bw], color = 'k', marker = 'o', linestyle = None, |
| 4312 |
label = f'bandwidth_limit = {f_bw} {unit}') |
| 4313 |
axs[0].legend() |
| 4314 |
axs[0].set_xlabel(f'Frequency ({s2xthru.frequency.unit})') |
| 4315 |
axs[0].set_ylabel('Alpha (Neper/length)') |
| 4316 |
axs[1].plot(s2xthru.frequency.f_scaled, beta_per_length, label = 'beta per length') |
| 4317 |
axs[1].set_xlabel(f'Frequency ({s2xthru.frequency.unit})') |
| 4318 |
axs[1].set_ylabel('Beta (rad/length)') |
| 4319 |
axs[1].legend() |
| 4320 |
|
| 4321 |
|
| 4322 |
|
| 4323 |
s_side1 = IEEEP370.thru(sfix_dut_fix) |
| 4324 |
s_side2 = IEEEP370.thru(sfix_dut_fix) |
| 4325 |
|
| 4326 |
|
| 4327 |
|
| 4328 |
|
| 4329 |
if self.pullback1 == self.pullback2 and self.side1 and self.side2: |
| 4330 |
(s_side1, s_side2) = self.makeErrorBox_v7(sfix_dut_fix, s2xthru, |
| 4331 |
self.gamma, self.z0, self.pullback1) |
| 4332 |
elif self.side1 and self.side2: |
| 4333 |
s_side1 = self.makeErrorBox_v8(sfix_dut_fix, s2xthru, |
| 4334 |
self.gamma, self.z0, self.pullback1) |
| 4335 |
s_side2 = self.makeErrorBox_v8(sfix_dut_fix.flipped(),s2xthru, |
| 4336 |
self.gamma, self.z0, self.pullback2) |
| 4337 |
s_side2 = s_side2.flipped() |
| 4338 |
elif self.side1: |
| 4339 |
s_side1 = self.makeErrorBox_v8(sfix_dut_fix, s2xthru, |
| 4340 |
self.gamma, self.z0, self.pullback1) |
| 4341 |
elif self.side2: |
| 4342 |
s_side2 = self.makeErrorBox_v8(sfix_dut_fix.flipped(),s2xthru, |
| 4343 |
self.gamma, self.z0, self.pullback2) |
| 4344 |
s_side2 = s_side2.flipped() |
| 4345 |
else: |
| 4346 |
warnings.warn( |
| 4347 |
"no output because no output was requested", |
| 4348 |
RuntimeWarning, stacklevel=2 |
| 4349 |
) |
| 4350 |
|
| 4351 |
|
| 4352 |
|
| 4353 |
|
| 4354 |
if self.flag_df: |
| 4355 |
f_interp = Frequency.from_f(f_original, unit = 'Hz') |
| 4356 |
s_side1.interpolate_self(f_interp, kind = 'cubic', |
| 4357 |
fill_value = 'extrapolate') |
| 4358 |
s_side2.interpolate_self(f_interp, kind = 'cubic', |
| 4359 |
fill_value = 'extrapolate') |
| 4360 |
|
| 4361 |
|
| 4362 |
if self.flag_DC: |
| 4363 |
s_side1 = IEEEP370.add_dc(s_side1) |
| 4364 |
s_side2 = IEEEP370.add_dc(s_side2) |
| 4365 |
|
| 4366 |
|
| 4367 |
if self.leadin > 0: |
| 4368 |
s_side1 = leadin1 ** s_side1 |
| 4369 |
s_side2 = s_side2 ** leadin2 |
| 4370 |
|
| 4371 |
|
| 4372 |
if self.NRP_enable: |
| 4373 |
s_side1, _ = IEEEP370.NRP(s_side1, TD, 0) |
| 4374 |
s_side2, _ = IEEEP370.NRP(s_side2, TD, 1) |
| 4375 |
|
| 4376 |
|
| 4377 |
return (s_side1, s_side2.flipped()) |
| 4378 |
|
| 4379 |
def plot_check_residuals(self, ax: Axes = None) -> (Figure, Axes): |
| 4380 |
res = self.deembed(self.s2xthru) |
| 4381 |
res.name = 'Residuals' |
| 4382 |
|
| 4383 |
if ax is None: |
| 4384 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 4385 |
else: |
| 4386 |
fig = ax.get_figure() |
| 4387 |
|
| 4388 |
fig.suptitle('Consistency test #1: Self de-embedding of 2X-Thru') |
| 4389 |
|
| 4390 |
ax[0].set_title('Magnitude residuals') |
| 4391 |
res.plot_s_db(1,0, ax = ax[0], color = '0.5') |
| 4392 |
res.plot_s_db(0,1, ax = ax[0], color = 'k') |
| 4393 |
ax[0].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4394 |
[0.1, 0.1], |
| 4395 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 4396 |
ax[0].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4397 |
[-0.1, -0.1], |
| 4398 |
linestyle = 'dashed', color = 'r') |
| 4399 |
ax[0].legend(loc = 'upper right') |
| 4400 |
|
| 4401 |
ax[1].set_title('Phase residuals') |
| 4402 |
res.plot_s_deg(1,0, ax = ax[1], color = '0.5') |
| 4403 |
res.plot_s_deg(0,1, ax = ax[1], color = 'k') |
| 4404 |
ax[1].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4405 |
[1, 1], |
| 4406 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 4407 |
ax[1].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4408 |
[-1, -1], |
| 4409 |
linestyle = 'dashed', color = 'r') |
| 4410 |
ax[1].legend(loc = 'upper right') |
| 4411 |
fig.tight_layout() |
| 4412 |
|
| 4413 |
return (fig, ax) |
| 4414 |
|
| 4415 |
def plot_check_impedance(self, fix_dut_fix: Network = None, ax: Axes = None, |
| 4416 |
window: str = 'hamming') -> (Figure, Axes): |
| 4417 |
|
| 4418 |
s2xthru = IEEEP370.extrapolate_to_dc(self.s2xthru) |
| 4419 |
fix1 = IEEEP370.extrapolate_to_dc(self.s_side1) |
| 4420 |
fix2 = IEEEP370.extrapolate_to_dc(self.s_side2) |
| 4421 |
if fix_dut_fix is not None: |
| 4422 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(fix_dut_fix) |
| 4423 |
else: |
| 4424 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(self.sfix_dut_fix) |
| 4425 |
n = s2xthru.frequency.npoints * 2 - 1 |
| 4426 |
dt = 1e9 / (n * s2xthru.frequency.step) |
| 4427 |
|
| 4428 |
if ax is None: |
| 4429 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 4430 |
else: |
| 4431 |
fig = ax.get_figure() |
| 4432 |
|
| 4433 |
fig.suptitle('Consistency test #2: Compare the TDR of the fixture model to the FIX-DUT-FIX') |
| 4434 |
ax[0].set_title('Side 1') |
| 4435 |
fix1.plot_z_time_step(0, 0, window = window, |
| 4436 |
ax = ax[0], color = 'k') |
| 4437 |
y = ax[0].lines[-1].get_ydata() |
| 4438 |
s2xthru.plot_z_time_step(0, 0, window = window, |
| 4439 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 4440 |
fix_dut_fix.plot_z_time_step(0, 0, window = window, |
| 4441 |
ax = ax[0], linestyle = 'dashed', color = 'm') |
| 4442 |
ax[0].plot([-self.leadin * dt], [y[n // 2 - self.leadin]], marker = 's', color = 'k', |
| 4443 |
label = f'start (leadin = {self.leadin})') |
| 4444 |
ax[0].plot([self.x_end * dt], [y[self.x_end + n // 2]], marker = 'o', color = 'k', |
| 4445 |
label = f'end (pullback1 = {self.pullback1})') |
| 4446 |
|
| 4447 |
ymax = np.max(np.array([ax[0].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 4448 |
ax[0].lines[2].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 4449 |
ymin = np.min(np.array([ax[0].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 4450 |
ax[0].lines[2].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 4451 |
ax[0].set_ylim((ymin - 5, ymax + 5)) |
| 4452 |
ax[0].legend(loc = 'lower left') |
| 4453 |
|
| 4454 |
ax[1].set_title('Side 2') |
| 4455 |
fix2.plot_z_time_step(0, 0, window = window, |
| 4456 |
ax = ax[1], color = 'k') |
| 4457 |
y = ax[1].lines[-1].get_ydata() |
| 4458 |
s2xthru.plot_z_time_step(1, 1, window = window, |
| 4459 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 4460 |
fix_dut_fix.plot_z_time_step(1, 1, window = window, |
| 4461 |
ax = ax[1], linestyle = 'dashed', color = 'm') |
| 4462 |
ax[1].plot([-self.leadin * dt], [y[n // 2 - self.leadin]], marker = 's', color = 'k', |
| 4463 |
label = f'start (leadin = {self.leadin})') |
| 4464 |
ax[1].plot([self.x_end * dt], [y[self.x_end + n // 2]], marker = 'o', color = 'k', |
| 4465 |
label = f'end (pullback2 = {self.pullback2})') |
| 4466 |
|
| 4467 |
ymax = np.max(np.array([ax[1].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 4468 |
ax[1].lines[2].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 4469 |
ymin = np.min(np.array([ax[1].lines[0].get_ydata()[(n // 2):(self.x_end + n // 2)], |
| 4470 |
ax[1].lines[2].get_ydata()[(n // 2):(self.x_end + n // 2)]])) |
| 4471 |
ax[1].set_ylim((ymin - 5, ymax + 5)) |
| 4472 |
delay = 2 * self.x_end * dt |
| 4473 |
ax[1].set_xlim((-0.5 * delay, 1.5 * delay)) |
| 4474 |
ax[1].legend(loc = 'lower left') |
| 4475 |
|
| 4476 |
fig.tight_layout() |
| 4477 |
|
| 4478 |
return (fig, ax) |
| 4479 |
|
| 4480 |
|
| 4481 |
class IEEEP370_MM_ZC_2xThru(IEEEP370): |
| 4482 |
""" |
| 4483 |
Creates error boxes from a 4-port from 2x-Thru and FIX-DUT-FIX networks. |
| 4484 |
|
| 4485 |
Based on [I3E370]_. |
| 4486 |
|
| 4487 |
A deembedding object is created with 2x-Thru (FIX-FIX) and FIX-DUT-FIX |
| 4488 |
measurements, which are split into left (FIX-1_2) and right (FIX-3_4) |
| 4489 |
fixtures with IEEEP370 Zc2xThru method. |
| 4490 |
|
| 4491 |
When :func:`Deembedding.deembed` is applied, the s-parameters of FIX-1_2 |
| 4492 |
and FIX-3_4 are deembedded from FIX_DUT_FIX network. |
| 4493 |
|
| 4494 |
This method is applicable only when there is 2xThru and FIX_DUT_FIX |
| 4495 |
networks. |
| 4496 |
|
| 4497 |
The possible difference of impedance between 2x-Thru and FIX-DUT-FIX |
| 4498 |
is corrected. |
| 4499 |
|
| 4500 |
The algorithm computes the length of the fixtures by halving the delay of |
| 4501 |
2x-Thru in time domain transmission. The propagation constant gamma is also |
| 4502 |
determined from the 2xThru. It then peels the FIX-DUT-FIX time domain |
| 4503 |
impedance profile iteratively in cycles of determining start impedance and |
| 4504 |
deembedding a single time sample long transmission line. |
| 4505 |
|
| 4506 |
Note |
| 4507 |
---- |
| 4508 |
The `port_order` ='first', means front-to-back also known as odd/even, |
| 4509 |
while `port_order`='second' means left-to-right also known as sequential. |
| 4510 |
`port_order`='third' means yet another numbering method. |
| 4511 |
Next figure show example of port numbering with 4-port networks. |
| 4512 |
|
| 4513 |
The `scikit-rf` cascade ** 2N-port operator use second scheme. This is very |
| 4514 |
convenient to write compact deembedding and other expressions. |
| 4515 |
|
| 4516 |
numbering diagram:: |
| 4517 |
|
| 4518 |
port_order = 'first' |
| 4519 |
+---------+ |
| 4520 |
-|0 1|- |
| 4521 |
-|2 3|- |
| 4522 |
+---------+ |
| 4523 |
|
| 4524 |
port_order = 'second' |
| 4525 |
+---------+ |
| 4526 |
-|0 2|- |
| 4527 |
-|1 3|- |
| 4528 |
+---------+ |
| 4529 |
|
| 4530 |
port_order = 'third' |
| 4531 |
+---------+ |
| 4532 |
-|0 3|- |
| 4533 |
-|1 2|- |
| 4534 |
+---------+ |
| 4535 |
|
| 4536 |
use `Network.renumber` to change port ordering. |
| 4537 |
|
| 4538 |
Example |
| 4539 |
-------- |
| 4540 |
>>> import skrf as rf |
| 4541 |
>>> from skrf.calibration import IEEEP370_MM_ZC_2xThru |
| 4542 |
|
| 4543 |
Create network objects for 2xThru and FIX-DUT-FIX |
| 4544 |
|
| 4545 |
>>> s2xthru = rf.Network('2xthru.s4p') |
| 4546 |
>>> fdf = rf.Network('f-dut-f.s4p') |
| 4547 |
|
| 4548 |
Create de-embedding object |
| 4549 |
|
| 4550 |
>>> dm = IEEEP370_MM_ZC_2xThru(dummy_2xthru = s2xthru, |
| 4551 |
dummy_fix_dut_fix = fdf, |
| 4552 |
bandwidth_limit = 10e9, |
| 4553 |
pullback1 = 0, pullback2 = 0, |
| 4554 |
leadin = 0, |
| 4555 |
name = 'zc2xthru') |
| 4556 |
|
| 4557 |
Apply deembedding to get the DUT |
| 4558 |
|
| 4559 |
>>> dut = dm.deembed(fdf) |
| 4560 |
|
| 4561 |
Note |
| 4562 |
---- |
| 4563 |
numbering diagram:: |
| 4564 |
|
| 4565 |
FIX-1_2 DUT FIX-3_4 |
| 4566 |
+----+ +----+ +----+ |
| 4567 |
-|1 3|---|1 3|---|3 1|- |
| 4568 |
-|2 4|---|2 4|---|4 2|- |
| 4569 |
+----+ +----+ +----+ |
| 4570 |
|
| 4571 |
|
| 4572 |
Warning |
| 4573 |
------- |
| 4574 |
There is one difference compared to the original matlab implementation |
| 4575 |
[I3E370]: |
| 4576 |
- FIX-2 is flipped (see diagram above) |
| 4577 |
|
| 4578 |
References |
| 4579 |
---------- |
| 4580 |
.. [I3E370] https://opensource.ieee.org/elec-char/ieee-370/-/blob/master/TG1/IEEEP370mmZc2xthru.m |
| 4581 |
commit 49ddd78cf68ad5a7c0aaa57a73415075b5178aa6 |
| 4582 |
|
| 4583 |
""" |
| 4584 |
def __init__(self, dummy_2xthru: Network, dummy_fix_dut_fix: Network, |
| 4585 |
name: str = None, |
| 4586 |
z0: float = 50, port_order: PortOrderT = 'second', |
| 4587 |
bandwidth_limit: float = 0, |
| 4588 |
pullback1: int = 0, pullback2: int = 0, |
| 4589 |
side1: bool = True, side2: bool = True, |
| 4590 |
NRP_enable: bool = True, leadin: int = 1, |
| 4591 |
verbose: bool = False, |
| 4592 |
*args, **kwargs) -> None: |
| 4593 |
""" |
| 4594 |
IEEEP370_MM_ZC_2xThru De-embedding Initializer |
| 4595 |
|
| 4596 |
Parameters |
| 4597 |
----------- |
| 4598 |
|
| 4599 |
dummy_2xthru : :class:`~skrf.network.Network` object |
| 4600 |
2xThru (FIX-FIX) network. |
| 4601 |
|
| 4602 |
name : string |
| 4603 |
optional name of de-embedding object |
| 4604 |
|
| 4605 |
z0 : |
| 4606 |
reference impedance of the S-parameters (default: 50) |
| 4607 |
|
| 4608 |
port_order : ['first', 'second', 'third'] |
| 4609 |
specify what numbering scheme to use. See above. (default: second) |
| 4610 |
|
| 4611 |
bandwidth_limit : |
| 4612 |
max frequency for a fitting function |
| 4613 |
(default: 0, use all s-parameters without fit) |
| 4614 |
|
| 4615 |
pullback1, pullback2 : |
| 4616 |
a number of discrete points to leave in the fixture on side 1 |
| 4617 |
respectively on side 2 (default: 0 leave all) |
| 4618 |
|
| 4619 |
side1, side2 : |
| 4620 |
set to de-embed the side1 resp. side2 errorbox (default: True) |
| 4621 |
|
| 4622 |
NRP_enable : |
| 4623 |
set to enforce the Nyquist Rate Point during de-embedding and to |
| 4624 |
add the appropriote delay to the errorboxes (default: True) |
| 4625 |
|
| 4626 |
leadin : |
| 4627 |
a number of discrete points before t = 0 that are non-zero from |
| 4628 |
calibration error (default: 1) |
| 4629 |
|
| 4630 |
verbose : |
| 4631 |
view the process (default: False) |
| 4632 |
|
| 4633 |
args, kwargs: |
| 4634 |
passed to :func:`Deembedding.__init__` |
| 4635 |
|
| 4636 |
See Also |
| 4637 |
--------- |
| 4638 |
:func:`Deembedding.__init__` |
| 4639 |
|
| 4640 |
""" |
| 4641 |
self.s2xthru = dummy_2xthru.copy() |
| 4642 |
self.sfix_dut_fix = dummy_fix_dut_fix.copy() |
| 4643 |
dummies = [self.s2xthru] |
| 4644 |
self.z0 = z0 |
| 4645 |
self.port_order = port_order |
| 4646 |
self.bandwidth_limit = bandwidth_limit |
| 4647 |
self.pullback1 = pullback1 |
| 4648 |
self.pullback2 = pullback2 |
| 4649 |
self.side1 = side1 |
| 4650 |
self.side2 = side2 |
| 4651 |
self.NRP_enable = NRP_enable |
| 4652 |
self.leadin = leadin |
| 4653 |
self.verbose = verbose |
| 4654 |
self.flag_DC = False |
| 4655 |
self.flag_df = False |
| 4656 |
|
| 4657 |
|
| 4658 |
self.gamma_dd = None |
| 4659 |
self.x_end_dd = None |
| 4660 |
self.z_side1_dd = None |
| 4661 |
self.z_side2_dd = None |
| 4662 |
self.gamma_cc = None |
| 4663 |
self.x_end_cc = None |
| 4664 |
self.z_side1_cc = None |
| 4665 |
self.z_side2_cc = None |
| 4666 |
|
| 4667 |
IEEEP370.__init__(self, dummies, name, *args, **kwargs) |
| 4668 |
self.se_side1, self.se_side2 = self.split2xthru(self.s2xthru, |
| 4669 |
self.sfix_dut_fix) |
| 4670 |
|
| 4671 |
def deembed(self, ntwk: Network) -> Network: |
| 4672 |
""" |
| 4673 |
Perform the de-embedding calculation |
| 4674 |
|
| 4675 |
Parameters |
| 4676 |
---------- |
| 4677 |
ntwk : :class:`~skrf.network.Network` object |
| 4678 |
FIX-DUT-FIX network from which FIX-1_2 and FIX-3_4 fixtures needs |
| 4679 |
to be removed via de-embedding |
| 4680 |
|
| 4681 |
Returns |
| 4682 |
------- |
| 4683 |
caled : :class:`~skrf.network.Network` object |
| 4684 |
Network data of the device after de-embedding |
| 4685 |
|
| 4686 |
""" |
| 4687 |
|
| 4688 |
|
| 4689 |
if ntwk.frequency != self.s2xthru.frequency: |
| 4690 |
warnings.warn('Network frequencies dont match dummy frequencies, attempting overlap.', |
| 4691 |
RuntimeWarning, stacklevel=2) |
| 4692 |
ntwk, s2xthru = overlap_multi([ntwk, self.s2xthru]) |
| 4693 |
se_side1, se_side2 = self.split2xthru(s2xthru, self.sfix_dut_fix) |
| 4694 |
else: |
| 4695 |
se_side1 = self.se_side1 |
| 4696 |
se_side2 = self.se_side2 |
| 4697 |
|
| 4698 |
|
| 4699 |
if ntwk.nports != 4: |
| 4700 |
raise(ValueError('2xthru has to be a 4-port network.')) |
| 4701 |
|
| 4702 |
if self.port_order == 'first': |
| 4703 |
N = ntwk.nports |
| 4704 |
old_order = list(range(N)) |
| 4705 |
new_order = list(range(0, N, 2)) + list(range(1, N, 2)) |
| 4706 |
ntwk.renumber(old_order, new_order) |
| 4707 |
elif self.port_order == 'third': |
| 4708 |
N = ntwk.nports |
| 4709 |
old_order = list(range(N)) |
| 4710 |
new_order = list(range(0, N//2)) + list(range(N-1, N//2-1, -1)) |
| 4711 |
ntwk.renumber(old_order, new_order) |
| 4712 |
|
| 4713 |
deembedded = se_side1.inv ** ntwk ** se_side2.flipped().inv |
| 4714 |
|
| 4715 |
if self.port_order != 'second': |
| 4716 |
deembedded.renumber(new_order, old_order) |
| 4717 |
return deembedded |
| 4718 |
|
| 4719 |
def split2xthru(self, se_2xthru: Network, se_fdf: Network) -> (Network, Network): |
| 4720 |
""" |
| 4721 |
Perform the fixtures extraction. |
| 4722 |
""" |
| 4723 |
|
| 4724 |
if se_2xthru.nports != 4 or se_fdf.nports != 4: |
| 4725 |
raise(ValueError('2xthru has to be a 4-port network.')) |
| 4726 |
|
| 4727 |
if self.port_order == 'first': |
| 4728 |
N = se_2xthru.nports |
| 4729 |
old_order = list(range(N)) |
| 4730 |
new_order = list(range(0, N, 2)) + list(range(1, N, 2)) |
| 4731 |
se_2xthru.renumber(old_order, new_order) |
| 4732 |
se_fdf.renumber(old_order, new_order) |
| 4733 |
elif self.port_order == 'third': |
| 4734 |
N = se_2xthru.nports |
| 4735 |
old_order = list(range(N)) |
| 4736 |
new_order = list(range(0, N//2)) + list(range(N-1, N//2-1, -1)) |
| 4737 |
se_2xthru.renumber(old_order, new_order) |
| 4738 |
se_fdf.renumber(old_order, new_order) |
| 4739 |
|
| 4740 |
|
| 4741 |
mm_2xthru = se_2xthru.copy() |
| 4742 |
mm_2xthru.se2gmm(p = 2) |
| 4743 |
mm_fdf = se_fdf.copy() |
| 4744 |
mm_fdf.se2gmm(p = 2) |
| 4745 |
|
| 4746 |
|
| 4747 |
sdd = subnetwork(mm_2xthru, [0, 1]) |
| 4748 |
scc = subnetwork(mm_2xthru, [2, 3]) |
| 4749 |
sdd_fdf = subnetwork(mm_fdf, [0, 1]) |
| 4750 |
scc_fdf = subnetwork(mm_fdf, [2, 3]) |
| 4751 |
dm_dd = IEEEP370_SE_ZC_2xThru(dummy_2xthru = sdd, |
| 4752 |
dummy_fix_dut_fix = sdd_fdf, |
| 4753 |
z0 = self.z0 * 2, |
| 4754 |
bandwidth_limit = self.bandwidth_limit, |
| 4755 |
pullback1 = self.pullback1, |
| 4756 |
pullback2 = self.pullback2, |
| 4757 |
side1 = self.side1, |
| 4758 |
side2 = self.side2, |
| 4759 |
NRP_enable = self.NRP_enable, |
| 4760 |
leadin = self.leadin, |
| 4761 |
verbose = self.verbose) |
| 4762 |
|
| 4763 |
self.gamma_dd = dm_dd.gamma |
| 4764 |
self.x_end_dd = dm_dd.x_end |
| 4765 |
self.z_side1_dd = dm_dd.z_side1 |
| 4766 |
self.z_side2_dd = dm_dd.z_side2 |
| 4767 |
dm_cc = IEEEP370_SE_ZC_2xThru(dummy_2xthru = scc, |
| 4768 |
dummy_fix_dut_fix = scc_fdf, |
| 4769 |
z0 = self.z0 / 2, |
| 4770 |
bandwidth_limit = self.bandwidth_limit, |
| 4771 |
pullback1 = self.pullback1, |
| 4772 |
pullback2 = self.pullback2, |
| 4773 |
side1 = self.side1, |
| 4774 |
side2 = self.side2, |
| 4775 |
NRP_enable = self.NRP_enable, |
| 4776 |
leadin = self.leadin, |
| 4777 |
verbose = self.verbose) |
| 4778 |
|
| 4779 |
self.gamma_cc = dm_cc.gamma |
| 4780 |
self.x_end_cc = dm_cc.x_end |
| 4781 |
self.z_side1_cc = dm_cc.z_side1 |
| 4782 |
self.z_side2_cc = dm_cc.z_side2 |
| 4783 |
|
| 4784 |
mm_side1 = concat_ports([dm_dd.s_side1, dm_cc.s_side1], port_order = 'first') |
| 4785 |
se_side1 = mm_side1.copy() |
| 4786 |
se_side1.gmm2se(p = 2) |
| 4787 |
mm_side2 = concat_ports([dm_dd.s_side2, dm_cc.s_side2], port_order = 'first') |
| 4788 |
se_side2 = mm_side2.copy() |
| 4789 |
se_side2.gmm2se(p = 2) |
| 4790 |
|
| 4791 |
return (se_side1, se_side2) |
| 4792 |
|
| 4793 |
def plot_check_residuals(self, ax: Axes = None) -> (Figure, Axes): |
| 4794 |
res = self.deembed(self.s2xthru) |
| 4795 |
res.name = 'Residuals' |
| 4796 |
res.se2gmm(p=2) |
| 4797 |
|
| 4798 |
if ax is None: |
| 4799 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 4800 |
else: |
| 4801 |
fig = ax.get_figure() |
| 4802 |
|
| 4803 |
fig.suptitle('Consistency test #1: Self de-embedding of 2X-Thru') |
| 4804 |
|
| 4805 |
ax[0].set_title('Magnitude residuals') |
| 4806 |
res.plot_s_db(1,0, ax = ax[0]) |
| 4807 |
res.plot_s_db(0,1, ax = ax[0]) |
| 4808 |
res.plot_s_db(3,2, ax = ax[0]) |
| 4809 |
res.plot_s_db(2,3, ax = ax[0]) |
| 4810 |
ax[0].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4811 |
[0.1, 0.1], |
| 4812 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 4813 |
ax[0].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4814 |
[-0.1, -0.1], |
| 4815 |
linestyle = 'dashed', color = 'r') |
| 4816 |
ax[0].legend(loc = 'upper right') |
| 4817 |
|
| 4818 |
ax[1].set_title('Phase residuals') |
| 4819 |
res.plot_s_deg(1,0, ax = ax[1]) |
| 4820 |
res.plot_s_deg(0,1, ax = ax[1]) |
| 4821 |
res.plot_s_deg(3,2, ax = ax[1]) |
| 4822 |
res.plot_s_deg(2,3, ax = ax[1]) |
| 4823 |
ax[1].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4824 |
[1, 1], |
| 4825 |
linestyle = 'dashed', color = 'r', label = 'Limit') |
| 4826 |
ax[1].plot([res.frequency.f[0], res.frequency.f[-1]], |
| 4827 |
[-1, -1], |
| 4828 |
linestyle = 'dashed', color = 'r') |
| 4829 |
ax[1].legend(loc = 'upper right') |
| 4830 |
fig.tight_layout() |
| 4831 |
|
| 4832 |
return (fig, ax) |
| 4833 |
|
| 4834 |
def plot_check_impedance(self, fix_dut_fix: Network = None, ax: Axes = None, |
| 4835 |
window: str = 'hamming') -> (Figure, Axes): |
| 4836 |
|
| 4837 |
s2xthru = self.s2xthru.copy() |
| 4838 |
s2xthru.se2gmm(p=2) |
| 4839 |
s2xthru = IEEEP370.extrapolate_to_dc(s2xthru) |
| 4840 |
fix1 = self.se_side1.copy() |
| 4841 |
fix1.se2gmm(p=2) |
| 4842 |
fix1 = IEEEP370.extrapolate_to_dc(fix1) |
| 4843 |
fix2 = self.se_side2.copy() |
| 4844 |
fix2.se2gmm(p=2) |
| 4845 |
fix2 = IEEEP370.extrapolate_to_dc(fix2) |
| 4846 |
if fix_dut_fix is not None: |
| 4847 |
fix_dut_fix = fix_dut_fix.copy() |
| 4848 |
fix_dut_fix.se2gmm(p=2) |
| 4849 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(fix_dut_fix) |
| 4850 |
else: |
| 4851 |
fix_dut_fix = self.sfix_dut_fix.copy() |
| 4852 |
fix_dut_fix.se2gmm(p=2) |
| 4853 |
fix_dut_fix = IEEEP370.extrapolate_to_dc(fix_dut_fix) |
| 4854 |
n = s2xthru.frequency.npoints * 2 - 1 |
| 4855 |
dt = 1e9 / (n * s2xthru.frequency.step) |
| 4856 |
|
| 4857 |
if ax is None: |
| 4858 |
fig, ax = subplots(1, 2, sharex = True, figsize=(10, 5)) |
| 4859 |
else: |
| 4860 |
fig = ax.get_figure() |
| 4861 |
|
| 4862 |
fig.suptitle('Consistency test #2: Compare the TDR of the fixture model to the FIX-DUT-FIX') |
| 4863 |
ax[0].set_title('Side 1') |
| 4864 |
fix1.plot_z_time_step(0, 0, window = window, |
| 4865 |
ax = ax[0], color = 'k') |
| 4866 |
y = ax[0].lines[-1].get_ydata() |
| 4867 |
s2xthru.plot_z_time_step(0, 0, window = window, |
| 4868 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 4869 |
fix_dut_fix.plot_z_time_step(0, 0, window = window, |
| 4870 |
ax = ax[0], linestyle = 'dashed', color = 'm') |
| 4871 |
ax[0].plot([-self.leadin * dt], [y[n // 2 - self.leadin]], marker = 's', color = 'k', |
| 4872 |
label = f'start (leadin = {self.leadin})') |
| 4873 |
ax[0].plot([self.x_end_dd * dt], [y[self.x_end_dd + n // 2]], marker = 'o', color = 'k', |
| 4874 |
label = f'end (pullback1 = {self.pullback1})') |
| 4875 |
fix1.plot_z_time_step(2, 2, window = window, |
| 4876 |
ax = ax[0], color = 'k') |
| 4877 |
s2xthru.plot_z_time_step(2, 2, window = window, |
| 4878 |
ax = ax[0], linestyle = 'dotted', color = '0.2') |
| 4879 |
fix_dut_fix.plot_z_time_step(2, 2, window = window, |
| 4880 |
ax = ax[0], linestyle = 'dashed', color = 'b') |
| 4881 |
ax[0].legend(loc = 'center left') |
| 4882 |
|
| 4883 |
ax[1].set_title('Side 2') |
| 4884 |
fix2.plot_z_time_step(0, 0, window = window, |
| 4885 |
ax = ax[1], color = 'k') |
| 4886 |
y = ax[1].lines[-1].get_ydata() |
| 4887 |
s2xthru.plot_z_time_step(1, 1, window = window, |
| 4888 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 4889 |
fix_dut_fix.plot_z_time_step(1, 1, window = window, |
| 4890 |
ax = ax[1], linestyle = 'dashed', color = 'm') |
| 4891 |
ax[1].plot([-self.leadin * dt], [y[n // 2 - self.leadin]], marker = 's', color = 'k', |
| 4892 |
label = f'start (leadin = {self.leadin})') |
| 4893 |
ax[1].plot([self.x_end_dd * dt], [y[self.x_end_dd + n // 2]], marker = 'o', color = 'k', |
| 4894 |
label = f'end (pullback2 = {self.pullback2})') |
| 4895 |
fix2.plot_z_time_step(2, 2, window = window, |
| 4896 |
ax = ax[1], color = 'k') |
| 4897 |
s2xthru.plot_z_time_step(3, 3, window = window, |
| 4898 |
ax = ax[1], linestyle = 'dotted', color = '0.2') |
| 4899 |
fix_dut_fix.plot_z_time_step(3, 3, window = window, |
| 4900 |
ax = ax[1], linestyle = 'dashed', color = 'b') |
| 4901 |
delay = 2 * self.x_end_dd * dt |
| 4902 |
ax[1].set_xlim((-0.5 * delay, 1.5 * delay)) |
| 4903 |
ax[1].legend(loc = 'center left') |
| 4904 |
|
| 4905 |
fig.tight_layout() |
| 4906 |
|
| 4907 |
return (fig, ax) |