mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-02 02:57:52 +00:00
Merge pull request #141 from ojnas/automatic-spacing
Simplify automatic spacing
This commit is contained in:
@@ -182,13 +182,7 @@ def automatic_spacing(baud_rate):
|
|||||||
"""return the min possible channel spacing for a given baud rate"""
|
"""return the min possible channel spacing for a given baud rate"""
|
||||||
spacing_list = [(38e9,50e9), (67e9,75e9), (92e9,100e9)] #list of possible tuples
|
spacing_list = [(38e9,50e9), (67e9,75e9), (92e9,100e9)] #list of possible tuples
|
||||||
#[(max_baud_rate, spacing_for_this_baud_rate)]
|
#[(max_baud_rate, spacing_for_this_baud_rate)]
|
||||||
acceptable_spacing_list = list(filter(lambda x : x[0]>baud_rate, spacing_list))
|
return next((s[1] for s in spacing_list if s[0] > baud_rate), baud_rate*1.2)
|
||||||
if len(acceptable_spacing_list) < 1:
|
|
||||||
#can't find an adequate spacing from the list, so default to:
|
|
||||||
return baud_rate*1.2
|
|
||||||
else:
|
|
||||||
#chose the lowest possible spacing
|
|
||||||
return min(acceptable_spacing_list, key=itemgetter(0))[1]
|
|
||||||
|
|
||||||
def automatic_nch(f_min, f_max, spacing):
|
def automatic_nch(f_min, f_max, spacing):
|
||||||
return int((f_max - f_min)//spacing)
|
return int((f_max - f_min)//spacing)
|
||||||
|
|||||||
Reference in New Issue
Block a user