IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25990


Ignore:
Timestamp:
Nov 1, 2009, 4:04:00 PM (17 years ago)
Author:
eugene
Message:

covariance needed when calculating chisq

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r25755 r25990  
    5959    }
    6060
     61    // XXX test: choose a larger-than expected radius:
     62    float covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix
     63    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "covariance factor: %f\n", covarFactor);
     64
     65    // XXX do not apply covarFactor for the moment...
     66    // covarFactor = 1.0;
     67
    6168    // select the sources which will be used for the fitting analysis
    6269    for (int i = 0; i < sources->n; i++) {
     
    120127
    121128        // diagonal elements of the sparse matrix (auto-cross-product)
    122         f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS);
     129        f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    123130        psSparseMatrixElement (sparse, i, i, f);
    124131
    125132        // the formal error depends on the weighting scheme
    126133        if (CONSTANT_PHOTOMETRIC_WEIGHTS) {
    127             float var = pmSourceModelDotModel (SRCi, SRCi, false);
     134            float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor);
    128135            errors->data.F32[i] = 1.0 / sqrt(var);
    129136        } else {
     
    133140
    134141        // find the image x model value
    135         f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS);
     142        f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    136143        psSparseVectorElement (sparse, i, f);
    137144
     
    139146        switch (SKY_FIT_ORDER) {
    140147          case 1:
    141             f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS);
     148            f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    142149            psSparseBorderElementB (border, i, 1, f);
    143             f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS);
     150            f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    144151            psSparseBorderElementB (border, i, 2, f);
    145152
    146153          case 0:
    147             f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS);
     154            f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    148155            psSparseBorderElementB (border, i, 0, f);
    149156            break;
     
    165172
    166173            // got an overlap; calculate cross-product and add to output array
    167             f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS);
     174            f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
    168175            psSparseMatrixElement (sparse, j, i, f);
    169176        }
     
    219226
    220227    // measure chisq for each source
    221     for (int i = 0; final && (i < fitSources->n); i++) {
     228    // for (int i = 0; final && (i < fitSources->n); i++) {
     229    for (int i = 0; i < fitSources->n; i++) {
    222230        pmSource *source = fitSources->data[i];
    223231        if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue;
    224232        pmModel *model = pmSourceGetModel (NULL, source);
    225         pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal);
     233        pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, covarFactor);
    226234    }
    227235    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "get chisqs: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem);
     
    238246
    239247    psphotVisualShowResidualImage (readout);
     248    psphotVisualPlotChisq (sources);
    240249    // psphotVisualShowFlags (sources);
    241250
     
    244253
    245254// XXX do we need this?
     255// XXX disallow the simultaneous sky fit and remove this code...
    246256
    247257// Calculate the weight terms for the sky fit component of the matrix.  This function operates
Note: See TracChangeset for help on using the changeset viewer.