Skip to content

Commit

Permalink
Merge commit '69a5b8a' into chad-2025.01.01
Browse files Browse the repository at this point in the history
  • Loading branch information
happycube committed Jan 1, 2025
2 parents 9ece493 + 69a5b8a commit 280aa89
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lddecode/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .utils import LRUupdate, clb_findbursts, angular_mean_helper, phase_distance
from .utils import build_hilbert, unwrap_hilbert, emphasis_iir, filtfft
from .utils import fft_do_slice, fft_determine_slices, StridedCollector, hz_to_output_array
from .utils import Pulse, nb_std, nb_gt, n_ornotrange, nb_concatenate
from .utils import Pulse, nb_std, nb_gt, n_ornotrange, nb_concatenate, gen_bpf_supergauss

try:
# If Anaconda's numpy is installed, mkl will use all threads for fft etc
Expand Down Expand Up @@ -446,6 +446,7 @@ def computeefmfilter(self):
)

self.Filters["Fefm"] = coeffs * 8
self.Filters["Fefm"] *= gen_bpf_supergauss(20000, 1600000, 60, 20000000, 32768)

# Lambda-scale functions used to simplify following filter builders

Expand Down
21 changes: 21 additions & 0 deletions lddecode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,27 @@ def calczc(data, _start_offset, target, edge=0, count=10, reverse=False):
return calczc_do(data, _start_offset, target, edge, count)


# copied from vhs-decode

def gen_bpf_supergauss(freq_low, freq_high, order, nyquist_hz, block_len):
sg = supergauss(
np.linspace(0, nyquist_hz, block_len // 2 + 1),
freq_high - freq_low,
order,
(freq_high + freq_low) / 2.0,
)[:-1]

return np.concatenate([sg, np.flip(sg)])

def supergauss(x, freq, order=1, centerfreq=0):
return np.exp(
-2
* np.power(
(2 * (x - centerfreq) * (math.log(2.0) / 2.0) ** (1 / (2 * order))) / freq,
2 * order,
)
)

# Shamelessly based on https://github.com/scipy/scipy/blob/v1.6.0/scipy/signal/signaltools.py#L2264-2267
# ... and intended for real FFT, but seems fine with complex as well ;)
def build_hilbert(fft_size):
Expand Down

0 comments on commit 280aa89

Please sign in to comment.