mirror of
https://github.com/majmongoose/ARRLFieldDayTools.git
synced 2024-11-08 10:26:10 -05:00
add cabrillostats
This commit is contained in:
parent
0f024b97fe
commit
873a0ebe25
@ -11,3 +11,6 @@ ADIF Converter can take command line arguments (input and output file), or it wi
|
||||
|
||||
## squirlConverter
|
||||
Squirl converter is a bit simpler to use. Put all of the exported log TXT files into the same directory as the script, and give it an argument for the name of the output file (it will default to "output.txt"). It will also have you enter the header information, and output another single large cabrillo file.
|
||||
|
||||
## cabrilloStats
|
||||
CabrilloStats is a simple tool to find how many contacts were made per band and mode, which is helpful in submission to the ARRL.
|
70
cabrilloStats.py
Normal file
70
cabrilloStats.py
Normal file
@ -0,0 +1,70 @@
|
||||
import re
|
||||
import pandas as pd
|
||||
import argparse
|
||||
|
||||
# Define the frequency to band conversion
|
||||
frequency_to_band = {
|
||||
'1800': '160m',
|
||||
'3500': '80m',
|
||||
'7000': '40m',
|
||||
'14000': '20m',
|
||||
'21000': '15m',
|
||||
'28000': '10m',
|
||||
}
|
||||
|
||||
# Define a function to parse the QSO lines
|
||||
def parse_qso_line(line):
|
||||
# Use regex to match the QSO line and extract the mode and frequency
|
||||
match = re.match(r"QSO:\s+(\d+)\s+(\w+)\s+\d{4}-\d{2}-\d{2}\s+\d{4}\s+\w+\s+\w+\s+\w+\s+\w+", line)
|
||||
if match:
|
||||
frequency, mode = match.groups()
|
||||
band = frequency_to_band.get(frequency, None) # Convert frequency to band
|
||||
if band:
|
||||
return mode, band
|
||||
return None, None
|
||||
|
||||
# Define a function to read the log file and count QSOs
|
||||
def read_log_file(file_path):
|
||||
# Initialize counters for QSOs
|
||||
counts = {'CW': {}, 'PH': {}, 'RY': {}, 'DG': {}}
|
||||
|
||||
# Read the log file
|
||||
with open(file_path, 'r') as file:
|
||||
for line in file:
|
||||
if line.startswith('QSO:'):
|
||||
mode, band = parse_qso_line(line.strip())
|
||||
if mode and mode in counts:
|
||||
if band not in counts[mode]:
|
||||
counts[mode][band] = 0
|
||||
counts[mode][band] += 1
|
||||
|
||||
# Convert counts to a DataFrame for better display
|
||||
# Define all possible bands
|
||||
all_bands = ['160m', '80m', '40m', '20m', '15m', '10m']
|
||||
|
||||
# Initialize the DataFrame with all bands and modes
|
||||
data = {band: {mode: counts[mode].get(band, 0) for mode in ['CW', 'DG', 'PH', 'RY']} for band in all_bands}
|
||||
df = pd.DataFrame(data).T.fillna(0).astype(int)
|
||||
|
||||
return df
|
||||
|
||||
# Define a function to print the results
|
||||
def print_summary(df):
|
||||
print("QSO Counts by Band and Mode:")
|
||||
print(df)
|
||||
|
||||
# Main function to run the script
|
||||
def main():
|
||||
# Set up command line argument parsing
|
||||
parser = argparse.ArgumentParser(description="Process a log file to count QSOs by band and mode.")
|
||||
parser.add_argument('file_path', help="Path to the log file")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read the log file and get QSO counts
|
||||
df = read_log_file(args.file_path)
|
||||
|
||||
# Print the summary
|
||||
print_summary(df)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user