When save_photons = True, drawing a ChromaticObject returns all the photons requested. However, if those objects are combined into a ChromaticSum only the photons drawn for the final object are returned:
import galsim
rng = galsim.BaseDeviate(215324)
sed = galsim.SED('vega.txt', wave_type="nm", flux_type="fphotons")
bandpass = galsim.Bandpass("LSST_r.dat", wave_type="nm")
# Create a bulge and disk and draw with 1000 photons each.
bulge = galsim.Sersic(n=3, half_light_radius=0.8) * sed
disk = galsim.Exponential(half_light_radius=1.4) * sed
bulge_image = bulge.drawImage(method="phot", n_photons=1000, save_photons=True, bandpass=bandpass, rng=rng)
disk_image = disk.drawImage(method="phot", n_photons=1000, save_photons=True, bandpass=bandpass, rng=rng)
# All 1000 photons are returned for each of the separate bulge and disk.
print(bulge_image.photons, disk_image.photons)
# Create a ChromaticSum object combining the bulge and disk then draw it with 1000 photons.
gal = bulge + disk
gal_image = gal.drawImage(method="phot", n_photons=1000, save_photons=True, bandpass=bandpass, rng=rng)
# The ChromaticSum's photon array only contains 511 photons.
print(gal_image.photons)
ChromaticSum.drawImage loops through the individual components, drawing them in sequence. The photons are actually saved in GSObject.drawImage at the very end of the function but simply does image.photons = photons, replacing any previously saved object's photon array with the current one.
I think either a full-sized photon array should be allocated in ChromaticSum.drawImage and then filled in GSObject.drawImage, or else the latter should check if a photon array has already been stored and if so extend rather than overwrite it.
When
save_photons = True
, drawing aChromaticObject
returns all the photons requested. However, if those objects are combined into aChromaticSum
only the photons drawn for the final object are returned:ChromaticSum.drawImage
loops through the individual components, drawing them in sequence. The photons are actually saved inGSObject.drawImage
at the very end of the function but simply doesimage.photons = photons
, replacing any previously saved object's photon array with the current one.I think either a full-sized photon array should be allocated in
ChromaticSum.drawImage
and then filled inGSObject.drawImage
, or else the latter should check if a photon array has already been stored and if so extend rather than overwrite it.