howtophil icon

swrpowerloss.sh

howtophil | PRO | 03/06/24 04:41:54 PM UTC (Edited) | 0 ⭐ | 868 👁️ | Never ⏰ | [Radio, swr, erp, hamradio, antenna, Ham radio, power loss, watts, effective radiated power, antennas]
Bash |

1.19 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
#------------------------------------------------------
# A power-loss-due-to-SWR estimation calculator
# based on the formula/table provided by Firestick
# on this page:
# http://www.firestik.com/Tech_Docs/SWRLOSS.htm
#------------------------------------------------------
# Code by Phillip J Rhoades (2024-03-06)
#------------------------------------------------------
# Save it is swrpowerloss.sh and use it:
# ./swrpowerloss.sh [Wattage-of-Radio] [SWR-of-Antenna]
#------------------------------------------------------
 
# Put some arguments into legible variables
RADIOPOWER=$1
SWR=$2
 
# Calculate the loss and remaining power in watts.
LOSS=$(echo "scale=2; ($RADIOPOWER*(($SWR-1)*($SWR-1)))/(($SWR+1)*($SWR+1))"|bc -l)
REMAIN=$(echo "scale=2;$RADIOPOWER-$LOSS" |bc -l)
 
# Convert the loss and remaining power into percentages.
PERCENTLOSS=$(echo "scale=2;($LOSS/$RADIOPOWER)*100" |bc -l)
PERCENTREMAIN=$(echo "scale=2;100-$PERCENTLOSS" |bc -l)
 
# Print out the estimates.
# I could make this prettier
# but this is fine...
echo "Loss in watts   : $LOSS"
echo "Radiated Watts  : $REMAIN"
echo "Percent Loss    : $PERCENTLOSS%"
echo "Radiated Percent: $PERCENTREMAIN%"
 
 

Comments