spacetelescope / imexam

imexam is a python tool for simple image examination, and plotting, with similar functionality to IRAF's imexamine
http://imexam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
74 stars 45 forks source link

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

Open ross-dobson opened 3 years ago

ross-dobson commented 3 years ago

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.

coveralls commented 3 years ago

Coverage Status

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