-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_yaesu_to_baofeng.py
executable file
·133 lines (106 loc) · 2.88 KB
/
convert_yaesu_to_baofeng.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python3
"""Convert a file exported from a Yaesu FTM400 to one that can be imported by a Baofeng UV-5R."""
import sys
import pandas as pd
IFILENAME = sys.argv[1]
OFILENAME = sys.argv[2]
def auto_truncate(val):
"""Truncate the input string to the max length allowed in the Baofeng name field."""
return val[:7]
DF = pd.read_csv(
IFILENAME, sep=",", keep_default_na=False, converters={"Name": auto_truncate}
)
del DF["Unnamed: 17"]
# Column headings in the file exported from RTSystemsYaesu
YAESU_COLUMNS = (
"Channel Number",
"Receive Frequency",
"Transmit Frequency",
"Offset Frequency",
"Offset Direction",
"Operating Mode",
"Name",
"Show Name",
"Tone Mode",
"CTCSS",
"DCS",
"Tx Power",
"Skip",
"Step",
"Clock Shift",
"Comment",
"User CTCSS",
)
# Column headings expected in the file imported into chirp/Baofeng
BAOFENG_COLUMNS = (
"Location",
"Name",
"Frequency",
"Duplex",
"Offset",
"Tone",
"rToneFreq",
"cToneFreq",
"DtcsCode",
"DtcsPolarity",
"Mode",
"TStep",
"Skip",
"Comment",
"URCALL",
"RPT1CALL",
"RPT2CALL",
"DVCODE",
)
for actual in DF.columns:
assert actual in YAESU_COLUMNS, f"{actual} not recognized"
df_out = pd.DataFrame(columns=BAOFENG_COLUMNS) # pylint: disable-msg=C0103
# Populate the Location column
df_out["Location"] = DF["Channel Number"] - 1
# Populate the Name column
df_out["Name"] = DF["Name"]
# Populate the Frequency column
df_out["Frequency"] = DF["Receive Frequency"]
# Populate the Duplex column
df_out["Duplex"] = (
DF["Offset Direction"]
.replace("Simplex", "")
.replace("Minus", "-")
.replace("Plus", "+")
)
# Populate the Offset column
df_out["Offset"] = (
DF["Offset Frequency"].replace("5.00 MHz", "5").replace("600 kHz", "0.6")
)
# Populate the Tone column
df_out["Tone"] = DF["Tone Mode"].replace("None", "")
# Populate the rToneFreq column
df_out["rToneFreq"] = DF["CTCSS"]
for ndx, s in enumerate(df_out["rToneFreq"]):
df_out.at[ndx, "rToneFreq"] = s.replace(" Hz", "")
# Populate the cToneFreq column
df_out["cToneFreq"] = df_out["rToneFreq"]
# Populate the DtcsCode column
df_out["DtcsCode"] = "23"
# Populate the DtcsPolarity column
df_out["DtcsPolarity"] = "NN"
# Populate the Mode column
df_out["Mode"] = DF["Operating Mode"]
# Populate the TStep column
df_out["TStep"] = "5"
# Populate the Skip column
# df_out["Skip"] = (
# DF["Skip"].replace("Off", "").replace("Select", "").replace("Skip", "S")
# )
df_out["Skip"] = ""
# Populate the Comment column
df_out["Comment"] = "" # DF["Comment"]
# Populate the URCALL column
df_out["URCALL"] = ""
# Populate the RPT1CALL column
df_out["RPT1CALL"] = ""
# Populate the RPT2CALL column
df_out["RPT2CALL"] = ""
# Populate the DVCODE column
df_out["DVCODE"] = ""
df_out.to_csv(OFILENAME, sep=",", columns=BAOFENG_COLUMNS, index=False)