
# these options turn on different inputs and/or outputs
SAVE.OUTPUT                         BOOL  TRUE
SAVE.BACKMDL                        BOOL  FALSE
SAVE.BACKMDL.STDEV                  BOOL  FALSE
SAVE.BACKGND                        BOOL  FALSE
SAVE.BACKSUB                        BOOL  FALSE
SAVE.RESID                          BOOL  FALSE
SAVE.PSF                            BOOL  FALSE
LOAD.PSF                            BOOL  FALSE
SAVE.PLOTS                          BOOL  FALSE

# the zero point is used to set a basic scale for DVO
# XXX it may not currently be read : double check this (EAM)
ZERO_POINT                          F32   25.000          # zero point used by DVO
ZERO_PT                             F32   25.000          # zero point used by DVO

OUTPUT.FORMAT                       STR   PS1_DEV_1

# these parameter govern how the background is measured
BACKGROUND.XBIN                     S32   128             # size of background superpixels
BACKGROUND.YBIN                     S32   128             # size of background superpixels
IMSTATS_NPIX                        S32   10000           # number of pixels to use for sky estimate boxes:

SKY_BIAS                            F32   0.0             # offset applied to measured sky (FOR TESTING)
SKY_FIT_ORDER                       S32   0
SKY_FIT_LINEAR                      BOOL  FALSE
SKY_STAT                            STR   FITTED_MEAN_V4  # statistic used to measure background
SKY_CLIP_SIGMA                      F32   2.0             # statistic used to measure background
SKY_SIG                             F32   1.0             # optional sky error for 

# allowed values for SKY_STAT: 
# SAMPLE_MEAN, SAMPLE_MEDIAN, CLIPPED_MEAN, ROBUST_MEAN, ROBUST_QUARTILE, FITTED_MEAN

# masking parameters (XXX EAM : rework this to use psRegion like ANALYSIS_REGION)
XMIN                                F32   0               # minimum valid x-coord
XMAX                                F32   0               # maximum valid x-coord
YMIN                                F32   0               # minimum valid y-coord
YMAX                                F32   0               # maximum valid y-coord

# peak finding 
PEAKS_SMOOTH_SIGMA                  F32   1.0             # smoothing kernel sigma in pixels
PEAKS_SMOOTH_NSIGMA                 F32   2.0             # smoothing kernel width in sigmas
PEAKS_NSIGMA_LIMIT                  F32   25.0            # peak significance threshold
PEAKS_NSIGMA_LIMIT_2                F32   5.0             # peak significance threshold
PEAKS_NMAX                          S32   0               # on first pass, only keep NMAX peaks (0 == all)

# parameters to control the selection of the peak in the Sx,Sy plane
MOMENTS_SCALE                       F32   0.25       
MOMENTS_SN_MIN                      F32   100.0           # min S/N to measure moments
MOMENTS_SX_MAX                      F32   5.0
MOMENTS_SY_MAX                      F32   5.0
MOMENTS_AR_MAX                      F32   1.5             # maximum axial ratio: 1 / AR < (sx / sy) < AR

# basic object statistics
SKY_INNER_RADIUS                    F32   15              # square annulus for local sky measurement
SKY_OUTER_RADIUS                    F32   25              # square annulus for local sky measurement
PSF_MOMENTS_RADIUS                  F32   3               # calculate initial source moments with this radius
PSF_SN_LIM                          F32   50              # minimum S/N for stars used for PSF model
PSF_MAX_NSTARS                      S32   200             # limit number of stars used for PSF model
PSF_CLUMP_NSIGMA                    F32   1.5             # region of Sx,Sy plane to use for selecting PSF stars
PSF_MIN_DS                          F32   0.01
PSF_PARAM_WEIGHTS                   BOOL  FALSE

PSF_FIT_ITER                        S32   50              # Maximum number of fitting iterations for PSF
PSF_FIT_TOL                         F32   0.01            # Fit tolerance for PSF

