psfex library README
--------------------

(0) What is PSFEx

PSFEx is a piece of code written by Emmanuel Bertin for modelling the point-spread function in astronomical images (including its variation over the image).
In essence, PSFEx models the surface brightness of the PSF as a polynomial function of the image coordinates. The surface brightness in this process is 
most commonly modelled in an arbitrary resolution pixel basis, but the use of other functional bases (such as Gauss-Laguerre) is also possible. PSFEx runs
on SExtractor catalogs and produces models than can in turn be used for SExtractor model-fitting photometry. 

You can use this class for exploiting the PSF model in other ways (among them weak lensing and studies of instrumental signatures).

(I) Compiling and linking against the psfex library

Since the library is very small, I suggest you just compile psfex.cpp and link your sources with psfex.o. 
The header psfex.h must be included in your sources.

Running 'make' will build psfdrawcube (you need to have the CCfits library installed, and might have to set your include and library path in the Makefile).

(II) Using the psfex library

The things you might want to use in the class are:

 * (constructor):	: reads model from a .psf (FITS table) or ASCII file (see below)
 * psfex::pixel_lanczos	: returns (non-normalized) surface brightness of the PSF at arbitrary position 
			  in the image and separation from the star centroid
 * psfex::pixel_raw	: returns (non-normalized) surface brightness of the PSF at arbitrary position 
			  in the image in the pixelized PSFEx coordinate system (can have different resolution than image pixels!)
 * psfex::centroid	: returns centroid of the PSF relative to the PSFEx model geometrical center
			  (can be non-zero depending on your settings) in the PSFEx coordinate system (can have different resolution than image pixels!)
 * psfex::sampling	: returns sampling scale of PSFEx model; e.g. 0.5 means that model pixels are smaller than image pixels by factor of 2
 * psfex::maxsize	: radius about center (in image scale pixels) out to which the PSFEx model contains valid information 
			  (depends on choice of interpolant, i.e. Lanczos order)

(III) Other pieces of code

 * psfdrawcube is a simple code that draws the PSF model at a list of positions into a data cube FITS file
 * psfextract.py converts FITS file .psf models into ASCII models (which can also be read by the psfex class, and is easily modifyable manually)

(IV) Example

Run 
	./psfdrawcube example.psf star.tab test.fits
to draw the PSF model in example.psf at 5 positions given in star.tab into a FITS datacube test.fits (to be viewed, e.g., with ds9).
