Skip to content

Speed up centroid function (remove interpolation)#179

Open
jordiferrero wants to merge 1 commit intoLumiSpy:mainfrom
jordiferrero:centroid_faster
Open

Speed up centroid function (remove interpolation)#179
jordiferrero wants to merge 1 commit intoLumiSpy:mainfrom
jordiferrero:centroid_faster

Conversation

@jordiferrero
Copy link
Contributor

@jordiferrero jordiferrero commented Feb 2, 2023

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

  • Change implemented (can be split into several points),
  • docstring updated (if appropriate),
  • ready for review.

@jordiferrero jordiferrero requested a review from jlaehne February 2, 2023 10:14
@jlaehne
Copy link
Contributor

jlaehne commented Feb 15, 2023

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.

@jlaehne jlaehne added this to the v0.2.2 milestone Feb 16, 2023
@jlaehne jlaehne modified the milestones: v0.2.2, v0.2.3 Mar 15, 2023
@jlaehne jlaehne modified the milestones: v0.3, v0.4 Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants