fit_wcs_from_points¶

astropy.wcs.utils.
fit_wcs_from_points
(xy, world_coords, proj_point='center', projection='TAN', sip_degree=None)[source]¶ Given two matching sets of coordinates on detector and sky, compute the WCS.
Fits a WCS object to matched set of input detector and sky coordinates. Optionally, a SIP can be fit to account for geometric distortion. Returns an
WCS
object with the best fit parameters for mapping between input pixel and sky coordinates.The projection type (default ‘TAN’) can passed in as a string, one of the valid threeletter projection codes  or as a WCS object with projection keywords already set. Note that if an input WCS has any nonpolynomial distortion, this will be applied and reflected in the fit terms and coefficients. Passing in a WCS object in this way essentially allows it to be refit based on the matched input coordinates and projection point, but take care when using this option as nonprojection related keywords in the input might cause unexpected behavior.
 Parameters
 xy(
numpy.ndarray
,numpy.ndarray
)tuple
x & y pixel coordinates.
 world_coords
SkyCoord
Skycoord object with world coordinates.
 proj_point‘center’ or ~astropy.coordinates.SkyCoord`
Defaults to ‘center’, in which the geometric center of input world coordinates will be used as the projection point. To specify an exact point for the projection, a Skycoord object with a coordinate pair can be passed in. For consistency, the units and frame of these coordinates will be transformed to match
world_coords
if they don’t. projection
str
orWCS
Three letter projection code, of any of standard projections defined in the FITS WCS standard. Optionally, a WCS object with projection keywords set may be passed in.
 sip_degree
None
orint
If set to a nonzero integer value, will fit SIP of degree
sip_degree
to model geometric distortion. Defaults to None, meaning no distortion corrections will be fit.
 xy(
 Returns
 wcs
WCS
The bestfit WCS to the points given.
 wcs
Notes
The fiducial point for the spherical projection can be set to ‘center’ to use the mean position of input sky coordinates, or as an
SkyCoord
object.Units in all output WCS objects will always be in degrees.
If the coordinate frame differs between
SkyCoord
objects passed in forworld_coords
andproj_point
, the frame forworld_coords
will override as the frame for the output WCS.If a WCS object is passed in to
projection
the CD/PC matrix will be used as an initial guess for the fit. If this is known to be significantly off and may throw off the fit, set to the identity matrix (for example, by doing wcs.wcs.pc = [(1., 0.,), (0., 1.)])