tso_source_centroid
- jwst.tso_photometry.tso_photometry.tso_source_centroid(datamodel, xcenter, ycenter, search_box_width=41, fit_box_width=11, source_radius=4.0)[source]
Centroid the source and fit a Gaussian PSF to a subimage.
For each integration, the source centroid is computed as the center-of-mass for the subimage.
The initial fit to the data uses a wider search box centered on the planned position to derive an initial guess for the centroid position. A secondary fit uses a smaller subimage to compute the final centroid position. The subimage in both cases is background-subtracted prior to the fit, from a median value of pixels outside an assumed source radius.
If the fit is successful, a Gaussian PSF is fit to the subimage at the centroid location and the PSF width and flux are reported in the output.
If the fit fails for all integrations in either the initial or the secondary pass, the returned centroid values will be all-NaN arrays and the PSF values will be None. If only some integrations fail, or if the centroid succeeds but the Gaussian fits fail, individual values within the returned arrays will be set to NaN.
- Parameters:
- datamodel
CubeModel The input data model of a TSO imaging observation.
- xcenterfloat
Initial guess for the x-center of the source.
- ycenterfloat
Initial guess for the y-center of the source.
- search_box_widthint, optional
Width of the subimage to use for an initial search for the source.
- fit_box_widthint, optional
Width of the subimage to use for the final fit to the source.
- source_radiusfloat, optional
Expected PSF source radius, used to mask the source for approximate background estimation.
- datamodel
- Returns:
- centroid_xndarray
The x center of the source for each integration, zero-indexed.
- centroid_yndarray
The y center of the source for each integration, zero-indexed.
- psf_width_xndarray or None
An array of PSF fit widths in the x-direction, one per integration.
- psf_width_yndarray or None
An array of PSF fit widths in the y-direction, one per integration.
- psf_fluxndarray or None
An array of PSF fit flux, one per integration.