find_centroid

jwst.ami.utils.find_centroid(a)[source]

Calculate the centroid of the image.

Parameters:
afloat

Input image array (2D square)

Returns:
htilt, vtiltfloat

Centroid of a, as offset from array center, as calculated by the DFT’s.

Notes

  • Original domain a, Fourier domain CV

  • sft square image a to CV array, no loss or oversampling - like an fft.

  • Normalize peak of abs(CV) to unity

  • Create ‘live area’ mask from abs(CV) with slight undersizing
    • (allow for 1 pixel shifts to live data still)

    • (splodges, or full image a la KP)

  • Calculate phase slopes using CV.angle() phase array

  • Calculate mean of phase slopes over mask

  • Normalize phase slopes to reflect image centroid location in pixels

XY conventions meshed to lg_model conventions:

  • if you simulate a psf with pixel_offset = ( (0.2, 0.4), ) then blind application centroid = utils.find_centroid()

Returns the image centroid (0.40036, 0.2000093) pixels in image space. To use this in lg_model, nrm_core, etc., you will want to calculate the new image center using:

image_center = utils.centerpoint(s) + np.array((centroid[1], centroid[0])

and everything holds together sensibly looking at DS9 images of a.