IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 17, 2011, 2:17:35 PM (15 years ago)
Author:
eugene
Message:

fix psphotStack 2nd pass (subtract 1st pass sources from the correct image); fix PS color plotting; plug a leak in psphotStack

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psphot

  • trunk/psphot/src/psphotReadout.c

    r32633 r32695  
    99}
    1010
    11 // for now, let's store the detections on the readout->analysis for each readout
    12 bool psphotDumpChisqs (pmConfig *config, const pmFPAview *view, const char *filerule)
    13 {
    14     static int npass = 0;
    15     char filename[64];
    16 
    17     return true;
    18 
    19     bool status = true;
    20 
    21     int num = psphotFileruleCount(config, filerule);
    22 
    23     snprintf (filename, 64, "chisq.%02d.dat", npass);
    24     FILE *f = fopen (filename, "w");
    25 
    26     // loop over the available readouts
    27     for (int i = 0; i < num; i++) {
    28 
    29         // find the currently selected readout
    30         pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest
    31         psAssert (file, "missing file?");
    32 
    33         pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    34         psAssert (readout, "missing readout?");
    35 
    36         pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    37         psAssert (detections, "missing detections?");
    38 
    39         psArray *sources = detections->allSources;
    40         psAssert (sources, "missing sources?");
    41 
    42         for (int i = 0; i < sources->n; i++) {
    43             pmSource *source = sources->data[i];
    44             if (!source) continue;
    45 
    46             pmModel *model = pmSourceGetModel (NULL, source);
    47             if (!model) continue;
    48        
    49             if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {
    50                 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);
    51             } else {
    52                 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);
    53             }
    54         }
    55     }
    56     fclose (f);
    57     npass ++;
    58 
    59     return true;
    60 }
    61 
    6211bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
    6312
     
    188137    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    189138    psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
    190     psphotDumpChisqs (config, view, filerule);
    191139
    192140    // measure the radial profiles to the sky
     
    208156    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    209157    psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources)
    210     psphotDumpChisqs (config, view, filerule);
    211158
    212159    // replace all sources
    213     psphotReplaceAllSources (config, view, filerule); // pass 1 (detections->allSources)
     160    psphotReplaceAllSources (config, view, filerule, false); // pass 1 (detections->allSources)
    214161
    215162    // linear fit to include all sources (subtract again)
    216163    // NOTE : apply to ALL sources (extended + psf)
    217164    psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources)
    218     psphotDumpChisqs (config, view, filerule);
    219165
    220166    // if we only do one pass, skip to extended source analysis
     
    253199        // replace all sources so fit below applies to all at once
    254200        // NOTE: apply only to OLD sources (which have been subtracted)
    255         psphotReplaceAllSources (config, view, filerule); // pass 2
     201        psphotReplaceAllSources (config, view, filerule, false); // pass 2
    256202
    257203        // merge the newly selected sources into the existing list
     
    262208        // NOTE: apply to ALL sources
    263209        psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
    264         psphotDumpChisqs (config, view, filerule);
    265210    }
    266211
     
    295240        // replace all sources so fit below applies to all at once
    296241        // NOTE: apply only to OLD sources (which have been subtracted)
    297         psphotReplaceAllSources (config, view, filerule); // pass 2
     242        psphotReplaceAllSources (config, view, filerule, false); // pass 2
    298243
    299244        // merge the newly selected sources into the existing list
Note: See TracChangeset for help on using the changeset viewer.