document and test automatic_nch and automatic_fmax
@@ -338,10 +338,32 @@ def automatic_spacing(baud_rate):
def automatic_nch(f_min, f_max, spacing):
+ """How many channels are available in the spectrum
+
+ :param f_min Lowest frequenecy [Hz]
+ :param f_max Highest frequency [Hz]
+ :param spacing Channel width [Hz]
+ :return Number of uniform channels
+
+ >>> automatic_nch(191.325e12, 196.125e12, 50e9)
+ 96
+ >>> automatic_nch(193.475e12, 193.525e12, 50e9)
+ 1
+ """
return int((f_max - f_min) // spacing)
def automatic_fmax(f_min, spacing, nch):
+ """Find the high-frequenecy boundary of a spectrum
+
+ :param f_min Start of the spectrum (lowest frequency edge) [Hz]
+ :param spacing Grid/channel spacing [Hz]
+ :param nch Number of channels
+ :return End of the spectrum (highest frequency) [Hz]
+
+ >>> automatic_fmax(191.325e12, 50e9, 96)
+ 196125000000000.0
+ """
return f_min + spacing * nch
