-
Notifications
You must be signed in to change notification settings - Fork 104
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
Add obj.makePhot method #1078
Add obj.makePhot method #1078
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just one question: would it be possible for drawPhot
to use makePhot
? Too tricky with the resume I'm guessing?
That was originally my plan, but with all the maxN and resume stuff, if seemed a little too much to untangle cleanly. This seemed simpler, and the unit tests make sure they are equivalent for their overlapping use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks! Two minor comments/question in the review.
Also, just for my education/curiosity: Why all the changes to " rng=rng.duplicate()" in the tests? Was it not giving a reproducible sequence before?
galsim/gsobject.py
Outdated
@@ -2067,6 +2067,101 @@ def _calculate_nphotons(self, n_photons, poisson_flux, max_extra_noise, rng): | |||
return iN, g | |||
|
|||
|
|||
def makePhot(self, n_photons=0, rng=None, max_extra_noise=0., poisson_flux=None, | |||
sensor=None, surface_ops=(), maxN=None, orig_center=PositionI(0,0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensor isn't in the parameter list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Also maxN. Fixed.
galsim/gsobject.py
Outdated
Returns: | ||
- a `PhotonArray` with the data about the photons. | ||
""" | ||
from .sensor import Sensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. No not needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to click approve..
These tests check that drawPhot and makePhot produce the same exact photons. So the first time, for drawPhot, I call rng.duplicate() to fork the RNG sequence. Then when I do it again with makePhot, the rng runs through the exact same sequence again, so should produce the same photons. |
This PR adds a way to draw photons without actually accumulating them onto an image.
It is functionally equivalent to
_, photons = obj.drawPhot(im, ...)
but without requiring the image.@cwwalter