line_fit: round centroid co-ord float to int, rather than truncate #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toxx=581
correctly, butyy=1906
incorrectly - the peak pixel at y=1907 is excluded. I believeyy
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)
toxx=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.