コード例 #1
0
    def update_bitmask_flat(self, flatfield):
        # doing this to avoid having to keep flatfield images in memory

        thresh = 0.6 # very little thought put into this choice..
        d = common.mask_bit_dict()
        if self.bitmask is None:
            self.bitmask = ((flatfield < thresh)*(2**d['FLATBAD'])).astype('byte')
        else:
            self.bitmask += ((flatfield < thresh)*(2**d['FLATBAD'])).astype('byte')
コード例 #2
0
ファイル: phot.py プロジェクト: dstndstn/gfa_reduce
def get_source_list(image, bitmask, extname, ivar_adu, max_cbox=31,
                    run_aper_phot=True, thresh=5, skip_2dg=False):

    print('Attempting to catalog sources in ' + extname + ' image')

    assert((thresh >= 4) and (thresh <= 100))

    par = common.mask_bit_dict()
    
    image = djs_maskinterp.average_bilinear(image, (np.bitwise_and(bitmask, 1) != 0))

    nominal_fwhm_pix = get_nominal_fwhm_pix(extname)

    detsn = detection_map(image, nominal_fwhm_pix)

    slices = detect_sources(detsn, thresh)

    all_detections = slices_to_table(slices, detsn, extname)

    all_detections = detmap_centroids(all_detections, detsn, max_cbox=max_cbox)

    if len(all_detections) == 0:
        return None, detsn, all_detections, image

    tab = copy.deepcopy(all_detections)

    # only compute this 'sigma map' once to avoid wasted processing time
    sig_adu_map = aper_phot_unc_map(ivar_adu)
    refine_centroids(tab, image, bitmask, ivar_adu, sig_adu=sig_adu_map,
                     skip_2dg=skip_2dg)

    # attempt to remove hot pixels, think this is safe since i end up
    # rejecting (sig_major_pix <= 1) sources when computing
    # overall FWHM and recalibrating the astrometry
    ### tab = tab[tab['sig_major_pix'] > 1.0] # HACK !!!!!
    
    add_metadata_columns(tab, bitmask)

    tab = tab[(tab['min_edge_dist_pix'] > -5)]

    if len(tab) == 0:
        return None, detsn, all_detections, image

    tab['DETMAP_THRESH'] = thresh

    if run_aper_phot:
        do_aper_phot(image, tab, extname, ivar_adu, sig_adu=sig_adu_map)

    # add 'image' to set of outputs since it gets modified
    # and this modification won't persist into the GFA_image object
    # when this is being run via multiprocessing
    return tab, detsn, all_detections, image
コード例 #3
0
    def create_dq_mask(self, dark_image):
        if self.bitmask is not None:
            return

        d = common.mask_bit_dict()
        thresh = scoreatpercentile(dark_image, 99.5)
        if self.bitmask is None:
            self.bitmask = ((dark_image > thresh)*(2**d['HOTDARK'])).astype('byte')
        else:
            self.bitmask += ((dark_image > thresh)*(2**d['HOTDARK'])).astype('byte')
        self.bitmask += self.satmask*(2**d['SATUR'])

        self.bitmask = self.bitmask.astype('byte') # just to make sure...
        del self.satmask
コード例 #4
0
ファイル: dq_mask.py プロジェクト: dstndstn/gfa_reduce
def add_dq_bitmask_header_cards(h):
    # h should be a FITS header
    # input gets modified !!

    maskbits = common.mask_bit_dict()

    for k, v in maskbits.items():
        card_name = 'MASKB' + str(v)
        card_value = common.mask_bit_description(k)

        comment = 'Mask bit 2**' + str(v) + '=' + str(2**v) + ' meaning'
        h[card_name] = (card_value, comment)

    return h