From 40377535c7738b8022fda859228520918a99b0ff Mon Sep 17 00:00:00 2001 From: hack Date: Mon, 7 Nov 2011 21:38:58 +0000 Subject: This revision fixes problems with WCSCORR table updates; specifically, - added fit keywords (rms*,nmatch,catalog) to SIPWCS header in headerlet for use in updating WCSCORR - changed definition of FIT_KW to get values from SCI header, not PRIMARY - changed calls to finding blank rows to also use rows with wcs_id='0.0' as a blank row. This also required updating the logic to support multiple selection criteria - implemented update of WCSCORR by wcskey value - get FIT keywords from full header, not just HSTWCS header - only update columns which have been defined (for backward compatiblity with WCSCORR tables with columns that have since been removed from the definition) These changes have been tested to insure that the RMS values get updated in the WCSCORR table properly from the SCI image as well as from the headerlet. They also make sure the headerlet gets updated with the correct values. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13971 fe389314-cf27-0410-b35b-8c050e845b92 --- lib/stwcs/wcsutil/headerlet.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib/stwcs/wcsutil/headerlet.py') diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py index 814d9c4..edcd9c6 100644 --- a/lib/stwcs/wcsutil/headerlet.py +++ b/lib/stwcs/wcsutil/headerlet.py @@ -773,7 +773,8 @@ def write_headerlet(filename, hdrname, output=None, sciext='SCI', fobj.append(hdrlet_hdu) # Update the WCSCORR table with new rows from the headerlet's WCSs - wcscorr.update_wcscorr(fobj, source=hdrletobj, extname='SIPWCS') + wcscorr.update_wcscorr(fobj, source=hdrletobj, extname='SIPWCS', + wcs_id=wname) fobj.flush() else: @@ -975,13 +976,13 @@ def create_headerlet(filename, sciext='SCI', hdrname=None, destim=None, wcskey=" distname = utils.build_distname(sipname, npolfile, d2imfile) rms_ra = getHeaderKWVals(fobj[wcsext].header, - ("RMS_RA"+wcskey).rstrip(), rms_ra, default=0) + ("RMS_RA"+wcskey).rstrip(), rms_ra, default=0) rms_dec = getHeaderKWVals(fobj[wcsext].header, - ("RMS_DEC"+wcskey).rstrip(), rms_dec, default=0) + ("RMS_DEC"+wcskey).rstrip(), rms_dec, default=0) nmatch = getHeaderKWVals(fobj[wcsext].header, - ("NMATCH"+wcskey).rstrip(), nmatch, default=0) + ("NMATCH"+wcskey).rstrip(), nmatch, default=0) catalog = getHeaderKWVals(fobj[wcsext].header, - ("CATALOG"+wcskey).rstrip(), catalog, default="") + ("CATALOG"+wcskey).rstrip(), catalog, default="") # get the version of STWCS used to create the WCS of the science file. try: @@ -1055,6 +1056,14 @@ def create_headerlet(filename, sciext='SCI', hdrname=None, destim=None, wcskey=" h = hwcs.wcs2header(sip2hdr=True) if hasattr(hwcs,'orientat'): h.update('ORIENTAT',hwcs.orientat, comment=orient_comment) + h.update('RMS_RA',rms_ra, + comment='RMS in RA at ref pix of headerlet solution') + h.update('RMS_DEC',rms_dec, + comment='RMS in Dec at ref pix of headerlet solution') + h.update('NMATCH',nmatch, + comment='Number of sources used for headerlet solution') + h.update('CATALOG',catalog, + comment='Astrometric catalog used for headerlet solution') if wcskey != ' ': # Now read in specified linear WCS terms from alternate WCS -- cgit