diff options
author | dencheva <dencheva@stsci.edu> | 2009-10-13 17:17:15 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2009-10-13 17:17:15 -0400 |
commit | 89d2a4afc0c4961baaa1ce47354f544ffc02f942 (patch) | |
tree | 2b279359d90399d1c0f05686acda754a6850b651 /updatewcs/dgeo.py | |
parent | a4d8cb52c1bc7649b13c292eb56f2059f38cfc95 (diff) | |
download | stwcs_hcf-89d2a4afc0c4961baaa1ce47354f544ffc02f942.tar.gz |
Changes to the WCSDVARR extension header which allow mapping of the dgeo table to image coordinates when the science image is a subarray.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@8334 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'updatewcs/dgeo.py')
-rw-r--r-- | updatewcs/dgeo.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/updatewcs/dgeo.py b/updatewcs/dgeo.py index e50725d..d1db3fd 100644 --- a/updatewcs/dgeo.py +++ b/updatewcs/dgeo.py @@ -184,23 +184,36 @@ class DGEOCorr(object): def createDgeoHdr(cls, sciheader, dgeofile, wdvarr_ver, dgeoname, extver): """ Creates a header for the WCSDVARR extension based on the DGEO reference file - and sci extension header. + and sci extension header. The goal is to always work in image coordinates + (also for subarrays and binned images. The WCS for the WCSDVARR extension + i ssuch that a full size dgeo table is created and then shifted or scaled + if the science image is a subarray or binned image. """ dgeo_header = pyfits.getheader(dgeofile, ext=(dgeoname,extver)) - sci_naxis1 = sciheader['NAXIS1'] - sci_naxis2 = sciheader['NAXIS2'] - sci_crpix1 = sciheader['CRPIX1'] - sci_crpix2 = sciheader['CRPIX2'] + + #LTV1/2 are needed to map correctly dgeo files into subarray coordinates + ltv1 = sciheader.get('LTV1', 0.0) + ltv2 = sciheader.get('LTV2', 0.0) + + # This is the size of the full dgeo chip + # recorded in the small dgeo table and needed in order to map to full dgeo + # chip coordinates. + chip_size1 = dgeo_header['ONAXIS1'] + chip_size2 = dgeo_header['ONAXIS2'] naxis1 = dgeo_header['naxis1'] naxis2 = dgeo_header['naxis2'] extver = dgeo_header['extver'] crpix1 = naxis1/2. crpix2 = naxis2/2. - cdelt1 = float(sci_naxis1)/naxis1 - cdelt2 = float(sci_naxis2)/naxis2 - crval1 = sci_crpix1 - crval2 = sci_crpix2 + cdelt1 = float(chip_size1)/naxis1 + cdelt2 = float(chip_size2)/naxis2 + + # CRVAL1/2 of the small dgeo table is the shifted center of the full + # dgeo chip. + crval1 = chip_size1/2. +ltv1 + crval2 = chip_size2/2. + ltv2 + keys = ['XTENSION','BITPIX','NAXIS','NAXIS1','NAXIS2', 'EXTNAME','EXTVER','PCOUNT','GCOUNT','CRPIX1', 'CDELT1','CRVAL1','CRPIX2','CDELT2','CRVAL2'] |