Skip to content

Commit a4d8c67

Browse files
committed
imgs in documentation, tests
1 parent 90db5db commit a4d8c67

8 files changed

Lines changed: 681 additions & 186 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 325 additions & 182 deletions
Large diffs are not rendered by default.

‎docs/DC_SPIKE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ from sdr_dsp import tune_to_baseband
6565
fs = 2e6
6666
hw_center = 433.77e6 # tune 150 kHz LOW of the target
6767
# ... capture iq at hw_center ...
68-
iq = tune_to_baseband(iq, offset_hz=150e3, sample_rate=fs)
68+
iq = tune_to_baseband(iq, sample_rate=fs, offset_hz=150e3)
6969
# signal now at 0 Hz; the DC spike is at -150 kHz — filter or ignore
7070
```
7171

Lines changed: 63 additions & 0 deletions
Loading

‎docs/img/dc_spike_receiver.svg‎

Lines changed: 75 additions & 0 deletions
Loading

‎sdr_dsp/src/sdr_dsp/__init__.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from __future__ import annotations
1212

13-
from typing import Any
13+
from typing import TYPE_CHECKING, Any
1414

1515
from . import core as core # noqa: F401 (importable attribute; not in __all__)
1616
from .core import (
@@ -62,6 +62,13 @@
6262
# partially initialized when `stream` was pulled in). Lazy access keeps
6363
# `sdr_dsp.io`, `sdr_dsp.sinks`, `sdr_dsp.stream`, `sdr_dsp.link`, and `sdr_dsp.Pipeline` working
6464
# identically while removing the fragility.
65+
# Type checkers do not run __getattr__, so without this they would see
66+
# `sdr_dsp.Pipeline` as Any; the block is never executed at runtime.
67+
if TYPE_CHECKING:
68+
from . import io as io, link as link, sinks as sinks, stream as stream
69+
from .stream import Pipeline as Pipeline
70+
71+
6572
def __getattr__(name: str) -> Any:
6673
if name in ("io", "sinks", "stream", "link"):
6774
import importlib

‎sdr_dsp/src/sdr_dsp/core/sync.py‎

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import csv
2121
import os
2222
from dataclasses import dataclass
23-
from typing import Any
23+
from typing import Any, Literal, overload
2424

2525
import numpy as np
2626
from ._validate import one_of, positive
@@ -120,6 +120,45 @@ def _timing_lock_trace(
120120
# ---------------------------------------------------------------------------
121121
# CARRIER RECOVERY
122122
# ---------------------------------------------------------------------------
123+
@overload
124+
def carrier_recovery(
125+
iq: Any,
126+
method: str = "costas",
127+
order: int = 2,
128+
loop_bw: float = 0.01,
129+
damping: float = 0.707,
130+
diagnostics: Literal[False] = False,
131+
csv_path: str | os.PathLike[str] | None = None,
132+
lock_threshold: float = 0.05,
133+
) -> np.ndarray: ...
134+
135+
136+
@overload
137+
def carrier_recovery(
138+
iq: Any,
139+
method: str = "costas",
140+
order: int = 2,
141+
loop_bw: float = 0.01,
142+
damping: float = 0.707,
143+
diagnostics: Literal[True] = ...,
144+
csv_path: str | os.PathLike[str] | None = None,
145+
lock_threshold: float = 0.05,
146+
) -> tuple[np.ndarray, LoopDiagnostics]: ...
147+
148+
149+
@overload
150+
def carrier_recovery(
151+
iq: Any,
152+
method: str = "costas",
153+
order: int = 2,
154+
loop_bw: float = 0.01,
155+
damping: float = 0.707,
156+
diagnostics: bool = ...,
157+
csv_path: str | os.PathLike[str] | None = None,
158+
lock_threshold: float = 0.05,
159+
) -> np.ndarray | tuple[np.ndarray, LoopDiagnostics]: ...
160+
161+
123162
def carrier_recovery(
124163
iq: Any,
125164
method: str = "costas",
@@ -233,6 +272,45 @@ def carrier_recovery(
233272
TED_GAIN = {"gardner": 0.13, "early_late": 0.13, "mueller_muller": 0.30}
234273

235274

275+
@overload
276+
def symbol_sync(
277+
iq: Any,
278+
samples_per_symbol: float,
279+
method: str = "gardner",
280+
loop_bw: float = 0.01,
281+
damping: float = 0.707,
282+
diagnostics: Literal[False] = False,
283+
csv_path: str | os.PathLike[str] | None = None,
284+
lock_threshold: float | None = None,
285+
) -> np.ndarray: ...
286+
287+
288+
@overload
289+
def symbol_sync(
290+
iq: Any,
291+
samples_per_symbol: float,
292+
method: str = "gardner",
293+
loop_bw: float = 0.01,
294+
damping: float = 0.707,
295+
diagnostics: Literal[True] = ...,
296+
csv_path: str | os.PathLike[str] | None = None,
297+
lock_threshold: float | None = None,
298+
) -> tuple[np.ndarray, LoopDiagnostics]: ...
299+
300+
301+
@overload
302+
def symbol_sync(
303+
iq: Any,
304+
samples_per_symbol: float,
305+
method: str = "gardner",
306+
loop_bw: float = 0.01,
307+
damping: float = 0.707,
308+
diagnostics: bool = ...,
309+
csv_path: str | os.PathLike[str] | None = None,
310+
lock_threshold: float | None = None,
311+
) -> np.ndarray | tuple[np.ndarray, LoopDiagnostics]: ...
312+
313+
236314
def symbol_sync(
237315
iq: Any,
238316
samples_per_symbol: float,

‎sdr_dsp/src/sdr_dsp/stream/pipeline.py‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import time
2323
from dataclasses import dataclass, field
24-
from typing import TYPE_CHECKING, Any, Callable, Iterator, Self
24+
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal, Self, overload
2525

2626
import numpy as np
2727

@@ -151,6 +151,46 @@ def flush(self) -> list[np.ndarray]:
151151
tails.append(x)
152152
return tails
153153

154+
@overload
155+
def run(
156+
self,
157+
sink: None = None,
158+
profile: Literal[False] = False,
159+
max_blocks: int | None = None,
160+
) -> list[np.ndarray]: ...
161+
162+
@overload
163+
def run(
164+
self,
165+
sink: Callable[[np.ndarray], Any],
166+
profile: Literal[False] = False,
167+
max_blocks: int | None = None,
168+
) -> None: ...
169+
170+
@overload
171+
def run(
172+
self,
173+
sink: None = None,
174+
profile: Literal[True] = ...,
175+
max_blocks: int | None = None,
176+
) -> tuple[list[np.ndarray], PipelineStats]: ...
177+
178+
@overload
179+
def run(
180+
self,
181+
sink: Callable[[np.ndarray], Any],
182+
profile: Literal[True] = ...,
183+
max_blocks: int | None = None,
184+
) -> tuple[None, PipelineStats]: ...
185+
186+
@overload
187+
def run(
188+
self,
189+
sink: Callable[[np.ndarray], Any] | None = None,
190+
profile: bool = ...,
191+
max_blocks: int | None = None,
192+
) -> list[np.ndarray] | None | tuple[list[np.ndarray] | None, PipelineStats]: ...
193+
154194
def run(
155195
self,
156196
sink: Callable[[np.ndarray], Any] | None = None,

0 commit comments

Comments
 (0)