summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2011-08-19 17:24:02 -0400
committerhack <hack@stsci.edu>2011-08-19 17:24:02 -0400
commitc762b30cd71f17debe7fc4ad3679e2c84ebd3915 (patch)
tree476cd5fbfa9f70d3572f56d023f06e21be19291d
parent2e1bac4dc7916e961180cdde875a3266f0a8fe7b (diff)
downloadstwcs_hcf-c762b30cd71f17debe7fc4ad3679e2c84ebd3915.tar.gz
The 'createDgeoHDU' and 'createNpolHDU' methods in 'udpatewcs' were updated to also include header keywords from the reference file's primary header. This information will provide the user with the source of the calibration data.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13649 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--lib/stwcs/updatewcs/det2im.py16
-rw-r--r--lib/stwcs/updatewcs/npol.py15
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/stwcs/updatewcs/det2im.py b/lib/stwcs/updatewcs/det2im.py
index fe683b4..bda3ca3 100644
--- a/lib/stwcs/updatewcs/det2im.py
+++ b/lib/stwcs/updatewcs/det2im.py
@@ -175,7 +175,21 @@ class DET2IMCorr(object):
cdl.append(pyfits.Card(key=key, value=kw_val0[key], comment=kw_comm0[key]))
for key in kw_comm1.keys():
cdl.append(pyfits.Card(key=key, value=kw_val1[key], comment=kw_comm1[key]))
-
+ # Now add keywords from NPOLFILE header to document source of calibration
+ # include all keywords after and including 'FILENAME' from header
+ d2im_phdr = pyfits.getheader(d2imfile)
+ start_indx = -1
+ end_indx = 0
+ for c,i in zip(d2im_phdr,range(len(d2im_phdr))):
+ if c == 'FILENAME':
+ start_indx = i
+ if c == '': # remove blanks from end of header
+ end_indx = i+1
+ break
+ if start_indx >= 0:
+ for card in d2im_phdr[start_indx:end_indx]:
+ cdl.append(card)
+
hdr = pyfits.Header(cards=cdl)
return hdr
diff --git a/lib/stwcs/updatewcs/npol.py b/lib/stwcs/updatewcs/npol.py
index acef50b..18f73b0 100644
--- a/lib/stwcs/updatewcs/npol.py
+++ b/lib/stwcs/updatewcs/npol.py
@@ -233,6 +233,7 @@ class NPOLCorr(object):
if the science image is a subarray or binned image.
"""
npl = pyfits.open(npolfile)
+ npol_phdr = npl[0].header
for ext in npl:
try:
nplextname = ext.header['EXTNAME']
@@ -294,7 +295,19 @@ class NPOLCorr(object):
cdl.append(pyfits.Card(key=key, value=kw_val0[key], comment=kw_comm0[key]))
for key in kw_comm1.keys():
cdl.append(pyfits.Card(key=key, value=kw_val1[key], comment=kw_comm1[key]))
-
+ # Now add keywords from NPOLFILE header to document source of calibration
+ # include all keywords after and including 'FILENAME' from header
+ start_indx = -1
+ end_indx = 0
+ for c,i in zip(npol_phdr,range(len(npol_phdr))):
+ if c == 'FILENAME':
+ start_indx = i
+ if c == '': # remove blanks from end of header
+ end_indx = i+1
+ break
+ if start_indx >= 0:
+ for card in npol_phdr[start_indx:end_indx]:
+ cdl.append(card)
hdr = pyfits.Header(cards=cdl)