# PSF model parameters : choose the PSF model
# list as many PSF_MODEL options as desired
# PSF_MODEL                         MULTI
PSF_MODEL                           STR   PS_MODEL_GAUSS
# PSF_MODEL                         STR   PS_MODEL_PGAUSS
# PSF_MODEL                         STR   PS_MODEL_QGAUSS
# PSF_MODEL                         STR   PS_MODEL_TGAUSS # not well tested, not very successful

# PSF.TREND.MASK must be a 2D polynomial
# the specified values are ignored but define the active components of the polynomial
PSF.TREND.MASK                      METADATA  
   NORDER_X                         S32   0               # number of x orders
   NORDER_Y                         S32   0               # number of y orders
   VAL_X00_Y00                      F64   1               # polynomial coefficient
   NELEMENTS                        S32   1               # number of unmasked components
END  # folder for 2D polynomial

PSF.TREND.MODE                      STR POLY_ORD         
PSF.TREND.NX                        S32   0 
PSF.TREND.NY                        S32   0

PSF.FAKE.ALLOW                      BOOL  FALSE           # Allow use of fake PSFs when having trouble?

PSF_FIT_RADIUS                      F32   15.0            # fitting radius for test PSF model
PSF_REF_RADIUS                      F32   25.0            # aperture magnitudes are scaled via 
                                         # curve-of-growth to this radius
# PSF-like source model parameters
PSF_FIT_NSIGMA                      F32   1.0             # significance for pixel included in fit
PSF_FIT_PADDING                     F32   2.0             # extra annulus to use for fit 
PSF_SHAPE_NSIGMA                    F32   3.0             # max significance for shape variation
PSF_MIN_SN                          F32   2.0             # reject objects below this significance
PSF_MAX_CHI                         F32   50.0            # reject objects worse that this
FULL_FIT_SN_LIM                     F32   50.0

# the RESIDUALS are pixelized psf residual tables
PSF.RESIDUALS                       BOOL  TRUE            # generate the residuals?
PSF.RESIDUALS.XBIN                  S32   1               # Nx(residual) = Nx(input)*XBIN
PSF.RESIDUALS.YBIN                  S32   1               # Ny(residual) = Ny(input)*YBIN
PSF.RESIDUALS.NSIGMA                F32   3.0             # clip input stack of NSIGMA outliers
PSF.RESIDUALS.INTERPOLATION         STR   BILINEAR        # interpolation to use when reconstructing residual
PSF.RESIDUALS.STATISTIC             STR   ROBUST_MEDIAN   # statistic to use for generating the residual
PSF.RESIDUALS.SPATIAL_ORDER         S32   0               # fit spatial variations of the residuals at this order (0,1)
PSF.RESIDUALS.PIX.SN                F32   0.0             # keep this pixel if residual is more significant than this
 
# this model is used for approximate subtraction in the main object analysis step
EXT_MODEL                           STR   PS_MODEL_QGAUSS
EXT_MIN_SN                          F32   50.0            # fit galaxies above this S/N limit
EXT_FIT_NSIGMA                      F32   1               # significance for pixel included in fit
EXT_FIT_PADDING                     F32   5               # extra annulus to use for fit 
EXT_MOMENTS_RADIUS                  F32   9

EXT_FIT_ITER                        S32   20              # Maximum number of fitting iterations for EXT
EXT_FIT_TOL                         F32   0.01            # Fit tolerance for EXT

# extended source aperture-like measurements
EXTENDED_SOURCE_ANALYSIS            BOOL  FALSE  # perform any of the aperture-like measurements?
EXTENDED_SOURCE_SN_LIM              F32   20.0
EXTENDED_SOURCE_PETROSIAN           BOOL  FALSE
EXTENDED_SOURCE_ISOPHOTAL           BOOL  FALSE
EXTENDED_SOURCE_ANNULI              BOOL  FALSE
EXTENDED_SOURCE_KRON                BOOL  FALSE

