From c309708ecefd456351667ab9a1636bf0e717a745 Mon Sep 17 00:00:00 2001 From: hack Date: Mon, 31 Oct 2011 20:36:18 +0000 Subject: Updates to STWCS correct the following problems: - DISTNAME value now generated without recursively stripping everything after the underscore by relying on fileutil.buildNewRootname() - error message for 'attach_to_file()' expanded to provide specific reason for failure - primary header keywords now updated, rather than inserted, by 'updateRefFiles()' to eliminate the problem with creating duplicate keywords git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13932 fe389314-cf27-0410-b35b-8c050e845b92 --- lib/stwcs/updatewcs/utils.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'lib/stwcs/updatewcs/utils.py') diff --git a/lib/stwcs/updatewcs/utils.py b/lib/stwcs/updatewcs/utils.py index 92966da..4a822a7 100644 --- a/lib/stwcs/updatewcs/utils.py +++ b/lib/stwcs/updatewcs/utils.py @@ -48,17 +48,10 @@ def extract_rootname(kwvalue): fullval = kwvalue # Extract filename without path from kwvalue fname = os.path.basename(fullval).strip() - + # Now, rip out just the rootname from the full filename - if '_' in fname: - rootname = fname[:fname.rfind('_')] - elif '.fit' in fname: # on some systems, only .fit is used instead of .fits - rootname = fname[:fname.rfind('.fit')] - elif '.' in fname: # account for non-standard file extensions - rootname = fname[:fname.rfind('.')] - else: - rootname = fname - + rootname = fileutil.buildNewRootname(fname) + return rootname.strip() def construct_distname(fobj,wcsobj): @@ -118,7 +111,7 @@ def build_sipname(fobj): def build_npolname(fobj): try: - npolfile = extract_rootname(fobj[0].header["NPOLFILE"]) + npolfile = extract_rootname(fobj[0].header["NPOLFILE"]).replace('_npl','') except KeyError: if fileutil.countExtn(f, 'WCSDVARR'): npolfile = 'UNKNOWN' @@ -128,7 +121,7 @@ def build_npolname(fobj): def build_d2imname(fobj): try: - d2imfile = extract_rootname(fobj[0].header["D2IMFILE"]) + d2imfile = extract_rootname(fobj[0].header["D2IMFILE"]).replace('_d2i','') except KeyError: if fileutil.countExtn(f, 'D2IMARR'): d2imfile = 'UNKNOWN' -- cgit