Python Multi-core / GPU Digital Phosphor Rendering of Huge Waveform Data
Most modern oscilloscopes are marketed as Digital Phosphor Oscilloscope (DPO) because the waveform shown on those scopes looks night-and-day compared to their old counterparts.
One way to speed things up and achieve a DPO look is to use plt.hist2d. There seems to be some automatic vectorization happening, but it's still ugly and slow. Another issue with this approach is that hist2d draws only the points but not the lines connecting them. In some applications (like the NTSC video signal example shown in the TDS784D comparison), the thin lines in regions like the rising and falling edges of a square wave will dissappear. And pyplt's hist2d implementation seems to also have some aliasing on the x axis.
I couldn't find any useful library for this particular requirement. So I wrote my own multi-thread rasterizer that can be deployed on CPU / GPU. The speed up is significant, and the result is a nice looking DPO plot with vector lines connecting all the dots together.
The implementation is straight forward. Think about a single-thread implementation: all we want to do is to use the Bresenham line drawing algorithm to draw all the lines connecting the points in your dataset into a pixel buffer. With Numba, it can be turned in to a parallel code such that each worker is responsible for one Bresenham line. The only modification we need to do is to change the add instruction into an atomic operation, which can be achieved by numba.cuda.atomic.add.
Comments
Post a Comment