# Extended source fit parameters
# these models are used for high-quality shape analysis after all sources have been removed
EXTENDED_SOURCE_FITS                BOOL  FALSE  # perform the detailed extended sourc fits?

# extended source models applied to sources
EXTENDED_SOURCE_MODELS METADATA 
 TYPE  	    EXTENDED_SOURCE_MODEL  MODEL            SNLIM   PSF_CONVOLVED
 #GAUSS_RAW   EXTENDED_SOURCE_MODEL  PS_MODEL_GAUSS    20.0    FALSE
 #PGAUSS_RAW  EXTENDED_SOURCE_MODEL  PS_MODEL_PGAUSS   20.0    FALSE
 #QGAUSS_RAW  EXTENDED_SOURCE_MODEL   PS_MODEL_QGAUSS   20.0    FALSE
 #SERSIC_RAW  EXTENDED_SOURCE_MODEL   PS_MODEL_SERSIC   20.0    FALSE
 #GAUSS_PSF   EXTENDED_SOURCE_MODEL  PS_MODEL_GAUSS    20.0    TRUE
 #PGAUSS_PSF  EXTENDED_SOURCE_MODEL  PS_MODEL_PGAUSS   20.0    TRUE
 #QGAUSS_PSF  EXTENDED_SOURCE_MODEL  PS_MODEL_QGAUSS   20.0    TRUE
 SERSIC_PSF  EXTENDED_SOURCE_MODEL  PS_MODEL_SERSIC   20.0    TRUE
END

# define the annuli (in pixels) for surface brightness measurements
@RADIAL.ANNULAR.BINS.LOWER           F32     0.0   5.0  10.0  20.0  40.0  80.0
@RADIAL.ANNULAR.BINS.UPPER           F32     5.0  10.0  20.0  40.0  80.0 160.0

# Extended source fit parameters
EXTENDED_TEST                       METADATA
  EXTENDED_SOURCE_ANALYSIS            BOOL  TRUE  # perform any of the aperture-like measurements?
  EXTENDED_SOURCE_SN_LIM              F32   20.0
  EXTENDED_SOURCE_PETROSIAN           BOOL  TRUE
  EXTENDED_SOURCE_ISOPHOTAL           BOOL  TRUE
  EXTENDED_SOURCE_ANNULI              BOOL  TRUE
  EXTENDED_SOURCE_KRON                BOOL  FALSE
END

ISOPHOTAL_FLUX                      F32   20.0
PETROSIAN_R0                        F32    5.0 # reference radius in pixels
PETROSIAN_FLUX_RATIO                F32    0.1 # we measure out to where flux = R0 * FLUX_RATIO

FITMODE                             STR   BLEND  
DEBLEND_PEAK_FRACTION               F32   0.1
DEBLEND_SKY_NSIGMA                  F32   10.0

# APTREND                           STR   NONE, CONSTANT, SKYBIAS, SKYSAT, XY_LIN, SKY_XY_LIN, SKYSAT_XY_LIN, ALL
MEASURE.APTREND	                    BOOL  FALSE		### Gene says there's bugs in this part
APTREND                             STR   CONSTANT
AP_MIN_SN                           F32   25.0
APTREND.NSTAR.MIN                   S32   5
APTREND.ORDER.MAX                   S32   5

# test options
# BREAK_POINT may be one of (PEAKS, MOMENTS, PSFMODEL, ENSEMBLE)
BREAK_POINT                         STR   NONE     
PEAKS_OUTPUT_FILE                   STR   NONE
MOMENTS_OUTPUT_FILE                 STR   NONE

# ANALYSIS_REGION                   STR   [1000:1600,2800:3400]

# optional parameter to limit the actual analysis to a fraction of the image
# do not uncomment this in the master psphot.config file
# ANALYSIS_REGION                   STR   [1000:1600,2800:3400]

