From 8352a68bc2286d6f74c99547285fa10ace542d22 Mon Sep 17 00:00:00 2001 From: Ian McGreer Date: Tue, 31 Jan 2017 11:49:05 -0700 Subject: [PATCH] handle existing dq masks --- bokpipe/bokproc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bokpipe/bokproc.py b/bokpipe/bokproc.py index 0603611..f94ad55 100644 --- a/bokpipe/bokproc.py +++ b/bokpipe/bokproc.py @@ -350,9 +350,20 @@ def __init__(self,**kwargs): # but only write out the 4-ccd mask at the end kwargs['read_only'] = True super(BokGenerateDataQualityMasks,self).__init__(**kwargs) + def process_file(self,f): + # need to overload process_file in order to check for output before + # opening input image + outf = self.outputNameMap(f) + if os.path.exists(outf): + if self.clobber: + os.unlink(outf) + else: + self._proclog('data quality mask for %s already exists' % f) + return None + super(BokGenerateDataQualityMasks,self).process_file(f) def _preprocess(self,fits,f): - self._proclog('data quality mask %s' % fits.outFileName) self.hduData = [] + self._proclog('data quality mask for %s' % f) @staticmethod def _grow_saturated_blobs(ccdIm,saturated,minNsat=1000): yi,xi = np.indices(ccdIm.shape)