Exemplo n.º 1
0
    def make_mask(self, isl, subn, subm, nsrc, src_id, g_list, delc):
        import functions as func
        # define stuff for calculating gaussian
        boxx, boxy = isl.bbox
        subn = boxx.stop - boxx.start
        subm = boxy.stop - boxy.start
        x, y = N.indices((subn, subm))
        # construct image of each source in the island
        src_image = N.zeros((subn, subm, nsrc), dtype=N.float32)
        nn = 1
        for isrc in range(nsrc):
            if nsrc == 1:
                g_sublist = g_list
            else:
                posn = N.where(src_id == isrc)[0]
                g_sublist = []
                for i in posn:
                    g_sublist.append(g_list[i])
            for g in g_sublist:
                params = func.g2param(g)
                params[1] -= delc[0]
                params[2] -= delc[1]
                gau = func.gaus_2d(params, x, y)
                src_image[:, :, isrc] = src_image[:, :, isrc] + gau
                # mark each pixel as belonging to one source
                # just compare value, should compare with sigma later
        mask = N.argmax(src_image, axis=2) + src_id
        orig_mask = isl.mask_active
        mask[N.where(orig_mask)] = -1

        return mask
Exemplo n.º 2
0
    def make_mask(self, isl, subn, subm, nsrc, src_id, g_list, delc):
        import functions as func
                                        # define stuff for calculating gaussian
        boxx, boxy = isl.bbox
        subn = boxx.stop-boxx.start; subm = boxy.stop-boxy.start
        x, y = N.indices((subn, subm))
                                        # construct image of each source in the island
        src_image = N.zeros((subn, subm, nsrc), dtype=N.float32)
        nn = 1
        for isrc in range(nsrc):
            if nsrc == 1:
                g_sublist = g_list
            else:
                posn = N.where(src_id == isrc)[0]
                g_sublist=[]
                for i in posn:
                    g_sublist.append(g_list[i])
            for g in g_sublist:
                params = func.g2param(g)
                params[1] -= delc[0]; params[2] -= delc[1]
                gau = func.gaus_2d(params, x, y)
                src_image[:,:,isrc] = src_image[:,:,isrc] + gau
                                        # mark each pixel as belonging to one source
                                        # just compare value, should compare with sigma later
        mask = N.argmax(src_image, axis=2) + src_id
        orig_mask = isl.mask_active
        mask[N.where(orig_mask)] = -1

        return mask
Exemplo n.º 3
0
    def make_subim(self, subn, subm, g_list, delc, mc=False):
        import functions as func

        subim = N.zeros((subn, subm), dtype=N.float32)
        x, y = N.indices((subn, subm))
        for g in g_list:
            params = func.g2param(g)
            params[1] -= delc[0]; params[2] -= delc[1]
            if mc:
                # draw random variables from distributions given by errors
                params_err = func.g2param_err(g)
                for i in range(len(params)):
                    mc_param = N.random.normal(loc=params[i], scale=params_err[i])
                    params[i] = mc_param
            gau = func.gaus_2d(params, x, y)
            subim = subim + gau

        return subim
Exemplo n.º 4
0
    def make_subim(self, subn, subm, g_list, delc, mc=False):
        import functions as func

        subim = N.zeros((subn, subm), dtype=N.float32)
        x, y = N.indices((subn, subm))
        for g in g_list:
            params = func.g2param(g)
            params[1] -= delc[0]; params[2] -= delc[1]
            if mc:
                # draw random variables from distributions given by errors
                params_err = func.g2param_err(g)
                for i in range(len(params)):
                    mc_param = N.random.normal(loc=params[i], scale=params_err[i])
                    params[i] = mc_param
            gau = func.gaus_2d(params, x, y)
            subim = subim + gau

        return subim