{"action":"created","issue":{"url":"https://api.github.com/repos/mperrin/poppy/issues/135","labels_url":"https://api.github.com/repos/mperrin/poppy/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/mperrin/poppy/issues/135/comments","events_url":"https://api.github.com/repos/mperrin/poppy/issues/135/events","html_url":"https://github.com/mperrin/poppy/issues/135","id":118461008,"number":135,"title":"Help request:  interpreting PSF","user":{"login":"gapster","id":15945736,"avatar_url":"https://avatars.githubusercontent.com/u/15945736?v=3","gravatar_id":"","url":"https://api.github.com/users/gapster","html_url":"https://github.com/gapster","followers_url":"https://api.github.com/users/gapster/followers","following_url":"https://api.github.com/users/gapster/following{/other_user}","gists_url":"https://api.github.com/users/gapster/gists{/gist_id}","starred_url":"https://api.github.com/users/gapster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gapster/subscriptions","organizations_url":"https://api.github.com/users/gapster/orgs","repos_url":"https://api.github.com/users/gapster/repos","events_url":"https://api.github.com/users/gapster/events{/privacy}","received_events_url":"https://api.github.com/users/gapster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-23T20:03:18Z","updated_at":"2015-11-25T18:21:10Z","closed_at":null,"body":"Sorry for putting a help request here.  If there's a better way to do this, let me know.  I'll be brief, hopefully not too brief.\r\n\r\nI'm exploring POPPY for use modeling a star camera. The model camera lens has a diameter of 25 mm,  focal length 50 mm, 20 deg FOV, with a focal plane array having pixel pitch 13 microns, 1024 x 1024.   This results in a pixel scale of about 70 arcsec/pixel and the focal plane array/camera produces an image that's roughly 70 arcsec/pixel, with 1024 pixels across. \r\n\r\nI set up a simple optical system,\r\n\r\n    lmda = 550e-9  # wavelength, meters\r\n    rad = 12.5e-3  # lens radius\r\n    pxscale = 70. # detector arcsec/pixel\r\n    fov_pixels = 1024 # full-angle FOV ??\r\n\r\n    osys = poppy.OpticalSystem()\r\n    osys.addPupil( poppy.CircularAperture(radius = rad))\r\n    osys.addDetector(pixelscale = pxscale,\r\n                 fov_arcsec = fov_pixels*pxscale)\r\n\r\nand produce a psf\r\n\r\n    psf = osys.calcPSF(lmda)\r\n    psf_ax, colorbar = poppy.display_PSF(psf,\r\n                                     return_ax=True,\r\n                                     title = 'The Airy Function',\r\n                                     scale = u'log')\r\n\r\nand extract the data\r\n\r\n    pdata = psf[0].data\r\n\r\nI expected a 1024 x 1024 array with a psf in the center.    Instead I get a 2048 x 2048 array containing many peaks:  23 x 23  of them.  Evidently I don't understand something essential about how poppy samples and does Fourier Transforms.  Of course, I'm interested in the details of the psf, not the complete image, but I think I need to understand what poppy is doing.  I have many questions, but perhaps just a pointer in the right direction will be all that I need.  Thanks."},"comment":{"url":"https://api.github.com/repos/mperrin/poppy/issues/comments/159693145","html_url":"https://github.com/mperrin/poppy/issues/135#issuecomment-159693145","issue_url":"https://api.github.com/repos/mperrin/poppy/issues/135","id":159693145,"user":{"login":"mperrin","id":1151745,"avatar_url":"https://avatars.githubusercontent.com/u/1151745?v=3","gravatar_id":"","url":"https://api.github.com/users/mperrin","html_url":"https://github.com/mperrin","followers_url":"https://api.github.com/users/mperrin/followers","following_url":"https://api.github.com/users/mperrin/following{/other_user}","gists_url":"https://api.github.com/users/mperrin/gists{/gist_id}","starred_url":"https://api.github.com/users/mperrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mperrin/subscriptions","organizations_url":"https://api.github.com/users/mperrin/orgs","repos_url":"https://api.github.com/users/mperrin/repos","events_url":"https://api.github.com/users/mperrin/events{/privacy}","received_events_url":"https://api.github.com/users/mperrin/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T18:21:10Z","updated_at":"2015-11-25T18:21:10Z","body":"There are a couple things going on here: \r\n\r\n * The 2048 vs 1024 pixels difference is simply explained by the default oversampling factor of 2x in `calcPSF`. This is a user-adjustible parameter so you can make it whatever you want.  (and the `Instrument` subclass provides a more sophisticated interface to this including automatic downsampling to the detector resolution but that takes some more work to set up.)\r\n * Secondly, the repeated copies of the PSF are due to the replication that is assumed by the FT algorithm, as @josePhoenix pointed out. The maximum spatial frequency that can be sampled is set by the sampling in the input pupil plane. If you have an pupil array that is 100 pixels across, you can represent up to 50 cycles per pupil (at Nyquist sampling, 2 pixels per cycle). This means you can represent up to 50 lambda/D in the image plane, and after that you will get aliasing.  See for instance the \"Sampling Sinusoidal Functions\" section of https://en.wikipedia.org/wiki/Aliasing.   The software attempts to calculate the FT of a high spatial frequency, but due to limited sampling it returns instead a value appropriate for a much lower frequency and this results in repeated copies of the (low spatial frequency!) core of the PSF.   The fix for this is to *increase the sampling* of the input pupil array.\r\nThe case you are interested in may actually be better represented by the new `FresnelOpticalSystem` functionality in our recent release. That class provides a more convenient interface to adjust the sampling of the input wavefront, since you can just specify `npix` and `pupil_diameter` directly in the creation of the `FresnelOpticalSystem`. (This newer code now has a better API than our older code I think... Lessons learned!)\r\n\r\nAll that said, your proposed system is *significantly* undersampled spatially. For a 50 mm lens the theoretical diffraction limited PSF is just a few arcseconds at visible wavelengths. It's at least an order of magnitude better than your stated 70 arcsec/pixel sampling. So the kinds of fine diffractive structure that poppy is designed to model will not be easily seen in your instrument. Furthermore, remember that poppy is just modeling the effects of diffraction, based on the input parameters describing an optical system. In your case with a simple circular pupil that will just give an Airy function, without any need for numerical calculations of a more complex PSF. More to the point, your instrument is not going to have diffraction limited optical performance with only a single lens. It takes multiple powered surfaces to get near diffraction limited performance over an extended field, particularly for anything as large as 20 degrees across. Depending on your application, you're likely in a regime dominated by geometric optics rather than diffraction. \r\n\r\nYour given parameters (50 mm focal length, 25 mm aperture diameter) are in the realm of commercial camera lenses, but even those don't give nearly diffraction limited performance over such a wide field. See for instance this Nikon 50 mm f/1.8 lens: http://imaging.nikon.com/lineup/lens/singlefocal/normal/af-s_50mmf_18g/\r\nThat page has a chart showing the modulation transfer function (MTF), which depicts how the MTF declines significantly as you move away from the optical axis. And that's for a seven lens system, one of which is an aspheric surface.  A single lens is going to be totally dominated by low-order aberrations off axis.  It's possible to model such effects in `poppy`, but that requires having an input model describing the wavefront error as a function of field angle, for instance as derived from the optical model of the lens. "}}