IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 19, 2006, 4:58:42 PM (20 years ago)
Author:
Paul Price
Message:

Working, I think

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageDetrendBias.c

    r5858 r6064  
    1 # include "ppImage.h"
     1#include "ppImage.h"
    22
    3 bool ppDetrendBias (pmCell *inputCell, pmReadout *inputReadout, pmReadout *pedestal, ppOptions *options) {
     3bool ppDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppOptions *options) {
    44
    5     psPolynomial1D *poly;
    6     psSpline1D *spline;
    7     psString coeffs;
    85
    9     // XXX EAM : renamed the general edge overscan concept
    10     if (options->overscanMode == PM_OVERSCAN_EDGE) {
    11         // Need to get the read direction
    12         int readdir = psMetadataLookupS32(NULL, inputCell->concepts, "CELL.READDIR");
    13         if (readdir == 1) {
    14             options->overscanMode = PM_OVERSCAN_ROWS;
    15         } else if (readdir == 2) {
    16             options->overscanMode = PM_OVERSCAN_COLUMNS;
    17         } else {
    18             psAbort("phase2", "CELL.READDIR (%d) is not 1 or 2", readdir);
    19         }
     6//    psMetadataPrint(inputCell->concepts, 7);
     7
     8    pmSubtractBias(inputReadout, options->overscan, bias, dark);
     9
     10    // Output overscan fit results, if required
     11    if (! options->doOverscan || ! options->overscan) {
     12        return true;
    2013    }
    2114
    22     // XXX : should this be a psArray?
    23     psList *inputOverscans = NULL;
    24     if (options->doOverscan) {
    25         inputOverscans = pmReadoutGetBias(inputReadout); // List of overscan bias regions
     15    if (!options->overscan->poly && !options->overscan->spline) {
     16        psLogMsg("ppImage", PS_LOG_WARN, "No fit generated!\n");
     17        return true;
    2618    }
    2719
    28     // supplies the fit result in 'overscanFit'
    29     pmSubtractBias(inputReadout,
    30                    options->overscanFit,
    31                    inputOverscans,
    32                    options->overscanMode,
    33                    options->overscanStats,
    34                    options->overscanBins,
    35                    options->overscanFitType,
    36                    pedestal);
    37     psFree(inputOverscans);
    38    
    39     // Output overscan fit results, if required
    40     if (! options->doOverscan) {
    41         return true;
     20    switch (options->overscan->fitType) {
     21      case PM_FIT_POLY_ORD:
     22      case PM_FIT_POLY_CHEBY:
     23        {
     24            psPolynomial1D *poly = options->overscan->poly; // The polynomial
     25            psString coeffs = NULL;     // String containing the coefficients
     26            for (int i = 0; i < poly->nX; i++) {
     27                psStringAppend(&coeffs, "%e ", poly->coeff[i]);
     28            }
     29            psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n", coeffs);
     30            psFree(coeffs);
     31            break;
     32        }
     33      case PM_FIT_SPLINE:
     34        {
     35            psSpline1D *spline = options->overscan->spline; // The spline
     36            psString coeffs = NULL;     // String containing the coefficients
     37            for (int i = 0; i < spline->n; i++) {
     38                psPolynomial1D *poly = spline->spline[i]; // i-th polynomial
     39                psStringAppend(&coeffs, "%d: ", i);
     40                for (int j = 0; j < poly->nX; j++) {
     41                    psStringAppend(&coeffs, "%e ", poly->coeff[i]);
     42                }
     43                psStringAppend(&coeffs, "\n");
     44            }
     45            psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n", coeffs);
     46            psFree(coeffs);
     47            break;
     48        }
     49      case PM_FIT_NONE:
     50        break;
     51      default:
     52        psAbort(__func__, "Should never get here!!!\n");
    4253    }
    4354
    44     if (! options->overscanFit) {
    45         psLogMsg("phase2", PS_LOG_WARN, "No fit generated!\n");
    46         return true;
    47     }
    48 
    49     switch (options->overscanFitType) {
    50       case PM_FIT_POLYNOMIAL:
    51         poly = (psPolynomial1D *) options->overscanFit; // The polynomial
    52         coeffs = NULL;     // String containing the coefficients
    53         for (int i = 0; i < poly->nX; i++) {
    54             psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    55         }
    56         psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n",
    57                  coeffs);
    58         psFree(coeffs);
    59         break;
    60 
    61       case PM_FIT_SPLINE:
    62         spline = (psSpline1D *) options->overscanFit; // The spline
    63         coeffs = NULL;     // String containing the coefficients
    64         for (int i = 0; i < spline->n; i++) {
    65             psPolynomial1D *poly = spline->spline[i]; // i-th polynomial
    66             psStringAppend(&coeffs, "%d: ", i);
    67             for (int j = 0; j < poly->nX; j++) {
    68                 psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    69             }
    70             psStringAppend(&coeffs, "\n");
    71         }
    72         psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n",
    73                  coeffs);
    74         psFree(coeffs);
    75         break;
    76 
    77       case PM_FIT_NONE:
    78         break;
    79 
    80       default:
    81         psAbort(__func__, "Should never get here!!!\n");
    82     }
    8355    return true;
    8456}
Note: See TracChangeset for help on using the changeset viewer.