skycoord_to_celestial_wcs#

astropy.wcs.utils.skycoord_to_celestial_wcs(reference_position, *, fov=None, pixel_shape=None, pixel_angular_size, reference_pixel=None, frame=None, projection='TAN', rotation=None)[source]#

Create a sky WCS from a reference position and a field of view.

Parameters:
reference_positionSkyCoord

The coordinates of the center of the WCS. It should be scalar.

fovAngle or Quantity

The field of view in physical units, in x/y order. fov and pixel_shape are mutually exclusive and one of them must be provided.

pixel_shapeSequence[int, int]

The image size in pixels (NAXIS), in x/y order. fov and pixel_shape are mutually exclusive and one of them must be provided.

pixel_angular_sizeAngle or Quantity

The pixel angular size along the x and y axis, in x/y order. It is either of length 2 for each axis or of length 1. Then cdelt will be set to [-pixel_angular_size, pixel_angular_size].

reference_pixelSequence[float, float], optional

Reference pixel for the projection. In zero-indexed (Python convention) x/y order. If None, it will be set to the center of the view.

frameBaseCoordinateFrame, optional

An instance of BaseCoordinateFrame or subclass. Defaults to the frame of reference_position.

projectionstr, optional

Any valid WCS projection code (see the list with from astropy.wcs import PRJ_CODES), by default “TAN”.

rotationAngle or Quantity, optional

Angle from the +y pixel axis to the latitude axis at the reference pixel, measured towards increasing longitude (as for CROTA2). By default no rotation.

Returns:
WCS

A celestial WCS object.

Examples

>>> from astropy.wcs.utils import skycoord_to_celestial_wcs
>>> from astropy.coordinates import Angle, SkyCoord
>>> center = SkyCoord(266.4, -29, unit="deg")
>>> fov = Angle([8, 4], unit="deg")
>>> wcs = skycoord_to_celestial_wcs(
...           center, fov=fov,
...           pixel_angular_size=Angle([-0.1, 0.1], unit="deg")
...           )
>>> print(wcs)
WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN' 'DEC--TAN'
CUNIT : '' ''
CRVAL : 266.4 -29.0
CRPIX : 40.5 20.5
PC1_1 PC1_2  : 1.0 0.0
PC2_1 PC2_2  : 0.0 1.0
CDELT : -0.1 0.1
NAXIS : 80  40

You can also use shape instead of fov:

>>> shape = (40, 80)
>>> wcs = skycoord_to_celestial_wcs(
...           center, pixel_shape=shape,
...           pixel_angular_size=Angle([-0.1, 0.1], unit="deg")
...           )
>>> print(wcs)
WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN' 'DEC--TAN'
CUNIT : '' ''
CRVAL : 266.4 -29.0
CRPIX : 20.5 40.5
PC1_1 PC1_2  : 1.0 0.0
PC2_1 PC2_2  : 0.0 1.0
CDELT : -0.1 0.1
NAXIS : 40  80