diff options
Diffstat (limited to 'distortion/mutil.py')
-rw-r--r-- | distortion/mutil.py | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/distortion/mutil.py b/distortion/mutil.py index 44b46cd..780de0b 100644 --- a/distortion/mutil.py +++ b/distortion/mutil.py @@ -74,7 +74,23 @@ def readIDCtab (tabname, chip=1, date=None, direction='forward', detector = str(ftab['PRIMARY'].header['CAMERA']) else: detector = 1 - + # First, read in TDD coeffs if present + phdr = ftab['PRIMARY'].header + skew_coeffs = read_tdd_coeffs(phdr) + """ + # Read in ACS TDD correction coefficients + if ftab['PRIMARY'].header.has_key('INSTRUME'): + instrument = ftab['PRIMARY'].header['INSTRUME'] + if instrument == 'ACS' and detector == 'WFC': + skew_coeffs = None + if phdr.has_key('TDD_DATE'): + print 'Reading TDD coefficients from ',tabname + skew_coeffs = read_tdd_coeffs(phdr) + # Using coefficients read in from IDCTAB Primary header + #skew_coeffs = {'TDD_A0':phdr['TDD_A0'],'TDD_A1':phdr["TDD_A1"], + # 'TDD_B0':phdr['TDD_B0'],'TDD_B1':phdr['TDD_B1'], + # 'TDD_D0':phdr['TDD_D0'],'TDD_DATE':phdr['TDD_DATE']} + """ # Set default filters for SBC if detector == 'SBC': if filter1 == 'CLEAR': @@ -195,6 +211,7 @@ def readIDCtab (tabname, chip=1, date=None, direction='forward', refpix['YDELTA'] = 0.0 refpix['DEFAULT_SCALE'] = yes refpix['centered'] = no + refpix['skew_coeffs'] = skew_coeffs # Now that we know which row to look at, read coefficients into the # numeric arrays we have set up... @@ -228,6 +245,41 @@ def readIDCtab (tabname, chip=1, date=None, direction='forward', # Return arrays and polynomial order read in from table. # NOTE: XREF and YREF are stored in Fx,Fy arrays respectively. return fx,fy,refpix,order +# +# +# Time-dependent skew correction coefficients (only ACS/WFC) +# +# +def read_tdd_coeffs(phdr): + ''' Read in the TDD related keywords from the PRIMARY header of the IDCTAB + ''' + skew_coeffs = {} + skew_coeffs['TDDORDER'] = 0 + skew_coeffs['TDD_DATE'] = "" + skew_coeffs['TDD_A'] = None + skew_coeffs['TDD_B'] = None + + if phdr.has_key("TDDORDER"): + n = int(phdr["TDDORDER"]) + else: + print 'TDDORDER kw not present, TDD correction will not be applied.' + return skew_coeffs + + a = np.zeros((n+1,), np.float64) + b = np.zeros((n+1,), np.float64) + for i in range(n+1): + a[i] = phdr.get(("TDD_A%d" % i), 0.0) + b[i] = phdr.get(("TDD_B%d" % i), 0.0) + if (a==0).all() and (b==0).all(): + print 'Warning: TDD_A and TDD_B coeffiecients have values of 0, \n \ + but TDDORDER is %d.' % TDDORDER + + skew_coeffs['TDDORDER'] = n + skew_coeffs['TDD_DATE'] = phdr['TDD_DATE'] + skew_coeffs['TDD_A'] = a + skew_coeffs['TDD_B'] = b + + return skew_coeffs def readOfftab(offtab, date, chip=None): |