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

Make it easier to specify how the PSF profile should be centered on an image #73

Closed
rmjarvis opened this issue Apr 13, 2018 · 4 comments
Milestone

Comments

@rmjarvis
Copy link
Owner

Currently psf.draw(x,y) centers the PSF profile at the sub-pixel values of the provided x,y positions.

This is sometimes a desirable feature, but not always. We should make it easier for the user to specify how they want the PSF image centered. I'm proposing a new center keyword argument to the draw command with the following options:

center=None   # (default) the current behavior using (x,y) for the sub-pixel position.
center=True     # center the profile at the actual center of the image.
center=pos      # center the profile at some other arbitrary position on the image.
@esheldon
Copy link
Collaborator

works for me

@RobertLuptonTheGood
Copy link
Collaborator

RobertLuptonTheGood commented Apr 15, 2018 via email

@rmjarvis
Copy link
Owner Author

Can't the user just say (int(x), int(y)) to centre in a pixel?

Yes, that is the current workaround.

im = psf.draw(x=int(x+0.5), y=int(y+0.5))

But it feels slightly clunky compared to

im = psf.draw(x,y, center=True)

I don't understand the center=pos option.

Well, you might not want the image you are drawing onto to have the same meanings of (x,y) as the original image where the interpolation is defined. For instance, you might have the image on which you are rendering the PSF be centered at (0,0) for convenience of some measuring code. Furthermore, you might be concerned about some pixelization effects in your code, so maybe you don't always want the PSF centered in the center of the central pixel. Maybe you want to dither around by a random sub-pixel offset relative to the center. Then you would do

cenx, ceny = np.random.rand(2) - 0.5
center = galsim.PositionD(cenx,ceny)
psf.draw(x,y, image=target_image, center=center)
measure_psf(target_image, center=center)

Anyway, if you don't have a use for it yourself, you don't need to use it (natch). But in some DES work we've been doing, there was some confusion on how Piff was working here, so this is intended to make it easier for the user to be clear about what they are asking Piff to do wrt the center of the rendering.

@rmjarvis
Copy link
Owner Author

FYI, I'll mostly be leveraging the work I did on this GalSim PR where I added a center parameter to the drawImage command. This will encompass how the center=pos option will work. The other two options described above will just define two reasonable values for what that pos might be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants