@@ -58,18 +58,6 @@ def setup(self, config, base, xsize, ysize, ignore, logger):
5858 # or cached by the skyCatalogs code.
5959 gal .flux = gal .calculateFlux (bandpass )
6060 self .flux = gal .flux
61- # Cap (star) flux at 30M photons to avoid gross artifacts when trying
62- # to draw the Roman PSF in finite time and memory
63- flux_cap = 3e7
64- if self .flux > flux_cap :
65- if (
66- hasattr (gal , "original" )
67- and hasattr (gal .original , "original" )
68- and isinstance (gal .original .original , galsim .DeltaFunction )
69- ) or (isinstance (gal , galsim .DeltaFunction )):
70- gal = gal .withFlux (flux_cap , bandpass )
71- self .flux = flux_cap
72- gal .flux = flux_cap
7361 base ["flux" ] = gal .flux
7462 base ["mag" ] = - 2.5 * np .log10 (gal .flux ) + bandpass .zeropoint
7563 # print('stamp setup2',process.memory_info().rss)
@@ -282,9 +270,12 @@ def draw(self, prof, image, method, offset, config, base, logger):
282270 # print('stamp draw2',process.memory_info().rss)
283271
284272 if method == "phot" :
273+ < << << << photon_sampling
285274 # We already calculated realized_flux above. Use that now and tell GalSim not
286275 # recalculate the Poisson realization of the flux.
287276 gal = gal .withFlux (self .realized_flux , bandpass )
277+ == == == =
278+ >> >> >> > main
288279 # print('stamp draw3b ',process.memory_info().rss)
289280
290281 if not faint and "photon_ops" in config :
@@ -304,7 +295,11 @@ def draw(self, prof, image, method, offset, config, base, logger):
304295
305296 # print('stamp draw3a',process.memory_info().rss)
306297 gal .drawImage (
298+ << << << < photon_sampling
307299 bandpass ,
300+ = == == ==
301+ bandpass = bandpass ,
302+ >> >> >> > main
308303 method = "phot" ,
309304 offset = offset ,
310305 rng = self .rng ,
@@ -314,7 +309,11 @@ def draw(self, prof, image, method, offset, config, base, logger):
314309 photon_ops = photon_ops ,
315310 sensor = None ,
316311 add_to_image = True ,
312+ < << << << photon_sampling
317313 poisson_flux = False ,
314+ == == == =
315+ poisson_flux = True ,
316+ >> >> >> > main
318317 )
319318 else :
320319 fft_image = image .copy ()
@@ -335,10 +334,9 @@ def draw(self, prof, image, method, offset, config, base, logger):
335334 )
336335
337336 # Go back to a combined convolution for fft drawing.
338- gal = gal .withFlux (self .flux , bandpass )
339337 prof = galsim .Convolve ([gal ] + psfs )
340338 try :
341- prof .drawImage (bandpass , ** kwargs )
339+ prof .drawImage (bandpass = bandpass , ** kwargs )
342340 except galsim .errors .GalSimFFTSizeError as e :
343341 # I think this shouldn't happen with the updates I made to how the image size
344342 # is calculated, even for extremely bright things. So it should be ok to
@@ -357,6 +355,7 @@ def draw(self, prof, image, method, offset, config, base, logger):
357355 # with FFT because we switched from phot to fft above.
358356 if self .use_fft_bright :
359357 self .add_poisson_noise (fft_image )
358+ << << << < photon_sampling
360359 # In case we had to make a bigger image, just copy the part we need.
361360 image += fft_image [image .bounds ]
362361 # print('stamp draw3',process.memory_info().rss)
@@ -759,9 +758,17 @@ def draw(self, prof, image, method, offset, config, base, logger):
759758 photons .flux = 1
760759 else :
761760 photons = galsim .PhotonArray (0 )
761+ == == == =
762+ # In case we had to make a bigger image, just copy the part we need.
763+ image += fft_image [image .bounds ]
764+ >> >> >> > main
762765 # print('stamp draw3',process.memory_info().rss)
763766 return photons
764767
768+ def add_poisson_noise (self , fft_image ):
769+ fft_image .array [fft_image .array < 0 ] = 0.0
770+ fft_image .addNoise (galsim .PoissonNoise (rng = self .rng ))
771+
765772
766773# Pick the right function to be _fix_seds.
767774if galsim .__version_info__ < (2 , 5 ):
0 commit comments