pynrc.maths.image_manip.optimal_difference

pynrc.maths.image_manip.optimal_difference(im_sci, im_ref, scale, binsize=1, center=None, mask_good=None, sub_mean=True, std_func=<function std>)[source]

Optimize subtraction of ref PSF

Scale factors from scale_ref_image work great for subtracting a reference PSF from a science image where there are plenty of photons, but perform poorly in the noise-limited regime. If we simply perform a difference by scaling the reference image, then we also amplify the noise. In the background, it’s better to simply subtract the unscaled reference pixels. This routine finds the radial cut-off of the dominant noise source.

Parameters
  • im_sci (ndarray) – Science star observation.

  • im_ref (ndarray) – Reference star observation.

  • scale (float) – Scale factor from scale_ref_image()

  • binsize (int) – Radial binsize (in pixels) to perform calculations

  • center (tuple or None) – Location (x,y) to calculate radial distances. Default is center of image.

  • mask_good (bool array) – Only perform operations on pixels where mask_good=True.

  • sub_mean (bool) – Subtract mean (median, actually) of pixels in each radial bin? Basically a background subtraction.

  • std_func (func) – What function do we want to use for calculating the standard deviation in each radial bin? After comparing the standard deviation between the two scaled differences in each radial bin, we only keep the better of the two.