IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2010, 11:22:22 PM (16 years ago)
Author:
Paul Price
Message:

Renormalise image so that the normalisation provided by the convolution kernel matches that of determined from stellar photometry.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppStack/src/ppStackMatch.c

    r26684 r26690  
    1818#define COVAR_FRAC 0.01                 // Truncation fraction for covariance matrix
    1919
    20 //#define TESTING                         // Enable debugging output
     20#define TESTING                         // Enable debugging output
    2121
    2222#ifdef TESTING
     
    274274                                                                PM_SUBTRACTION_ANALYSIS_KERNEL);
    275275
    276             pmSubtractionAnalysis(readout->analysis, NULL, kernels, region,
     276            pmSubtractionAnalysis(conv->analysis, NULL, kernels, region,
    277277                                  readout->image->numCols, readout->image->numRows);
    278278
     
    372372            fake->mask = psImageCopy(NULL, readout->mask, PS_TYPE_IMAGE_MASK);
    373373
     374#if 1
    374375            // Add the background into the target image
    375376            psImage *bgImage = stackBackgroundModel(readout, config); // Image of background
    376377            psBinaryOp(fake->image, fake->image, "+", bgImage);
    377378            psFree(bgImage);
     379#endif
    378380
    379381#ifdef TESTING
     
    456458                    return false;
    457459                }
    458                                               psFree(widthsCopy);
     460                psFree(widthsCopy);
    459461            }
    460462
     
    559561        }
    560562
     563        // Kernel normalisation
     564        {
     565            double sum = 0.0;           // Sum of chi^2
     566            int num = 0;                // Number of measurements of chi^2
     567            psString regex = NULL;      // Regular expression
     568            psStringAppend(&regex, "^%s$", PM_SUBTRACTION_ANALYSIS_NORM);
     569            psMetadataIterator *iter = psMetadataIteratorAlloc(conv->analysis, PS_LIST_HEAD, regex);
     570            psFree(regex);
     571            psMetadataItem *item = NULL;// Item from iteration
     572            while ((item = psMetadataGetAndIncrement(iter))) {
     573                assert(item->type == PS_TYPE_F32);
     574                float norm = item->data.F32; // Normalisation
     575                sum += norm;
     576                num++;
     577            }
     578            psFree(iter);
     579            float conv = sum/num;       // Mean normalisation from convolution
     580            float stars = powf(10.0, -0.4 * options->norm->data.F32[index]); // Normalisation from stars
     581            float renorm =  stars / conv; // Renormalisation to apply
     582            psLogMsg("ppStack", PS_LOG_INFO, "Renormalising image %d by %f (kernel: %f, stars: %f)\n",
     583                     index, renorm, conv, stars);
     584            psBinaryOp(readout->image, readout->image, "*", psScalarAlloc(renorm, PS_TYPE_F32));
     585            psBinaryOp(readout->variance, readout->variance, "*", psScalarAlloc(PS_SQR(renorm), PS_TYPE_F32));
     586        }
     587
    561588        // Reject image completely if the maximum deconvolution fraction exceeds the limit
    562589        float deconv = psMetadataLookupF32(NULL, conv->analysis,
Note: See TracChangeset for help on using the changeset viewer.