summaryrefslogtreecommitdiff
path: root/lib/stwcs/updatewcs/utils.py
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2011-10-31 16:36:18 -0400
committerhack <hack@stsci.edu>2011-10-31 16:36:18 -0400
commitc309708ecefd456351667ab9a1636bf0e717a745 (patch)
treedcfd5bbe89b033e5b51231da7a8439e96bd834b6 /lib/stwcs/updatewcs/utils.py
parentebbd2caa93a0144fcea6e8f368ebaf012b8d1d13 (diff)
downloadstwcs_hcf-c309708ecefd456351667ab9a1636bf0e717a745.tar.gz
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
Diffstat (limited to 'lib/stwcs/updatewcs/utils.py')
-rw-r--r--lib/stwcs/updatewcs/utils.py17
1 files changed, 5 insertions, 12 deletions
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'