From 15e0141499e89b08947161fb6546b6ad1a85b2f0 Mon Sep 17 00:00:00 2001 From: Ian McGreer Date: Tue, 31 Jan 2017 13:25:42 -0700 Subject: [PATCH] add mask to fringe master creation, part of #20 --- bokpipe/bokpl.py | 3 ++- bokpipe/bokutil.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bokpipe/bokpl.py b/bokpipe/bokpl.py index 932ece4..76f57e8 100644 --- a/bokpipe/bokpl.py +++ b/bokpipe/bokpl.py @@ -369,7 +369,8 @@ def make_fringe_masters(dataMap,byUtd=False,**kwargs): caldir = dataMap.getCalDir() stackin = dataMap('fringe') # XXX fringeStack = bokproc.BokFringePatternStack(input_map=stackin, -# mask_map=dataMap('skymask'), + mask_map=dataMap('imgmask'), + mask_type='nonzero', raw_stack_file=bokio.FileNameMap(caldir,'_raw'), header_bad_key='BADSKY', **kwargs) diff --git a/bokpipe/bokutil.py b/bokpipe/bokutil.py index 76332b5..b3d1d8d 100644 --- a/bokpipe/bokutil.py +++ b/bokpipe/bokutil.py @@ -496,12 +496,14 @@ def __init__(self,**kwargs): self.inputNameMap = kwargs.get('input_map',IdentityNameMap) self.outputNameMap = kwargs.get('output_map',IdentityNameMap) self.masks = [] + self.maskTypes = [] self.maskNameMap = kwargs.get('mask_map') + self.maskType = kwargs.get('mask_type','gtzero') if self.maskNameMap is None: self.maskNameMap = NullNameMap elif isinstance(self.maskNameMap,fitsio.FITS): # a master mask instead of a map - self.add_mask(self.maskNameMap) + self.add_mask(self.maskNameMap,self.maskType) self.maskNameMap = NullNameMap self.clobber = kwargs.get('clobber',False) self.readOnly = kwargs.get('read_only',False) @@ -515,13 +517,14 @@ def __init__(self,**kwargs): self.nProc = kwargs.get('processes',1) self.procMap = kwargs.get('procmap',map) self.noConvert = False - def add_mask(self,maskFits): + def add_mask(self,maskFits,maskType): if not isinstance(maskFits,FakeFITS): try: maskFits = maskFits(None) # assume it is a map except: maskFits = FakeFITS(maskFits) self.masks.append(maskFits) + self.maskTypes.append(maskType) def _proclog(self,s): if self.nProc > 1: pid = multiprocessing.current_process().name.split('-')[1] @@ -546,6 +549,7 @@ def process_file(self,f): fits = BokMefImage(self.inputNameMap(f), output_file=self.outputNameMap(f), mask_file=self.maskNameMap(f), + mask_type=self.maskType, keep_headers=self.keepHeaders, clobber=self.clobber, header_key=self.headerKey, @@ -560,8 +564,8 @@ def process_file(self,f): return else: raise OutputExistsError(msg) - for maskIm in self.masks: - fits.add_mask(maskIm) + for maskIm,maskType in zip(self.masks,self.maskTypes): + fits.add_mask(maskIm,maskType) self._preprocess(fits,f) for extName,data,hdr in fits: data,hdr = self.process_hdu(extName,data,hdr)