from math import pi
from vortex.scan import RepeatedRasterScanConfig, RepeatedRasterScan
from vortex_tools.scan import plot_annotated_waveforms_space

cfg = RepeatedRasterScanConfig()
cfg.bscans_per_volume = 8
cfg.angle = pi / 2

cfg.bidirectional_segments = True

cfg.repeat_count = 2
cfg.repeat_period = 4

scan = RepeatedRasterScan()
scan.initialize(cfg)

path = scan.scan_buffer()

_, ax = plt.subplots(constrained_layout=True)
ax.plot(path)
ax.set_title('XY Position vs Sample')
ax.set_ylabel('position')
ax.set_xlabel('sample')

fg = plt.rcParams['lines.color']
fig, ax = plot_annotated_waveforms_space(path, scan.scan_markers(), inactive_marker=None, scan_line=fg)
ax.set_title('Scan Pattern in XY Plane')
ax.set_ylabel('y')
ax.set_xlabel('x')
fig.tight_layout()