Much faster atomic column integration implementation
In similar fashion to !47 (merged), I have sped up the atomic column integration implementation. Particularly so for the Voronoi cell integration method.
For a 512px by 512px, the old code took 124 seconds. The new version takes 3.6 seconds. The new version makes it reasonable to perform Voronoi integration on 1024px (45 sec) and 2048px images (half-an-hour ish) as well, where the old version took a LOT longer.
I have achieved the speed-boost partly by rewriting some code and moving things that did not need to be inside loops, outside loops. But the main speed-increase has come from implementing the numba jit (just-in-time) compilation decorator around the function that calculates the shortest distance between points for the point-record image.
I need some help with writing some tests: Some of the tests require voronoi integration on a "live dataset", and I'm not sure what the best approach is here.
In addition, I have added a function that removes any cells that are near the edges of the image/dataset. These are often annoying in that they get mess up the contrast of the displayed integrated_record image, and they are complicated to manually remove in order to calculate correct statistics (think, mean of the atomic column intensity).
Attached is an example file and example result, showing the raw data (1024px), Voronoi integration and integration with removed border cells.
%matplotlib widget import atomap.api as am import hyperspy.api as hs s = hs.load("20181005_2006_STEM_HAADF_2.7_Mx.tif") s2 = s.isig[:1024,:1024] #nav = hs.signals.Signal2D([[1,2,3], [4,5,6]]).T S = s2#nav*s2.T points_x, points_y = am.get_atom_positions(s2).T i, ir, pr = am.integrate(S, points_x, points_y, method='Voronoi') i2, ir2, pr2 = remove_integrated_edge_cells(i, ir, pr, pixels=20) fig = plt.figure(dpi=200) hs.plot.plot_images([s2, ir, ir2], fig=fig, colorbar=False)