Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line_fit: round centroid co-ord float to int, rather than truncate #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ross-dobson
Copy link

Line_fit (and thus col_fit) truncate the centroid float co-ordinates to ints (the ints are used to access the array position). For example, I have a star with centroid xout=581.24, yout=1906.72. It was being truncated to xx=581 correctly, but yy=1906 incorrectly - the peak pixel at y=1907 is excluded. I believe yy should be rounded to 1907 instead, to ensure the line_fit/col_fit includes the peak pixel.

In-built conversion from float to int is a flooring function, so changing xx=int(xout) to xx=int(xout+0.5) (and same for y) ensures values of decimal >= .5 will get rounded correctly upwards, rather than truncated downwards.

This doesn't work for negative x or y, but this is an unlikely situation? If not, it is easily implemented: if x or y <0, subtract 0.5 instead.

@ross-dobson ross-dobson changed the title line_fit rounds centroid co-ord float to int, rather than truncate line_fit: round centroid co-ord float to int, rather than truncate Dec 27, 2020
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 38.483% when pulling 1a2efbb on Ross-Dobson:linefit-centroid into d6f21d1 on spacetelescope:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants