From 08ff952636ea40303e0aed293d5724ba0349a359 Mon Sep 17 00:00:00 2001 From: pux Date: Mon, 22 Mar 2021 01:14:18 +0100 Subject: units in src --- calctenna.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'calctenna.py') diff --git a/calctenna.py b/calctenna.py index 0ca70d2..c8668d0 100755 --- a/calctenna.py +++ b/calctenna.py @@ -17,13 +17,13 @@ class Tests(unittest.TestCase): class AntennaData(): def __init__(self, frequency, velocity_factor): - self.frequency = frequency + self.frequency_hz = frequency self.velocity_factor = velocity_factor # fill me - self.wavelength = 0 - self.wavelength_2 = 0 - self.wavelength_4 = 0 - self.dipole_leg_length = 0 + self.wavelength_m = 0 + self.wavelength_2_m = 0 + self.wavelength_4_m = 0 + self.dipole_leg_length_m = 0 def run_argparse(): argparser = argparse.ArgumentParser() @@ -86,10 +86,10 @@ def check_input(frequency, velocity_factor): # fill struct def calc(antenna_data): c = 299792458.0 # speed of light - antenna_data.wavelength = c / 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 \ + antenna_data.wavelength_m = c / antenna_data.frequency_hz + antenna_data.wavelength_2_m = antenna_data.wavelength_m/2 + antenna_data.wavelength_4_m = antenna_data.wavelength_m/4 + antenna_data.dipole_leg_length_m = antenna_data.wavelength_4_m \ * antenna_data.velocity_factor if __name__ == '__main__': @@ -107,10 +107,10 @@ if __name__ == '__main__': calc(antenna_data) if not args.quiet: - print("Desired Frequency: " + str(antenna_data.frequency) + " Hz") - print("Wavelength: %.3f m" % antenna_data.wavelength) - print("Wavelength / 2: %.3f cm" % (antenna_data.wavelength_2*100)) - print("Wavelength / 4: %.3f cm" % (antenna_data.wavelength_4*100)) + print("Desired Frequency: " + str(antenna_data.frequency_hz) + " Hz") + print("Wavelength: %.3f m" % antenna_data.wavelength_m) + print("Wavelength / 2: %.3f cm" % (antenna_data.wavelength_2_m*100)) + print("Wavelength / 4: %.3f cm" % (antenna_data.wavelength_4_m*100)) print("Velocity factor: " + str(antenna_data.velocity_factor)) print("-> Dipole leg length (lambda/4): ", end='') - print("%.3f cm" % (antenna_data.dipole_leg_length*100)) + print("%.3f cm" % (antenna_data.dipole_leg_length_m*100)) -- cgit v1.2.2-1-g5e49