IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 4:13:46 PM (16 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppbgrestore/src/ppbgrestoreLoop.c

    r25974 r26871  
    3030        exit(PS_EXIT_PROG_ERROR);
    3131    }
     32    pmFPAfile *background= psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.BACKGROUND");
     33    if (!status) {
     34        psErrorStackPrint(stderr, "Can't find output data!\n");
     35        ppbgrestoreCleanup(config, options);
     36        exit(PS_EXIT_PROG_ERROR);
     37    }
     38    bool save_background = psMetadataLookupBool(&status, config->arguments, "SAVE_BACKGROUND");
    3239
    3340    pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest
     
    9097        }
    9198        output->save = true;
     99        background->save = save_background;
    92100
    93101        psImageBinning *binning = psphotBackgroundBinning(image, config);
     
    96104            return false;
    97105        }
    98         pmReadout *background = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);
     106        pmReadout *backgroundRO;
     107#define USE_CELL
     108#ifdef USE_CELL
     109        pmCell *backgroundCell = pmFPAviewThisCell(&roView, background->fpa);
     110        backgroundRO = pmReadoutAlloc(backgroundCell);
     111#else
     112        backgroundRO = pmFPAviewThisReadout(&roView, background->fpa);
     113//        backgroundRO = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);
     114#endif
     115        backgroundRO->image = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
     116        backgroundRO->data_exists = true;
     117        backgroundRO->parent->data_exists = true;
     118        backgroundRO->parent->parent->data_exists = true;
    99119
    100120        // linear interpolation to full-scale
    101         if (!psImageUnbin (background->image, modelRO->image, binning)) {
     121        if (!psImageUnbin (backgroundRO->image, modelRO->image, binning)) {
    102122            psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for unbinning");
    103123            psFree(binning);
     
    105125        }
    106126        psFree(binning);
    107         psF32 **backData = background->image->data.F32;
     127        psF32 **backData = backgroundRO->image->data.F32;
    108128
    109         // Do the background subtraction
     129        // Undo the background subtraction
    110130        int numCols = image->numCols, numRows = image->numRows; // Size of image
    111131        long nancount = 0;
     132        long naninputs = 0;
    112133        long finitecount = 0;
    113134        for (int y = 0; y < numRows; y++) {
     
    130151                } else if (isfinite(imageval)) {
    131152                    // XXX: TODO:following ppImage we should not modify pixels that are masked.
    132                     image->data.F32[y][x] += bgvalue;
    133                 }
     153                    image->data.F32[y][x] = imageval + bgvalue;
     154                } else {
     155                    naninputs++;
     156                }
    134157            }
     158        }
     159        if (naninputs) {
     160            printf("%ld infinite pixels found in input image\n", naninputs);
    135161        }
    136162        if (nancount) {
    137163            psWarning("%ld infinite pixels found in background %ld pixels were finite\n", nancount, finitecount);
    138164        }
    139         pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
     165//        pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
    140166
    141167        // Close chip
Note: See TracChangeset for help on using the changeset viewer.