IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 27, 2008, 3:19:23 PM (18 years ago)
Author:
Paul Price
Message:

Split the combination run into two --- one for the initial combination and rejection, and the second for the final combination. Forced to do this because of the convolution of the rejected pixels --- the convolution area can go beyond the individual scans, so it's necessary to gather the list of all rejected pixels before doing the final combination run. The code seems to be working rather well now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackLoop.c

    r16686 r16693  
    413413#endif
    414414
    415             if (!ppStackReadout(config, outRO, readouts, subRegions, subKernels)) {
     415            if (!ppStackReadoutInitial(config, outRO, readouts, subRegions, subKernels)) {
    416416                psError(PS_ERR_UNKNOWN, false, "Unable to stack images.\n");
    417417                psFree(readouts);
     
    432432        }
    433433
    434         psFree(readouts);
     434        // Reset for the second read
     435        // Extract the rejection lists
    435436        psFree(subKernels);
    436437        psFree(subRegions);
     438        psArray *rejected = psArrayAlloc(num); // Rejected pixels
     439        for (int i = 0; i < num; i++) {
     440            pmReadout *ro = readouts->data[i]; // Readout of interest
     441            pmReadoutFreeData(ro);
     442
     443            psPixels *rejects = NULL;   // Rejection list for this readout
     444            psMetadataIterator *iter = psMetadataIteratorAlloc(ro->analysis, PS_LIST_HEAD,
     445                                                               "^" PPSTACK_REJECTED_PIXELS "$"); // Iterator
     446            psMetadataItem *item;
     447            while ((item = psMetadataGetAndIncrement(iter))) {
     448                psPixels *pixels = item->data.V; // Rejected pixels
     449                psTrace("ppStack", 5, "Adding %ld rejected pixels to image %d", pixels->n, i);
     450                rejects = psPixelsConcatenate(rejects, pixels);
     451            }
     452            psFree(iter);
     453            psTrace("ppStack", 5, "%ld rejected pixels rejected from image %d", rejects->n, i);
     454            psMetadataRemoveKey(ro->analysis, PPSTACK_REJECTED_PIXELS);
     455            rejected->data[i] = rejects;
     456        }
     457
     458
     459        // Read convolutions by chunks
     460        more = true;
     461        for (int numChunk = 0; more; numChunk++) {
     462            for (int i = 0; i < num; i++) {
     463                pmReadout *readout = readouts->data[i];
     464                assert(readout);
     465
     466                if (!pmReadoutReadChunk(readout, imageFits->data[i], 0, numScans, 0) ||
     467                    !pmReadoutReadChunkMask(readout, maskFits->data[i], 0, numScans, 0) ||
     468                    !pmReadoutReadChunkWeight(readout, weightFits->data[i], 0, numScans, 0)) {
     469                    psError(PS_ERR_IO, false, "Unable to read chunk %d for file %d", numChunk, i);
     470                    psFree(readouts);
     471                    psFree(rejected);
     472                    psFree(outRO);
     473                    psFree(view);
     474                    return false;
     475                }
     476            }
     477
     478#ifdef TESTING
     479            {
     480                pmReadout *ro = readouts->data[0];
     481                psTrace("ppStack", 1, "Stack: [%d:%d,%d:%d]\n", ro->col0, ro->col0 + ro->image->numCols,
     482                        ro->row0, ro->row0 + ro->image->numRows);
     483            }
     484#endif
     485
     486            if (!ppStackReadoutFinal(config, outRO, readouts, rejected)) {
     487                psError(PS_ERR_UNKNOWN, false, "Unable to stack images.\n");
     488                psFree(readouts);
     489                psFree(rejected);
     490                psFree(outRO);
     491                psFree(view);
     492                return false;
     493            }
     494
     495            for (int i = 0; i < num && more; i++) {
     496                pmReadout *readout = readouts->data[i];
     497                assert(readout);
     498                more &= pmReadoutMore(readout, imageFits->data[i], 0, numScans);
     499                more &= pmReadoutMoreMask(readout, maskFits->data[i], 0, numScans);
     500                more &= pmReadoutMoreWeight(readout, weightFits->data[i], 0, numScans);
     501            }
     502        }
     503
     504        psFree(readouts);
     505
    437506        for (int i = 0; i < num; i++) {
    438507            psFitsClose(imageFits->data[i]);
Note: See TracChangeset for help on using the changeset viewer.