def _get_meds_weight(self, meds, mindex, icut): """ Get a weight map from the input MEDS file """ maxfrac=self.conf['max_zero_weight_frac'] skip=False wt_raw = meds.get_cutout(mindex, icut, type='weight') if self.conf['region'] == 'mof': wt=wt_raw.copy() wt_us = meds.get_cweight_cutout_nearest(mindex, icut) elif self.conf['region'] == "cweight-nearest": wt = meds.get_cweight_cutout_nearest(mindex, icut) wt_us = None elif self.conf['region'] == 'seg_and_sky': wt=meds.get_cweight_cutout(mindex, icut) wt_us = None elif self.conf['region'] == 'weight': wt=wt_raw.copy() wt_us = None else: raise ValueError("no support for region type %s" % self.conf['region']) wt = self._clip_weight(wt) wt_raw = self._clip_weight(wt_raw) if wt_us is not None: wt_us = self._clip_weight(wt_us) try: seg = meds.interpolate_coadd_seg(mindex, icut) except: seg = meds.get_cutout(mindex, icut, type='seg') ''' if self.conf['symmetrize_weight']: raise RuntimeError("this is bogus! Need to zero the map not add") wt = wt + numpy.rot90(wt) wt_raw = wt_raw + numpy.rot90(wt_raw) if wt_us is not None: wt_us = wt_us + numpy.rot90(wt_us) ''' # check raw weight map for zero pixels wzero=numpy.where(wt_raw == 0.0) notok=self._badfrac_too_high( icut, wzero[0].size, wt_raw.shape, maxfrac, 'zero weight' ) if notok: skip=True return wt,wt_us,wt_raw,seg, skip
def _get_meds_weight(self, meds, mindex, icut): """ Get a weight map from the input MEDS file """ if self.conf["region"] == "mof": wt = meds.get_cutout(mindex, icut, type="weight") wt_us = meds.get_cweight_cutout_nearest(mindex, icut) elif self.conf["region"] == "cweight-nearest": wt = meds.get_cweight_cutout_nearest(mindex, icut) wt_us = None elif self.conf["region"] == "seg_and_sky": wt = meds.get_cweight_cutout(mindex, icut) wt_us = None elif self.conf["region"] == "weight": wt = meds.get_cutout(mindex, icut, type="weight") wt_us = None else: raise ValueError("no support for region type %s" % self.conf["region"]) wt = wt.astype("f8", copy=False) w = numpy.where(wt < self.conf["min_weight"]) if w[0].size > 0: wt[w] = 0.0 if wt_us is not None: wt_us = wt_us.astype("f8", copy=False) w = numpy.where(wt_us < self.conf["min_weight"]) if w[0].size > 0: wt_us[w] = 0.0 try: seg = meds.interpolate_coadd_seg(mindex, icut) except: seg = meds.get_cutout(mindex, icut, type="seg") return wt, wt_us, seg