@@ -118,6 +118,125 @@ adifmt fix log1.adi \
118
118
creates a file named ` minimal.csv` with just the date, time, and callsign from
119
119
each record in the input file ` log1.adi` .
120
120
121
+ # # Practical examples
122
+
123
+ The following examples transform data into a format expected by a particular
124
+ program or ham radio activity. For details on how they work, see documentation
125
+ for individual commands or formats below. For contest log examples, see the
126
+ [Cabrillo](# cabrillo) section. Contributions of useful pipelines are welcome.
127
+
128
+ # ## Add station and location to a log
129
+
130
+ This example uses ` edit` to add several fields to a POTA log saved in CSV
131
+ format. It then uses ` fix` to remove the ` :` from the time, transform the
132
+ decimal (GPS) latitude and longitude to ADIF sexagesimal format and transforms
133
+ ` USA` and ` CAN` country abbreviations to DXCC entity numbers. ` flatten` makes
134
+ two copies of each record, one for park ` US-0791` and one for park ` US-4567` .
135
+ ` infer` then sets the band from the frequency, grid square (Maidenhead locator)
136
+ based on the latitude and longitude, ` STATION_CALLSIGN` field to the ` OPERATOR`
137
+ field, and ` SIG` and ` SIG_INFO` from the ` POTA_REF` field. (POTA doesn' t
138
+ require the country or latitude/longitude fields; they' re included for
139
+ illustration.) The input log might look like this:
140
+
141
+ ` ` ` csv
142
+ TIME_ON,FREQ,MODE,CALL,STATE,COUNTRY
143
+ 12:34,7.012,CW,W1AW,CT,USA
144
+ 12:56,14.234,SSB,VA1XYZ,NS,CAN
145
+ ` ` `
146
+
147
+ ` ` ` sh
148
+ adiifmt edit mylog.csv \
149
+ --add qso_date=20240704 \
150
+ --add operator=WT0RJ \
151
+ --add my_pota_ref=US-0791,US-4567 \
152
+ --add my_state=DC --add my_country=USA \
153
+ --add my_lat=38.899736 --add my_lon=-77.063331 \
154
+ | adifmt fix \
155
+ | adifmt flatten --fields pota_ref,my_pota_ref \
156
+ | adifmt infer --fields band,my_gridsquare,station_callsign
157
+ ` ` `
158
+
159
+ # ## ADIF to SOTA CSV
160
+
161
+ This example uses ` find` to filter out any records which don’t have ` SOTA_REF`
162
+ or ` MY_SOTA_REF` fields, ` edit` to add a ` V2` field to each record (required by
163
+ the SOTA uploader), ` select` to output only the fields expected by the SOTA
164
+ uploader and in the right order, ` validate` to ensure fields are present and
165
+ correctly formatted, and ` save --csv-omit-header` to create a file with just
166
+ the records, no file header. If your log lacks frequencies, replace the ` freq`
167
+ field with ` band` . (Note that the SOTA uploader now accepts ADIF files, so you
168
+ could just use the ` find` command and upload directly. This example may be
169
+ useful if the data need to be further transformed or imported by a SOTA data
170
+ analysis program.)
171
+
172
+ ` ` ` sh
173
+ SOTA_CSV_ORDER=version,station_callsign,my_sota_ref,qso_date,time_on,freq,mode,call,sota_ref,comment
174
+ adifmt find mylog.adi --if-not ' my_sota_ref=' --or-if-not ' sota_ref=' \
175
+ | adifmt edit --set version=V2 \
176
+ | adifmt select --fields $SOTA_CSV_ORDER \
177
+ | adifmt validate --required-fields station_callsign,qso_date,time_on,freq,mode,call \
178
+ | adifmt save --csv-omit-header --field-order $SOTA_CSV_ORDER sotalog.csv
179
+ ` ` `
180
+
181
+ The variable assignment syntax for ` SOTA_CSV_ORDER` works on Mac and Linux. On
182
+ Windows PowerShell assign the variable as ` $SOTA_CSV_ORDER =
183
+ version,station_callsign,...` . On Windows cmd.exe, assign it as
184
+ ` set SOTA_CSV_ORDER = version,station_callsign,...` and reference it as
185
+ ` %SOTA_CSV_ORDER%` rather than the ` $` prefix.
186
+
187
+ # ## Filter WARC bands
188
+
189
+ This example uses ` infer` to set the band from the frequency if the former
190
+ isn’t set. It then uses ` find` to filter out any contacts made on the
191
+ [WARC bands](https://en.wikipedia.org/wiki/WARC_bands): 12, 17, 30, and 60
192
+ meters. Contesting is not allowed on those bands, so this is useful when
193
+ preparing a contest submission from a general station log where contacts may
194
+ have been made on bands not part of the contest.
195
+
196
+ ` ` ` sh
197
+ adifmt infer --fields band mylog.adi \
198
+ | adifmt find --if-not ' band=60m|30m|17m|12m'
199
+ ` ` `
200
+
201
+ # ## Set mode from frequency (U.S. band plan)
202
+
203
+ This example sets the mode and submode based on the frequency, according to the
204
+ U.S. band plan. It assumes that CW and SSB are the only modes in use (no FM,
205
+ AM, or digital), but can be extended if there are frequency ranges that you use
206
+ exclusively for one mode. ` edit --add` will not overwrite the mode if it
207
+ already has a value (` edit --set` would force the new value).
208
+
209
+ ` ` ` sh
210
+ # US HF SSB (overlaps SSTV & AM) 80m: 3.6:4, 40m: 7.125:7.3, 20m:14.15:14.35,
211
+ # 17m:18.11:18.168, 15m:21.2:21.45, 12m:24.93 to 24.99, 10m: 28.3:29
212
+ # 6m 50.1:50.3 is CW/SSB, SSB calling 60.125, assume 60.120+ is SSB
213
+ adifmt edit --if ' freq>3.6' --if ' freq<4' \
214
+ --or-if ' freq>7.125' --if ' freq<=7.3' \
215
+ --or-if ' freq>=14.15' --if ' freq<14.35' \
216
+ --or-if ' freq>=18.11' --if ' freq<18.168' \
217
+ --or-if ' freq>=21.2' --if ' freq<21.45' \
218
+ --or-if ' freq>=24.93' --if ' freq<24.99' \
219
+ --or-if ' freq>=28.3' --if ' freq<29' \
220
+ --or-if ' freq>=50.12' --if ' freq<50.3' \
221
+ --add mode=SSB | \
222
+
223
+ # US HF CW (some digital could occur) low end of the band, below FT8 and friends
224
+ adifmt edit --if ' freq>3.5' --if ' freq<3.7' \
225
+ --or-if ' freq>7' --if ' freq<7.07' \
226
+ --or-if ' freq>10.1' --if ' freq<10.3' \
227
+ --or-if ' freq>14' --if ' freq<14.07' \
228
+ --or-if ' freq>18.068' --if ' freq<18.1' \
229
+ --or-if ' freq>21' --if ' freq<21.07' \
230
+ --or-if ' freq>24.89' --if ' freq<14.91' \
231
+ --or-if ' freq>28' --if ' freq<28.07' \
232
+ --or-if ' freq>50.1' --if ' freq<50.12' \
233
+ --add mode=CW | \
234
+
235
+ # SSB is usually LSB on 40m and below except 60m, USB on 20m and above
236
+ adifmt edit --if mode=SSB --if ' freq<8' --if-not band=60m --add submode=LSB | \
237
+ adifmt edit --if mode=SSB --if ' freq>=14' --or-if band=60m --add submode=USB
238
+ ` ` `
239
+
121
240
# # Features
122
241
123
242
# ## Input/Output formats
@@ -559,7 +678,7 @@ and a change:
559
678
560
679
` ` ` sh
561
680
adifmt cat mylog.adi \
562
- | adifmt edit --if ' mode=SSB' --if ' band>=20m' --add ' submode=USB' \
681
+ | adifmt edit --if ' mode=SSB' --if ' band>=20m' --or-if ' band=60m ' -- add ' submode=USB' \
563
682
| adifmt edit --if ' mode=SSB' --if ' band=40m|80m|160m' --add ' submode=LSB' \
564
683
| adifmt save fixed_sideband.adi
565
684
` ` `
@@ -613,8 +732,8 @@ contacts on the border of a square as separate:
613
732
614
733
` ` ` sh
615
734
adifmt flatten --fields VUCC_GRIDS --output tsv \
616
- | adifmt select --fields VUCC_GRIDS --output tsv \
617
- | tail +2 | sort | uniq -c
735
+ | adifmt select --fields VUCC_GRIDS --output tsv --tsv-omit-header \
736
+ | sort | uniq -c
618
737
` ` `
619
738
620
739
The ` flatten` command will turn
@@ -762,8 +881,8 @@ find duplicate QSOs by date, band, and mode, use
762
881
[uniq](https://man7.org/linux/man-pages/man1/uniq.1.html):
763
882
764
883
```sh
765
- adifmt select --fields call,qso_date,band,mode --output tsv mylog.adi \
766
- | tail +2 | sort | uniq -d
884
+ adifmt select --fields call,qso_date,band,mode --output tsv --tsv-omit-header mylog.adi \
885
+ | sort | uniq -d
767
886
```
768
887
769
888
This is similar to a SQL `SELECT` clause, except it cannot (yet?) transform the
@@ -846,6 +965,7 @@ Features I plan to add:
846
965
the same callsign on the same band with the same mode on the same Zulu day
847
966
and the same ` MY_SIG_INFO` value.
848
967
* Option for ` save` to append records to an existing ADIF file.
968
+ * [FLE (fast log entry)](https://df3cb.com/fle/documentation/) format support.
849
969
* Count the total number of records or the number of distinct values of a
850
970
field. (The total number of records can currently be counted with
851
971
` --output=tsv --tsv-omit-header` and piping the output to ` wc -l` .) This
0 commit comments