Skip to content

Commit

Permalink
more darn suffix manipulation. this fixes the case where the orig_fil…
Browse files Browse the repository at this point in the history
…ename is the same as the ad.filename.
  • Loading branch information
KathleenLabrie committed Sep 15, 2021
1 parent 2be662e commit 0c499b9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions geminidr/core/primitives_calibdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def storeCalibration(self, adinputs=None, **params):
(not is_science and 'calibs' in self.upload)):
try:
upload_calibration(fname, is_science=is_science)
pass
except:
log.warning("Unable to upload file to {} system"
.format("science" if is_science else "calibration"))
Expand Down Expand Up @@ -379,13 +380,21 @@ def storeProcessedScience(self, adinputs=None, suffix=None):
if suffix:
ad.update_filename(suffix=suffix, strip=True)
else: # None. Keep the one it has now. (eg. 'stack' for imaging)
# Got to do a bit of gymnastic
# Got to do a bit of gymnastic to figure what the current
# suffix is. If orig.filename and filename are equal and have
# `_`, I have to assume that the last `_` is a suffix. (KL)
root, filetype = os.path.splitext(ad.orig_filename)
m = re.match('(.*){}(.*)'.format(re.escape(root)), ad.filename)
if m.groups()[1]:
suffix, filetype = os.path.splitext(m.groups()[1])
if ad.orig_filename == ad.filename:
pre, post = ad.orig_filename.rsplit('_', 1)
suffix, filetype = os.path.splitext(post)
suffix = '_' + suffix
else:
suffix = ''
m = re.match('(.*){}(.*)'.format(re.escape(root)), ad.filename)
if m.groups()[1] and m.groups()[1] != filetype:

suffix, filetype = os.path.splitext(m.groups()[1])
else:
suffix = ''

ad.phu.set('PROCMODE', self.mode)

Expand Down

0 comments on commit 0c499b9

Please sign in to comment.