Chase
softlora.chase
Chase (soft-decision) decoding for LoRa payload symbols.
Port of the Chase decoder used by the real-signal multi-receiver decoder
(lorab_receiver): given the per-symbol FFT power spectra of the payload,
a hard decision is taken and the least-reliable symbols/bits are probed with
alternative candidates until decode_fn accepts one.
Two stages are tried, in order:
- Symbol-level Chase -- each symbol's spectrum is reduced to its top-K
bins; the ratio of the top bin to the second bin is the reliability.
The max-likelihood (argmax) symbol vector is tried first; if it fails,
single, pair and triple symbol flips among the least-reliable positions are
tried, ranked by their
-log(power ratio)cost. - Bit-level Chase -- symbol spectra are converted to per-bit LLRs; the least-reliable bits are flipped one at a time, then in pairs, and each candidate is re-decoded.
decode_fn is the injected success predicate (e.g. full payload decode
with a valid CRC-16), so this module is agnostic to the exact coding scheme.
chase_decode(spectra, decode_fn, *, sf, offset=0, K=5, reliability_thresh=15.0, max_flip_pos=6, max_attempts=120, max_bit_flips=40, max_pair_flips=15, enable_bit_chase=True)
Chase-decode payload symbols from their FFT power spectra.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectra
|
ndarray
|
(num_syms, N_bins) per-symbol FFT power spectra. The hard symbol
value for symbol m is taken as |
required |
decode_fn
|
callable
|
|
required |
sf
|
int
|
Spreading factor (needed for the bit-level stage). |
required |
offset
|
int
|
Bin offset applied when converting spectra to symbol values.
|
0
|
K
|
int
|
Number of top bins considered per symbol. |
5
|
reliability_thresh
|
float
|
Symbols with reliability below this value are treated as ambiguous flip positions. |
15.0
|
max_flip_pos
|
int
|
Maximum number of least-reliable symbol positions to flip. |
6
|
max_attempts
|
int
|
Maximum symbol-level candidates tried. |
120
|
max_bit_flips
|
int
|
Maximum number of single-bit flips tried in the bit-level stage. |
40
|
max_pair_flips
|
int
|
Maximum number of bit-pair flips tried in the bit-level stage. |
15
|
enable_bit_chase
|
bool
|
Set False to skip the bit-level stage. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
ok |
bool
|
True if a candidate decoded successfully. |
symbols |
ndarray or None
|
The accepted symbol vector ( |
info |
dict
|
Debug info: attempts, labels tried, and which stage succeeded. |
Source code in softlora/chase.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
spectra_to_probs(spectra)
Normalize per-symbol power spectra into probability vectors.
Rows with zero total power carry no information and become uniform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectra
|
ndarray
|
(num_syms, N_bins) non-negative FFT power spectra. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
(num_syms, N_bins) rows normalized to sum to 1. |