aboutsummaryrefslogtreecommitdiff
path: root/calctenna.py
diff options
context:
space:
mode:
Diffstat (limited to 'calctenna.py')
-rwxr-xr-xcalctenna.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/calctenna.py b/calctenna.py
index 34cc2b8..83f6ff3 100755
--- a/calctenna.py
+++ b/calctenna.py
@@ -11,8 +11,19 @@ import sys
class Tests(unittest.TestCase):
def test_calc(self):
- self.assertEqual(calc(100e6, 0.951),
- (2.99792458, 1.49896229, 0.749481145, 0.7127565688949999))
+ antenna_data = AntennaData(100e6, 0.951)
+ antenna_data = calc(antenna_data)
+ self.assertEqual(antenna_data.dipole_leg_length, 0.7127565688949999)
+
+class AntennaData():
+ def __init__(self, frequency, velocity_factor):
+ self.frequency = frequency
+ self.velocity_factor = velocity_factor
+ # fill me
+ self.wavelength = 0
+ self.wavelength_2 = 0
+ self.wavelength_4 = 0
+ self.dipole_leg_length = 0
def run_argparse():
argparser = argparse.ArgumentParser()
@@ -72,13 +83,15 @@ def check_input(frequency, velocity_factor):
return True
-def calc(frequency, velocity_factor):
+# fill struct
+def calc(antenna_data):
c = 299792458 # speed of light
- wavelength = float(c) / float(frequency)
- wavelength_2 = wavelength/2
- wavelength_4 = wavelength/4
- dipole_leg_length = wavelength/4 * float(velocity_factor)
- return (wavelength, wavelength_2, wavelength_4, dipole_leg_length)
+ antenna_data.wavelength = float(c) / float(antenna_data.frequency)
+ antenna_data.wavelength_2 = antenna_data.wavelength/2
+ antenna_data.wavelength_4 = antenna_data.wavelength/4
+ antenna_data.dipole_leg_length = antenna_data.wavelength_4 \
+ * float(antenna_data.velocity_factor)
+ return antenna_data
if __name__ == '__main__':
args = run_argparse()
@@ -90,14 +103,14 @@ if __name__ == '__main__':
if not check_input(args.frequency, args.velocity_factor):
exit()
- (wavelength, wavelength_2, wavelength_4, dipole_leg_length) = \
- calc(args.frequency, args.velocity_factor)
+ antenna_data = AntennaData(args.frequency, args.velocity_factor)
+ antenna_data = calc(antenna_data)
if not args.quiet:
- print("Desired Frequency: " + str(args.frequency) + " Hz")
- print("Wavelength: %.3f m" % wavelength)
- print("Wavelength / 2: %.3f m" % wavelength_2)
- print("Wavelength / 4: %.3f m" % wavelength_4)
- print("Velocity factor: " + str(args.velocity_factor))
+ print("Desired Frequency: " + str(antenna_data.frequency) + " Hz")
+ print("Wavelength: %.3f m" % antenna_data.wavelength)
+ print("Wavelength / 2: %.3f m" % antenna_data.wavelength_2)
+ print("Wavelength / 4: %.3f m" % antenna_data.wavelength_4)
+ print("Velocity factor: " + str(antenna_data.velocity_factor))
print("-> Dipole leg length (lambda/4): ", end='')
- print("%.3f m" % dipole_leg_length)
+ print("%.3f m" % antenna_data.dipole_leg_length)
in each repos: see "about"-tab (if existing) for more details / README.
mailto contact at omeckman dot net
all timestamps in UTC (German winter time: UTC+01:00, summer time: UTC+02:00)
dark theme is a modded version of: https://gist.github.com/Yoplitein/f4b671a2ec70c9e743fa