IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/ppStack/src/ppStackLoop.c

    r27075 r27517  
    1818    psString summary = NULL;        // Summary of images
    1919    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";
     20        psString reason = NULL;         // Reason for rejecting
     21        if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
     22            psStringAppend(&reason, " Good.");
    2423            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]);
     24        } else {
     25            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_CAL) {
     26                psStringAppend(&reason, " Calibration failed.");
     27            }
     28            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_PSF) {
     29                psStringAppend(&reason, " PSF measurement failed.");
     30            }
     31            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_MATCH) {
     32                psStringAppend(&reason, " PSF matching failed.");
     33            }
     34            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_CHI2) {
     35                psStringAppend(&reason, " PSF matching chi^2 deviant.");
     36            }
     37            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_REJECT) {
     38                psStringAppend(&reason, " Rejection exceeded threshold.");
     39            }
    4340        }
    4441        psStringAppend(&summary, "Image %d: %s\n", i, reason);
     42        psFree(reason);
    4543    }
    4644    psLogMsg("ppStack", PS_LOG_INFO, "Summary of images for %s:\n%s", place, summary);
     
    5250
    5351
    54 bool ppStackLoop(pmConfig *config)
     52bool ppStackLoop(pmConfig *config, ppStackOptions *options)
    5553{
    5654    assert(config);
     
    5856    psTimerStart("PPSTACK_TOTAL");
    5957    psTimerStart("PPSTACK_STEPS");
    60 
    61     ppStackOptions *options = ppStackOptionsAlloc(); // Options for stacking
    6258
    6359    // Setup
     
    6561    if (!ppStackSetup(options, config)) {
    6662        psError(psErrorCodeLast(), false, "Unable to setup.");
    67         psFree(options);
    6863        return false;
    6964    }
     
    7671    if (!ppStackPrepare(options, config)) {
    7772        psError(psErrorCodeLast(), false, "Unable to prepare for stacking.");
    78         psFree(options);
    7973        return false;
    8074    }
     
    8276             psTimerClear("PPSTACK_STEPS"));
    8377    ppStackMemDump("prepare");
    84 
     78    if (options->quality) {
     79        // Can't do anything else
     80        return true;
     81    }
    8582
    8683    // Convolve inputs
     
    8885    if (!ppStackConvolve(options, config)) {
    8986        psError(psErrorCodeLast(), false, "Unable to convolve images.");
    90         psFree(options);
    9187        return false;
    9288    }
     
    111107    if (!stack) {
    112108        psError(psErrorCodeLast(), false, "Unable to initialise stack threads.");
    113         psFree(options);
    114109        return false;
    115110    }
    116111
    117112    // Prepare for combination
    118     if (!ppStackCombinePrepare(stack, options, config)) {
     113    if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK,
     114                               stack, options, config)) {
    119115        psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
    120116        psFree(stack);
    121         psFree(options);
    122117        return false;
    123118    }
     
    128123        psError(psErrorCodeLast(), false, "Unable to perform initial combination.");
    129124        psFree(stack);
    130         psFree(options);
    131         return false;
    132     }
    133     ppStackMemDump("convolve");
     125        return false;
     126    }
     127    ppStackMemDump("initial");
    134128    psLogMsg("ppStack", PS_LOG_INFO, "Stage 3: Make Initial Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
    135129
     130    // Done with stack inputs for now
     131    for (int i = 0; i < options->num; i++) {
     132        pmCellFreeData(options->cells->data[i]);
     133    }
     134    psFree(stack);
    136135
    137136    // Pixel rejection
     
    140139        psError(psErrorCodeLast(), false, "Unable to reject pixels.");
    141140        psFree(stack);
    142         psFree(options);
    143141        return false;
    144142    }
    145143    psLogMsg("ppStack", PS_LOG_INFO, "Stage 4: Pixel Rejection: %f sec", psTimerClear("PPSTACK_STEPS"));
    146     ppStackMemDump("reject");
    147144
    148145    // Check inputs
     
    155152    }
    156153
     154    stack = ppStackThreadDataSetup(options, config, true);
     155    if (!stack) {
     156        psError(psErrorCodeLast(), false, "Unable to initialise stack threads.");
     157        return false;
     158    }
     159
    157160    // Final combination
    158161    psTrace("ppStack", 2, "Final stack of convolved images....\n");
    159     if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, false, false)) {
     162    if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true)) {
    160163        psError(psErrorCodeLast(), false, "Unable to perform final combination.");
    161164        psFree(stack);
    162         psFree(options);
    163165        return false;
    164166    }
    165167    psLogMsg("ppStack", PS_LOG_INFO, "Stage 5: Final Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
    166168    ppStackMemDump("final");
     169
     170    // Photometry
     171    psTrace("ppStack", 1, "Photometering stacked image....\n");
     172    if (!ppStackPhotometry(options, config)) {
     173        psError(psErrorCodeLast(), false, "Unable to perform photometry.");
     174        return false;
     175    }
     176    psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS"));
     177    ppStackMemDump("photometry");
    167178
    168179    // Clean up
     
    171182        psError(psErrorCodeLast(), false, "Unable to clean up.");
    172183        psFree(stack);
    173         psFree(options);
    174         return false;
    175     }
    176     psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
     184        return false;
     185    }
     186    for (int i = 0; i < options->num; i++) {
     187        pmCellFreeData(options->cells->data[i]);
     188    }
     189    psFree(stack);
     190    psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
    177191    ppStackMemDump("cleanup");
    178 
    179     psFree(stack);
    180192
    181193#if 1
     
    186198        if (!stack) {
    187199            psError(psErrorCodeLast(), false, "Unable to initialise stack threads.");
    188             psFree(options);
    189             return false;
    190         }
     200            return false;
     201        }
     202
     203        // Prepare for combination
     204        if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV,
     205                                   stack, options, config)) {
     206            psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
     207            psFree(stack);
     208            return false;
     209        }
     210
    191211        psTrace("ppStack", 2, "Stack of unconvolved images....\n");
    192         if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, false, true)) {
     212        if (!ppStackCombineFinal(stack, options->origCovars, options, config,
     213                                 false, true, false)) {
    193214            psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination.");
    194215            psFree(stack);
    195             psFree(options);
    196             return false;
    197         }
    198         psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
     216            return false;
     217        }
     218        psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
    199219        ppStackMemDump("unconv");
    200220
     221        if (!ppStackFilesIterateUp(config)) {
     222            psError(psErrorCodeLast(), false, "Unable to close files.");
     223            psFree(stack);
     224            return false;
     225        }
     226        ppStackFileActivation(config, PPSTACK_FILES_UNCONV, false);
     227        options->outRO->data_exists = false;
     228        options->outRO->parent->data_exists = false;
     229        options->outRO->parent->parent->data_exists = false;
     230        psFree(options->outRO);
     231        options->outRO = NULL;
     232        options->expRO->data_exists = false;
     233        options->expRO->parent->data_exists = false;
     234        options->expRO->parent->parent->data_exists = false;
     235        psFree(options->expRO);
     236        options->expRO = NULL;
     237
     238        for (int i = 0; i < options->num; i++) {
     239            pmCellFreeData(options->cells->data[i]);
     240        }
    201241        psFree(stack);
    202242    }
    203243    psFree(options->cells); options->cells = NULL;
    204244#endif
    205 
    206     // Photometry
    207     psTrace("ppStack", 1, "Photometering stacked image....\n");
    208     if (!ppStackPhotometry(options, config)) {
    209         psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    210         psFree(options);
    211         return false;
    212     }
    213     psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS"));
    214     ppStackMemDump("photometry");
    215245
    216246    // Finish up
     
    218248    if (!ppStackFinish(options, config)) {
    219249        psError(psErrorCodeLast(), false, "Unable to finish up.");
    220         psFree(options);
    221         return false;
    222     }
    223     psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Final output: %f sec", psTimerClear("PPSTACK_STEPS"));
     250        return false;
     251    }
    224252    ppStackMemDump("finish");
    225 
    226     psFree(options);
    227253
    228254    return true;
Note: See TracChangeset for help on using the changeset viewer.