IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 3, 2011, 3:11:09 PM (15 years ago)
Author:
eugene
Message:

fix the calculation of chisq values for constant errors (re-calculated, do not attempt to correct raw value)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/psphotReadout.c

    r30749 r30784  
    99}
    1010
     11// for now, let's store the detections on the readout->analysis for each readout
     12bool psphotDumpChisqs (pmConfig *config, const pmFPAview *view, const char *filerule)
     13{
     14    static int npass = 0;
     15    char filename[64];
     16
     17    bool status = true;
     18
     19    int num = psphotFileruleCount(config, filerule);
     20
     21    snprintf (filename, 64, "chisq.%02d.dat", npass);
     22    FILE *f = fopen (filename, "w");
     23
     24    // loop over the available readouts
     25    for (int i = 0; i < num; i++) {
     26
     27        // find the currently selected readout
     28        pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest
     29        psAssert (file, "missing file?");
     30
     31        pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     32        psAssert (readout, "missing readout?");
     33
     34        pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     35        psAssert (detections, "missing detections?");
     36
     37        psArray *sources = detections->allSources;
     38        psAssert (sources, "missing sources?");
     39
     40        for (int i = 0; i < sources->n; i++) {
     41            pmSource *source = sources->data[i];
     42            if (!source) continue;
     43
     44            pmModel *model = pmSourceGetModel (NULL, source);
     45            if (!model) continue;
     46       
     47            if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {
     48                fprintf (f, "%f %f %f %d %d %f  1 NONLINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);
     49            } else {
     50                fprintf (f, "%f %f %f %d %d %f  0 LINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);
     51            }
     52        }
     53    }
     54    fclose (f);
     55    npass ++;
     56
     57    return true;
     58}
     59
    1160bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
    1261
     
    147196    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    148197    psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
     198    psphotDumpChisqs (config, view, filerule);
    149199
    150200    // identify CRs and extended sources (only unmeasured sources are measured)
     
    157207    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    158208    psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources)
     209    psphotDumpChisqs (config, view, filerule);
    159210
    160211    // replace all sources
     
    164215    // NOTE : apply to ALL sources (extended + psf)
    165216    psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources)
     217    psphotDumpChisqs (config, view, filerule);
    166218
    167219    // if we only do one pass, skip to extended source analysis
     
    209261        // NOTE: apply to ALL sources
    210262        psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     263        psphotDumpChisqs (config, view, filerule);
    211264    }
    212265
Note: See TracChangeset for help on using the changeset viewer.