Skip to content

swaped coordinates in picasso.gausslq._sum_and_center_of_mass #616

@TG-fresnel

Description

@TG-fresnel

Hello,

I started using picasso recently and really enjoy it. While looking at some of it's functions i believe i found a bug in the gaussian least squre module
picasso.gausslq. The function _sum_and_center_of_mass computes the center of mass like this:

    x = 0.0
    y = 0.0
    _sum_ = 0.0
    for i in range(size):
        for j in range(size):
            x += spot[i, j] * i
            y += spot[i, j] * j
            _sum_ += spot[i, j]
    x /= _sum_
    y /= _sum_

If im not mistaken in the rest of the code the first dimension in this case the index i corresponds to the y coordinate. So in the end the x and y coordinates are swapped.

I checked the time it takes to fit a gaussian at the coordinates (3,3) where this have no effect, compared to one a (3,-3) where the inital guess for the fit would not be a the right position. I attach the file.

test_fit_spot.py

the averaget time for the fit at (3,3): 0.1018.ms
the averaget time for the fit at (3,-3): 0.6346ms

I guess the effect on real data is smaller since it's usually well centered.

Thanks for the great work with the picasso software and best regards

Tobias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions