IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10574


Ignore:
Timestamp:
Dec 8, 2006, 10:46:16 AM (20 years ago)
Author:
Paul Price
Message:

Adding additional metadata to output.

File:
1 edited

Legend:

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

    r10541 r10574  
    110110
    111111// Produce an overscan vector from an array of pixels
    112 static psVector *overscanVector(pmOverscanOptions *overscanOpts, // Overscan options
     112static psVector *overscanVector(float *chi2, // chi^2 from fit
     113                                pmOverscanOptions *overscanOpts, // Overscan options
    113114                                const psArray *pixels, // Array of vectors containing the pixel values
    114115                                psStats *myStats // Statistic to use in reducing the overscan
     
    145146
    146147    // Fit the overscan, if required
     148    psVector *fitted;                   // Fitted overscan values
    147149    switch (overscanOpts->fitType) {
    148150    case PM_FIT_NONE:
    149151        // No fitting --- that's easy.
     152        fitted = psMemIncrRefCounter(reduced);
    150153        break;
    151154    case PM_FIT_POLY_ORD:
     
    159162        }
    160163        psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate);
    161         psFree(reduced);
    162         reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
     164        fitted = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
    163165        break;
    164166    case PM_FIT_POLY_CHEBY:
     
    172174        }
    173175        psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate);
    174         psFree(reduced);
    175         reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
     176        fitted = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
    176177        break;
    177178    case PM_FIT_SPLINE:
     
    179180        // input spline
    180181        overscanOpts->spline = psVectorFitSpline1D(reduced, ordinate);
    181         psFree(reduced);
    182         reduced = psSpline1DEvalVector(overscanOpts->spline, ordinate);
     182        fitted = psSpline1DEvalVector(overscanOpts->spline, ordinate);
    183183        break;
    184184    default:
     
    188188    }
    189189
     190    if (chi2) {
     191        *chi2 = 0.0;                    // chi^2 (sort of)
     192        for (int i = 0; i < reduced->n; i++) {
     193            *chi2 += PS_SQR(fitted->data.F32[i] - reduced->data.F32[i]);
     194        }
     195    }
     196
     197    psFree(reduced);
    190198    psFree(ordinate);
    191199    psFree(mask);
    192200
    193     return reduced;
     201    return fitted;
    194202}
    195203
     
    273281            // We do the regular overscan subtraction
    274282            bool readRows = psMetadataLookupBool(NULL, in->parent->concepts, "CELL.READDIR");// Read direction
     283            float chi2 = NAN;           // chi^2 from fit
    275284
    276285            if (readRows) {
     
    301310
    302311                // Reduce the overscans
    303                 psVector *reduced = overscanVector(overscanOpts, pixels, stats);
     312                psVector *reduced = overscanVector(&chi2, overscanOpts, pixels, stats);
    304313                psFree(pixels);
    305314                if (! reduced) {
     
    344353
    345354                // Reduce the overscans
    346                 psVector *reduced = overscanVector(overscanOpts, pixels, stats);
     355                psVector *reduced = overscanVector(&chi2, overscanOpts, pixels, stats);
    347356                psFree(pixels);
    348357                if (! reduced) {
     
    364373            case PM_FIT_POLY_CHEBY: {
    365374                    psString comment = NULL;    // Comment to add
    366                     psStringAppend(&comment, "Overscan fit: ");
     375                    psStringAppend(&comment, "Overscan fit (chi^2: %.2f):", chi2);
    367376                    psPolynomial1D *poly = overscanOpts->poly; // The polynomial
    368377                    for (int i = 0; i < poly->nX; i++) {
     
    376385                    psSpline1D *spline = overscanOpts->spline; // The spline
    377386                    for (int i = 0; i < spline->n; i++) {
    378                         psStringAppend(&comment, "Overscan fit %d: ", i);
     387                        psStringAppend(&comment, "Overscan fit (chi^2: %.2f) %d :", chi2, i);
    379388                        psPolynomial1D *poly = spline->spline[i]; // i-th polynomial
    380389                        for (int j = 0; j < poly->nX; j++) {
Note: See TracChangeset for help on using the changeset viewer.