Skip to content

Commit d8f9be0

Browse files
committed
Fix broken links in README. Fix broken parameter in annotate.
1 parent 6f7ce8c commit d8f9be0

7 files changed

+41
-41
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ annotation_utils.annotate(
100100
avg_window_len=256, # The number of samples over which to average signal power
101101
avg_duration=0.25, # The number of seconds, from the start of the recording to use to automatically calculate the SNR threshold, if it is None then all of the samples will be used
102102
debug=False,
103-
estimate_frequency=True, # Whether the frequency bounds for an annotation should be calculated. estimate_frequency needs to be enabled if you use min/max_bandwidth
103+
set_bandwidth=10000000, # Manually set the bandwidth of the signals in Hz, if this parameter is set, then spectral_energy_threshold is ignored
104104
spectral_energy_threshold=0.95, # Percentage used to determine the upper and lower frequency bounds for an annotation
105105
force_threshold_db=-58, # Used to manually set the threshold used for detecting a signal and creating an annotation. If None, then the automatic threshold calculation will be used instead.
106106
overwrite=False, # If True, any existing annotations in the .sigmf-meta file will be removed
@@ -138,7 +138,7 @@ After you have finished labeling your data, the next step is to train a model on
138138

139139
### Configure
140140

141-
This repo provides an automated script for training and evaluating models. To do this, configure the [run_experiments.py](./run_experiments.py) file to point to the data you want to use and set the training parameters:
141+
This repo provides an automated script for training and evaluating models. To do this, configure the [run_experiments.py](rfml/run_experiments.py) file to point to the data you want to use and set the training parameters:
142142

143143
```python
144144
"experiment_0": { # A name to refer to the experiment
@@ -186,29 +186,29 @@ This will generate a **.mar** file in the [models/](./models/) folder. [GamutRF]
186186
## Files
187187

188188

189-
[annotation_utils.py](annotation_utils.py) - DSP based automated labelling tools
189+
[annotation_utils.py](rfml/annotation_utils.py) - DSP based automated labelling tools
190190

191-
[auto_label.py](auto_label.py) - CV based automated labelling tools
191+
[auto_label.py](rfml/auto_label.py) - CV based automated labelling tools
192192

193-
[data.py](data.py) - RF data operations tool
193+
[data.py](rfml/data.py) - RF data operations tool
194194

195-
[experiment.py](experiment.py) - Class to manage experiments
195+
[experiment.py](rfml/experiment.py) - Class to manage experiments
196196

197-
[models.py](models.py) - Class for I/Q models (based on TorchSig)
197+
[models.py](rfml/models.py) - Class for I/Q models (based on TorchSig)
198198

199-
[run_experiments.py](run_experiments.py) - Experiment configurations and run script
199+
[run_experiments.py](rfml/run_experiments.py) - Experiment configurations and run script
200200

201-
[sigmf_pytorch_dataset.py](sigmf_pytorch_dataset.py) - PyTorch style dataset class for SigMF data (based on TorchSig)
201+
[sigmf_pytorch_dataset.py](rfml/sigmf_pytorch_dataset.py) - PyTorch style dataset class for SigMF data (based on TorchSig)
202202

203-
[spectrogram.py](spectrogram.py) - Spectrogram tools
203+
[spectrogram.py](rfml/spectrogram.py) - Spectrogram tools
204204

205-
[test_data.py](test_data.py) - Test for data.py (might be outdated)
205+
[test_data.py](rfml/test_data.py) - Test for data.py (might be outdated)
206206

207-
[train_iq.py](train_iq.py) - Training script for I/Q models
207+
[train_iq.py](rfml/train_iq.py) - Training script for I/Q models
208208

209-
[train_spec.py](train_spec.py) - Training script for spectrogram models
209+
[train_spec.py](rfml/train_spec.py) - Training script for spectrogram models
210210

211-
[zst_parse.py](zst_parse.py) - ZST file parsing tool, for GamutRF-style filenames
211+
[zst_parse.py](rfml/zst_parse.py) - ZST file parsing tool, for GamutRF-style filenames
212212

213213
The [notebooks/](./notebooks/) directory contains various experiments we have conducted during development.
214214

label_scripts/label_env.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
for label in data_globs:
2525
for data_glob in data_globs[label]:
2626
for f in tqdm(glob.glob(str(Path(data_glob)))):
27-
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
27+
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
2828

2929
data_obj = data_class.Data(f)
3030
annotation_utils.reset_annotations(data_obj)
@@ -34,7 +34,6 @@
3434
avg_window_len=256,
3535
avg_duration=0.10,
3636
debug=False,
37-
estimate_frequency=True,
3837
spectral_energy_threshold=0.90,
3938
# force_threshold_db=-48,
4039
overwrite=True,

label_scripts/label_mavic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
for label in data_globs:
2424
for data_glob in data_globs[label]:
2525
for f in tqdm(glob.glob(str(Path(data_glob)))):
26-
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
26+
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
2727

2828
print(f"\nAnnotating {f}\n-----------------------------------\n")
2929

@@ -35,7 +35,6 @@
3535
# avg_window_len=256,
3636
# avg_duration=0.10,
3737
# debug=False,
38-
# estimate_frequency=True,
3938
# spectral_energy_threshold=0.90,
4039
# #force_threshold_db=-48,
4140
# overwrite=True,
@@ -51,7 +50,6 @@
5150
avg_window_len=256,
5251
avg_duration=0.25,
5352
debug=False,
54-
estimate_frequency=True,
5553
spectral_energy_threshold=0.99,
5654
force_threshold_db=-58,
5755
overwrite=True,

label_scripts/label_mini2.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
for label in data_globs:
2222
for data_glob in data_globs[label]:
2323
for f in tqdm(glob.glob(str(Path(data_glob)))):
24-
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
24+
# annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.99, force_threshold_db=-40)
2525

2626
data_obj = data_class.Data(f)
2727
annotation_utils.reset_annotations(data_obj)
@@ -31,7 +31,6 @@
3131
avg_window_len=256,
3232
avg_duration=0.25,
3333
debug=False,
34-
estimate_frequency=True,
3534
spectral_energy_threshold=0.95,
3635
force_threshold_db=-58,
3736
overwrite=False,
@@ -46,7 +45,6 @@
4645
avg_window_len=256,
4746
avg_duration=0.25,
4847
debug=False,
49-
estimate_frequency=True,
5048
spectral_energy_threshold=0.95,
5149
force_threshold_db=-58,
5250
overwrite=False,

label_scripts/label_nz_wifi_multiprocessing.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def try_fn():
7373
"filename": f,
7474
"label": label[0],
7575
"avg_duration": 3,
76-
"estimate_frequency": label[1],
76+
"set_bandwidth": label[1],
7777
"time_start_stop": 5,
7878
}
7979
)
@@ -89,11 +89,7 @@ def try_fn():
8989
resource.setrlimit(resource.RLIMIT_AS, (memory_limit, memory_limit))
9090

9191
pool = Pool(16)
92-
# common_args = {
93-
# 'avg_duration':3,
94-
# 'estimate_frequency':
95-
# 'time_start_stop': 5,
96-
# }
92+
9793
# pool.starmap(partial(annotation_utils.annotate, **common_args), job_args)
9894

9995

notebooks/Label_DJI.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@
370370
"for label in data_globs:\n",
371371
" for data_glob in data_globs[label]:\n",
372372
" for f in tqdm(glob.glob(str(Path(data_glob)))):\n",
373-
" # annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.99, force_threshold_db=-40)\n",
373+
" # annotation_utils.annotate(f, label=label, avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.99, force_threshold_db=-40)\n",
374374
" print(f\"{f=}\")\n",
375375
" data_obj = data_class.Data(f)\n",
376376
" annotation_utils.reset_annotations(data_obj)\n",
377-
" annotation_utils.annotate(f, label=\"mini2_video\", avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.95, force_threshold_db=-58, overwrite=False, min_bandwidth=16e6, min_annotation_length=10000, max_annotations=10, dc_block=True, verbose=False, dry_run=True)\n",
378-
" annotation_utils.annotate(f, label=\"mini2_telem\", avg_window_len=256, avg_duration=0.25, debug=True, estimate_frequency=True, spectral_energy_threshold=0.95, force_threshold_db=-58, overwrite=False, max_bandwidth=16e6, min_annotation_length=10000, max_annotations=10, dc_block=True, verbose=False, dry_run=True)\n",
377+
" annotation_utils.annotate(f, label=\"mini2_video\", avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.95, force_threshold_db=-58, overwrite=False, min_bandwidth=16e6, min_annotation_length=10000, max_annotations=10, dc_block=True, verbose=False, dry_run=True)\n",
378+
" annotation_utils.annotate(f, label=\"mini2_telem\", avg_window_len=256, avg_duration=0.25, debug=True, spectral_energy_threshold=0.95, force_threshold_db=-58, overwrite=False, max_bandwidth=16e6, min_annotation_length=10000, max_annotations=10, dc_block=True, verbose=False, dry_run=True)\n",
379379
" "
380380
]
381381
},

rfml/annotation_utils.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def annotate_power_squelch(
4848
avg_window_len,
4949
label=None,
5050
skip_validate=False,
51-
estimate_frequency=False,
51+
spectral_energy_threshold=False,
5252
dry_run=False,
5353
min_annotation_length=400,
5454
min_bandwidth=None,
@@ -59,6 +59,7 @@ def annotate_power_squelch(
5959
verbose=False,
6060
n_seek_samples=None,
6161
n_samples=None,
62+
set_bandwidth=None,
6263
):
6364
iq_samples = data_obj.get_samples(
6465
n_seek_samples=n_seek_samples, n_samples=n_samples
@@ -73,17 +74,23 @@ def annotate_power_squelch(
7374
if min_annotation_length and (stop - start < min_annotation_length):
7475
continue
7576

76-
if isinstance(estimate_frequency, bool):
77-
if estimate_frequency:
78-
estimate_frequency = 0.94
79-
else:
80-
estimate_frequency = None
81-
if isinstance(estimate_frequency, float):
77+
if isinstance(spectral_energy_threshold, bool) and spectral_energy_threshold:
78+
spectral_energy_threshold = 0.94
79+
80+
if set_bandwidth:
81+
freq_lower_edge = (
82+
data_obj.metadata["captures"][0]["core:frequency"] - set_bandwidth / 2
83+
)
84+
freq_upper_edge = (
85+
data_obj.metadata["captures"][0]["core:frequency"] + set_bandwidth / 2
86+
)
87+
88+
elif isinstance(spectral_energy_threshold, float):
8289
freq_lower_edge, freq_upper_edge = get_occupied_bandwidth(
8390
iq_samples[start:stop],
8491
data_obj.metadata["global"]["core:sample_rate"],
8592
data_obj.metadata["captures"][0]["core:frequency"],
86-
spectral_energy_threshold=estimate_frequency,
93+
spectral_energy_threshold=spectral_energy_threshold,
8794
dc_block=dc_block,
8895
verbose=verbose,
8996
)
@@ -141,7 +148,7 @@ def annotate(
141148
debug=False,
142149
dry_run=False,
143150
min_annotation_length=400,
144-
estimate_frequency=True,
151+
spectral_energy_threshold=True,
145152
force_threshold_db=None,
146153
overwrite=True,
147154
min_bandwidth=None,
@@ -150,6 +157,7 @@ def annotate(
150157
dc_block=None,
151158
verbose=False,
152159
time_start_stop=None,
160+
set_bandwidth=None,
153161
):
154162

155163
data_obj = data_class.Data(filename)
@@ -249,7 +257,7 @@ def median_absolute_deviation(series):
249257
avg_window_len,
250258
label=label,
251259
skip_validate=True,
252-
estimate_frequency=estimate_frequency,
260+
spectral_energy_threshold=spectral_energy_threshold,
253261
min_bandwidth=min_bandwidth,
254262
max_bandwidth=max_bandwidth,
255263
dry_run=dry_run,
@@ -260,6 +268,7 @@ def median_absolute_deviation(series):
260268
verbose=verbose,
261269
n_seek_samples=n_seek_samples,
262270
n_samples=n_samples,
271+
set_bandwidth=set_bandwidth,
263272
)
264273

265274

0 commit comments

Comments
 (0)