2016 WPX SSB

A45WG log file analysis

import pandas as pd
import numpy as np
import hamcabrillo
from ham.band import HamBand
from ham.dxcc import DxccAll
band=HamBand()
cabdata=hamcabrillo.LoadCab()
df=cabdata.convert_to_df('2016-cqww-ssb.cbr')
#create my dx object from my DxccAll
dx=DxccAll()

def get_country(call):
    fnd = dx.find(call)
    if fnd and fnd.Country_Name:
        return fnd.Country_Name
    else:
        return ""

def get_freq(x):
    try:  
        x=float('0'+x)
    except Exception as err:
        x=0
    return x

df['country']=df.dxcall.apply(lambda x: get_country(x))


# Create some new Columns
df['hour']=pd.to_datetime(df.when).apply(lambda x: x.hour)
# Convert Z time to Oman time.
df['om_hour']=(df.hour+4)%24
# Make freq a float
df['freq'] = df.freq.apply(lambda x:get_freq(x))
#Create the Band column
df['band']=df.freq.apply(lambda x: band.khz_to_m(x))
df
want to open /Users/tim/pe39/lib/python3.9/site-packages/ham/dxcc/data/cty.dat
freq mode when mycall myrst myexch dxcall dxrst dxexch txnum country hour om_hour band
0 21000.0 CW 2016-10-30 1148 A45WG 59 21 CN2R 599 33 0 Morocco 11 15 15
1 21318.0 CW 2016-10-30 1151 A45WG 59 21 9A5D 599 14 0 Croatia 11 15 15
2 21330.0 CW 2016-10-30 1151 A45WG 59 21 C4A 599 20 0 Cyprus 11 15 15
3 21312.0 CW 2016-10-30 1156 A45WG 59 21 IW2HAJ 599 15 0 Italy 11 15 15
4 21280.0 CW 2016-10-30 1201 A45WG 59 21 ET3AA 599 37 0 Ethiopia 12 16 15
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
92 21187.0 PH 2016-10-30 1312 A45WG 59 21 DL6NDW 59 14 0 Fed. Rep. of Germany 13 17 15
93 21187.0 PH 2016-10-30 1312 A45WG 59 21 IV3NTI 59 15 0 Italy 13 17 15
94 21187.0 PH 2016-10-30 1313 A45WG 59 21 OK4RQ 59 15 0 Czech Republic 13 17 15
95 21187.0 PH 2016-10-30 1313 A45WG 59 21 IK1MAF 59 14 0 Italy 13 17 15
96 21187.0 PH 2016-10-30 1315 A45WG 59 21 M1O 59 14 0 England 13 17 15

97 rows × 14 columns

# Activity per hour

when_active=df.om_hour.unique()
when_active.sort()
print("Active Hours")
for h in when_active:
    print(f"\t{h}")
Active Hours
    15
    16
    17
df.groupby(['om_hour']).agg({'band':'count'}).reset_index().rename(columns={"band":"Count"}).set_index('om_hour')
Count
om_hour
15 4
16 62
17 31
# Activity per hour Per Country
df.groupby(['om_hour','band']).agg({'country':'count'}).reset_index().rename(columns={"band":"Band"}).set_index('om_hour')
Band country
om_hour
15 15 4
16 15 62
17 15 31
# Create a Pivot table showing when Each State was active
pd.pivot_table(df,index='om_hour',columns=['country'], aggfunc='count').fillna('-')
band ... when
country Argentina Aruba Austria Belarus Belgium Brazil Bulgaria Canary Islands Croatia Cyprus ... Saudi Arabia Slovenia South Africa Spain St. Kitts & Nevis Switzerland US Virgin Islands Ukraine Venezuela Zambia
om_hour
15 - - - - - - - - 1.0 1.0 ... - - - - - - - - - -
16 2.0 - 2.0 - 1.0 3.0 2.0 2.0 2.0 - ... 1.0 1.0 3.0 1.0 1.0 - 1.0 2.0 2.0 1.0
17 - 1.0 1.0 1.0 - - - - - - ... - 1.0 2.0 - - 1.0 - 1.0 - -

3 rows × 456 columns

# Activity per hour to the US per Band 
df.groupby(['om_hour','band']).agg({'country':'count'}).reset_index().rename(columns={"band":"Band"}).set_index('om_hour')
Band country
om_hour
15 15 4
16 15 62
17 15 31