diff options
author | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-13 09:20:14 -0400 |
---|---|---|
committer | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-13 09:20:14 -0400 |
commit | 9969898117c0befb4b8fbd7cb2740ed153e16a4d (patch) | |
tree | 41f52845f2e9362ecd09641cdcacdf961727c580 /stwcs | |
parent | 13f7b5958e4ec02bf3a2324d28db57d865349514 (diff) | |
download | stwcs_hcf-9969898117c0befb4b8fbd7cb2740ed153e16a4d.tar.gz |
fix for refframe=OTHER
Diffstat (limited to 'stwcs')
-rw-r--r-- | stwcs/tests/test_hstwcs.py | 15 | ||||
-rw-r--r-- | stwcs/wcsutil/hstwcs.py | 27 |
2 files changed, 36 insertions, 6 deletions
diff --git a/stwcs/tests/test_hstwcs.py b/stwcs/tests/test_hstwcs.py new file mode 100644 index 0000000..8a4a9ba --- /dev/null +++ b/stwcs/tests/test_hstwcs.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import, division, print_function +from astropy.io import fits +from ..wcsutil import hstwcs + + +def test_radesys(): + phdr = fits.PrimaryHDU().header + phdr['refframe'] = 'icrs' + assert hstwcs.determine_refframe(phdr) == 'ICRS' + phdr['refframe'] = 'gsc1' + assert hstwcs.determine_refframe(phdr) == 'FK5' + phdr['refframe'] = 'other' + assert hstwcs.determine_refframe(phdr) is None + phdr['refframe'] = ' ' + assert hstwcs.determine_refframe(phdr) is None diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index 27f6467..aeaa43f 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -137,7 +137,8 @@ class HSTWCS(WCS): self.instrument = instrument_name # Set the correct reference frame refframe = determine_refframe(hdr0) - ehdr['RADESYS'] = refframe + if refframe is not None: + ehdr['RADESYS'] = refframe WCS.__init__(self, ehdr, fobj=phdu, minerr=self.minerr, key=self.wcskey) @@ -960,20 +961,34 @@ adaptive=False, detect_divergence=False, quiet=False) def determine_refframe(phdr): """ - Determine the reference frame in standard FITS WCS terms. + Determine the reference frame in standard FITS WCS. + + This is necessary for two reasons: + - The reference frame in HST images is stored not in RADESYS (FITS standard) but in REFFRAME. + - REFFRAME is in the primary header, while the rest of the WCS keywords are in the + extension header. + + The values of REFFRAME are populated from the APT template where observers are + given three options: GSC1 (corresponds to FK5), ICRS or OTHER. + In the case of "OTHER", we leave this to wcslib which has a default of ICRS. Parameters ---------- phdr : `astropy.io.fits.Header` Primary Header of an HST observation - In HST images the reference frame is recorded in the primary extension as REFFRAME. - Values are "GSC1" which means FK5 or ICRS (for GSC2 observations). + Returns + ------- + refframe : str or None + One of the FITS WCS standard reference frames. + """ try: - refframe = phdr['REFFRAME'] + refframe = phdr['REFFRAME'].upper() except KeyError: - refframe = " " + refframe = None if refframe == "GSC1": refframe = "FK5" + elif refframe != "ICRS": + refframe = None return refframe |