IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20116


Ignore:
Timestamp:
Oct 13, 2008, 3:21:07 PM (18 years ago)
Author:
Paul Price
Message:

Adding source output: more values than is in a CMF file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubReadout.c

    r20055 r20116  
    547547                             psTimerClear("PPSUB_PHOT"));
    548548        }
     549
     550#ifdef TESTING
     551        // Record data about sources: not everything gets into the output CMF files
     552        {
     553            pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
     554            psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
     555            FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
     556            fprintf(sourceFile, "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
     557            for (int i = 0; i < sources->n; i++) {
     558                pmSource *source = sources->data[i];
     559                if (!source) {
     560                    continue;
     561                }
     562
     563                float x, y;             // Position of source
     564                float chi2;             // chi^2 for source
     565                if (source->modelPSF) {
     566                    x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
     567                    y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
     568                    chi2 = source->modelPSF->chisq;
     569                } else if (source->peak) {
     570                    x = source->peak->xf;
     571                    y = source->peak->yf;
     572                    chi2 = NAN;
     573                } else {
     574                    psWarning("No position available for source.");
     575                    continue;
     576                }
     577
     578                float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
     579                if (source->moments) {
     580                    xMoment = source->moments->Mx;
     581                    yMoment = source->moments->My;
     582                    xxMoment = source->moments->Mxx;
     583                    xyMoment = source->moments->Mxy;
     584                    yyMoment = source->moments->Myy;
     585                }
     586
     587                fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f",
     588                        x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
     589                        source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
     590            }
     591            fclose(sourceFile);
     592        }
     593#endif
     594
    549595    }
    550596
     
    594640    }
    595641
     642#ifdef TESTING
    596643    // Significance image
    597644    {
     
    603650        psFree(sig);
    604651    }
     652#endif
    605653
    606654    psFree(outRO);
Note: See TracChangeset for help on using the changeset viewer.