Commit 66f3e5a0712a21133d5d0d6c39776b7ee820442e
1 parent
b689e55e
Add DRW file suffix to combined DRW filename
Showing
1 changed file
with
28 additions
and
2 deletions
modules/comscripts/comobsadd.py
... | ... | @@ -21,6 +21,7 @@ |
21 | 21 | import sys |
22 | 22 | import glob |
23 | 23 | import os |
24 | +import re | |
24 | 25 | import gammalib |
25 | 26 | import ctools |
26 | 27 | |
... | ... | @@ -254,10 +255,35 @@ class comobsadd(ctools.csobservation): |
254 | 255 | drw.num_used_superpackets(ebin['nspuse']) |
255 | 256 | drw.num_skipped_superpackets(ebin['nspskp']) |
256 | 257 | |
257 | - # Set DRE, DRB and DRW filenames | |
258 | + # Set DRE and DRB filenames | |
258 | 259 | dre.name('%s/%s_%s_dre.fits' % (self['outfolder'].string(), prefix, id)) |
259 | 260 | drb.name('%s/%s_%s_drb.fits' % (self['outfolder'].string(), prefix, id)) |
260 | - drw.name('%s/%s_%s_drw.fits' % (self['outfolder'].string(), prefix, id)) | |
261 | + | |
262 | + # Determine DRW method | |
263 | + drwmethod = None | |
264 | + for drwname in ebin['drws']: | |
265 | + | |
266 | + # Extract method | |
267 | + suffix = re.findall('drw-(.*)_', drwname.url()) | |
268 | + if len(suffix) > 0: | |
269 | + method = suffix[0] | |
270 | + else: | |
271 | + method = '' | |
272 | + | |
273 | + # Check DRW method | |
274 | + if drwmethod == None: | |
275 | + drwmethod = method | |
276 | + else: | |
277 | + if drwmethod != method: | |
278 | + msg = ('Inconsistent DRW method "'+method+'" encountered, ' | |
279 | + 'expected "'+drwmethod+'".') | |
280 | + raise RuntimeError(msg) | |
281 | + | |
282 | + # Set DRW filename | |
283 | + if drwmethod == None or drwmethod == '': | |
284 | + drw.name('%s/%s_%s_drw.fits' % (self['outfolder'].string(), prefix, id)) | |
285 | + else: | |
286 | + drw.name('%s/%s_%s_drw-%s.fits' % (self['outfolder'].string(), prefix, id, drwmethod)) | |
261 | 287 | |
262 | 288 | # Put DRE, DRB and DRW in lists |
263 | 289 | self._dres.append(dre.copy()) | ... | ... |