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

galsim.Aperture specified with a pupil_plane_im is 4 times slower than using galsim.Aperture parameters #1182

Closed
aaronroodman opened this issue Aug 30, 2022 · 2 comments
Labels
optics/atm Related to realistic PSFs from optics, atmosphere, etc. optimization/performance Related to the speed and/or memory consumption of some aspect of the code
Milestone

Comments

@aaronroodman
Copy link

I'm making a PSF from a galsim.PhaseScreenPSF and a galsim.VonKarman and find that drawing the PSF is 4 times slower using a pupil_plane_im than using Aperture parameters. I was hoping that using a pupil image would be just as fast as the parametrization.

A sample script is attached, along with two files used to define a phase screen and the pupil aperture. The scripts makes 500 stars with either Aperture specification.

test_galsim_opticspsf.zip

@rmjarvis
Copy link
Member

rmjarvis commented Sep 12, 2022

The issue here is just that the pupil plane image you are providing is quite a lot larger than the image that gets made automatically from struts and obscuration. More than 2x larger in each dimension. The tall pole numerical computation in phase_screen scales with the number of pixels in the illumination image (based on this image), so that's the 4x you're seeing.

I think the solution (i.e. to make it faster at the expense of some precision) is probably to rebin the input image before passing it to Aperture. If I add the line:

pupil_plane_uv = pupil_plane_uv.bin(2,2)

in getAperture, then the speed comes out much closer to the same:

Parametrized Aperture, 500 stars
time for make_images = 4.01
Image File Aperture, 500 stars
time for make_images = 4.87

If you're willing to cut the resolution even more at the expense of still more precision, you can use bin(4,4). Then GalSim will complain, but it will run nonetheless:

Parametrized Aperture, 500 stars
time for make_images = 3.93
Image File Aperture, 500 stars
/Users/Mike/mambaforge/envs/py3.8/lib/python3.8/site-packages/galsim/errors.py:416: GalSimWarning: The calculated stepk (1.04824) for PhaseScreenPSF is smaller than what was used to build the wavefront (1.48892). This could lead to aliasing problems. Increasing pad_factor is recommended.
  warnings.warn(message, GalSimWarning)
time for make_images = 2.15

The rendered stars still look visually identical to me with the 4,4 binning, so this might be acceptable. But I didn't try too hard to find where there might be aliasing issues with that.

@rmjarvis rmjarvis added optics/atm Related to realistic PSFs from optics, atmosphere, etc. optimization/performance Related to the speed and/or memory consumption of some aspect of the code labels Sep 12, 2022
@rmjarvis rmjarvis added this to the No action milestone Sep 12, 2022
@aaronroodman
Copy link
Author

aaronroodman commented Oct 11, 2022 via email

@rmjarvis rmjarvis closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optics/atm Related to realistic PSFs from optics, atmosphere, etc. optimization/performance Related to the speed and/or memory consumption of some aspect of the code
Projects
None yet
Development

No branches or pull requests

2 participants