IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9317


Ignore:
Timestamp:
Oct 5, 2006, 1:42:11 PM (20 years ago)
Author:
rhl
Message:

Handle case when some models are NULL

File:
1 edited

Legend:

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

    r9270 r9317  
    7676    // select the best of the models
    7777    // here we are using the clippedStdev on the metric as the indicator
    78     try = models->data[0];
    79     int bestN = 0;
    80     float bestM = try->psf->dApResid;
    81     for (int i = 1; i < models->n; i++) {
     78    int bestN = -1;
     79    float bestM = 0.0;
     80    for (int i = 0; i < models->n; i++) {
    8281        try = models->data[i];
     82        if (try == NULL) {
     83            psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
     84            continue;
     85        }
    8386        float M = try->psf->dApResid;
    84         if (M < bestM) {
     87        if (bestN < 0 || M < bestM) {
    8588            bestM = M;
    8689            bestN = i;
     
    8992
    9093    // use the best model:
     94    if (bestN < 0) {
     95        psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
     96        psFree (models);
     97        return NULL;
     98    }
     99   
    91100    try = models->data[bestN];
    92101
Note: See TracChangeset for help on using the changeset viewer.