Advertisement
howtophil

swrpowerloss.sh

Mar 6th, 2024 (edited)
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1. #!/bin/bash
  2. #------------------------------------------------------
  3. # A power-loss-due-to-SWR estimation calculator
  4. # based on the formula/table provided by Firestick
  5. # on this page:
  6. # http://www.firestik.com/Tech_Docs/SWRLOSS.htm
  7. #------------------------------------------------------
  8. # Code by Phillip J Rhoades (2024-03-06)
  9. #------------------------------------------------------
  10. # Save it is swrpowerloss.sh and use it:
  11. # ./swrpowerloss.sh [Wattage-of-Radio] [SWR-of-Antenna]
  12. #------------------------------------------------------
  13.  
  14. # Put some arguments into legible variables
  15. RADIOPOWER=$1
  16. SWR=$2
  17.  
  18. # Calculate the loss and remaining power in watts.
  19. LOSS=$(echo "scale=2; ($RADIOPOWER*(($SWR-1)*($SWR-1)))/(($SWR+1)*($SWR+1))"|bc -l)
  20. REMAIN=$(echo "scale=2;$RADIOPOWER-$LOSS" |bc -l)
  21.  
  22. # Convert the loss and remaining power into percentages.
  23. PERCENTLOSS=$(echo "scale=2;($LOSS/$RADIOPOWER)*100" |bc -l)
  24. PERCENTREMAIN=$(echo "scale=2;100-$PERCENTLOSS" |bc -l)
  25.  
  26. # Print out the estimates.
  27. # I could make this prettier
  28. # but this is fine...
  29. echo "Loss in watts   : $LOSS"
  30. echo "Radiated Watts  : $REMAIN"
  31. echo "Percent Loss    : $PERCENTLOSS%"
  32. echo "Radiated Percent: $PERCENTREMAIN%"
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement