From 93c2fa40dbcf4ad66b3a272a15ed29c68410db1a Mon Sep 17 00:00:00 2001 From: Felipe Menanteau Date: Fri, 22 Jul 2016 18:19:04 +0000 Subject: [PATCH] added --null_mask_sci option to coadd_nwgint.py --- pixcorrect_test.build | 2 +- python/pixcorrect/coadd_nwgint.py | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pixcorrect_test.build b/pixcorrect_test.build index 2c05542..8c3fe50 100755 --- a/pixcorrect_test.build +++ b/pixcorrect_test.build @@ -9,7 +9,7 @@ echo "Will Install to: $PRODUCT_DIR" source $EUPS_DIR/desdm_eups_setup.sh setup -v scipy 0.14.0+7 -setup -v despyfits 0.5.0+0 +setup -v despyfits 0.5.1+2 #setup -v -r ~/build-test/despyfits export PYTHONPATH=$PRODUCT_DIR/python:$PYTHONPATH diff --git a/python/pixcorrect/coadd_nwgint.py b/python/pixcorrect/coadd_nwgint.py index 432dc4c..85cf1aa 100755 --- a/python/pixcorrect/coadd_nwgint.py +++ b/python/pixcorrect/coadd_nwgint.py @@ -30,12 +30,12 @@ class CoaddZipperInterpNullWeight(PixCorrectMultistep): DEFAULT_TILENAME = False DEFAULT_TILEID = False DEFAULT_ME_WGT_KEEPMASK = False + DEFAULT_NULL_MASK_SCI = '0' # Fix the step_name for passing the command-line arguments to the classes null_weights.__class__.step_name = config_section row_zipper.__class__.step_name = config_section - def __call__(self): """ Run row_zipper and null_weights in one step, we run the tasks @@ -77,6 +77,9 @@ def __call__(self): logger.info("Running row_zipper on: %s" % input_image) row_zipper.step_run(self.sci,self.config) logger.info("Time ZipperInterp : %s" % elapsed_time(t2)) + + # Null the sci image only if null_mask_sci !=0 + self.null_sci(input_image) output_image = self.config.get(self.config_section, 'out') # Special write out @@ -113,6 +116,18 @@ def update_sci_header(cls,input_image): cls.sci.header.add_record(record) + def null_sci(cls, input_image): + + null_mask_sci = parse_badpix_mask( cls.config.get(cls.config_section, 'null_mask_sci') ) + if null_mask_sci !=0: + logger.info('Nulling science image from null_mask_bits') + kill = np.array(cls.sci.mask & null_mask_sci, dtype=bool) + cls.sci.data[kill] = 0.0 + else: + logger.info('Science image was not null') + + return + def custom_weight(cls,input_image): # Make custom weight, that will not zero STAR maskbit logger.info("Will perform special weighting for multi-epoch input on %s" % input_image) @@ -183,10 +198,12 @@ def add_step_args(cls, parser): """ null_weights.add_step_args(parser) row_zipper.add_step_args(parser) - parser.add_argument('--custom_weight', action='store_true',default=cls.DEFAULT_CUSTOM_WEIGHT, - help='Run custom weights for STAR and do not write MSK plane for multi-epoch (me)') + #parser.add_argument('--custom_weight', action='store_true',default=cls.DEFAULT_CUSTOM_WEIGHT, + # help='Run custom weights for STAR and do not write MSK plane for multi-epoch (me)') parser.add_argument('--me_wgt_keepmask', action='store',default=cls.DEFAULT_ME_WGT_KEEPMASK, - help='Run custom weight and preserve bits and do not write MSK plane for multi-epoch (me)') + help='Run custom weight for multi-epoch (me) WGT_ME and preserve KEEPMASK') + parser.add_argument('--null_mask_sci', action='store',default=cls.DEFAULT_NULL_MASK_SCI, + help='Names of mask bits to null (or an integer mask) on the SCI plane') parser.add_argument('--headfile', action='store', default=cls.DEFAULT_HEADFILE, help='Headfile (containing most update information)') parser.add_argument('--hdupcfg', action='store', default=cls.DEFAULT_HDUPCFG,