Skip to content

Commit

Permalink
Merge pull request #1027 from anarkiwi/offline
Browse files Browse the repository at this point in the history
Offline
  • Loading branch information
anarkiwi authored Dec 8, 2023
2 parents b4c7977 + 730a3f4 commit 6308833
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 24 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ jobs:
docker build -f docker/Dockerfile.base docker -t iqtlabs/gamutrf-base:latest
docker build -f Dockerfile . -t iqtlabs/gamutrf:latest
docker build -f docker/Dockerfile.torchsig . -t iqtlabs/gamutrf-torchsig:latest
docker run -t iqtlabs/gamutrf:latest gamutrf-compress_dirs --help
docker run -t iqtlabs/gamutrf:latest gamutrf-freqxlator --help
docker run -t iqtlabs/gamutrf:latest gamutrf-offline --help
docker run -t iqtlabs/gamutrf:latest gamutrf-samples2raw --help
docker run -t iqtlabs/gamutrf:latest gamutrf-scan --help
docker run -t iqtlabs/gamutrf:latest gamutrf-sigfinder --help
docker run -t iqtlabs/gamutrf:latest gamutrf-worker --help
docker run -t iqtlabs/gamutrf:latest gamutrf-samples2raw --help
docker run -t iqtlabs/gamutrf:latest gamutrf-freqxlator --help
docker run -t iqtlabs/gamutrf:latest gamutrf-waterfall --help
docker run -t iqtlabs/gamutrf:latest gamutrf-compress_dirs --help
docker run -t iqtlabs/gamutrf:latest gamutrf-worker --help
sudo apt-get update && sudo apt-get install -qy python3-pip
docker compose -f orchestrator.yml -f worker.yml -f docker/monitoring.yml -f specgram.yml build
18 changes: 12 additions & 6 deletions gamutrf/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
"""Main entrypoint for GamutRF"""
from gamutrf.worker import main as worker_main
from gamutrf.compress_dirs import main as compress_dirs_main
from gamutrf.freqxlator import main as freqxlator_main
from gamutrf.offline import main as offline_main
from gamutrf.samples2raw import main as samples2raw_main
from gamutrf.scan import main as scan_main
from gamutrf.sigfinder import main as sigfinder_main
from gamutrf.specgram import main as specgram_main
from gamutrf.waterfall import main as waterfall_main


def worker():
"""Entrypoint for worker"""
worker_main()
from gamutrf.worker import main as worker_main


def compress_dirs():
Expand All @@ -24,6 +20,11 @@ def freqxlator():
freqxlator_main()


def offline():
"""Entrypoint for offline"""
offline_main()


def samples2raw():
"""Entrypoint for samples2raw"""
samples2raw_main()
Expand All @@ -47,3 +48,8 @@ def specgram():
def waterfall():
"""Entrypoint for waterfall"""
waterfall_main()


