diff --git a/ObservationSim/MockObject/MockObject.py b/ObservationSim/MockObject/MockObject.py index bbb1b6e8b21c25e4c51040bdd73363250ff6cf64..ca9d41f11ab00d467437afb3f32880f58c0dbba2 100755 --- a/ObservationSim/MockObject/MockObject.py +++ b/ObservationSim/MockObject/MockObject.py @@ -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 = 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) + # 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