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_position
SkyCoord The coordinates of the center of the WCS. It should be scalar.
- fov
AngleorQuantity The field of view in physical units, in x/y order.
fovandpixel_shapeare mutually exclusive and one of them must be provided.- pixel_shape
Sequence[int,int] The image size in pixels (NAXIS), in x/y order.
fovandpixel_shapeare mutually exclusive and one of them must be provided.- pixel_angular_size
AngleorQuantity 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
cdeltwill be set to[-pixel_angular_size, pixel_angular_size].- reference_pixel
Sequence[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.- frame
BaseCoordinateFrame, optional An instance of
BaseCoordinateFrameor subclass. Defaults to the frame ofreference_position.- projection
str, optional Any valid WCS projection code (see the list with
from astropy.wcs import PRJ_CODES), by default “TAN”.- rotation
AngleorQuantity, 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.
- reference_position
- Returns:
WCSA 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
shapeinstead offov:>>> 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