examples/a121/algo/sparse_iq/sparse_iq.py#
1# Copyright (c) Acconeer AB, 2023-2026
2# All rights reserved
3
4from __future__ import annotations
5
6import acconeer.exptool as et
7from acconeer.exptool import a121
8from acconeer.exptool.a121._core.entities.configs.config_enums import PRF, IdleState, Profile
9from acconeer.exptool.a121.algo.sparse_iq import AmplitudeMethod, Processor, ProcessorConfig
10
11
12def main():
13 args = a121.ExampleArgumentParser().parse_args()
14 et.utils.config_logging(args)
15
16 client = a121.Client.open(**a121.get_client_args(args))
17 processor_config = ProcessorConfig()
18
19 processor_config.amplitude_method = AmplitudeMethod.COHERENT # Either COHERENT or FFTMAX
20 sensor_id = 1
21
22 sensor_config = a121.SensorConfig(
23 sweeps_per_frame=8,
24 sweep_rate=None,
25 frame_rate=None,
26 inter_frame_idle_state=IdleState.READY,
27 inter_sweep_idle_state=IdleState.READY,
28 continuous_sweep_mode=False,
29 double_buffering=False,
30 subsweeps=[
31 # Generate 3 subsweep configurations
32 a121.SubsweepConfig(start_point=70),
33 a121.SubsweepConfig(),
34 a121.SubsweepConfig(profile=Profile.PROFILE_2),
35 ],
36 )
37
38 # Multiple subsweep configuration can be assigned in single group SensorConfig
39 # through 'subweeps' fields shown above or in these way below
40 sensor_config.subsweeps[0].num_points = 140
41 sensor_config.subsweeps[1].prf = PRF.PRF_15_6_MHz
42
43 # Create a SessionConfig with (e.g.) two groups SensorConfig
44 # First group will contain multiple subsweeps, second group will contain single subsweep
45 # Multiple group configurations are required when certain parameters cannot be configured in subsweep config
46 session_config = a121.SessionConfig(
47 [
48 {
49 sensor_id: sensor_config,
50 },
51 {
52 sensor_id: a121.SensorConfig(
53 sweeps_per_frame=20,
54 )
55 },
56 ],
57 extended=True,
58 )
59 client.setup_session(session_config)
60 client.start_session()
61 processor = Processor(session_config=session_config, processor_config=processor_config)
62
63 interrupt_handler = et.utils.ExampleInterruptHandler()
64
65 while not interrupt_handler.got_signal:
66 results = client.get_next()
67 result_sensor_configs = processor.process(results=results)
68 result_first_sensor_config = result_sensor_configs[0][sensor_id]
69 result_third_subsweep = result_first_sensor_config[2]
70 # Sparse IQ results contain amplitudes, phases, and distance velocity
71 try:
72 print("Amplitudes results of 3rd subsweep from first group ")
73 print(result_third_subsweep.amplitudes)
74
75 print("Distance velocity results of 1st subsweep from second group ")
76 print(result_sensor_configs[1][sensor_id][0].distance_velocity_map)
77 except et.PGProccessDiedException:
78 break
79
80 print("Disconnecting...")
81 client.close()
82
83
84if __name__ == "__main__":
85 main()
View this example on GitHub: acconeer/acconeer-python-exploration