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/ppImageDetrendCell.c

    r5858 r6064  
    11# include "ppImage.h"
     2#include "pmFPA.h"
    23
    34// mask, bias, dark, flat are defined per Cell
    45// pedestal is constructed for each readout, which may have different exposure times
    56
    6 pmReadout *ppDetrendSelectFirst (pmCell *cell, char *name, bool doThis) {
     7pmReadout *ppDetrendSelectFirst(pmCell *cell, char *name, bool doThis)
     8{
    79
    810    if (!doThis) {
    9         return NULL;
     11        return NULL;
    1012    }
    1113
    1214    if (cell->readouts->n > 1) {
    13         psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name);
     15        psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name);
    1416    }
    1517
     
    1921}
    2022
    21 bool ppDetrendCell (ppDetrend *detrend, ppOptions *options, ppConfig *config) {
     23bool ppDetrendCell(ppDetrend *detrend, ppOptions *options, ppConfig *config)
     24{
    2225
    23     pmReadout *mask = ppDetrendSelectFirst (detrend->mask, "mask", options->doMask);
    24     pmReadout *bias = ppDetrendSelectFirst (detrend->bias, "bias", options->doBias);
    25     pmReadout *dark = ppDetrendSelectFirst (detrend->dark, "dark", options->doDark);
    26     // pmReadout *flat = ppDetrendSelectFirst (detrend->flat, "flat", options->doFlat);
     26    pmCellSetWeights(detrend->input);
     27
     28    pmReadout *mask = ppDetrendSelectFirst(detrend->mask, "mask", options->doMask);
     29    pmReadout *bias = ppDetrendSelectFirst(detrend->bias, "bias", options->doBias);
     30    pmReadout *dark = ppDetrendSelectFirst(detrend->dark, "dark", options->doDark);
     31    pmReadout *flat = ppDetrendSelectFirst(detrend->flat, "flat", options->doFlat);
    2732
    2833    // Dark time for dark image
    29     float darkTime = 1.0;       
     34    float darkTime = 1.0;
    3035    if (options->doDark) {
    31         darkTime = psMetadataLookupF32(NULL, detrend->dark->concepts, "CELL.DARKTIME");
    32         if (darkTime <= 0.0) {
    33             psErrorStackPrint(stderr, "DARKTIME for dark image (%f) is non-positive.\n", darkTime);
    34             exit(EXIT_FAILURE);
    35         }
     36        darkTime = psMetadataLookupF32(NULL, detrend->dark->concepts, "CELL.DARKTIME");
     37        if (darkTime <= 0.0) {
     38            psErrorStackPrint(stderr, "DARKTIME for dark image (%f) is non-positive.\n", darkTime);
     39            exit(EXIT_FAILURE);
     40        }
    3641    }
    37 
    38     // the pedestal combines the bias and dark contributions for a single readout
    39     pmReadout *pedestal = NULL;
    4042
    4143    for (int k = 0; k < detrend->input->readouts->n; k++) {
    4244
    43         pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image
     45        pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image
    4446
    45         // Mask bad pixels
    46         if (options->doMask) {
    47             ppDetrendMask (detrend->input, input, mask);
    48         }
     47        // Mask bad pixels
     48        if (options->doMask) {
     49            ppDetrendMask (detrend->input, input, mask);
     50        }
    4951
    50         // Non-linearity correction
    51         if (options->doNonLin) {
    52             ppDetrendNonLinear (detrend->input, input, options);
    53         }
     52        // Non-linearity correction
     53        if (options->doNonLin) {
     54            ppDetrendNonLinear (detrend->input, input, options);
     55        }
    5456
    55         // generate the pedestal image (passes through the old pedestal if current exptime == last exptime)
    56         pedestal = ppDetrendPedestal (pedestal, detrend->input, bias, dark, darkTime, options);
     57        // Bias, dark and overscan subtraction are all merged.
     58        ppDetrendBias(input, bias, dark, options);
    5759
    58         // Bias, dark and overscan subtraction are all merged.
    59         ppDetrendBias (detrend->input, input, pedestal, options);
    60 
    61         // Flat-field correction (no options used?)
    62         if (options->doFlat) {
    63             psLogMsg("phase2", PS_LOG_INFO, "flat field disabled.\n");
    64             // pmFlatField (input, flat);
    65         }
     60        // Flat-field correction (no options used?)
     61        if (options->doFlat) {
     62#if 0
     63            psLogMsg("phase2", PS_LOG_INFO, "flat field disabled.\n");
     64#endif
     65            pmFlatField(input, flat);
     66        }
    6667    }
    6768    return true;
Note: See TracChangeset for help on using the changeset viewer.