def worker():
"""Entrypoint for worker"""
worker_main()
5 changes: 4 additions & 1 deletion gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def __init__(
pretune,
)
self.fft_blocks = fft_blocks + self.get_db_blocks(nfft, samp_rate, scaling)
fft_dir = sample_dir
if not write_samples:
fft_dir = ""
retune_fft = self.iqtlabs.retune_fft(
"rx_freq",
nfft,
Expand All @@ -181,7 +184,7 @@ def __init__(
skip_tune_step,
db_clamp_floor,
db_clamp_ceil,
sample_dir,
fft_dir,
write_samples,
bucket_range,
tuning_ranges,
Expand Down
3 changes: 3 additions & 0 deletions gamutrf/grsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def work(self, input_items, output_items):
self.need_tags = False
n = len(output_items[0])
samples = self.samples[self.i : self.i + n]
if len(samples) < n:
self.i = self.n_samples
return 0
self.i += len(samples)
output_items[0][:] = samples
return len(samples)
Expand Down
88 changes: 88 additions & 0 deletions gamutrf/offline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/python3
from argparse import ArgumentParser, BooleanOptionalAction
import os
import logging
import tempfile
import time

from gnuradio import iqtlabs
from gamutrf.grscan import grscan
from gamutrf.sample_reader import parse_filename


def argument_parser():
parser = ArgumentParser()
parser.add_argument("filename", type=str, help="Recording filename")
parser.add_argument(
"--tune-step-fft",
dest="tune_step_fft",
type=int,
default=512,
help="tune FFT step [default=%(default)r]",
)
parser.add_argument(
"--vkfft",
dest="vkfft",
default=True,
action=BooleanOptionalAction,
help="use VkFFT",
)
parser.add_argument(
"--db_clamp_floor",
dest="db_clamp_floor",
type=float,
default=-150,
help="clamp dB output floor",
)
parser.add_argument(
"--db_clamp_ceil",
dest="db_clamp_ceil",
type=float,
default=50,
help="clamp dB output ceil",
)
parser.add_argument(
"--nfft",
dest="nfft",
type=int,
default=1024,
help="FFTI size [default=%(default)r]",
)
parser.add_argument(
"--n_image",
dest="n_image",
type=int,
default=10,
help="if > 1, only log 1/n images",
)
return parser


def main():
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(message)s")
options = argument_parser().parse_args()
filename = options.filename
out_dir = os.path.dirname(filename)
meta = parse_filename(filename)
tb = grscan(
db_clamp_floor=-1e9,
fft_batch_size=256,
freq_end=0,
freq_start=meta["freq_center"],
inference_min_db=-1e9,
inference_output_dir=out_dir,
iqtlabs=iqtlabs,
n_image=options.n_image,
nfft=options.nfft,
pretune=True,
samp_rate=meta["sample_rate"],
sample_dir=out_dir,
sdr="file:" + filename,
tune_step_fft=options.tune_step_fft,
vkfft=options.vkfft,
)
tb.start()
while not tb.sources[0].complete():
time.sleep(1)
tb.stop()
tb.wait()
25 changes: 12 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,50 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
"RPi.GPIO" = {version = "0.7.1", markers = "platform_machine != 'aarch64'"}
Flask = "3.0.0"
Jinja2 = "3.1.2"
bjoern = "3.2.2"
cairocffi = "^1.3.0"
falcon = "3.1.3"
falcon-cors = "1.1.7"
gpsd-py3 = "0.3.0"
Jinja2 = "3.1.2"
matplotlib = "3.8.2"
numpy = "1.26.2"
paho-mqtt = "1.6.1"
pandas = "2.1.3"
prometheus_client = "0.19.0"
pycairo = "^1.21.0"
python = ">=3.9,<3.13"
pyzmq = "^25.1.0"
requests = "2.31.0"
"RPi.GPIO" = {version = "0.7.1", markers = "platform_machine != 'aarch64'"}
schedule = "1.2.1"
scipy = "1.11.4"
sigmf = "1.1.3"
zstandard = "0.22.0"
pycairo = "^1.21.0"
cairocffi = "^1.3.0"
Flask = "3.0.0"
sysrsync = "^1.1.1"
pyzmq = "^25.1.0"
zstandard = "0.22.0"

[tool.poetry.dev-dependencies]
attr = "0.3.2"
attrs = "23.1.0"
black = "23.11.0"
docker = "6.1.3"
pdbpp = "^0.10.3"
pylint = "3.0.2"
pytest = "7.4.3"
pytest-cov = "4.1.0"
pytype = "2023.12.7"
pdbpp = "^0.10.3"

[tool.poetry.scripts]
gamutrf-worker = 'gamutrf.__main__:worker'
gamutrf-compress_dirs = 'gamutrf.__main__:compress_dirs'
gamutrf-freqxlator = 'gamutrf.__main__:freqxlator'
gamutrf-offline= 'gamutrf.__main__:offline'
gamutrf-samples2raw = 'gamutrf.__main__:samples2raw'
gamutrf-scan = 'gamutrf.__main__:scan'

gamutrf-sigfinder = 'gamutrf.__main__:sigfinder'
gamutrf-specgram = 'gamutrf.__main__:specgram'
gamutrf-compress_dirs = 'gamutrf.__main__:compress_dirs'

gamutrf-waterfall = 'gamutrf.__main__:waterfall'
gamutrf-worker = 'gamutrf.__main__:worker'

[tool.poetry.urls]
homepage = "https://github.com/IQTLabs/gamutRF"
Expand Down

0 comments on commit 6308833

Please sign in to comment.