diff options
author | dencheva <dencheva@stsci.edu> | 2015-05-22 12:30:48 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2015-05-22 12:30:48 -0400 |
commit | e61b0356aae80773baa27d8fd5bfbd5d5393fa85 (patch) | |
tree | 3116a5ce8e40b4eedc770de8b7b8646ea07cbca5 /lib | |
parent | dc070c60f0d9124ad8ef4c04cd04d96bb5b9a23f (diff) | |
download | stwcs_hcf-e61b0356aae80773baa27d8fd5bfbd5d5393fa85.tar.gz |
Fixes #1074. Raises an IOError is IDCTAB file not found on disk. Tests added too.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@40328 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stwcs/updatewcs/apply_corrections.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/stwcs/updatewcs/apply_corrections.py b/lib/stwcs/updatewcs/apply_corrections.py index 2871a46..7019863 100644 --- a/lib/stwcs/updatewcs/apply_corrections.py +++ b/lib/stwcs/updatewcs/apply_corrections.py @@ -12,7 +12,6 @@ logger = logging.getLogger("stwcs.updatewcs.apply_corrections") #Note: The order of corrections is important -__docformat__ = 'restructuredtext' # A dictionary which lists the allowed corrections for each instrument. # These are the default corrections applied also in the pipeline. @@ -64,17 +63,35 @@ def setCorrections(fname, vacorr=True, tddcorr=True, npolcorr=True, d2imcorr=Tru logger.info("\n\tCorrections to be applied to %s: %s " % (fname, str(acorr))) return acorr + def foundIDCTAB(fname): + """ + This functions looks for an "IDCTAB" keyword in the primary header. + + Returns + ------- + status : bool + If False : MakeWCS, CompSIP and TDDCorr should not be applied. + If True : there's no restriction on corrections, they all should be applied. + + Raises + ------ + IOError : If IDCTAB file not found on disk. + """ + try: - idctab = fileutil.osfn(fits.getval(fname, 'IDCTAB')) + #idctab = fileutil.osfn(fits.getval(fname, 'IDCTAB')) + idctab = fits.getval(fname, 'IDCTAB').strip() + if idctab == 'N/A' or idctab == "": + return False except KeyError: return False - if idctab == 'N/A' or idctab == "": - return False + idctab = fileutil.osfn(idctab) if os.path.exists(idctab): return True else: - return False + raise IOError("IDCTAB file {0} not found".format(idctab)) + def applyTDDCorr(fname, utddcorr): """ |