#!/usr/bin/perl # Copyright (c) 2006 Fabian Kurz, DJ1YFK # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # Extract all QSOs x minutes after a Spot from a log. # (indentation looks best with tab width = 4) # Run ./wrtc-spots.pl | sort -n | tac for a nice output. use strict; use warnings; my $window = 2; # minutes my $threshold = 20; # QSOs over all logs my %callhash; # keys=calls that are in logs after spots, value=count my %allcalls; # keys=calls that appear in all logs, value=count # The calls which are used to generate the statistics. my @ptcalls = qw/PT5A PT5B PT5C PT5D PT5E PT5F PT5G PT5I PT5J PT5K PT5L PT5M PT5N PT5O PT5P PT5Q PT5R PT5T PT5U PT5V PT5W PT5X PT5Y PW5A PW5B PW5C PW5D PW5E PW5F PW5G PW5I PW5J PW5K PW5L PW5M PW5N PW5O PW5P PW5Q PW5T PW5U PW5V PW5W PW5X PW5Y PW5Z/; my $ptcall; foreach $ptcall (@ptcalls) { # Open and read the log of each call. open LOG, "logs/$ptcall.LOG"; my @log = ; while (!($log[0] =~ /^QSO:/)) { # remove non-log lines shift @log; } pop @log; # remove END-OF-LOG: open SPOTS, "spots/$ptcall.SPT"; my $ignoreuntil=0; # see below. while (defined(my $line = )) { # making the window shorter in some cases because of overlapping # spots/windows. # by default the full window length is used of course, thus 0 my $windowcorrection=0; my $time = substr($line, 60, 4); $time = &utc2min($time); # conv time to minutes from contest start # if 2 spots are sent close to each other and the time frames are # overlapping, QSOs would be counted twice. to avoid this, a variable # "$ignoreuntil" will be intruduced which gives the time in minutes # relative to the start of the contest until when to ignore any new QSOs. if ($ignoreuntil >= $time) { # overlap! $windowcorrection = $ignoreuntil - $time; $time = $ignoreuntil; } $ignoreuntil = $time + $window+1 - $windowcorrection; my $freq = substr($line, 10,5); my $spotter = substr($line, 0, 6); $spotter =~ s/ //g; $spotter =~ s/-@//g; # -@ added by OH2AQ removed. my $i; foreach $i (0 .. $#log) { my $diff = (utc2min(substr($log[$i],25,4))-$time); if (($diff >= 0) && ($diff < ($window+1-$windowcorrection))) { my $callsign = substr($log[$i],55,10); $callsign =~ s/ //g; if ($callsign eq $spotter) {next}; if (defined($callhash{$callsign})) { $callhash{$callsign}++; } else { $callhash{$callsign}=1; } } } } # in order to give the ratio of QSOs within the x-minute time frame after a QSO # vs. all QSOs, quickly count number of QSOs for every station # (yes, could have done before, monkey code) my $i; foreach $i (0 .. $#log) { my $callsign = substr($log[$i],55,10); $callsign =~ s/ //g; if (defined($allcalls{$callsign})) { $allcalls{$callsign}++; } else { $allcalls{$callsign}=1; } } } # read categories.txt based on arrl logsumbissions my %cat; open CAT, "categories.txt"; while (my $lin = ) { chomp($lin); my $call = substr($lin,0,10); $call =~ s/ //g; $cat{$call} = substr($lin, 21,28); # category $cat{$call} .= substr($lin, 63,); # score } foreach (keys %callhash) { if ($callhash{$_} > $threshold) { my $line = sprintf( "%10.3f %5s %5s %12s ", ($callhash{$_}/$allcalls{$_})*100, $callhash{$_}, $allcalls{$_}, $_); if (defined($cat{$_})) { $line .= $cat{$_}; } print $line."\n" if (defined($line)); } } # Convert a UTC-Time to 'minutes since contest start' sub utc2min { my $time = shift; my $return=0; my $hour = substr($time, 0,2); my $min = substr($time, 2,2); if ($hour > 11) { # between 12 UTC and midnight $return += ($hour - 12)*60; } else { # morning hours $return += (12*60 + $hour*60); } $return += $min; return $return; }