IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 29, 2010, 11:00:08 AM (16 years ago)
Author:
eugene
Message:

save a sample dump output function

File:
1 edited

Legend:

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

    r29548 r29607  
    360360    return true;
    361361}
     362bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule, char *filename) {
     363
     364    bool status;
     365
     366    psTimerStart ("psphot.models");
     367
     368    // find the currently selected readout
     369    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest
     370    psAssert (file, "missing file?");
     371
     372    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     373    psAssert (readout, "missing readout?");
     374
     375    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     376    psAssert (detections, "missing detections?");
     377
     378    psArray *sources = detections->newSources;
     379    psAssert (sources, "missing sources?");
     380
     381    FILE *f = NULL;
     382
     383    f = fopen (filename, "w");
     384    psAssert(f, "cannot open file");
     385
     386    for (int i = 0; i < sources->n; i++) {
     387        pmSource *source = sources->data[i];
     388
     389        // skip non-astronomical objects (very likely defects)
     390        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     391        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     392        if (!source->peak) continue;
     393        if (!source->moments) continue;
     394
     395        float Io = source->peak->flux;
     396
     397        fprintf (f, "%f %f : %f %f :: %f\n",
     398                 source->moments->Mx, source->moments->My,
     399                 source->peak->xf, source->peak->yf, Io);
     400    }
     401    fclose (f);
     402    return true;
     403}
     404
Note: See TracChangeset for help on using the changeset viewer.