IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2008, 3:14:42 PM (18 years ago)
Author:
Paul Price
Message:

Moving concepts averaging to a place where we actually have the FPA and cell handy.

File:
1 edited

Legend:

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

    r19475 r19476  
    466466#endif
    467467
    468     ppStackThreadInit();
    469     ppStackThreadData *stack = ppStackThreadDataSetup(cells, imageNames, maskNames, weightNames,
    470                                                       config); // Data for stacking
    471     psFree(cells);
    472468
    473469    memDump("preinitial");
     
    478474    pmFPAview *view = NULL;             // View to readout
    479475    psArray *inspect = NULL;            // Array of arrays of pixels to inspect
     476    ppStackThreadData *stack = NULL;    // Data for stacking
     477    psVector *exptimes = psVectorAlloc(num, PS_TYPE_F32); // Exposure times for each input
    480478    {
    481479        int row0, col0;                 // Offset for readout
     
    488486            psFree(stack);
    489487            psFree(inputMask);
     488            psFree(exptimes);
    490489            return false;
    491490        }
     
    499498            psFree(stack);
    500499            psFree(inputMask);
     500            psFree(exptimes);
    501501            return false;
    502502        }
     
    515515            psFree(view);
    516516            psFree(outRO);
    517             return false;
    518         }
     517            psFree(exptimes);
     518            return false;
     519        }
     520
     521        psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
     522        psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
     523        for (int i = 0; i < num; i++) {
     524            pmCell *inCell = cells->data[i]; // Input cell
     525            exptimes->data.F32[i] = psMetadataLookupF32(NULL, inCell->concepts, "CELL.EXPOSURE");
     526            psListAdd(cellList, PS_LIST_TAIL, inCell);
     527            psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
     528        }
     529
     530        // Copy concepts
     531        pmChip *outChip = outCell->parent;  // Output chip
     532        pmFPA *outFPA = outChip->parent;    // Output FPA
     533        pmConceptsAverageFPAs(outFPA, fpaList);
     534        pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
     535        psFree(fpaList);
     536        psFree(cellList);
     537
     538        // Start threading
     539        ppStackThreadInit();
     540        ppStackThreadData *stack = ppStackThreadDataSetup(cells, imageNames, maskNames, weightNames, config);
     541        psFree(cells);
    519542
    520543        bool status;                    // Status of read
     
    531554                psFree(view);
    532555                psFree(outRO);
     556                psFree(exptimes);
    533557                return false;
    534558            }
     
    553577                psFree(view);
    554578                psFree(outRO);
     579                psFree(exptimes);
    555580                return false;
    556581            }
     
    566591            psFree(view);
    567592            psFree(outRO);
     593            psFree(exptimes);
    568594            return false;
    569595        }
     
    622648                psFree(inspect);
    623649                psFree(rejected);
     650                psFree(exptimes);
    624651                return false;
    625652            }
     
    637664            psFree(inspect);
    638665            psFree(rejected);
     666            psFree(exptimes);
    639667            return false;
    640668        }
     
    714742            psFree(view);
    715743            psFree(outRO);
     744            psFree(exptimes);
    716745            return false;
    717746        }
     
    735764                psFree(view);
    736765                psFree(outRO);
     766                psFree(exptimes);
    737767                return false;
    738768            }
     
    755785                psFree(view);
    756786                psFree(outRO);
     787                psFree(exptimes);
    757788                return false;
    758789            }
     
    767798            psFree(view);
    768799            psFree(outRO);
     800            psFree(exptimes);
    769801            return false;
    770802        }
     
    788820    // Close up
    789821    bool wcsDone = false;           // Have we done the WCS?
    790     psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
    791     psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
    792822    float totExposure = 0.0;            // Total exposure time
    793823    for (int i = 0; i < num; i++) {
     
    795825            continue;
    796826        }
     827        totExposure += exptimes->data.F32[i];
     828
    797829        ppStackThread *thread = stack->threads->data[0]; // Representative stack
    798830        pmReadout *inRO = thread->readouts->data[i]; // Template readout
    799         if (!inRO) {
    800             continue;
    801         }
    802         float exposure = psMetadataLookupF32(NULL, inRO->parent->concepts, "CELL.EXPOSURE"); // Exposure time
    803         if (!isfinite(exposure)) {
    804             psWarning("CELL.EXPOSURE not set for readout %d", i);
    805         } else {
    806             totExposure += exposure;
    807         }
    808 
    809         psListAdd(cellList, PS_LIST_TAIL, inRO->parent);
    810         psListAdd(fpaList, PS_LIST_TAIL, inRO->parent->parent->parent);
    811 
    812         if (!wcsDone) {
     831        if (inRO && !wcsDone) {
    813832            // Copy astrometry over
    814833            wcsDone = true;
     
    856875    psFree(weightNames);
    857876
    858     // Copy concepts
    859     pmCell *outCell = outRO->parent;    // Output cell
    860     pmChip *outChip = outCell->parent;  // Output chip
    861     pmFPA *outFPA = outChip->parent;    // Output FPA
    862     psMetadataAddF32(outCell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE,
    863                      "Summed exposure time (sec)", totExposure);
    864     psMetadataAddF32(outFPA->concepts, PS_LIST_TAIL, "FPA.EXPOSURE", PS_META_REPLACE,
    865                      "Summed exposure time (sec)", totExposure);
    866 
    867     pmConceptsAverageFPAs(outFPA, fpaList);
    868     pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
    869     psFree(fpaList);
    870     psFree(cellList);
    871 
     877    psFree(exptimes);
    872878    psFree(inputMask);
    873879    psFree(stack);
Note: See TracChangeset for help on using the changeset viewer.