Skip to content

Commit

Permalink
add mask to fringe master creation, part of #20
Browse files Browse the repository at this point in the history
  • Loading branch information
imcgreer committed Jan 31, 2017
1 parent 8352a68 commit 15e0141
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bokpipe/bokpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions bokpipe/bokutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 15e0141

Please sign in to comment.