Commit 042e55d9 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

fix sign conventions for field distortion shear

parent 63ca249f
Loading
Loading
Loading
Loading
+6 −37
Original line number Diff line number Diff line
@@ -87,8 +87,6 @@ class Galaxy(MockObject):
            gal = gal.shear(gal_shear)
            gal = galsim.Convolve(psf, gal)
            
            # if fd_shear is not None:
            #     gal = gal.shear(fd_shear)
            objs.append(gal)
        final = galsim.Sum(objs)
        return final
@@ -144,6 +142,11 @@ class Galaxy(MockObject):
        bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
        bulge = bulge.shear(bulge_shape)
        
        if fd_shear:
            g1 += fd_shear.g1
            g2 += fd_shear.g2
        gal_shear = galsim.Shear(g1=g1, g2=g2)

        for i in range(len(bandpass_list)):
            bandpass = bandpass_list[i]

@@ -167,14 +170,9 @@ class Galaxy(MockObject):
            # print("nphotons_sub-band_%d = %.2f"%(i, nphotons))

            psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold)
            # disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp)
            # disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk)
            # disk = disk.shear(disk_shape)
            # bulge = galsim.Sersic(n=self.bulge_sersic_idx, half_light_radius=self.hlr_bulge, flux=1.0, gsparams=gsp)
            # bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
            # bulge = bulge.shear(bulge_shape)
            
            gal_temp = self.bfrac * bulge + (1.0 - self.bfrac) * disk
            gal_temp = gal_temp.shear(gal_shear)

            gal_temp = gal_temp.withFlux(nphotons)
            if not big_galaxy: # Not apply PSF for very big galaxy
@@ -190,27 +188,6 @@ class Galaxy(MockObject):
            # kfrac = np.random.random()*(1.0 - self.bfrac)
            # gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots

            # gal = gal.withFlux(nphotons)
            # gal_shear = galsim.Shear(g1=g1, g2=g2)
            # gal = gal.shear(gal_shear)

            # if not big_galaxy: # Not apply PSF for very big galaxy
            #     gal = galsim.Convolve(psf, gal)
            #     # if fd_shear is not None:
            #     #     gal = gal.shear(fd_shear)

            # # Use (explicit) stamps to draw
            # stamp = gal.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
            
            # xmax = max(xmax, stamp.xmax - stamp.xmin)
            # ymax = max(ymax, stamp.ymax - stamp.ymin)

            # photons = stamp.photons
            # photons.x += x_nominal
            # photons.y += y_nominal
            # photons_list.append(photons)
            # del gal

        # # [C6 TEST]
        # print('xmax = %d, ymax = %d '%(xmax, ymax))
        # # Output memory usage
@@ -218,13 +195,6 @@ class Galaxy(MockObject):
        # top_stats = snapshot.statistics('lineno')
        # for stat in top_stats[:10]:
        #     print(stat)
        if fd_shear:
            g1 += fd_shear.g1
            g2 += fd_shear.g2
        gal_shear = galsim.Shear(g1=g1, g2=g2)
        gal = gal.shear(gal_shear)
        # if fd_shear is not None:
        #     gal = gal.shear(fd_shear)

        stamp = gal.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
        photons = stamp.photons
@@ -232,7 +202,6 @@ class Galaxy(MockObject):
        photons.y += y_nominal
        photons_list.append(photons)

        # stamp = galsim.ImageF(int(xmax * 1.1), int(ymax * 1.1))
        stamp.wcs = real_wcs_local
        stamp.setCenter(x_nominal, y_nominal)
        bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ class Observation(object):
                    continue
                
                # [TODO] Testing
                chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()]))
                # chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()]))

                # Exclude very bright/dim objects (for now)
                if cut_filter.is_too_bright(
+2 −6
Original line number Diff line number Diff line
@@ -102,12 +102,8 @@ class FieldDistortion(object):
        g_abs = np.sqrt(g1k_fd**2 + g2k_fd**2)
        phi = cmath.phase(complex(g1k_fd, g2k_fd))
        # g_abs = 0.7
        g1k_fd = g_abs * np.cos(phi - 2*img_rot)
        g2k_fd = g_abs * np.sin(phi - 2*img_rot)
        # g1k_fd = g_abs * np.cos(phi - 2*img_rot)
        # g2k_fd = -g_abs * np.sin(phi - 2*img_rot)
        # g1k_fd = g_abs * np.cos(0. - 2*img_rot)
        # g2k_fd = g_abs * np.sin(0. - 2*img_rot)
        g1k_fd = g_abs * np.cos(phi + 2*img_rot)
        g2k_fd = g_abs * np.sin(phi + 2*img_rot)

        fd_shear = galsim.Shear(g1=g1k_fd, g2=g2k_fd)
        return galsim.PositionD(x, y), fd_shear