[SciPy-Dev] Negative Data Points in Center of Mass

Phil Hodge hodge at stsci.edu
Tue Oct 11 08:41:22 EDT 2016


On 10/10/2016 07:54 PM, G Young wrote:
> I have a PR open (#6668 <https://github.com/scipy/scipy/pull/6668>) 
> that issues a UserWarning if negative values for data inputs are 
> passed in for "center_of_mass".  While I cannot think of any 
> applications of negative values, initial discussion suggested it would 
> be prudent to double check with other developers in the community to 
> see if there were any applications.
>
> Thanks!

There will likely be negative values in measured data after subtracting 
a bias level or background, due to random noise.  If you set those 
negative-valued elements to zero, that will bias the result.  Consider 
the case of using center_of_mass to determine the location of a star 
image.  There will be a background due to dark current in the sensor and 
sky brightness.  If you don't subtract the background, the output of 
center_of_mass will be biased toward the center of the slice passed to 
center_of_mass.  A common way to measure the background is to find the 
average value (excluding outliers) within an annular ring around the 
star. After subtracting the value, the average (again, excluding 
outliers) in that annular region will be zero, and if there's any noise 
at all (e.g. read noise, Poisson noise) there should be pixels with 
negative values.

If there is a case where negative values should never be encountered, 
please just let the user check his/her own data. There can be other 
values (e.g. saturated) that would cause center_of_mass to give an 
incorrect result, and the user is responsible for checking for those, too.

Phil



More information about the SciPy-Dev mailing list