IGNORE_GROWTH                       BOOL  FALSE
CONSTANT_PHOTOMETRIC_WEIGHTS        BOOL  TRUE 		  # Should the photometric code [currently only ensemblePSF] refuse to weight each pixel by it's significance?
INTERPOLATE_AP                      BOOL  TRUE

POISSON.ERRORS.PHOT.LMM             BOOL  TRUE   
POISSON.ERRORS.PHOT.LIN             BOOL  FALSE
POISSON.ERRORS.PARAMS               BOOL  TRUE

PCM_BOX_SIZE                        S32   8

NOISE.FACTOR                        F32   5.0
NOISE.SIZE                          F32   2.0

USE_FOOTPRINTS                      BOOL  F       	  # use new pmFootprint peak packaging
FOOTPRINT_NPIXMIN                   S32   5       	  # Minimum size of a pmFootprint
FOOTPRINT_NSIGMA_LIMIT              F32   20      	  # threshold for bright pmFootprint detection
FOOTPRINT_NSIGMA_LIMIT_2            F32   4       	  # threshold for faint pmFootprint detection
FOOTPRINT_GROW_RADIUS               S32   3       	  # How much to grow bright footprints
FOOTPRINT_GROW_RADIUS_2             S32   5       	  # How much to grow faint footprints
FOOTPRINT_CULL_NSIGMA_DELTA         F32   4       	  # Cull peaks that aren't nsigma above coll to neighbour
FOOTPRINT_CULL_NSIGMA_MIN           F32   1       	  # Minimum height of colls in units of skyStdev

# alternate PSPHOT-type recipes
PSPHOT.FIXED.PSF METADATA
END

# alternate PSPHOT-type recipes
PSPHOT.SUMMIT METADATA
END

# alternate PSPHOT-type recipes
PSPHOT.SEEING METADATA
END

TEST_FIT                            BOOL  FALSE
TEST_FIT_MODE                       STR   DEFAULT # PSF, CONV, DEFAULT
TEST_FIT_MODEL                      STR   DEFAULT # PS_MODEL_SERSIC
TEST_FIT_INNER_RADIUS               F32   NAN 
TEST_FIT_OUTER_RADIUS               F32   NAN
TEST_FIT_RADIUS                     F32   NAN
TEST_MOMENTS_RADIUS                 F32   NAN
TEST_FIT_X                          F32   NAN
TEST_FIT_Y                          F32   NAN

TEST_FIT_PAR0                       F32   NAN
TEST_FIT_PAR1                       F32   NAN
TEST_FIT_PAR2                       F32   NAN
TEST_FIT_PAR3                       F32   NAN
TEST_FIT_PAR4                       F32   NAN
TEST_FIT_PAR5                       F32   NAN
TEST_FIT_PAR6                       F32   NAN
TEST_FIT_PAR7                       F32   NAN
TEST_FIT_PAR8                       F32   NAN
TEST_FIT_PAR                        F32   NAN

DIAGNOSTIC.PLOTS                    METADATA
  IMAGE.BACKGROUND.CELL.HISTOGRAM   BOOL  FALSE
  IMAGE.BACKGROUND.CELL.HISTOGRAM.X S32   35
  IMAGE.BACKGROUND.CELL.HISTOGRAM.Y S32   -1
END

PSF.FLUXSCALE.NX                    S32   5 		  # number cells to measure flux scale variations
PSF.FLUXSCALE.NY                    S32   5 		  # number cells to measure flux scale variations

PSPHOT.CR.NSIGMA.LIMIT              F32   3.0  # sources with crNsigma greater that this get tagged as likely cosmic rays
PSPHOT.EXT.NSIGMA.LIMIT             F32   4.0  # sources with extNsigma greater that this get tagged as likely extended sources
PSPHOT.CR.GROW                      S32   1               # Number of pixels to grow CR mask
