GalSim-developers/GalSim — pull request #80 by barnabytprowe (2012-04-06 07:07:57+00:00)
Title: #34 optics wrapper

The optics class is ready (in a basic version), which instantiates a GSObject containing an SBPixel attribute.

The docstring is as follows:

@brief Class describing aberrated PSFs due to telescope optics.

Input aberration coefficients are assumed to be supplied in units of incident light wavelength,
and correspond to the conventions adopted here:
http://en.wikipedia.org/wiki/Optical_aberration#Zernike_model_of_aberrations

Initialization
--------------
>>> optical_psf = galsim.Optics(lod, dx=None, defocus=0., astig1=0., astig2=0., coma1=0.,
coma2=0., spher=0., circular_pupil=True, interpolantxy=None,
oversampling=2.)

Initializes optical_psf as a galsim.Optics() instance.

@param lod lambda / D in the physical units adopted (user responsible for
consistency).
@param defocus defocus in units of incident light wavelength.
@param astig1 first component of astigmatism (like e1) in units of incident light
wavelength.
@param astig2 second component of astigmatism (like e2) in units of incident light
wavelength.
@param coma1 coma along x in units of incident light wavelength.
@param coma2 coma along y in units of incident light wavelength.
@param spher spherical aberration in units of incident light wavelength.
@param circular_pupil adopt a circular pupil?
@param obs add a central obstruction due to secondary mirror?
@param interpolantxy optional keyword for specifiying the interpolation scheme [default =
galsim.InterpolantXY(galsim.Lanczos(5, True, 1.e-4))]
@param dx optional specifier for pixel scale of aberration lookup table images
[default just samples PSF well]
@param oversampling optional oversampling factor for the SBPixel table [default = 3.],
ignored if dx is set. Setting oversampling < 1 is silly.

To make this class (and the optics module functions) compatible with the SBPixel default all image functions are now generated at np.float32 (ImageF), which is single precision (not Python default).

There are also some changes to the test_optics.py unit tests. All the the functions now test against ImageF array views, which means that the decimal point precision has to be lowered. We also now compare the Optics flux (to unity) and the whole image against an SBAiry for a variety of different physical scales. All tests pass on my machine, but this may be single float precision dependent at some level.

I think this is one of the last pieces necessary for the milestone - more changes to come I'm sure, but will merge tomorrow for completeness unless there are big issues.