IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2008, 1:28:38 PM (18 years ago)
Author:
Paul Price
Message:

Adding supplementary output: count and stdev images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080320/psModules/src/imcombine/pmReadoutCombine.c

    r17139 r17155  
    1818
    1919//#define SHOW_BUSY 1                   // Show that the function is busy
     20
    2021
    2122//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    9495    }
    9596
    96     psStats *stats = psStatsAlloc(params->combine); // The statistics to use in the combination
     97    psStatsOptions combineStdev = 0; // Statistics option for weights
     98    switch (params->combine) {
     99      case PS_STAT_SAMPLE_MEAN:
     100      case PS_STAT_SAMPLE_MEDIAN:
     101        combineStdev = PS_STAT_SAMPLE_STDEV;
     102        break;
     103      case PS_STAT_ROBUST_MEDIAN:
     104        combineStdev = PS_STAT_ROBUST_STDEV;
     105        break;
     106      case PS_STAT_FITTED_MEAN:
     107        combineStdev = PS_STAT_FITTED_STDEV;
     108        break;
     109      case PS_STAT_CLIPPED_MEAN:
     110        combineStdev = PS_STAT_CLIPPED_STDEV;
     111        break;
     112      default:
     113        psAbort("Should never get here --- checked params->combine before.\n");
     114    }
     115
     116    psStats *stats = psStatsAlloc(params->combine | combineStdev); // The statistics to use in the combination
    97117    if (params->combine == PS_STAT_CLIPPED_MEAN) {
    98118        stats->clipSigma = params->rej;
     
    107127        }
    108128    }
     129    if (params->weights && first) {
     130        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
     131                         "Using input weights to combine images", "");
     132    }
    109133
    110134    int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine
     
    120144    psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", output->col0, output->row0);
    121145
    122     psStatsOptions combineStdev = 0; // Statistics option for weights
    123     if (params->weights) {
    124         if (first) {
    125             psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
    126                              "Using input weights to combine images", "");
    127         }
    128 
    129         // Get the correct statistics option for weights
    130         switch (params->combine) {
    131         case PS_STAT_SAMPLE_MEAN:
    132         case PS_STAT_SAMPLE_MEDIAN:
    133             combineStdev = PS_STAT_SAMPLE_STDEV;
    134             break;
    135         case PS_STAT_ROBUST_MEDIAN:
    136             combineStdev = PS_STAT_ROBUST_STDEV;
    137             break;
    138         case PS_STAT_FITTED_MEAN:
    139             combineStdev = PS_STAT_FITTED_STDEV;
    140             break;
    141         case PS_STAT_CLIPPED_MEAN:
    142             combineStdev = PS_STAT_CLIPPED_STDEV;
    143             break;
    144         default:
    145             psAbort("Should never get here --- checked params->combine before.\n");
    146         }
    147         stats->options |= combineStdev;
    148     }
     146    psImage *counts = pmReadoutAnalysisImage(output, PM_READOUT_STACK_ANALYSIS_COUNT, xSize, ySize,
     147                                             PS_TYPE_U16, 0);
     148    if (!counts) {
     149        return false;
     150    }
     151    psImage *sigma = pmReadoutAnalysisImage(output, PM_READOUT_STACK_ANALYSIS_SIGMA, xSize, ySize,
     152                                            PS_TYPE_F32, NAN);
     153    if (!sigma) {
     154        psFree(counts);
     155        return false;
     156    }
     157
     158    stats->options |= combineStdev;
    149159
    150160    // We loop through each pixel in the output image.  We loop through each input readout.  We determine if
     
    273283                outputMask[yOut][xOut] = params->blank;
    274284                outputImage[yOut][xOut] = NAN;
     285                counts->data.U16[yOut][xOut] = 0;
     286                sigma->data.F32[yOut][xOut] = NAN;
    275287                continue;
    276288            }
     
    288300                        maskData[indexData[k]] = 1;
    289301                        numMasked++;
     302                        numValid--;
    290303                    }
    291304                }
     
    293306                for (int k = pixels->n - 1, numMasked = 0; numMasked < numHigh && k >= 0; k--) {
    294307                    // Don't count the ones that are already masked
    295                     if (! maskData[indexData[k]]) {
     308                    if (!maskData[indexData[k]]) {
    296309                        maskData[indexData[k]] = 1;
    297310                        numMasked++;
     311                        numValid--;
    298312                    }
    299313                }
    300314            }
     315            counts->data.U16[yOut][xOut] = numValid;
    301316
    302317            // XXXXX this step probably is very expensive : convert errors to variance everywhere?
     
    314329                    outputWeight[yOut][xOut] = NAN;
    315330                }
     331                sigma->data.F32[yOut][xOut] = NAN;
    316332            } else {
    317333                outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine);
     
    323339                    // also, the weighted mean is not obviously the correct thing here
    324340                }
     341                sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev);
    325342            }
    326343        }
     
    338355    psFree(stats);
    339356    psFree(invScale);
     357    psFree(counts);
     358    psFree(sigma);
    340359
    341360    // Update the "concepts"
Note: See TracChangeset for help on using the changeset viewer.