-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinMaxFreqs.py
43 lines (35 loc) · 1.05 KB
/
MinMaxFreqs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class MinMaxFreqs:
def __init__(self, minf=None, maxf=None, bw=None):
self.minf = minf
self.maxf = maxf
self.bw = bw # max bw
def setMinMax(self, f):
self.setMin(f)
self.setMax(f)
def setMin(self, f):
if self.minf is not None:
if self.minf > f:
self.minf = f
else:
self.minf = f
def setMax(self, f):
if self.maxf is not None:
if self.maxf < f:
self.maxf = f
else:
self.maxf = f
def setBW(self, bw):
if self.bw is not None:
if self.bw < bw:
self.bw = bw
else:
self.bw = bw
def avgFreqs(self):
if self.minf is None or self.maxf is None:
return None
return (self.minf + self.maxf) / 2.0
def computeBW(self, bw=None):
bw = self.bw if bw is None else bw
return (self.maxf - self.minf + bw)
def __str__(self):
return "%s - %s (%s)" % (self.minf, self.maxf, self.bw)