Skip to content

Commit

Permalink
host: Properly handle most corner cases in VSWR calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
chemeris committed Dec 21, 2015
1 parent 9309e3c commit 4f909bc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions host/utils/umtrx_vswr.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def vswr(self):
gamma = self._gamma
if gamma == 1.0:
return float("inf")
elif gamma > 1.0:
return float("nan")
else:
return (1+gamma)/(1-gamma)

Expand All @@ -54,15 +56,21 @@ def mismatch_loss(self):
gamma = self._gamma
if gamma == 1.0:
return float("-inf")
elif gamma > 1.0:
return float("nan")
else:
return -10.0 * math.log(1.0-gamma*gamma, 10)

def pf_rate(self):
''' Estimated reflected power rate, % '''
gamma = self._gamma
if gamma > 1.0:
return float("nan")
return 1.0 - gamma*gamma

def pr_rate(self):
''' Estimated reflected power rate, % '''
gamma = self._gamma
if gamma > 1.0:
return float("nan")
return gamma*gamma

0 comments on commit 4f909bc

Please sign in to comment.