IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2010, 10:58:13 AM (16 years ago)
Author:
Paul Price
Message:

Ensure files are closed when exiting with an error. Moved target PSF to its own file so that it can be closed independently of the images (they share data_exists, which need to have multiple states if they're on the same file).

File:
1 edited

Legend:

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

    r27004 r27075  
    99#include "ppStack.h"
    1010#include "ppStackLoop.h"
     11
     12/// Print a summary of the inputs, and return the number of good inputs
     13static int stackSummary(const ppStackOptions *options, // Stack options, with input mask
     14                        const char *place              // Place in code
     15    )
     16{
     17    int numGood = 0;                // Number of good inputs
     18    psString summary = NULL;        // Summary of images
     19    for (int i = 0; i < options->num; i++) {
     20        char *reason;               // Reason for rejecting
     21        switch (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
     22          case PPSTACK_MASK_NONE:
     23            reason = "Good";
     24            numGood++;
     25            break;
     26          case PPSTACK_MASK_CAL:
     27            reason = "Calibration failed";
     28            break;
     29          case PPSTACK_MASK_PSF:
     30            reason = "PSF measurement failed";
     31            break;
     32          case PPSTACK_MASK_MATCH:
     33            reason = "PSF matching failed";
     34            break;
     35          case PPSTACK_MASK_CHI2:
     36            reason = "PSF matching chi^2 deviant";
     37            break;
     38          case PPSTACK_MASK_REJECT:
     39            reason = "Rejection exceeded threshold";
     40            break;
     41          default:
     42            psAbort("Unrecognised mask value: %x", options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
     43        }
     44        psStringAppend(&summary, "Image %d: %s\n", i, reason);
     45    }
     46    psLogMsg("ppStack", PS_LOG_INFO, "Summary of images for %s:\n%s", place, summary);
     47    psFree(summary);
     48
     49    return numGood;
     50}
     51
     52
    1153
    1254bool ppStackLoop(pmConfig *config)
     
    5395    ppStackMemDump("convolve");
    5496
     97    // Ensure sufficient inputs
     98    {
     99        int numGood = stackSummary(options, "initial combination");
     100        psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     101        bool safe = psMetadataLookupBool(NULL, recipe, "SAFE"); // Be safe when combining
     102        if (safe && numGood <= 1) {
     103            psError(PPSTACK_ERR_REJECTED, true, "Insufficient inputs for combination with safety on");
     104            return false;
     105        }
     106    }
    55107
    56108    // Start threading
     
    94146    ppStackMemDump("reject");
    95147
     148    // Check inputs
     149    {
     150        int numGood = stackSummary(options, "final combination");
     151        if (numGood <= 0) {
     152            psError(PPSTACK_ERR_REJECTED, true, "Insufficient inputs for combination");
     153            return false;
     154        }
     155    }
    96156
    97157    // Final combination
Note: See TracChangeset for help on using the changeset viewer.