calclambda.py 591 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python3
  2. import sys
  3. try:
  4. factor = 0.97
  5. lowerMhz = float(sys.argv[1])
  6. upperMhz = float(sys.argv[2])
  7. if len(sys.argv) >= 4:
  8. factor = float(sys.argv[3])
  9. except (IndexError, ValueError) as e:
  10. print("Usage: %s LOWERMHZ UPPERMHZ [FACTOR]" % sys.argv[0])
  11. sys.exit(1)
  12. centerMhz = (upperMhz - lowerMhz) / 2 + lowerMhz
  13. centerHz = centerMhz * 1000000
  14. c = 299792458 # m/sec
  15. lambd = (float(c) / centerHz) * factor
  16. lambd4 = lambd / 4
  17. lambd4mm = lambd4 * 1000
  18. print("%.1f < %.1f < %.1f (* %.2f) ==> lambda/4 = %.1f mm" %\
  19. (lowerMhz, centerMhz, upperMhz, factor, lambd4mm))