GalSim-developers/GalSim — pull request #346 by rmandelb (2013-01-22 16:24:55+00:00)
Title: #305

This pull request is for some updates to enable lookup tables in python in general, and some related updates to the lensing engine. Summary of changes:

* Table class from C++ is now visible in python as a LookupTable class, which has additional functionality beyond that in C++ for example to allow interpolation in log space. While this work was done for the lensing engine (so we can read in a P(k) defined at specific k, as output by a standard cosmology calculator) it should be more generally useful than that. The LookupTable can take lists, tuples, or Numpy arrays of points, or the name of an ascii file containing 2 columns, one for x and one for f(x).

* Lensing engine updated in multiple ways:
* PowerSpectrum can take a LookupTable for the P(k), or a filename from which to read a tabulated P(k)
* It no longer requires P(k) to be defined at k=0; instead, it enforces P(0)=0 as is required for physically-reasonable shear power spectra.
* It handles different units, i.e., if someone hands in a P(k) with k in inverse radians (as is common for cosmology calculators) and requests shears at positions in degrees, then as long as they tell the PowerSpectrum object that they used those units, it will convert properly between those units and the ones that are actually used by the code (arcsec).
* It can accept Delta^2 = k^2 P(k)/(2pi) and convert to P.
* The building of the grid and interpolation to non-gridded positions are now split into two separate functions. The grid-building function must be called before the interpolation function.

* The above functionality is accessible via config, provided that the user has a file containing the tabulated k and P(k).

* There's a new demo11 to demonstrate InterpolatedImage, new LookupTable+units+Delta^2 functionality for PowerSpectrum, shears at non-gridded positions, and Rice compression of outputs. For these purposes, I put an example iCosmo shear power spectrum into the repository.

* Fix for InterpolatedImage constructor to calculate the best maxK and stepK (can give factor of 100 optimization compared to the very slow results when using default/conservative maxK and stepK).

* A work-around for a pyfits bug that means our Rice-compressed output files (using pyfits) were not readable by ds9.

* New utility function for checking the 2d-interpolants that are passed into many different functions (e.g., the constructors for AtmosphericPSF, OpticalPSF, and many more) to avoid duplication of code.