IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 8, 2009, 2:01:33 PM (17 years ago)
Author:
Paul Price
Message:

Attempt to fix exposure time in output: ppStackSourcesTransparency now returns the total exposure time (since it calculates it, and corrects all the photometry to correspond to that exposure time), and ppStackLoop applies it to the output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackLoop.c

    r20997 r21092  
    254254    psArray *sourceLists = psArrayAlloc(num); // Individual lists of sources for matching
    255255    pmPSF *targetPSF = NULL;            // Target PSF
     256    float sumExposure = NAN;            // Sum of exposure times
    256257    if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {
    257258        pmFPAfileActivate(config->files, false, NULL);
     
    348349
    349350        // Zero point calibration
    350         if (!ppStackSourcesTransparency(sourceLists, view, config)) {
     351        sumExposure = ppStackSourcesTransparency(sourceLists, view, config);
     352        if (!isfinite(sumExposure) || sumExposure <= 0) {
    351353            psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");
    352354            psFree(sourceLists);
     
    407409    psVector *weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2)
    408410    psVectorInit(weightings, NAN);
     411    psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
     412    psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
    409413    for (int i = 0; i < num; i++) {
    410414        psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
     
    475479        writeImage(weightNames->data[i], hdu->header, readout->weight, config);
    476480
    477         cells->data[i] = psMemIncrRefCounter(readout->parent);
     481        pmCell *inCell = readout->parent; // Input cell
     482
     483        psListAdd(cellList, PS_LIST_TAIL, inCell);
     484        psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
     485
     486        cells->data[i] = psMemIncrRefCounter(inCell);
    478487        if (!filesIterateUp(config)) {
    479488            return false;
     
    496505        return false;
    497506    }
     507
     508
     509    // Update concepts for output
     510    {
     511        pmFPAview view;                 // View for output
     512        view.chip = view.cell = view.readout = 0;
     513        pmCell *outCell = pmFPAfileThisCell(config->files, &view, "PPSTACK.OUTPUT"); // Output cell
     514        pmFPA *outFPA = outCell->parent->parent; // Output FPA
     515        pmConceptsAverageFPAs(outFPA, fpaList);
     516        pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
     517        psFree(fpaList);
     518        psFree(cellList);
     519
     520        // Update the value of a concept
     521#define UPDATE_CONCEPT(SOURCE, NAME, VALUE) { \
     522            psMetadataItem *item = psMetadataLookup(SOURCE->concepts, NAME); \
     523            psAssert(item, "Concept should be present"); \
     524            psAssert(item->type == PS_TYPE_F32, "Concept should be F32"); \
     525            item->data.F32 = VALUE; \
     526        }
     527
     528        UPDATE_CONCEPT(outFPA,  "FPA.EXPOSURE",  sumExposure);
     529        UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", sumExposure);
     530        UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);
     531    }
     532
    498533
    499534    // Reject images out-of-hand on the basis of their match chi^2
     
    626661            return false;
    627662        }
    628 
    629         psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
    630         psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
    631         for (int i = 0; i < num; i++) {
    632             pmCell *inCell = cells->data[i]; // Input cell
    633             if (!inCell) {
    634                 exptimes->data.F32[i] = 0.0;
    635                 continue;
    636             }
    637             exptimes->data.F32[i] = psMetadataLookupF32(NULL, inCell->concepts, "CELL.EXPOSURE");
    638             psListAdd(cellList, PS_LIST_TAIL, inCell);
    639             psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
    640         }
    641 
    642         // Copy concepts
    643         pmChip *outChip = outCell->parent;  // Output chip
    644         pmFPA *outFPA = outChip->parent;    // Output FPA
    645         pmConceptsAverageFPAs(outFPA, fpaList);
    646         pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
    647         psFree(fpaList);
    648         psFree(cellList);
    649663
    650664        psFree(cells);
     
    977991    // Close up
    978992    bool wcsDone = false;           // Have we done the WCS?
    979     float totExposure = 0.0;            // Total exposure time
    980993    for (int i = 0; i < num; i++) {
    981994        if (inputMask->data.U8[i]) {
    982995            continue;
    983996        }
    984         totExposure += exptimes->data.F32[i];
    985997
    986998        ppStackThread *thread = stack->threads->data[0]; // Representative stack
Note: See TracChangeset for help on using the changeset viewer.