IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41843


Ignore:
Timestamp:
Oct 16, 2021, 3:54:37 PM (5 years ago)
Author:
eugene
Message:

add utility command to report on pmFPAfiles; fix typo; add quick combine-by-percentile; remove some old and excessively-verbose test blocks

Location:
branches/eam_branches/ipp-dev-20210817/psModules/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-dev-20210817/psModules/src/camera/pmFPAfileIO.c

    r41535 r41843  
    145145}
    146146
     147// list all defined pmFPAfiles
     148bool pmFPAfileIOList (pmConfig *config)
     149{
     150    PS_ASSERT_PTR_NON_NULL(config, false);
     151    PS_ASSERT_PTR_NON_NULL(config->files, false);
     152
     153    psMetadata *files = config->files;
     154
     155    // attempt to perform all create, read, write, close operations
     156    psMetadataItem *item = NULL;
     157    psMetadataIterator *iter = psMetadataIteratorAlloc (files, PS_LIST_HEAD, NULL);
     158    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
     159        pmFPAfile *file = item->data.V;
     160       
     161        fprintf (stderr, "%s : %d %d %d : %d %d %d %d\n", file->name, file->type, file->mode, file->state,
     162                 file->fileLevel, file->dataLevel, file->freeLevel, file->mosaicLevel);
     163    }
     164    psFree (iter);
     165    return true;
     166}
     167
    147168// read the file, if necessary and possible
    148169bool pmFPAfileRead(pmFPAfile *file, const pmFPAview *view, pmConfig *config)
     
    359380
    360381    if (file->state & PM_FPA_STATE_INACTIVE) {
    361         psTrace("psModules.camera", 6, "skip write for %s, files is inactive", file->name);
     382        psTrace("psModules.camera", 6, "skip write for %s, file is inactive", file->name);
    362383        return true;
    363384    }
  • branches/eam_branches/ipp-dev-20210817/psModules/src/camera/pmFPAfileIO.h

    r23576 r41843  
    5555bool pmFPAfileReadPHU (pmFPAfile *file, const pmFPAview *view, pmConfig *config);
    5656
     57bool pmFPAfileIOList (pmConfig *config);
     58
    5759/// @}
    5860# endif
  • branches/eam_branches/ipp-dev-20210817/psModules/src/imcombine/pmStack.c

    r36710 r41843  
    961961
    962962    // KMM values;
    963     float Punimodal = 1.0,KMMmean = NAN,KMMsigma = NAN,KMMpi = NAN;
     963    float Punimodal = 1.0, KMMmean = NAN, KMMsigma = NAN, KMMpi = NAN;
    964964    int KMM_MINIMUM_INPUTS = 6;
    965965    bool useKMM = false;
     
    15101510}
    15111511
     1512# define MIN_GOOD_PERCENTILE 2
     1513bool pmStackCombineByPercentile(
     1514    pmReadout *combined,
     1515    psArray *stackData,
     1516    psF64 minRange,
     1517    psF64 maxRange,
     1518    psImageMaskType badMaskBits,        // treat these bits as 'bad'
     1519    psImageMaskType suspectMaskBits,    // treat these bits as 'suspect'
     1520    psImageMaskType blankMaskBits       // use this mask value for pixels missing input data (distinguish between Ninput = 0 and Ngood = 0?)
     1521) {
     1522    int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine
     1523    int xSize, ySize;                   // Size of the output image
     1524
     1525    // we need to copy the readouts to their own array for validation
     1526    psArray *stackReadouts = psArrayAlloc(stackData->n);
     1527    for (int i = 0; i < stackData->n; i++) {
     1528        pmStackData *data = stackData->data[i]; // Stack data for this input
     1529        pmReadout *ro = data->readout;  // Readout of interest
     1530        stackReadouts->data[i] = psMemIncrRefCounter(ro);
     1531    }
     1532
     1533    if (!pmReadoutStackValidate(&minInputCols, &maxInputCols, &minInputRows, &maxInputRows, &xSize, &ySize, stackReadouts)) {
     1534        psError(psErrorCodeLast(), false, "Input stack is not valid.");
     1535        psFree(stackReadouts);
     1536        return false;
     1537    }
     1538    psFree(stackReadouts);
     1539
     1540    psVector *pixelData = psVectorAlloc(stackData->n, PS_TYPE_F32);
     1541    psVector *pixelMask = psVectorAlloc(stackData->n, PS_TYPE_VECTOR_MASK);
     1542
     1543    for (int y = minInputRows; y < maxInputRows; y++) {
     1544        for (int x = minInputCols; x < maxInputCols; x++) {
     1545
     1546            int nGood = 0;
     1547            for (int i = 0; i < stackData->n; i++) {
     1548
     1549                pmStackData *data = stackData->data[i]; // Stack data for this input
     1550                pmReadout *ro = data->readout;  // Readout of interest
     1551                psImage *image = ro->image;
     1552
     1553                int xIn = x - data->readout->col0;
     1554                int yIn = y - data->readout->row0; // Coordinates on input readout
     1555
     1556                if (!isfinite(image->data.F32[yIn][xIn])) continue;
     1557                if (fabs(image->data.F32[yIn][xIn]) > 1e5) continue;
     1558                // XXX need to test the input mask as well here
     1559
     1560                pixelData->data.F32[nGood] = image->data.F32[yIn][xIn];
     1561                nGood ++;
     1562            }
     1563            pixelData->n = nGood;
     1564            psVectorSortInPlace (pixelData);
     1565
     1566            if (nGood < MIN_GOOD_PERCENTILE) {
     1567                combined->image->data.F32[y][x] = NAN;
     1568                combined->variance->data.F32[y][x] = NAN;
     1569                combined->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = 1;
     1570                continue;
     1571            }
     1572
     1573            int Ns = MIN(MAX(0, minRange * nGood),nGood); // e.g., 0.1 * 50 = 5
     1574            int Ne = MIN(MAX(0, maxRange * nGood),nGood); // e.g., 0.9 * 50 = 45
     1575            int Npt = Ne - Ns;
     1576
     1577            float sum = 0.0;
     1578            for (int n = Ns; n < Ne; n++) {
     1579                sum += pixelData->data.F32[n];
     1580            }
     1581            float mean = sum / (float) Npt;
     1582
     1583            float varSum = 0.0;
     1584            for (int n = Ns; n < Ne; n++) {
     1585                varSum += SQ(pixelData->data.F32[n] - mean);
     1586            }
     1587            // variance on the mean (stdev / sqrt(N))^2
     1588            float varValue = varSum / (Npt - 1) / Npt;
     1589
     1590            combined->image->data.F32[y][x] = mean;
     1591            combined->variance->data.F32[y][x] = varValue;
     1592            combined->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = 0;
     1593        }
     1594    }
     1595 
     1596    psFree(pixelData);
     1597    psFree(pixelMask);
     1598
     1599    return (true);
     1600}
     1601
    15121602/// Stack input images
    15131603bool pmStackCombine(
     
    16441734        expweight = expmaps->variance;
    16451735    }
    1646 
    1647 /*     // Pre-reject inputs using KMM bimodality test. */
    1648 /*     if (1)  { */
    1649 /* /\*       KMMRejectUnpopular(input,x,y); *\/ */
    1650 /*       rejection = true; */
    1651 /*     } */
    16521736   
    16531737    // Set up rejection list
     
    16601744    for (int y = minInputRows; y < maxInputRows; y++) {
    16611745        for (int x = minInputCols; x < maxInputCols; x++) {
     1746            // this is only for TESTING:
    16621747            CHECKPIX(x, y, "Combining pixel %d,%d: %x %x %f %f %f %f %d %d %d\n", x, y, badMaskBits, blankMaskBits, iter, rej, sys, olympic, useVariance, safe, rejection);
    1663 
    1664 /*          // Pre-reject inputs using KMM bimodality test. */
    1665 /*        if (1)  { */
    1666 /*          KMMRejectUnpopular(input,x,y); */
    1667 /* /\*      rejection = true; *\/ */
    1668 /*        } */
    1669 /*        else { */
    1670 /*          KMMRejectBright(input,x,y); */
    1671 /*        } */
    1672 
    1673 #ifdef TESTING
    1674             if (PS_SQR(x - TEST_X) + PS_SQR(y - TEST_Y) <= PS_SQR(TEST_RADIUS)) {
    1675                 fprintf (stderr, "combine\n");
    1676             }
    1677 # endif
    16781748
    16791749            psVector *reject = NULL; // Images to reject for this pixel
  • branches/eam_branches/ipp-dev-20210817/psModules/src/imcombine/pmStack.h

    r36710 r41843  
    4747                                );
    4848
     49bool pmStackCombineByPercentile(
     50    pmReadout *combined,
     51    psArray *input,
     52    psF64 minRange,
     53    psF64 maxRange,
     54    psImageMaskType badMaskBits,        // treat these bits as 'bad'
     55    psImageMaskType suspectMaskBits,    // treat these bits as 'suspect'
     56    psImageMaskType blankMaskBits       // use this mask value for pixels missing input data (distinguish between Ninput = 0 and Ngood = 0?)
     57  );
     58
    4959/// Stack input images
    5060bool pmStackCombine(pmReadout *combined,///< Combined readout (output)
Note: See TracChangeset for help on using the changeset viewer.