Beispiel #1
0
    def do_main_calculation(self, central_data, neighbour_data, sel):
        self.generate_central_realisation(central_data, sel)
        if self.complexity != 0:
            self.generate_neighbour_realisation(neighbour_data, central_data,
                                                sel)
            # Draw this neighbour realisation repeatedly on a ring of angular position
            snr, e1, e2 = self.do_position_loop()
        else:
            noise = self.generate_effective_noise(neighbour_data, central_data,
                                                  sel)
            gal, psf = i3s.setup_simple(boxsize=32,
                                        shear=self.g,
                                        flux=self.central_flux,
                                        psf_ellipticity=self.psf_e,
                                        psf_size=self.psf_size,
                                        neighbour=[np.inf, np.inf],
                                        wcs=self.wcs,
                                        opt=self.opt)
            res, cat = i3s.run(gal + noise,
                               psf,
                               opt=self.opt,
                               return_cat=True,
                               show=False)
            snr, e1, e2 = cat.snr, res.e1, res.e2

        return snr, e1, e2
Beispiel #2
0
    def do_position_loop(self):
        """Loop over all possible angular positions for this neighbour realisation."""
        # Some empty datavectors
        De1 = []
        De2 = []
        snr = []

        theta= np.linspace(0,2,10)*np.pi

        for i,t in enumerate(theta):
            print "  --  Level 2 iteration: %d (theta=%f)"%(i,t)

            x = self.neighbour_distance*np.cos(t)
            y = self.neighbour_distance*np.sin(t)

            gal, psf = i3s.setup_simple(boxsize=32, shear=self.g, flux=self.central_flux, psf_ellipticity=self.psf_e, psf_size=self.psf_size, neighbour_ellipticity=self.neighbour_e, neighbour=[x,y], neighbour_flux=self.neighbour_flux, neighbour_size=self.neighbour_radius, wcs=self.wcs, opt=self.opt)
            if self.neighbour_distance< 23:
                wts = self.generate_mock_weightmap(gal.array, x, y)
            else:
                wts = np.ones_like(gal.array)
            res, cat = i3s.run(gal, psf, weights=wts, opt=self.opt, return_cat=True, show=False)

            De1.append(res.e1)
            De2.append(res.e2)
            snr.append(cat.snr)

        # Compute the mean over all positions
        return np.mean(snr), np.mean(De1), np.mean(De2)
Beispiel #3
0
    def do_main_calculation(self, central_data, neighbour_data, sel):
        self.generate_central_realisation(central_data, sel)
        if self.complexity!=0:
            self.generate_neighbour_realisation(neighbour_data, central_data, sel)
            # Draw this neighbour realisation repeatedly on a ring of angular position
            snr, e1, e2 = self.do_position_loop()
        else:
            noise = self.generate_effective_noise(neighbour_data, central_data, sel)
            gal, psf = i3s.setup_simple(boxsize=32, shear=self.g, flux=self.central_flux, psf_ellipticity=self.psf_e, psf_size=self.psf_size,  neighbour=[np.inf,np.inf], wcs=self.wcs, opt=self.opt)
            res, cat = i3s.run(gal+noise, psf, opt=self.opt, return_cat=True, show=False)
            snr, e1, e2 = cat.snr, res.e1, res.e2

        return snr, e1, e2
Beispiel #4
0
    def do_position_loop(self):
        """Loop over all possible angular positions for this neighbour realisation."""
        # Some empty datavectors
        De1 = []
        De2 = []
        snr = []

        theta = np.linspace(0, 2, 10) * np.pi

        for i, t in enumerate(theta):
            print "  --  Level 2 iteration: %d (theta=%f)" % (i, t)

            x = self.neighbour_distance * np.cos(t)
            y = self.neighbour_distance * np.sin(t)

            gal, psf = i3s.setup_simple(boxsize=32,
                                        shear=self.g,
                                        flux=self.central_flux,
                                        psf_ellipticity=self.psf_e,
                                        psf_size=self.psf_size,
                                        neighbour_ellipticity=self.neighbour_e,
                                        neighbour=[x, y],
                                        neighbour_flux=self.neighbour_flux,
                                        neighbour_size=self.neighbour_radius,
                                        wcs=self.wcs,
                                        opt=self.opt)
            if self.neighbour_distance < 23:
                wts = self.generate_mock_weightmap(gal.array, x, y)
            else:
                wts = np.ones_like(gal.array)
            res, cat = i3s.run(gal,
                               psf,
                               weights=wts,
                               opt=self.opt,
                               return_cat=True,
                               show=False)

            De1.append(res.e1)
            De2.append(res.e2)
            snr.append(cat.snr)

        # Compute the mean over all positions
        return np.mean(snr), np.mean(De1), np.mean(De2)