IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42776


Ignore:
Timestamp:
Dec 29, 2024, 4:02:56 PM (19 months ago)
Author:
eugene
Message:

set freeLevel for inputs to CELL so data can be freed after readout loop; change API to set the dataLevel and freeLevel to specific values (no user option); plug a mem leak (free zerors); free input readout data after each cell is done

Location:
branches/eam_branches/ipp-ppmerge-20241229/ppMerge/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-ppmerge-20241229/ppMerge/src/ppMerge.h

    r33666 r42776  
    117117    );
    118118
     119bool ppMergeFileFreeInput(pmConfig *config, const pmFPAview *view, int num);
     120
    119121/**
    120122 * Set the data level for files specified by name; return an array of the files
    121123 */
    122124psArray *ppMergeFileDataLevel(const pmConfig *config, ///< Configuration
    123                               const char *name, ///< Name of files
    124                               pmFPALevel level ///< Level for file data level
     125                              const char *name ///< Name of files
    125126    );
    126127
  • branches/eam_branches/ipp-ppmerge-20241229/ppMerge/src/ppMergeFiles.c

    r33666 r42776  
    105105}
    106106
    107 psArray *ppMergeFileDataLevel(const pmConfig *config, const char *name, pmFPALevel level)
     107bool ppMergeFileFreeInput(pmConfig *config, const pmFPAview *view, int num)
     108{
     109    {
     110        pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", num);
     111        if (!pmFPAfileFreeData(input, view)) {
     112            psError(PS_ERR_UNKNOWN, false, "Unable to free data for image file %d", num);
     113            return false;
     114        }
     115    }
     116    bool mdok;          // Status of MD lookup
     117    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS")) {
     118        pmFPAfile *mask = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.MASK", num); // Mask file
     119        if (!pmFPAfileFreeData(mask, view)) {
     120            psError(PS_ERR_UNKNOWN, false, "Unable to free data for mask file %d", num);
     121            return false;
     122        }
     123    }
     124    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES")) {
     125        pmFPAfile *variance = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.VARIANCE", num); // Variance file
     126        if (!pmFPAfileFreeData(variance, view)) {
     127            psError(PS_ERR_UNKNOWN, false, "Unable to free data for variance file %d", num);
     128            return false;
     129        }
     130    }
     131    return true;
     132}
     133
     134// Select the specified input files and assign the dataLevel and freeLevel,
     135// saving a pointer on output array.
     136// This function takes the argument pmFPALevel and sets the dataLevel based on that value.
     137// However, this is only used with the value PM_FPA_LEVEL_READOUT, and it must be set
     138// to that level for the rest of ppMerge to work correctly.  Furthermore, the freeLevel
     139// must be set to Cell.  Remove the (false) option.
     140psArray *ppMergeFileDataLevel(const pmConfig *config, const char *name)
    108141{
    109142    assert(config);
     
    115148    for (int i = 0; i < numFiles; i++) {
    116149        pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // Image file
    117         file->dataLevel = level;
    118         file->freeLevel = level;
     150        file->dataLevel = PM_FPA_LEVEL_READOUT;
     151        file->freeLevel = PM_FPA_LEVEL_CELL;
    119152        files->data[i] = psMemIncrRefCounter(file);
    120153    }
  • branches/eam_branches/ipp-ppmerge-20241229/ppMerge/src/ppMergeLoop.c

    r42764 r42776  
    3939    bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances?
    4040
    41     psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); // Input images
    42     psArray *masks = NULL, *variances = NULL; // Input masks and variances
    43     if (haveMasks) {
    44         masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK", PM_FPA_LEVEL_READOUT);
    45     }
    46     if (haveVariances) {
    47         variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
    48     }
     41    psArray *inputs    = ppMergeFileDataLevel(config, "PPMERGE.INPUT"); // Input images
     42    psArray *masks     = haveMasks ? ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK") : NULL; // Input masks
     43    psArray *variances = haveVariances ? ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE") : NULL; // Input variances
    4944
    5045    int nThreads = psMetadataLookupS32 (&mdok, arguments, "NTHREADS");
     
    135130    psString darkNorm = psMetadataLookupStr(&mdok, arguments, "DARK.NORM"); ///< Dark normalisation
    136131
    137 
    138132    if (!ppMergeFileActivate(config, PPMERGE_FILES_ALL, true)) {
    139133        psError(PS_ERR_UNKNOWN, false, "Unable to activate files.");
     
    152146    }
    153147
    154 
    155148    // Average concepts across inputs
    156149    {
     
    180173        {
    181174            psList *inChips = psListAlloc(NULL);
    182             for (int i=0; i < numFiles; i++) {
     175            for (int i = 0; i < numFiles; i++) {
    183176                pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa);
    184177                psListAdd(inChips, PS_LIST_TAIL, chip);
     
    193186
    194187        pmCell *outCell;                ///< Cell of interest
    195 
    196         // XXX TEST : force a single loop
    197         // outCell = pmFPAviewNextCell(view, outFPA, 1); {
    198188
    199189        while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) {
     
    305295                psAbort("Should never get here.");
    306296            }
     297            // XXX EAM : for testing purposes
     298            fprintf (stderr, "after pmDarkCombinePrepare / pmReadoutCombinePrepare:\n");
     299            psMemStats(true, NULL, NULL);
    307300
    308301            // Read input data by chunks
     
    320313                    break;
    321314                }
     315
     316               
    322317
    323318                // Start a job
     
    357352                      // call: pmDarkCombine(outCell, fileGroup->readouts, iter, rej, maskVal);
    358353                      if (!psThreadJobAddPending(job)) {
    359                         //                          goto ERROR;
    360                         // continue; // I don't care.
     354                        // CZW commented this out with a note that this was needed to allow ppMerge to work even if some inputs are invalid.
     355                        // EAM thinks pmDarkCombine will only return FALSE if there is a programming or setup error (see pmDark.c:pmDarkCombine)
     356                        // if so, we should raise an error here.
     357                        // goto ERROR;
    361358                      }
    362359                      break;
     
    400397
    401398            psFree(fileGroups);
    402             //            psFree(zeros);
    403399
    404400            // XXX eventually need to keep both the shutter and the pattern, as we do with dark
     
    541537            }
    542538
     539            // free the data used by the input files (we need to do the work ourselves)
     540            for (int i = 0; i < numFiles; i++) {
     541                if (!ppMergeFileFreeInput(config, view, i)) {
     542                    psError(PS_ERR_UNKNOWN, false, "Unable to open file %d", i);
     543                    goto ERROR;
     544                }
     545            }
     546
    543547            psFree(outRO);
    544548            cellNum++;
     
    547551                goto ERROR;
    548552            }
     553
     554            pmFPAfileIOList (config);
    549555        }
    550556
     
    564570    psFree(variances);
    565571    psFree(stats);
     572    psFree(zeros);
    566573    return true;
    567574
     
    573580    psFree(variances);
    574581    psFree(stats);
     582    psFree(zeros);
    575583    return false;
    576584}
  • branches/eam_branches/ipp-ppmerge-20241229/ppMerge/src/ppMergeMask.c

    r39500 r42776  
    427427    }
    428428
    429     psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); ///< Input images
     429    psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT"); ///< Input images
    430430    psFree(inputs);
    431431    if (haveMasks) {
    432         psArray *masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK", PM_FPA_LEVEL_READOUT);
     432        psArray *masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK");
    433433        psFree(masks);
    434434    }
    435435    if (haveVariances) {
    436         psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
     436        psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE");
    437437        psFree(variances);
    438438    }
Note: See TracChangeset for help on using the changeset viewer.