summaryrefslogtreecommitdiff
path: root/controller/fw/tools/cwt_wavelet_header_gen.py
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-05 19:15:28 +0100
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-05 19:15:28 +0100
commit4b419bd1ad9f22266e068341176f5ab665a26222 (patch)
treeec5ee9e379d4de3e15b33f0b640b700bef0750bc /controller/fw/tools/cwt_wavelet_header_gen.py
parentd9b26d16c063aec32b70287ff861a1f23642a9f2 (diff)
downloadmaster-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.gz
master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.bz2
master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.zip
Working on DSSS demodulator sim
Diffstat (limited to 'controller/fw/tools/cwt_wavelet_header_gen.py')
-rw-r--r--controller/fw/tools/cwt_wavelet_header_gen.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/controller/fw/tools/cwt_wavelet_header_gen.py b/controller/fw/tools/cwt_wavelet_header_gen.py
new file mode 100644
index 0000000..e9713a7
--- /dev/null
+++ b/controller/fw/tools/cwt_wavelet_header_gen.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+import textwrap
+
+import scipy.signal as sig
+import numpy as np
+
+if __name__ == '__main__':
+ import argparse
+ parser = argparse.ArgumentParser()
+ parser.add_argument('n', type=int, help='Window size')
+ parser.add_argument('w', type=float, help='Wavelet width')
+ parser.add_argument('-v', '--variable', default='cwt_ricker_table', help='Name for alias variable pointing to generated wavelet LUT')
+ args = parser.parse_args()
+
+ print(f'/* CWT Ricker wavelet LUT for {args.n} sample window of width {args.w}. */')
+ varname = f'cwt_ricker_{args.n}_window_{str(args.w).replace(".", "F")}'
+ print(f'const float {varname}[{args.n}] = {{')
+
+ win = sig.ricker(args.n, args.w)
+ par = ' '.join(f'{f:>015.8g}f,' for f in win)
+ print(textwrap.fill(par,
+ initial_indent=' '*4, subsequent_indent=' '*4,
+ width=120,
+ replace_whitespace=False, drop_whitespace=False))
+ print('};')
+ print()
+ print(f'const float * const {args.variable} __attribute__((weak)) = {varname};')
+