Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save photons from the component objects of a ChromaticSum #1285

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion galsim/gsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,21 @@

image.added_flux = added_photons / flux_scale
if save_photons:
image.photons = photons
# We need to check if image already contains photons from a previous call to drawImage,
# for example if doing a ChromaticSum.
if not hasattr(image, 'photons'):
# If not, then simply put the photons into the image.
image.photons = photons
else:
# If photons have already been saved, need to create a new larger array and copy
# in from both the original and new photon arrays.
n_orig_photons = image.photons.size()
n_new_photons = photons.size()
n_total_photons = n_orig_photons + n_new_photons
total_photons = pa.PhotonArray(n_total_photons)
total_photons.copyFrom(image.photons, slice(0, n_orig_photons))
total_photons.copyFrom(photons, slice(n_orig_photons, n_total_photons))
image.photons = total_photons

Check warning on line 1851 in galsim/gsobject.py

View check run for this annotation

Codecov / codecov/patch

galsim/gsobject.py#L1845-L1851

Added lines #L1845 - L1851 were not covered by tests

return image

Expand Down
Loading