IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2008, 2:59:07 PM (18 years ago)
Author:
Paul Price
Message:

Adding count and sigma files as outputs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080320/ppMerge/src/ppMergeLoop.c

    r17083 r17157  
    4949    int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y
    5050
    51     // Shutter parameters
    52     int shutterIter = psMetadataLookupS32(NULL, arguments, "SHUTTER.ITER"); // Number of shutter iterations
    53     float shutterRej = psMetadataLookupF32(NULL, arguments, "SHUTTER.REJ"); // Rejection limit for shutter
    54 
    5551    pmCombineParams *combination = pmCombineParamsAlloc(combineStat); // Combination parameters
    5652    combination->maskVal = maskVal;
     
    152148            }
    153149
    154             if (type == PPMERGE_TYPE_MASK) {
    155                 psAbort("Can't do masks yet.");
    156 #if 0
    157                 ppMergeMask(readouts, config);
    158 #endif
    159             } else {
    160                 float shutterRef = NAN;     // Reference shutter correction
    161                 if (type == PPMERGE_TYPE_SHUTTER) {
    162                     shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]);
    163                 }
    164 
    165                 // Read convolutions by chunks
    166                 bool more = true;               // More to read?
    167                 for (int numChunk = 0; more; numChunk++) {
    168                     psTrace("ppStack", 2, "Initial stack of chunk %d....\n", numChunk);
    169                     for (int i = 0; i < numFiles; i++) {
    170                         pmReadout *inRO = readouts->data[i]; // Input readout
    171 
    172                         // Read a chunk from a file
    173                         #define READ_CHUNK(NAME,TYPE) { \
    174                             pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
    175                             if (!pmReadoutReadChunk##TYPE(inRO, file->fits, 0, rows, 0)) { \
    176                                 psError(PS_ERR_IO, false, "Unable to read chunk %d for file %s %d", \
    177                                         numChunk, NAME, i); \
    178                                 psFree(readouts); \
    179                                 psFree(outRO); \
    180                                 psFree(view); \
    181                                 return false; \
    182                             } \
    183                         }
    184 
    185                         READ_CHUNK("PPMERGE.INPUT", /* Blank */);
    186                         if (haveMasks) {
    187                             READ_CHUNK("PPMERGE.INPUT.MASK", Mask);
    188                         }
    189                         if (haveWeights) {
    190                             READ_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
    191                         }
    192                     }
    193 
    194                     switch (type) {
    195                       case PPMERGE_TYPE_SHUTTER:
    196                         pmShutterCorrectionGenerate(outRO, NULL, readouts, shutterRef,
    197                                                     shutters->data[cellNum], shutterIter, shutterRej,
    198                                                     maskVal);
    199                         break;
    200                       case PPMERGE_TYPE_DARK:
    201                         pmDarkCombine(outCell, readouts, darkOrdinates, darkNorm, iter, rej, maskVal);
    202                         break;
    203                       case PPMERGE_TYPE_BIAS:
    204                       case PPMERGE_TYPE_FLAT:
    205                       case PPMERGE_TYPE_FRINGE:
    206                         pmReadoutCombine(outRO, readouts, zeros, scales, combination);
    207                         break;
    208                       default:
    209                         psAbort("Should never get here.");
    210                     }
    211 
    212 
    213                     for (int i = 0; i < numFiles && more; i++) {
    214                         pmReadout *inRO = readouts->data[i];
    215 
    216                         // Check to see if there's more chunks to read
    217                         #define MORE_CHUNK(NAME,TYPE) { \
    218                             pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
    219                             more &= pmReadoutMore##TYPE(inRO, file->fits, 0, rows); \
    220                         }
    221 
    222                         MORE_CHUNK("PPMERGE.INPUT", /* Blank */);
    223                         if (haveMasks) {
    224                             MORE_CHUNK("PPMERGE.INPUT.MASK", Mask);
    225                         }
    226                         if (haveWeights) {
    227                             MORE_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
    228                         }
     150            float shutterRef = NAN;     // Reference shutter correction
     151            if (type == PPMERGE_TYPE_SHUTTER) {
     152                shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]);
     153            }
     154
     155            // Read convolutions by chunks
     156            bool more = true;               // More to read?
     157            for (int numChunk = 0; more; numChunk++) {
     158                psTrace("ppStack", 2, "Initial stack of chunk %d....\n", numChunk);
     159                for (int i = 0; i < numFiles; i++) {
     160                    pmReadout *inRO = readouts->data[i]; // Input readout
     161
     162                    // Read a chunk from a file
     163                    #define READ_CHUNK(NAME,TYPE) { \
     164                        pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
     165                        if (!pmReadoutReadChunk##TYPE(inRO, file->fits, 0, rows, 0)) { \
     166                            psError(PS_ERR_IO, false, "Unable to read chunk %d for file %s %d", \
     167                                    numChunk, NAME, i); \
     168                            psFree(readouts); \
     169                            psFree(outRO); \
     170                            psFree(view); \
     171                            return false; \
     172                        } \
     173                    }
     174
     175                    READ_CHUNK("PPMERGE.INPUT", /* Blank */);
     176                    if (haveMasks) {
     177                        READ_CHUNK("PPMERGE.INPUT.MASK", Mask);
     178                    }
     179                    if (haveWeights) {
     180                        READ_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
     181                    }
     182                }
     183
     184                switch (type) {
     185                  case PPMERGE_TYPE_SHUTTER:
     186                    pmShutterCorrectionGenerate(outRO, NULL, readouts, shutterRef,
     187                                                shutters->data[cellNum], iter, rej,
     188                                                maskVal);
     189                    break;
     190                  case PPMERGE_TYPE_DARK:
     191                    pmDarkCombine(outCell, readouts, darkOrdinates, darkNorm, iter, rej, maskVal);
     192                    break;
     193                  case PPMERGE_TYPE_BIAS:
     194                  case PPMERGE_TYPE_FLAT:
     195                  case PPMERGE_TYPE_FRINGE:
     196                    pmReadoutCombine(outRO, readouts, zeros, scales, combination);
     197                    break;
     198                  default:
     199                    psAbort("Should never get here.");
     200                }
     201
     202
     203                for (int i = 0; i < numFiles && more; i++) {
     204                    pmReadout *inRO = readouts->data[i];
     205
     206                    // Check to see if there's more chunks to read
     207                    #define MORE_CHUNK(NAME,TYPE) { \
     208                        pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
     209                        more &= pmReadoutMore##TYPE(inRO, file->fits, 0, rows); \
     210                    }
     211
     212                    MORE_CHUNK("PPMERGE.INPUT", /* Blank */);
     213                    if (haveMasks) {
     214                        MORE_CHUNK("PPMERGE.INPUT.MASK", Mask);
     215                    }
     216                    if (haveWeights) {
     217                        MORE_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
    229218                    }
    230219                }
    231220            }
    232221            psFree(readouts);
     222
     223            // Plug supplementary images into their own FPAs
     224            {
     225                pmCell *countsCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.COUNT");
     226                pmReadout *countsRO = pmReadoutAlloc(countsCell); // Readout with count of inputs per pixel
     227                psImage *counts = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_COUNT);
     228                countsRO->image = psImageCopy(countsRO->image, counts, PS_TYPE_F32);
     229                psMetadataRemoveKey(outRO->analysis, PM_READOUT_STACK_ANALYSIS_COUNT);
     230                countsRO->data_exists = countsCell->data_exists = countsCell->parent->data_exists = true;
     231                psFree(countsRO);
     232
     233                pmCell *sigmaCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.SIGMA");
     234                pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); // Readout with stdev per pixel
     235                psImage *sigma = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_SIGMA);
     236                sigmaRO->image = psImageCopy(sigmaRO->image, sigma, PS_TYPE_F32);
     237                psMetadataRemoveKey(outRO->analysis, PM_READOUT_STACK_ANALYSIS_SIGMA);
     238                sigmaRO->data_exists = sigmaCell->data_exists = sigmaCell->parent->data_exists = true;
     239                psFree(sigmaRO);
     240            }
    233241
    234242            // Measure the fringes for this cell
Note: See TracChangeset for help on using the changeset viewer.