IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16989


Ignore:
Timestamp:
Mar 13, 2008, 2:29:14 PM (18 years ago)
Author:
Paul Price
Message:

Fix for outrageous use of memory when combining GPC images --- there are so many chips and cells, each with their own concepts metadata, that the memory is filled with metadataItems. Added a purge of the ones that aren't required. Since the concepts are integral to the system, it's sometimes necessary when iterating to skip cells that have had the concepts purged.

Location:
trunk/ppMerge/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeCheckInputs.c

    r13246 r16989  
    106106        }
    107107
    108         data->in->data[i] = pmFPAConstruct(config->camera);
    109         pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, options->format);
     108        pmFPA *fpa = pmFPAConstruct(config->camera);
     109        pmFPAview *view = pmFPAAddSourceFromHeader(fpa, header, options->format);
    110110        psFree(view);
     111
     112        // Cull chips and cells that don't have data
     113        // Otherwise the abundance of metadata in the concepts (esp. for GPC) can overload the memory
     114        psArray *chips = fpa->chips; // Array of chips in output
     115        for (int i = 0; i < chips->n; i++) {
     116            pmChip *chip = chips->data[i]; // Chip of interest
     117            psArray *cells = chip->cells; // Array of cells
     118            int culled = 0;             // Number of culled cells
     119            for (int j = 0; j < cells->n; j++) {
     120                pmCell *cell = cells->data[j];
     121                pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU for cell
     122                if (!hdu || hdu->blankPHU) {
     123                    psFree(cell->concepts);
     124                    cell->concepts = NULL;
     125                    culled++;
     126                }
     127            }
     128            if (culled == cells->n) {
     129                psFree(chip->concepts);
     130                chip->concepts = NULL;
     131            }
     132        }
     133        data->in->data[i] = fpa;
     134
    111135
    112136        // Use the first valid input as the basis for the output --- including the header
  • trunk/ppMerge/src/ppMergeCombine.c

    r16950 r16989  
    133133        while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
    134134            cellNum++;
     135
     136            pmHDU *hdu = pmHDUGetLowest(data->out, chip, cell); // HDU for cell
     137            if (!hdu || hdu->blankPHU) {
     138                pmCellWrite(cell, data->outFile, config->database, true); // Write header only
     139                continue;
     140            }
    135141            if (cell->hdu) {
    136142                // Data will exist soon
     
    138144                chip->data_exists = cell->data_exists = true;
    139145            }
    140             pmCellWrite(cell, data->outFile, config->database, true); // Write header only
    141146            pmReadout *readout = pmReadoutAlloc(cell); // Output readout of interest
    142147            psArray *stack = psArrayAlloc(filenames->n); // Stack of readouts to combine
     
    155160
    156161            // Put version metadata into header
    157             pmHDU *hdu = pmHDUFromCell(cell);
    158162            if (hdu && hdu != lastHDU) {
    159163                if (!hdu->header) {
  • trunk/ppMerge/src/ppMergeMaskAverageConcepts.c

    r15937 r16989  
    1818// Generate a mask
    1919bool ppMergeMaskAverageConcepts(ppMergeData *data,  // Data
    20                                 ppMergeOptions *options, // Options
    21                                 pmConfig *config    // Configuration
     20                                ppMergeOptions *options, // Options
     21                                pmConfig *config    // Configuration
    2222    )
    2323{
     
    3838        while ((cellOut = pmFPAviewNextCell(view, fpaOut, 1))) {
    3939
     40            pmHDU *hdu = pmHDUGetLowest(fpaOut, chipOut, cellOut);
     41            if (!hdu || hdu->blankPHU) {
     42                continue;
     43            }
     44
    4045            // Get list of cells for concepts averaging
    41             psList *inCells = psListAlloc(NULL); // List of cells
    42             for (int i = 0; i < filenames->n; i++) {
    43                 if (! filenames->data[i] || strlen(filenames->data[i]) == 0) {
    44                     continue;
    45                 }
    46                 pmCell *cellIn = pmFPAviewThisCell(view, data->in->data[i]); // Input cell
    47                 psListAdd(inCells, PS_LIST_TAIL, cellIn);
    48             }
    49             if (!pmConceptsAverageCells(cellOut, inCells, NULL, NULL, true)) {
    50                 psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
    51                 psFree(inCells);
    52                 return false;
    53             }
    54             psFree(inCells);
     46            psList *inCells = psListAlloc(NULL); // List of cells
     47            for (int i = 0; i < filenames->n; i++) {
     48                if (! filenames->data[i] || strlen(filenames->data[i]) == 0) {
     49                    continue;
     50                }
     51                pmCell *cellIn = pmFPAviewThisCell(view, data->in->data[i]); // Input cell
     52                psListAdd(inCells, PS_LIST_TAIL, cellIn);
     53            }
     54            if (!pmConceptsAverageCells(cellOut, inCells, NULL, NULL, true)) {
     55                psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
     56                psFree(inCells);
     57                return false;
     58            }
     59            psFree(inCells);
    5560        }
    5661    }
     
    5964    psList *inFPAs = psListAlloc(NULL); // List of FPAs
    6065    for (int i = 0; i < filenames->n; i++) {
    61         if (! filenames->data[i] || strlen(filenames->data[i]) == 0) {
    62             continue;
    63         }
    64         pmFPA *fpaIn = data->in->data[i]; // Input FPA
    65         psListAdd(inFPAs, PS_LIST_TAIL, fpaIn);
     66        if (! filenames->data[i] || strlen(filenames->data[i]) == 0) {
     67            continue;
     68        }
     69        pmFPA *fpaIn = data->in->data[i]; // Input FPA
     70        psListAdd(inFPAs, PS_LIST_TAIL, fpaIn);
    6671    }
    6772
    6873    if (!pmConceptsAverageFPAs(fpaOut, inFPAs)) {
    69         psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts.");
    70         psFree(inFPAs);
    71         return false;
     74        psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts.");
     75        psFree(inFPAs);
     76        return false;
    7277    }
    7378    psFree(inFPAs);
Note: See TracChangeset for help on using the changeset viewer.