IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9384


Ignore:
Timestamp:
Oct 6, 2006, 5:52:39 PM (20 years ago)
Author:
Paul Price
Message:

Adding additional error checking. Plug a memory leak.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r9352 r9384  
    481481        pmShutterCorrection *guess = pmShutterCorrectionGuess(exptimes, counts); // Guess at correction
    482482        pmShutterCorrection *corr = pmShutterCorrectionFullFit(exptimes, counts, errors, guess); // Correct'n
     483        if (!corr) {
     484            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to measure shutter reference correction.\n");
     485            psFree(guess);
     486            psFree(counts);
     487            psFree(errors);
     488            goto MEASURE_ERROR;
     489        }
    483490        psTrace("psModules.detrend", 5, "Sample reference value: %f\n", corr->offref);
    484491        if (isfinite(corr->offref)) {
     
    508515                // We don't have weights, so no realistic errors: turn off iteration
    509516                if (nIter > 0) {
    510                     psWarning("Not all images have weights --- turning weighting off.\n");
     517                    psWarning("Not all images have weights --- turning iteration off.\n");
    511518                }
    512519                nIter = 1;
     
    516523
    517524    psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image
    518     //psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
     525    psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
    519526    psVector *mask = psVectorAlloc(num, PS_TYPE_U8); // Mask for each image
    520527    mask->n = num;
     
    541548                                        nIter, rej, maskVal);
    542549            shutter->data.F32[y][x] = corr->offset;
    543             //pattern->data.F32[y][x] = corr->scale;
     550            pattern->data.F32[y][x] = corr->scale;
    544551            psFree(corr);
    545552        }
    546553    }
     554    psFree(mask);
    547555    psFree(counts);
    548556    psFree(errors);
    549557    psFree(refs);
     558
     559    psFits *fits = psFitsOpen("pattern.fits", "w");
     560    psFitsWriteImage(fits, NULL, pattern, 0, NULL);
     561    psFitsClose(fits);
     562    psFree(pattern);
    550563
    551564    return shutter;
Note: See TracChangeset for help on using the changeset viewer.