IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2006, 5:57:23 PM (20 years ago)
Author:
eugene
Message:

substantial upgrade to work with the pmFPAfile paradigm

File:
1 edited

Legend:

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

    r6747 r6817  
    1 #include <stdio.h>
    2 #include "pslib.h"
    3 #include "psmodules.h"
    4 #include "ppImageDetrend.h"
    5 #include "ppImageOptions.h"
     1#include "ppImage.h"
    62
    7 // mask, bias, dark, flat are defined per Cell
     3bool ppImageDetrendReadout (ppImageOptions *options, pmConfig *config, pmFPAview *view) {
    84
    9 pmReadout *ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis)
    10 {
    11     if (!doThis) {
    12         return NULL;
     5    bool status;
     6    pmFPAfile *file;
     7
     8    // construct a view for the detrend images (which have only one readout)
     9    pmFPAview *detview = pmFPAviewAlloc (0);
     10    *detview = *view;
     11    detview->readout = 0;
     12
     13    // find the currently selected readout
     14    file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT");
     15    pmReadout *input = pmFPAviewThisReadout (view, file->fpa);
     16
     17    pmReadoutSetWeights (input);
     18
     19    // Mask bad pixels
     20    if (options->doMask) {
     21        file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.MASK");
     22        pmReadout *mask = pmFPAviewThisReadout (detview, file->fpa);
     23        ppImageDetrendMask(input, mask);
    1324    }
    1425
    15     if (cell->readouts->n > 1) {
    16         psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name);
     26# if 0
     27    // Non-linearity correction
     28    if (options->doNonLin) {
     29        ppImageDetrendNonLinear(detrend->input, input, options);
     30    }
     31# endif
     32
     33    // set up the readouts for dark and bias
     34    pmReadout  *dark = NULL;
     35    pmReadout  *bias = NULL;
     36    if (options->doBias) {
     37        file   = psMetadataLookupPtr (&status, config->files, "PPIMAGE.BIAS");
     38        bias = pmFPAviewThisReadout (detview, file->fpa);
     39    }
     40    if (options->doDark) {
     41        file   = psMetadataLookupPtr (&status, config->files, "PPIMAGE.DARK");
     42        dark = pmFPAviewThisReadout (detview, file->fpa);
    1743    }
    1844
    19     pmReadout *readout = cell->readouts->data[0]; // Readout of interest in this cell
     45    // Bias, dark and overscan subtraction are all merged.
     46    ppImageDetrendBias(input, bias, dark, options);
    2047
    21     return readout;
     48    // Flat-field correction (no options used?)
     49    if (options->doFlat) {
     50        file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.FLAT");
     51        pmReadout *flat = pmFPAviewThisReadout (detview, file->fpa);
     52        pmFlatField(input, flat);
     53    }
     54
     55    psFree (detview);
     56    return true;
    2257}
    2358
    24 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config)
    25 {
    26 #if 0
    27     pmCellSetWeights(detrend->input);
    28 #endif
     59    // XXX in psphot, the recipe options are parsed at this depth
     60    // XXX consider if we move ppImageOptions in here
     61    // psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    2962
    30     pmReadout *mask = ppImageDetrendSelectFirst(detrend->mask, "mask", options->doMask);
    31     pmReadout *bias = ppImageDetrendSelectFirst(detrend->bias, "bias", options->doBias);
    32     pmReadout *dark = ppImageDetrendSelectFirst(detrend->dark, "dark", options->doDark);
    33     pmReadout *flat = ppImageDetrendSelectFirst(detrend->flat, "flat", options->doFlat);
    34 
    35 #if 0
    36     printf("Flat type: %x\n", flat->image->type.type);
    37     printf("Flat value: %f\n", flat->image->data.F32[flat->image->numRows/2][flat->image->numCols/2]);
    38 #endif
    39 
    40     for (int k = 0; k < detrend->input->readouts->n; k++) {
    41 
    42         pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image
    43 
    44         // Mask bad pixels
    45         if (options->doMask) {
    46             ppImageDetrendMask(detrend->input, input, mask);
    47         }
    48 
    49         // Non-linearity correction
    50         if (options->doNonLin) {
    51             ppImageDetrendNonLinear(detrend->input, input, options);
    52         }
    53 
    54         // Bias, dark and overscan subtraction are all merged.
    55         ppImageDetrendBias(input, bias, dark, options);
    56 
    57         // Flat-field correction (no options used?)
    58         if (options->doFlat) {
    59             pmFlatField(input, flat);
    60         }
    61     }
    62     return true;
    63 }
Note: See TracChangeset for help on using the changeset viewer.