/usr/lib/python3/dist-packages/aplpy/header.py is in python3-aplpy 1.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | from __future__ import absolute_import, print_function, division
from astropy import log
def check(header, convention=None, dimensions=[0, 1]):
ix = dimensions[0] + 1
iy = dimensions[1] + 1
# If header does not contain CTYPE keywords, assume that the WCS is
# missing or incomplete, and replace it with a 1-to-1 pixel mapping
if 'CTYPE%i' % ix not in header or 'CTYPE%i' % iy not in header:
log.warning("No WCS information found in header - using pixel coordinates")
header['CTYPE%i' % ix] = 'PIXEL'
header['CTYPE%i' % iy] = 'PIXEL'
header['CRVAL%i' % ix] = 0.
header['CRVAL%i' % iy] = 0.
header['CRPIX%i' % ix] = 0.
header['CRPIX%i' % iy] = 0.
header['CDELT%i' % ix] = 1.
header['CDELT%i' % iy] = 1.
if header['CTYPE%i' % ix][4:] == '-CAR' and header['CTYPE%i' % iy][4:] == '-CAR':
if header['CTYPE%i' % ix][:4] == 'DEC-' or header['CTYPE%i' % ix][1:4] == 'LAT':
ilon = iy
ilat = ix
elif header['CTYPE%i' % iy][:4] == 'DEC-' or header['CTYPE%i' % iy][1:4] == 'LAT':
ilon = ix
ilat = iy
else:
ilon = None
ilat = None
if ilat is not None and header['CRVAL%i' % ilat] != 0:
if convention == 'calabretta':
pass # we don't need to do anything
elif convention == 'wells':
if 'CDELT%i' % ilat not in header:
raise Exception("Need CDELT%i to be present for wells convention" % ilat)
crpix = header['CRPIX%i' % ilat]
crval = header['CRVAL%i' % ilat]
cdelt = header['CDELT%i' % ilat]
crpix = crpix - crval / cdelt
try:
header['CRPIX%i' % ilat] = crpix
header['CRVAL%i' % ilat] = 0.
except: # older versions of PyFITS
header.update('CRPIX%i' % ilat, crpix)
header.update('CRVAL%i' % ilon, 0.)
else:
raise Exception('''WARNING: projection is Plate Caree (-CAR) and
CRVALy is not zero. This can be interpreted either according to
Wells (1981) or Calabretta (2002). The former defines the
projection as rectilinear regardless of the value of CRVALy,
whereas the latter defines the projection as rectilinear only when
CRVALy is zero. You will need to specify the convention to assume
by setting either convention='wells' or convention='calabretta'
when initializing the FITSFigure instance. ''')
return header
|