File: plot_ofdm_demod_syms

package info (click to toggle)
codec2 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,376 kB
  • sloc: ansic: 436,819; cpp: 2,091; objc: 1,736; sh: 1,510; python: 1,405; asm: 683; makefile: 605
file content (54 lines) | stat: -rwxr-xr-x 1,505 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
""" plot_ofdm_demod_syms

    Plot QPSK constelations of reference demods.

    Later read stm32 log......

    """

import numpy as np
import os
import sys


##############################################################################
# Read Octave text file
##############################################################################

def read_octave_text(fname):
    data = {}
    with open(fname, "r") as f:
      for line in f:
        if (line[0:8] == '# name: '):
          var = line.split()[2]
          print('found {}'.format(var))
          line = next(f)
          if (line.startswith('# type: matrix')):
            line = next(f)
            rows = int(line.split()[2])
            line = next(f)
            cols = int(line.split()[2])
            print('  matrix({}, {})'.format(rows, cols))
            data[var] = np.empty((rows, cols), np.float32)
            # Read rows one at a time
            for row in range(rows):
              line = next(f)
              data[var][row] = np.fromstring(line, np.float32, cols, ' ')

          # end while True
      # end with
    return(data)


##############################################################################
# Main
##############################################################################

### Text not supported!!!  ref_data = sio.loadmat('ofdm_demod_ref_log.mat')

ref_data = read_octave_text('ofdm_demod_ref_log.txt')

import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(ref_data)