AstropyWCS

class snappl.wcs.AstropyWCS(apwcs=None)[source]

Bases: BaseWCS

A WCS that is defined by an astropy.wcs.WCS.

Methods Summary

from_header(header)

Create an AstropyWCS from a FITS header.

get_astropy_wcs([readonly])

Return an astropy.wcs.WCS object, if possible.

get_galsim_wcs()

Return a glasim.AstropyWCS object, if possible.

pixel_to_world(x, y)

Go from (x, y) coordinates to ICRS (ra, dec)

to_fits_header()

Return an astropy.io.fits.Header object, if possible, with the WCS in it.

world_to_pixel(ra, dec)

Go from (ra, dec) coordinates to (x, y)

Methods Documentation

classmethod from_header(header)[source]

Create an AstropyWCS from a FITS header.

NOTE: if the header claims that the transformation type is “TAN” (i.e. CTYPE1 is “RA—TAN”), but the header also has a “PV1_0” keyword, this function will assume that the transformation is actually TPV.

See: https://github.com/thomasvrussell/sfft/blob/45efa77452f020b8832a14c8682b87c5ffee4a93/sfft/utils/ReadWCS.py

Parameters:

header (duckish astropy.io.fits.header.Header) – Something that behaves like a FITS header, in that it can be accessed as a dictionary, has the copy() method, and canbe fead to astropy.wcs.WCS().

Return type:

AstropyWCS

get_astropy_wcs(readonly=True)[source]

Return an astropy.wcs.WCS object, if possible.

Parameters:
  • readonly (bool, default True) – If True, you are promising not to modify the WCS you get back! If you’re going to modify it, set readonly to False. (For some subclasses, this doesn’t actually change behavior.)

  • degree (int) – The degree of the astropy WCS used to approximate the WCS in the object. The default is subclass-dependent. Ignored by some subclasses.

For some subclasses, this astropy.wcs.WCS may only be an approximation of the true WCS represented by the object.

get_galsim_wcs()[source]

Return a glasim.AstropyWCS object, if possible.

pixel_to_world(x, y)[source]

Go from (x, y) coordinates to ICRS (ra, dec)

Parameters:
  • x (float or sequence of float) – The x position on the image. The center of the lower-left pixel is at x=0.0

  • y (float or sequence of float) – The y position on the image. The center of the lower-left pixle is y=0.0

Returns:

  • ra, dec (floats or arrays of floats, decimal degrees)

  • You will get back two floats if x an y were floats. If x and

  • y were lists (or other sequences), you will get back two numpy

  • arrays of floats.

to_fits_header()[source]

Return an astropy.io.fits.Header object, if possible, with the WCS in it.

world_to_pixel(ra, dec)[source]

Go from (ra, dec) coordinates to (x, y)

Parameters:
  • ra (float or sequence of float) – RA in decimal degrees

  • dec (float or sequence of float) – Dec in decimal degrees

Returns:

  • x, y (floats or arrays of floats)

  • Pixel position on the image; the center of the lower-left pixel is (0.0, 0.0).

  • If ra and dec were floats, x and y are floats. If ra and dec

  • were sequences of floats, x and y will be numpy arrays of floats.