Commit 9129df8f authored by xin's avatar xin
Browse files

upload code to server

parent 2468ff7c
Loading
Loading
Loading
Loading
+32 −32
Original line number Diff line number Diff line
@@ -197,46 +197,29 @@ class MockObject(object):
            star = star.withFlux(nphotons)
            star = galsim.Convolve(psf, star)

            # stamp = star.drawImage(wcs=self.localWCS, method='phot', offset=self.offset, save_photons=True)
            # xmax = max(xmax, stamp.xmax)
            # ymax = max(ymax, stamp.ymax)
            # photons = stamp.photons
            # photons.x += self.x_nominal
            # photons.y += self.y_nominal
            # photons_list.append(photons)



            stamp = star.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
            stamp = star.drawImage(wcs=self.localWCS, method='phot', offset=self.offset, save_photons=True)
            xmax = max(xmax, stamp.xmax)
            ymax = max(ymax, stamp.ymax)
            photons = stamp.photons
            photons.x += x_nominal
            photons.y += y_nominal
            photons.x += self.x_nominal
            photons.y += self.y_nominal
            photons_list.append(photons)

        stamp = galsim.ImageF(int(xmax * 1.1), int(ymax * 1.1))
        stamp.wcs = self.real_wcs_local
        stamp.setCenter(x_nominal, y_nominal)
        bounds = stamp.bounds & galsim.BoundsD(0, chip.npix_x-1, 0, chip.npix_y-1)
        chip.img.setOrigin(0, 0)
        stamp[bounds] = chip.img[bounds]
        for i in range(len(photons_list)):
            if i == 0:
                chip.sensor.accumulate(photons_list[i], stamp)
            else:
                chip.sensor.accumulate(photons_list[i], stamp, resume=True)

        chip.img[bounds] = stamp[bounds]

        chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
        # Test stamp size
        # print(xmax, ymax)
            # stamp = star.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
            # xmax = max(xmax, stamp.xmax)
            # ymax = max(ymax, stamp.ymax)
            # photons = stamp.photons
            # photons.x += x_nominal
            # photons.y += y_nominal
            # photons_list.append(photons)

        # stamp = galsim.ImageF(int(xmax * 1.1), int(ymax * 1.1))
        # stamp.wcs = self.localWCS
        # stamp.setCenter(self.x_nominal, self.y_nominal)
        # bounds = stamp.bounds & chip.img.bounds
        # 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)
        # chip.img.setOrigin(0, 0)
        # stamp[bounds] = chip.img[bounds]
        # for i in range(len(photons_list)):
        #     if i == 0:
@@ -245,6 +228,23 @@ class MockObject(object):
        #         chip.sensor.accumulate(photons_list[i], stamp, resume=True)
        #
        # chip.img[bounds] = stamp[bounds]
        #
        # chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
        # Test stamp size
        # print(xmax, ymax)

        stamp = galsim.ImageF(int(xmax*1.1), int(ymax*1.1))
        stamp.wcs = self.localWCS
        stamp.setCenter(self.x_nominal, self.y_nominal)
        bounds = stamp.bounds & chip.img.bounds
        stamp[bounds] = chip.img[bounds]
        for i in range(len(photons_list)):
            if i == 0:
                chip.sensor.accumulate(photons_list[i], stamp)
            else:
                chip.sensor.accumulate(photons_list[i], stamp, resume=True)

        chip.img[bounds] = stamp[bounds]
        # print(chip.img.array.sum())
        # print("nphotons_sum = ", nphotons_sum)
        del photons_list