IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2012, 5:15:08 PM (14 years ago)
Author:
eugene
Message:

some tests to check working analysis; add some additional stats to psphotFitSourcesLinear

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120601/psphot/src/psphotFitSourcesLinear.c

    r34060 r34071  
    273273            source->mode |= PM_SOURCE_MODE_PSFMODEL;
    274274        }           
    275        
     275
    276276        psArrayAdd (fitSources, 100, source);
    277277    }
     
    308308
    309309        // diagonal elements of the sparse matrix (auto-cross-product)
    310         f = pmSourceModelDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
    311         psSparseMatrixElement (sparse, i, i, f);
     310        float MM = pmSourceModelDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
     311        psSparseMatrixElement (sparse, i, i, MM);
    312312
    313313        // if we have used CONSTANT errors, then we need to re-calculate the value of the parameter error
    314         if (fitVarMode == PM_SOURCE_PHOTFIT_CONST) {
     314        if (fitVarMode != PM_SOURCE_PHOTFIT_IMAGE_VAR) {
    315315            float var = pmSourceModelDotModel (SRCi, SRCi, PM_SOURCE_PHOTFIT_IMAGE_VAR, covarFactor, maskVal);
    316316            errors->data.F32[i] = 1.0 / sqrt(var);
    317317        } else {
    318             errors->data.F32[i] = 1.0 / sqrt(f);
     318            errors->data.F32[i] = 1.0 / sqrt(MM);
    319319        }
    320320
    321321        // find the image x model value
    322         f = pmSourceDataDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
    323         psSparseVectorElement (sparse, i, f);
     322        float FM = pmSourceDataDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
     323        psSparseVectorElement (sparse, i, FM);
    324324
    325325        // add the per-source variances (border region)
     
    435435    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "sub models: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem);
    436436
     437    // mean stats on fit windows
     438    float sumRadius = 0.0;
     439    float sumPixels = 0.0;
     440    float sumSource = 0.0;
     441
    437442    // measure chisq for each source
    438443    // for (int i = 0; final && (i < fitSources->n); i++) {
     
    440445        pmSource *source = fitSources->data[i];
    441446        pmModel *model = pmSourceGetModel (NULL, source);
     447
     448        // accumulate fit windows statistics
     449        sumRadius += model->fitRadius;
     450        sumPixels += M_PI*PS_SQR(model->fitRadius);
     451        sumSource += 1.0;
     452
    442453        if (!(source->mode & PM_SOURCE_MODE_NONLINEAR_FIT)) {
    443454            model->nPar = 1; // LINEAR-only sources have 1 parameter; NONLINEAR sources have their original value
     
    446457    }
    447458    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "get chisqs: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem);
     459
     460    float meanRadius = sumRadius / sumSource;
     461    float meanPixels = sumPixels / sumSource;
    448462
    449463    // psFree (index);
     
    455469    psFree (border);
    456470
    457     psLogMsg ("psphot.ensemble", PS_LOG_WARN, "measure ensemble of PSFs: %f sec\n", psTimerMark ("psphot.linear"));
     471    psLogMsg ("psphot.ensemble", PS_LOG_WARN, "measure ensemble of PSFs (mean radius = %f pixels, mean area = %f pixels: %f sec\n", meanRadius, meanPixels, psTimerMark ("psphot.linear"));
    458472
    459473    psphotVisualPlotChisq (sources);
     
    466480    return true;
    467481}
    468 
    469 // XXX do we need this?
    470 // XXX disallow the simultaneous sky fit and remove this code...
    471482
    472483// Calculate the weight terms for the sky fit component of the matrix.  This function operates
     
    558569    );
    559570
    560 bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources) {
     571 bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources) {
    561572
    562573    bool status = false;
     
    599610        return false;
    600611    }
    601 
    602612    psFree (varModel);
    603613    psFree (varModelStdev);
     
    612622    }
    613623    if (gain > 2.0) { /* warn? */ }
     624    // XXX we are not actually using the gain, but need to test it to avoid gcc pedantic warnings
    614625
    615626    // insert all of the source models
Note: See TracChangeset for help on using the changeset viewer.