ARRL CW Contest 2022
DV3A log file analysis
Prior to this stage the Cabrillo file had been read in and a dataframe produced and saved as a pickle file. No columns were added to the cabrillo file before this phase.
import pandas as pd
import numpy as np
from ham.band import HamBand
band=HamBand()
df= pd.read_pickle("./cw.pkl")
#Remove a couple of bad data records
df = df[~df.dxexch.isin(['1','100'])]
# Create some new Columns
df['hour']=pd.to_datetime(df.when).apply(lambda x: x.hour)
# Convert Z time to Philippine time.
df['ph_hour']=(df.hour+8)%24
# Make freq a float
df['freq'] = df.freq.apply(lambda x: float('0'+x))
#Create the Band column
df['band']=df.freq.apply(lambda x: band.khz_to_m(x))
# Rename Exchange to state
df.rename(columns={'dxexch':'state'},inplace=True)
#Check what the DataFrame now looks like
df.head()
|
freq |
mode |
when |
mycall |
myrst |
myexch |
dxcall |
dxrst |
state |
txnum |
hour |
ph_hour |
band |
0 |
21022.0 |
CW |
2022-02-19 0001 |
DV3A |
59 |
400 |
K5ZG |
599 |
CO |
0 |
0 |
8 |
15 |
1 |
21030.0 |
CW |
2022-02-19 0002 |
DV3A |
59 |
400 |
K4PV |
599 |
FL |
0 |
0 |
8 |
15 |
2 |
21023.0 |
CW |
2022-02-19 0003 |
DV3A |
59 |
400 |
W8TK |
599 |
AZ |
0 |
0 |
8 |
15 |
3 |
21040.0 |
CW |
2022-02-19 0004 |
DV3A |
59 |
400 |
W7CXX |
599 |
UT |
0 |
0 |
8 |
15 |
4 |
21034.0 |
CW |
2022-02-19 0005 |
DV3A |
59 |
400 |
K6SRZ |
599 |
CA |
0 |
0 |
8 |
15 |
# Activity per hour
when_active=df.ph_hour.unique()
when_active.sort()
print("Active Hours")
for h in when_active:
print(f"\t{h}")
Active Hours
6
7
8
9
10
11
16
17
18
# Activity per hour to the US
df.groupby(['ph_hour']).agg({'band':'count'}).reset_index().rename(columns={"band":"Count"}).set_index('ph_hour')
|
Count |
ph_hour |
|
6 |
25 |
7 |
65 |
8 |
132 |
9 |
54 |
10 |
6 |
11 |
3 |
16 |
3 |
17 |
13 |
18 |
16 |
# Activity per hour to the US per Band
df.groupby(['ph_hour','band']).agg({'state':'count'}).reset_index().rename(columns={"band":"Band"}).set_index('ph_hour')
|
Band |
state |
ph_hour |
|
|
6 |
15 |
2 |
6 |
20 |
23 |
7 |
15 |
53 |
7 |
20 |
12 |
8 |
15 |
130 |
8 |
20 |
2 |
9 |
10 |
1 |
9 |
15 |
31 |
9 |
20 |
22 |
10 |
15 |
1 |
10 |
20 |
5 |
11 |
20 |
3 |
16 |
40 |
3 |
17 |
40 |
13 |
18 |
40 |
16 |
# Create a Pivot table showing when Each State was active
pd.pivot_table(df,index='ph_hour',columns=['state'], aggfunc='count').fillna('-')
|
band |
... |
when |
state |
AB |
AR |
AZ |
BC |
CA |
CO |
FL |
ID |
IL |
IN |
... |
PA |
QC |
SD |
SK |
TN |
TX |
UT |
WA |
WI |
WY |
ph_hour |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
1.0 |
- |
3.0 |
2.0 |
4.0 |
- |
- |
1.0 |
- |
- |
... |
1.0 |
1.0 |
1.0 |
- |
1.0 |
1.0 |
- |
2.0 |
- |
- |
7 |
3.0 |
1.0 |
5.0 |
3.0 |
13.0 |
4.0 |
1.0 |
- |
2.0 |
- |
... |
- |
- |
- |
- |
2.0 |
5.0 |
1.0 |
7.0 |
- |
- |
8 |
2.0 |
1.0 |
12.0 |
3.0 |
34.0 |
6.0 |
4.0 |
2.0 |
3.0 |
- |
... |
1.0 |
- |
- |
1.0 |
- |
10.0 |
3.0 |
15.0 |
3.0 |
1.0 |
9 |
- |
1.0 |
4.0 |
6.0 |
18.0 |
4.0 |
- |
1.0 |
- |
- |
... |
- |
- |
- |
1.0 |
- |
3.0 |
1.0 |
8.0 |
- |
- |
10 |
1.0 |
- |
- |
2.0 |
1.0 |
- |
- |
- |
- |
- |
... |
- |
- |
- |
- |
- |
- |
- |
1.0 |
- |
- |
11 |
- |
- |
- |
- |
1.0 |
- |
- |
- |
- |
- |
... |
- |
- |
- |
- |
- |
- |
- |
1.0 |
- |
- |
16 |
- |
- |
- |
1.0 |
1.0 |
- |
- |
- |
- |
- |
... |
- |
- |
- |
- |
- |
1.0 |
- |
- |
- |
- |
17 |
- |
- |
2.0 |
1.0 |
4.0 |
- |
1.0 |
- |
1.0 |
1.0 |
... |
- |
- |
- |
- |
- |
1.0 |
- |
1.0 |
- |
- |
18 |
- |
- |
3.0 |
3.0 |
3.0 |
1.0 |
1.0 |
- |
1.0 |
- |
... |
- |
- |
- |
- |
- |
- |
- |
1.0 |
- |
- |
9 rows × 440 columns
# Activity per hour to the US per Band
df.groupby(['ph_hour','band']).agg({'state':'count'}).reset_index().rename(columns={"band":"Band"}).set_index('ph_hour')
|
Band |
state |
ph_hour |
|
|
6 |
15 |
2 |
6 |
20 |
23 |
7 |
15 |
53 |
7 |
20 |
12 |
8 |
15 |
130 |
8 |
20 |
2 |
9 |
10 |
1 |
9 |
15 |
31 |
9 |
20 |
22 |
10 |
15 |
1 |
10 |
20 |
5 |
11 |
20 |
3 |
16 |
40 |
3 |
17 |
40 |
13 |
18 |
40 |
16 |