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/ppStackConvolve.c

    r23602 r26076  
    99#include "ppStack.h"
    1010#include "ppStackLoop.h"
     11
     12//#define TESTING
     13
    1114
    1215// Update the value of a concept
     
    3942    options->weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2)
    4043    psVectorInit(options->weightings, 0.0);
    41     options->covariances = psArrayAlloc(num); // Covariance matrices
     44    options->origCovars = psArrayAlloc(num);
     45    options->convCovars = psArrayAlloc(num); // Covariance matrices
     46
     47    psVector *renorms = psVectorAlloc(num, PS_TYPE_F32); // Renormalisation values for variances
     48    psVectorInit(renorms, NAN);
    4249
    4350    psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
     
    7986        // Background subtraction, scaling and normalisation is performed automatically by the image matching
    8087        psTimerStart("PPSTACK_MATCH");
     88        options->origCovars->data[i] = psMemIncrRefCounter(readout->covariance);
    8189        if (!ppStackMatch(readout, options, i, config)) {
    8290            psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
     
    8593            continue;
    8694        }
    87         options->covariances->data[i] = psMemIncrRefCounter(readout->covariance);
     95        options->convCovars->data[i] = psMemIncrRefCounter(readout->covariance);
     96
     97        float renorm = psMetadataLookupF32(NULL, readout->analysis, PM_READOUT_ANALYSIS_RENORM);
     98        if (!isfinite(renorm)) {
     99            renorm = 1.0;
     100        }
     101        renorms->data.F32[i] = renorm;
    88102
    89103        if (options->stats) {
     
    114128        pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image
    115129        assert(hdu);
    116         ppStackWriteImage(options->imageNames->data[i], hdu->header, readout->image, config);
     130        ppStackWriteImage(options->convImages->data[i], hdu->header, readout->image, config);
    117131        psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask
    118132        pmConfigMaskWriteHeader(config, maskHeader);
    119         ppStackWriteImage(options->maskNames->data[i], maskHeader, readout->mask, config);
     133        ppStackWriteImage(options->convMasks->data[i], maskHeader, readout->mask, config);
    120134        psFree(maskHeader);
    121         psImageCovarianceTransfer(readout->variance, readout->covariance);
    122         ppStackWriteImage(options->varianceNames->data[i], hdu->header, readout->variance, config);
     135        ppStackWriteImage(options->convVariances->data[i], hdu->header, readout->variance, config);
    123136#ifdef TESTING
    124137        {
     
    129142            psFree(name);
    130143        }
     144        {
     145            int numCols = readout->image->numCols, numRows = readout->image->numRows;
     146            psImage *sn = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     147            for (int y = 0; y < numRows; y++) {
     148                for (int x = 0; x < numCols; x++) {
     149                    sn->data.F32[y][x] = readout->image->data.F32[y][x] /
     150                        sqrtf(readout->variance->data.F32[y][x]);
     151                }
     152            }
     153            psString name = NULL;
     154            psStringAppend(&name, "signoise_%d.fits", i);
     155            ppStackWriteImage(name, hdu->header, sn, config);
     156            psFree(name);
     157            psFree(sn);
     158        }
    131159#endif
    132160
     
    149177    psFree(rng);
    150178
    151     psFree(options->norm); options->norm = NULL;
    152179    psFree(options->sourceLists); options->sourceLists = NULL;
    153180    psFree(options->psf); options->psf = NULL;
     
    211238            numGood = 0;                    // Number of good images
    212239            for (int i = 0; i < num; i++) {
    213               if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
     240                if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
    214241                    continue;
    215242                }
     
    233260    }
    234261
     262    // Correct chi^2 for renormalisation
     263    psBinaryOp(options->matchChi2, options->matchChi2, "/", renorms);
     264    for (int i = 0; i < num; i++) {
     265        psLogMsg("ppStack", PS_LOG_INFO, "Additional variance for image %d: %f\n",
     266                 i, options->matchChi2->data.F32[i]);
     267    }
     268    psFree(renorms);
     269
    235270    return true;
    236271}
Note: See TracChangeset for help on using the changeset viewer.