FITS Region File Format Limitations¶
Region Shapes¶
FITS regions are specified in pixel units, thus a
SkyRegioncannot be serialized to the FITS region format. Regions are always parsed and serialized asPixelRegionobjects when using the FITS region format.When reading a
elliptannulus, the firstROTANGwill be used for both the inner and outer ellipse. The secondROTANGwill be ignored. In other words, you cannot have an elliptical annulus where the inner and outer ellipse have different rotation angles.Shapes where the value in the SHAPE column is preceded by an exclamation mark (e.g.,
!circle) will be read in as aPixelRegionobject and haveinclude = 0in theirmetadictionary. When such objects are serialized, their shape will be prepended by!.The FITS
box,rotbox,rectangle, androtrectangleshapes will all be parsed as aRectanglePixelRegion. In turn,RectanglePixelRegionis always serialized as arotboxshape.The following
PixelRegionclasses do not have corresponding FITS shapes and therefore are not supported (a warning will be raised):FITS regions are always parsed and serialized into separate regions. Shapes that have the
COMPONENTcolumn will have that value stored in thePixelRegionmetadictionary with thecomponentkey. Such regions will include theCOMPONENTcolumn when serialized.FITS parsing and serialization use only the
includeandcomponentmetadata and no visual metadata.
Coordinate Frames¶
Regionobjects represent abstract shapes that are not tied to any particular image or WCS transformation. Therefore, any WCS information in the FITS region file header will not be read. Regions are always parsed and serialized asPixelRegionobjects when using the FITS region format. However, if desired you can use the WCS information in the FITS region file to convert aPixelRegionobject to aSkyRegionobject, e.g.,:
>>> from astropy.io import fits
>>> from astropy.wcs import WCS
>>> header = fits.getheader('my_region.fits', 1)
>>> wcs = WCS(header, keysel=('image', 'binary', 'pixel'))
>>> sky_region = pix_region.to_sky(wcs)
Other Limitations¶
Reading and then writing a FITS region file will not produce an identical file to the original, but the encoded regions are identical. Therefore, it will produce identical
Regionobjects when read back in again. In other words, read/write/read (or parse/serialize/parse) will exactly roundtripRegionobjects.