LumiSpy / lumispy

Luminescence data analysis with HyperSpy.
https://lumispy.org
GNU General Public License v3.0
25 stars 17 forks source link

Speed up centroid function (remove interpolation) #179

Open jordiferrero opened 1 year ago

jordiferrero commented 1 year ago

Description of the change

I realised I had overengineered the com utils function. I have now simplified it with a huge speed improvement. It does not rely on scipy interpolation anymore.

Progress of the PR

jlaehne commented 1 year ago

Indeed, the function runs through about 6-times faster on a map of mine. For the uniform axis, the results are the same - but when converting to non-uniform axes, the results are not the same as for the old implementation. In particular, for jacobian=False the centroid in the old implementation is the same in energy and wavelength scale, which makes sense. In the new implementation, they are not the same.

I think the weighted average that you calculate is correct for the equidistant scale, but for non-uniform axes you still would need interpolation if you want to use that formula.