PSFEx stands for ``PSF Extractor'': a software that makes PSF models for
use with the SExtractor program or QualityFITS by Frederic Magnard.
Here is a short and preliminary cookbook.

1: 
First of all, a binary FITS catalog of the bright sources in the image to
analyse must be created with SExtractor.
- CATALOG_TYPE in the .sex SExtractor configuration file must be set to
  FITS_LDAC. This will allow PSFex to have access to the content of the
  original FITS image header.
- The .param SExtractor file must contain at least the
   following parameters:
  NUMBER
  X_IMAGE
  Y_IMAGE
  FLUX_RADIUS
  FLAGS
  FLUX_APER(1)
  FLUXERR_APER(1)
  ELONGATION
  VIGNET(35,35)
  The VIGNET size (here, 35x35 pixels) sets the maximum size of the fittable
  zone around each PSF candidate star.
The extraction parameters in the .sex configuration file do not have to be
refined much; however it is important to check that GAIN, SATUR_LEVEL and
PHOT_APERTURES (which will act as the reference aperture for profile-fitting
photometry) are all set to the correct values.

2:
Now the PSF model can be created with psfex from the previously SExtracted
catalog. In the PSFEx configuration file ("default.psfex" by default), one
should mostly care about the following parameters:

PSF model
---------
PSF_ACCURACY:      Accuracy to expect from pixel values. This represents more
                   or less the pixel-to-pixel stability of the detector
                   response or its calibration. You might want to increase the
                   value of PSF_ACCURACY if the intra-pixel response is a bit
                   bumpy (e.g. old NICMOS detectors). The default is 0.01 (1%).

BASIS_NUMBER:      sqrt of the maximum number of super-resolved pixels. Pixels
                   are super-resolved in priority in the brightest areas of the
                   PSF, and then in the darker portions.

PSF selection
-------------
* SAMPLE_FWHMRANGE:the range in FWHM in which the PSF candidate stars are
                   selected. Allows the bigger galaxies and artifacts such as
                   cosmic-ray impacts to be rejected early in the processing.
* SAMPLE_VARIABILITY:
                   The larger this parameter, the wider the fluctuations in
                   FWHM are allowed among PSF candidate stars. For instance,
                   0.2 means that a 20% peak-to-peak variation of the FWHM is
                   allowed.
* SAMPLE_MINSN:    The minimum Signal-to-Noise Ratio (on aperture fluxes) for a
                   non-saturated candidate star to be eligible for contributing
                   to the PSF model.
* SAMPLE_MAXELLIP: Maximum ellipticity (A-B)/(A+B) for a non-saturated candidate
                   star to be eligible for contributing to the PSF model.

Modeling the PSF variability
----------------------------

* PSFVAR_KEYS:     List of "keys" (SExtractor parameters) on which the PSF is
                   supposed to depend (e.g. X_IMAGE,Y_IMAGE for a spatial
                   mapping of the PSF). Use an empty string ("") to specify a
                   constant PSF.

* PSFVAR_GROUPS:   Some context keys can be grouped together in a such way that
                   the associated polynom degree does not excede a given value.
                   PSFVAR_GROUPS defines the index of the group to which each
                   PSFVAR_KEYS belongs. This index designates the position of
                   the group in the list of PSFVAR_DEGREES. For instance, to
                   make the PSF vary with pixel coordinates x and y as a 3rd
                   order polynomial (that is, 10 parameters: cste,x,y,x2,xy,y2,
                   x3,x2y,xy2,y3), one should use the following configuration:
 
                   PSFVAR_KEYS		X_IMAGE,Y_IMAGE  
                   PSFVAR_GROUPS	1,1
                   PSFVAR_DEGREES	3

                   If one wants to allow the PSF to vary with both x,y in a
                   quadratic way, and the airmass in a linear way, one should
                   use

                   PSFVAR_KEYS   X_IMAGE,Y_IMAGE,:AIRMASS
                   PSFVAR_GROUPS 1,1,2
                   PSFVAR_DEGREES  2,1

                   The colon before the AIRMASS parameter indicates that
                   AIRMASS should be interpreted as a FITS keyword of the
                   SExtracted image header, and not as a SExtractor catalog
                   parameter (this example supposes of course that the AIRMASS
                   keyword was present in the image header, and that it
                   contains the average airmass during the exposure).

A typical session
-----------------
Building a model of the PSF:
% sex -c psf.sex foo.fits -CATALOG_NAME mypsf.cat
% psfex mypsf.cat

Using it in SExtractor (this is not recommended for serious science use at
the moment):
% sex -PSF_NAME mypsf.psf foo.fits

Please report any bug or strange behaviour to the AstrOmatic forum:
http://astromatic.net/forum

					Emmanuel Bertin.

