examples/a121/load_record.py

examples/a121/load_record.py#

 1# Copyright (c) Acconeer AB, 2022
 2# All rights reserved
 3
 4import argparse
 5
 6import numpy as np
 7
 8from acconeer.exptool import a121
 9
10
11def main() -> None:
12    parser = argparse.ArgumentParser()
13    parser.add_argument("filename")
14    parser.add_argument("--plot", action="store_true")
15    args = parser.parse_args()
16    filename = args.filename
17
18    record = a121.load_record(filename)
19
20    print_record(record)
21
22    if args.plot:
23        plot_record(record)
24
25
26def print_record(record: a121.Record) -> None:
27    estimated_update_rate = 1 / np.diff(record.stacked_results.tick_time).mean()
28
29    print("ET version: ", record.lib_version)
30    print("RSS version:", record.server_info.rss_version)
31    print("HW name:    ", record.server_info.hardware_name)
32    print("Data shape: ", record.frames.shape)
33    print("Est. rate:  ", f"{estimated_update_rate:.3f} Hz")
34    print("Timestamp:  ", record.timestamp)
35    print()
36    print(record.session_config)
37    print()
38    print(record.metadata)
39    print()
40
41    first_result = next(record.results)
42    print(first_result)
43
44
45def plot_record(record: a121.Record) -> None:
46    import matplotlib.pyplot as plt
47
48    fig, ax = plt.subplots()
49
50    z = abs(record.frames.mean(axis=1)).T
51    x = record.stacked_results.tick_time
52    x -= x[0]
53    y = np.arange(z.shape[0])
54
55    ax.pcolormesh(x, y, z)
56    ax.set_xlabel("Time (s)")
57    ax.set_ylabel("Distance point")
58    ax.set_title("Mean sweep amplitude")
59
60    fig.tight_layout()
61    plt.show()
62
63
64if __name__ == "__main__":
65    main()

View this example on GitHub: acconeer/acconeer-python-exploration