Converts between frequency in Hz and meters based on the speed of light in a vaccum. Calculates heterodyne frequencies for multiple orders
c = 299792458 # speed of light # convert wavelength and frequency def ftom(f): return c/f def mtof(m): return c/m # calculate heterodynes def hd(fIn,fLo,o=3,r=[0,float("inf")]): f=[fIn,fLo,abs(fLo-fIn), fLo+fIn] for m in range(2, max(2,o+1)): f += [m*fLo, m*fIn, abs(m*fLo-fIn), m*fLo+fIn, abs(fLo-m*fIn), fLo+m*fIn] print("\n".join(map(lambda s: "{:.6g}".format(round(s, 4), 4),sorted(filter(lambda x: x>=r[0] and x<=r[1], f)))))