IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9661


Ignore:
Timestamp:
Oct 19, 2006, 1:10:23 PM (20 years ago)
Author:
Paul Price
Message:

Adding error checks on recipe parameters; providing defaults with warnings where not provided.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotChoosePSF.c

    r9567 r9661  
    1313
    1414    // check if a PSF model is supplied by the user
    15     psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     15    psf = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.PSF");
    1616    if (psf != NULL) return psf;
    1717
     
    2121    // array to store candidate PSF stars
    2222    int NSTARS = psMetadataLookupS32 (&status, recipe, "PSF_MAX_NSTARS");
    23     if (!status) NSTARS = PS_MIN (sources->n, 200);
     23    if (!status) {
     24        NSTARS = PS_MIN (sources->n, 200);
     25        psWarning("PSF_MAX_NSTARS is not set in the recipe --- defaulting to %d\n", NSTARS);
     26    }
    2427
    2528    // use poissonian errors or local-sky errors
    2629    bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS");
    27     if (!status) POISSON_ERRORS = true;
     30    if (!status) {
     31        POISSON_ERRORS = true;
     32        psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n");
     33    }
    2834
    2935    // how to model the PSF variations across the field
    3036    // XXX make a default value?  or not?
    3137    psMetadata *md = psMetadataLookupMetadata (&status, recipe, "PSF.TREND.MASK");
    32     psPolynomial2D *psfTrendMask = psPolynomial2DfromMetadata (md);
    33     if (!psfTrendMask) {
    34         psError(PSPHOT_ERR_PSF, true, "PSF.TREND.MASK is not defined in recipe");
    35         return false;
     38    psPolynomial2D *psfTrendMask;
     39    if (!status || !md) {
     40        psWarning("PSF.TREND.MASK is not set in the recipe --- defaulting to use zeroth order.\n");
     41        psfTrendMask = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0);
     42    } else {
     43        psfTrendMask = psPolynomial2DfromMetadata (md);
     44        if (!psfTrendMask) {
     45            psError(PSPHOT_ERR_PSF, true, "Unable to construct polynomial from PSF.TREND.MASK in the recipe");
     46            return false;
     47        }
    3648    }
    3749
     
    4860
    4961    if (stars->n == 0) {
    50         psError(PSPHOT_ERR_PSF, true, "Failed to find any PSF candidates");
    51         return NULL;
     62        psError(PSPHOT_ERR_PSF, true, "Failed to find any PSF candidates");
     63        return NULL;
    5264    }
    5365
     
    5567    // XXX EAM : check that PSF_FIT_RADIUS < SKY_OUTER_RADIUS
    5668    float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS");
     69    if (!status) {
     70        psWarning("PSF_FIT_RADIUS is not set in the recipe --- defaulting to 20.0\n");
     71        RADIUS = 20.0;
     72    }
    5773
    5874    // get the list pointers for the PSF_MODEL entries
     
    91107    for (int i = 0; i < models->n; i++) {
    92108        try = models->data[i];
    93         if (try == NULL) {
    94             psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
    95             continue;
    96         }
     109        if (try == NULL) {
     110            psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
     111            continue;
     112        }
    97113        float M = try->psf->dApResid;
    98114        if (bestN < 0 || M < bestM) {
     
    104120    // use the best model:
    105121    if (bestN < 0) {
    106         psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
    107         psFree (models);
    108         return NULL;
    109     }
    110    
     122        psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
     123        psFree (models);
     124        return NULL;
     125    }
     126
    111127    try = models->data[bestN];
    112128
     
    199215    for (int i = 0; i < sources->n; i++) {
    200216        pmSource *source = sources->data[i];
    201         if (!source) continue;
     217        if (!source) continue;
    202218        if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
    203219
Note: See TracChangeset for help on using the changeset viewer.