diff options
author | jaseg <git@jaseg.de> | 2024-06-23 23:13:34 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2024-06-23 23:13:34 +0200 |
commit | 66e0f462d379b1cb3f42e988eb8ccca614d967d5 (patch) | |
tree | 948a643e90855176d06788201b610ae726b71ea3 /downsample_rigol_wfm.py | |
parent | 8c5c8aee5113dd1249f71530c372c7eff3e7f5ef (diff) | |
download | barcode-66e0f462d379b1cb3f42e988eb8ccca614d967d5.tar.gz barcode-66e0f462d379b1cb3f42e988eb8ccca614d967d5.tar.bz2 barcode-66e0f462d379b1cb3f42e988eb8ccca614d967d5.zip |
Add test data and working manchester decodermain
Diffstat (limited to 'downsample_rigol_wfm.py')
-rw-r--r-- | downsample_rigol_wfm.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/downsample_rigol_wfm.py b/downsample_rigol_wfm.py new file mode 100644 index 0000000..d700c39 --- /dev/null +++ b/downsample_rigol_wfm.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import json +from pathlib import Path +import lzma + +import click +import RigolWFM.wfm as rigol +import scipy + + +@click.command() +@click.argument('infile', type=click.Path(dir_okay=False, exists=True)) +@click.argument('outfile', type=click.Path(dir_okay=False, path_type=Path), required=False) +@click.option('-f', '--factor', type=int, default=500, help='Downsampling factor') +def cli(infile, outfile, factor): + if outfile is None: + outfile = Path(infile).with_suffix('.lzjson') + wf = rigol.Wfm.from_file(infile, 'DS1054Z') + data = wf.channels[0].volts + + data = scipy.signal.decimate(data, factor, ftype='fir')[::-1] + td = wf.channels[0].seconds_per_point * factor + + outfile.write_bytes(lzma.compress(json.dumps({'sample_interval_s': td, 'samples': list(data)}).encode())) + + +if __name__ == '__main__': + cli() |