From 9129df8f51b94535cea7ef704c95739af597acae Mon Sep 17 00:00:00 2001
From: xin <zhangxinbjfu@gmail.com>
Date: Wed, 28 Sep 2022 09:43:51 +0800
Subject: [PATCH] upload code to server

---
 ObservationSim/MockObject/MockObject.py | 64 ++++++++++++-------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/ObservationSim/MockObject/MockObject.py b/ObservationSim/MockObject/MockObject.py
index bbb1b6e..ca9d41f 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
-- 
GitLab