IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 9, 2009, 2:53:12 PM (17 years ago)
Author:
Paul Price
Message:

Merging branches/pap (unconvolved stacks, reworked combinePixels function into clearer roles, only throw out most variant pixel on each iteration, throw suspect pixels out as first rejection step) stack development. I think I've got everything, but not entirely sure, since I've already merged this branch once before (for dual convolution).

Location:
trunk/ppStack
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack

  • trunk/ppStack/src/ppStackThread.c

    r24796 r26076  
    5656}
    5757
    58 ppStackThreadData *ppStackThreadDataSetup(const ppStackOptions *options, const pmConfig *config)
     58ppStackThreadData *ppStackThreadDataSetup(const ppStackOptions *options, const pmConfig *config, bool conv)
    5959{
    6060    psAssert(options, "Require options");
     
    6262
    6363    const psArray *cells = options->cells; // Array of input cells
    64     const psArray *imageNames = options->imageNames; // Names of images to read
    65     const psArray *maskNames = options->maskNames; // Names of masks to read
    66     const psArray *varianceNames = options->varianceNames; // Names of variance maps to read
    67     const psArray *covariances = options->covariances; // Covariance matrices (already read)
     64    const psArray *imageNames = conv ? options->convImages : options->origImages; // Names of images to read
     65    const psArray *maskNames = conv ? options->convMasks : options->origMasks; // Names of masks to read
     66    const psArray *varianceNames = conv ? options->convVariances : options->origVariances; // Variance names
     67    const psArray *covariances = conv ? options->convCovars : options->origCovars; // Covariance matrices
    6868
    6969    PS_ASSERT_ARRAY_NON_NULL(cells, NULL);
    70     PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, imageNames, NULL);
    71     PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, maskNames, NULL);
    72     PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, varianceNames, NULL);
    73     PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL);
     70    if (imageNames) {
     71        PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, imageNames, NULL);
     72    }
     73    if (maskNames) {
     74        PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, maskNames, NULL);
     75    }
     76    if (varianceNames) {
     77        PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, varianceNames, NULL);
     78    }
     79    if (covariances) {
     80        PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL);
     81    }
    7482
    7583    ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return
     
    8795            continue;
    8896        }
    89         // Resolved names
    90         psString imageResolved = pmConfigConvertFilename(imageNames->data[i], config, false, false);
    91         psString maskResolved = pmConfigConvertFilename(maskNames->data[i], config, false, false);
    92         psString varianceResolved = pmConfigConvertFilename(varianceNames->data[i], config, false, false);
    93         stack->imageFits->data[i] = psFitsOpen(imageResolved, "r");
    94         stack->maskFits->data[i] = psFitsOpen(maskResolved, "r");
    95         stack->varianceFits->data[i] = psFitsOpen(varianceResolved, "r");
    96         psFree(imageResolved);
    97         psFree(maskResolved);
    98         psFree(varianceResolved);
    99         if (!stack->imageFits->data[i] || !stack->maskFits->data[i] || !stack->varianceFits->data[i]) {
    100             psError(PS_ERR_UNKNOWN, false, "Unable to open convolved files %s, %s, %s",
    101                     (char*)imageNames->data[i], (char*)maskNames->data[i], (char*)varianceNames->data[i]);
    102             return NULL;
    103         }
     97
     98// Open an image
     99#define IMAGE_OPEN(NAMES, FITS, INDEX)          \
     100        if (NAMES) { \
     101            psString resolved = pmConfigConvertFilename((NAMES)->data[INDEX], config, false, false); \
     102            (FITS)->data[INDEX] = psFitsOpen(resolved, "r");                            \
     103            if (!(FITS)->data[INDEX]) { \
     104                psError(PS_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \
     105                psFree(resolved); \
     106                return NULL; \
     107            } \
     108            psFree(resolved); \
     109        }
     110
     111        IMAGE_OPEN(imageNames, stack->imageFits, i);
     112        IMAGE_OPEN(maskNames, stack->maskFits, i);
     113        IMAGE_OPEN(varianceNames, stack->varianceFits, i);
    104114    }
    105115
     
    116126            }
    117127            pmReadout *ro = pmReadoutAlloc(cell); // Readout for thread
    118             ro->covariance = psMemIncrRefCounter(covariances->data[j]);
     128            if (covariances) {
     129                ro->covariance = psMemIncrRefCounter(covariances->data[j]);
     130            }
    119131            readouts->data[j] = ro;
    120132        }
     
    186198                psFits *varianceFits = stack->varianceFits->data[i]; // FITS file for variance
    187199
    188 
    189                 int zMax = 0;
     200                int zMax = 0;
    190201                bool keepReading = false;
    191                 if (pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) {
     202
     203                if (imageFits && pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) {
    192204                    keepReading = true;
    193205                    if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) {
     
    199211                }
    200212
    201                 if (pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) {
     213                if (maskFits && pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) {
    202214                    keepReading = true;
    203215                    if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) {
     
    209221                }
    210222
    211                 if (pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) {
     223                if (varianceFits && pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) {
    212224                    keepReading = true;
    213225                    if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) {
     
    263275
    264276    {
    265         psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 2);
     277        psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 3);
    266278        task->function = &ppStackInspect;
    267279        psThreadTaskAdd(task);
     
    270282
    271283    {
    272         psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 3);
     284        psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6);
    273285        task->function = &ppStackReadoutFinalThread;
    274286        psThreadTaskAdd(task);
Note: See TracChangeset for help on using the changeset viewer.