IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23576 for trunk/ppStack


Ignore:
Timestamp:
Mar 27, 2009, 1:26:55 PM (17 years ago)
Author:
Paul Price
Message:

Can now combine images without convolving, but it doesn't apply any rejection yet.

Location:
trunk/ppStack/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/Makefile.am

    r23341 r23576  
    2929        ppStackPrepare.c        \
    3030        ppStackConvolve.c       \
     31        ppStackCombinePrepare.c \
    3132        ppStackCombineInitial.c \
    3233        ppStackReject.c         \
  • trunk/ppStack/src/ppStackCamera.c

    r23371 r23576  
    5151    bool status = false;                // Status of file definition
    5252
     53    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim
     54    if (!recipe) {
     55        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
     56        return false;
     57    }
     58    bool convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images before stack?
     59
    5360    psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config,
    5461                                                        "PPSTACK.INPUT"); // Input images from previous run
     
    98105        }
    99106        if (!runSrc) {
    100             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadta.");
     107            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata.");
    101108            psFree(runImages);
    102109            return false;
     
    104111        psFree(runSrc);
    105112
    106         psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    107                                                             "PPSTACK.CONV.KERNEL"); // Convolution kernels
    108         if (!status) {
    109             psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata.");
    110             psFree(runImages);
    111             return false;
    112         }
    113         if (!runSrc) {
    114             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define convolution kernels from RUN metadta.");
    115             psFree(runImages);
    116             return false;
    117         }
    118         psFree(runKernel);
     113        if (convolve) {
     114            psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
     115                                                                "PPSTACK.CONV.KERNEL"); // Convolution kernels
     116            if (!status) {
     117                psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata.");
     118                psFree(runImages);
     119                return false;
     120            }
     121            if (!runKernel) {
     122                psError(PS_ERR_UNEXPECTED_NULL, true,
     123                        "Unable to define convolution kernels from RUN metadata.");
     124                psFree(runImages);
     125                return false;
     126            }
     127            psFree(runKernel);
     128        }
    119129
    120130        psFree(runImages);
     
    200210            }
    201211
    202             pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL");
    203             if (!kernel) {
    204                 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL"));
    205                 return false;
    206             }
    207             kernel->save = true;
     212            if (convolve) {
     213                pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL");
     214                if (!kernel) {
     215                    psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL"));
     216                    return false;
     217                }
     218                kernel->save = true;
     219            }
    208220
    209221            i++;
     
    300312    }
    301313    jpeg2->save = true;
    302 
    303 
    304     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim
    305     if (!recipe) {
    306         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
    307         return false;
    308     }
    309314
    310315    // For photometry, we operate on the chip-mosaicked image
  • trunk/ppStack/src/ppStackCombineInitial.c

    r23573 r23576  
    2323    psTimerStart("PPSTACK_INITIAL");
    2424
    25     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
    26     psAssert(recipe, "We've thrown an error on this before.");
    27 
    2825    psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe
    2926    int overlap = 2 * psMetadataLookupS32(NULL, ppsub,
    3027                                          "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans
    3128
    32     pmFPAview *view = NULL;             // View to readout
    33 
    34     int row0, col0;                 // Offset for readout
    35     int numCols, numRows;           // Size of readout
    36     ppStackThread *thread = stack->threads->data[0]; // Representative thread
    37     if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {
    38         psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");
    39         return false;
    40     }
    41 
    42     pmFPAfileActivate(config->files, false, NULL);
    43     ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);
    44     view = ppStackFilesIterateDown(config);
    45     if (!view) {
    46         return false;
    47     }
    48 
    49     pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell
    50     options->outRO = pmReadoutAlloc(outCell); // Output readout
    51     psFree(view);
    52 
    53     psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    54     psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    55     if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {
    56         psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");
    57         return false;
    58     }
    59 
    60     psFree(options->cells); options->cells = NULL;
    6129
    6230    bool status;                    // Status of read
  • trunk/ppStack/src/ppStackLoop.c

    r23367 r23576  
    5959    if (!stack) {
    6060        psError(PS_ERR_IO, false, "Unable to initialise stack threads.");
     61        psFree(options);
     62        return false;
     63    }
     64    psFree(options->cells); options->cells = NULL;
     65
     66    // Prepare for combination
     67    if (!ppStackCombinePrepare(stack, options, config)) {
     68        psError(PS_ERR_UNKNOWN, false, "Unable to prepare for combination.");
     69        psFree(stack);
    6170        psFree(options);
    6271        return false;
  • trunk/ppStack/src/ppStackLoop.h

    r23368 r23576  
    3030// Convolve inputs to match target PSF
    3131bool ppStackConvolve(
     32    ppStackOptions *options,            // Options
     33    pmConfig *config                    // Configuration
     34    );
     35
     36// Prepare for combination
     37bool ppStackCombinePrepare(
     38    ppStackThreadData *stack,           // Stack
    3239    ppStackOptions *options,            // Options
    3340    pmConfig *config                    // Configuration
  • trunk/ppStack/src/ppStackReadout.c

    r23346 r23576  
    185185    assert(outRO);
    186186    assert(readouts);
    187     assert(rejected);
    188     assert(readouts->n == rejected->n);
     187    assert(!rejected || readouts->n == rejected->n);
    189188    assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK);
    190189    assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32);
     
    207206    psArray *stack = psArrayAlloc(num); // Array for stacking
    208207
    209     int numGood = num;                  // Number of good inputs: images that haven't been completely rejected
     208    bool entire = (rejected ? false : true); // Combine entire image?
    210209    for (int i = 0; i < num; i++) {
    211210        pmReadout *ro = readouts->data[i];
    212         if (!ro || !rejected->data[i] || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    213             // Image completely rejected
    214             numGood--;
     211        if (mask->data.U8[i] & (PPSTACK_MASK_REJECT | PPSTACK_MASK_BAD)) {
     212            // Image completely rejected since previous combination
     213            entire = true;
     214            continue;
     215        } else if (mask->data.U8[i]) {
     216            // Image completely rejected before original combination
    215217            continue;
    216218        }
     
    234236        pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i],
    235237                                             addVariance ? addVariance->data.F32[i] : NAN);
    236         data->reject = psMemIncrRefCounter(rejected->data[i]);
     238        data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL;
    237239        stack->data[i] = data;
    238240    }
    239241
    240242    if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 0, NAN, NAN, NAN,
    241                         numGood != num, useVariance, false)) {
     243                        entire, useVariance, false)) {
    242244        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts.");
    243245        psFree(stack);
  • trunk/ppStack/src/ppStackSetup.c

    r23573 r23576  
    1414
    1515// Generate an array of input filenames
    16 static psArray *stackNameArray(pmConfig *config, // Configuration
     16static psArray *stackNameArray(const ppStackOptions *options, // Stack options
     17                               pmConfig *config, // Configuration
    1718                               const char *name // Name of file
    1819    )
     
    2122    psAssert(config, "Require file name");
    2223
    23     psString regex = NULL;             // Regular expression for selecting file
    24     psStringAppend(&regex, "^%s$", name);
    25     psMetadataIterator *iter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, regex); // Iterator
    26     psFree(regex);
    27     psMetadataItem *item;               // Item from iteration
    28     psArray *array = psArrayAlloc(BUFFER); // Array of file names
    29     while ((item = psMetadataGetAndIncrement(iter))) {
    30         psAssert(item->type == PS_DATA_UNKNOWN, "Should be this type");
    31         pmFPAfile *file = item->data.V; // An input file
     24    psArray *array = psArrayAllocEmpty(options->num); // Array with filenames
     25    pmFPAview *view = pmFPAviewAlloc(0);// View to readout
     26    view->chip = view->cell = view->readout = -1;
    3227
    33         psString filename = psStringCopy(file->filename); // Filename of interest
     28    for (int i = 0; i < options->num; i++) {
     29        pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest
     30
     31        psString filename = pmFPAfileName(file, view, config); // Filename of interest
     32        psAssert(filename, "Can't determine filename");
    3433        psArrayAdd(array, array->n, filename);
    3534        psFree(filename);               // Drop reference
    3635    }
    37     psFree(iter);
    3836
    3937    return array;
     
    114112        psFree(outputName);
    115113    } else {
    116         options->imageNames = stackNameArray(config, "PPSTACK.INPUT");
    117         options->maskNames = stackNameArray(config, "PPSTACK.INPUT.MASK");
    118         options->varianceNames = stackNameArray(config, "PPSTACK.INPUT.VARIANCE");
     114        options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT");
     115        options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK");
     116        options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE");
    119117    }
    120118
Note: See TracChangeset for help on using the changeset viewer.