IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20083


Ignore:
Timestamp:
Oct 12, 2008, 4:05:13 PM (18 years ago)
Author:
eugene
Message:

move psf star dump to own function

File:
1 edited

Legend:

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

    r19963 r20083  
    226226    return header;
    227227}
     228
     229// XXX add args as needed
     230bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psMaskType maskVal, psMaskType markVal) {
     231
     232    psphotSaveImage (NULL, readout->image,  "rawstars.fits");
     233
     234    for (int i = 0; i < try->sources->n; i++) {
     235        // masked for: bad model fit, outlier in parameters
     236        if (try->mask->data.U8[i] & PSFTRY_MASK_ALL)
     237            continue;
     238
     239        pmSource *source = try->sources->data[i];
     240        float x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
     241        float y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
     242
     243        // set the mask and subtract the PSF model
     244        // XXX should we be using maskObj? should we be unsetting the mask?
     245        // use pmModelSub because modelFlux has not been generated
     246        assert (source->maskObj);
     247        psImageKeepCircle (source->maskObj, x, y, radius, "OR", markVal);
     248        pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
     249        psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_U8(markVal));
     250    }
     251
     252    FILE *f = fopen ("shapes.dat", "w");
     253    for (int i = 0; i < try->sources->n; i++) {
     254        psF32 inPar[10];  // must be psF32 to pmPSF_FitToModel
     255
     256        // masked for: bad model fit, outlier in parameters
     257        if (try->mask->data.U8[i] & PSFTRY_MASK_ALL) continue;
     258
     259        pmSource *source = try->sources->data[i];
     260        psF32 *outPar = source->modelEXT->params->data.F32;
     261
     262        psEllipseShape shape;
     263
     264        shape.sx  = outPar[PM_PAR_SXX] / M_SQRT2;
     265        shape.sy  = outPar[PM_PAR_SYY] / M_SQRT2;
     266        shape.sxy = outPar[PM_PAR_SXY];
     267
     268        psEllipsePol pol = pmPSF_ModelToFit (outPar);
     269        inPar[PM_PAR_E0] = pol.e0;
     270        inPar[PM_PAR_E1] = pol.e1;
     271        inPar[PM_PAR_E2] = pol.e2;
     272        pmPSF_FitToModel (inPar, 0.1);
     273
     274        psEllipseAxes axes1 = psEllipseShapeToAxes (shape, 20.0);
     275        psEllipseAxes axes2 = psEllipsePolToAxes(pol, 0.1);
     276
     277        psEllipsePol pol2 = psEllipseAxesToPol (axes1);
     278
     279        fprintf (f, "%3d  %7.2f %7.2f  %7.4f %7.4f %7.4f  --  %7.4f %7.4f %7.4f  :  %7.4f %7.4f %7.4f  --  %7.4f %7.4f %7.4f : %7.4f %7.4f %6.1f : %7.4f %7.4f %6.1f\n",
     280                 i, outPar[PM_PAR_XPOS], outPar[PM_PAR_YPOS],
     281                 outPar[PM_PAR_SXX], outPar[PM_PAR_SXY], outPar[PM_PAR_SYY],
     282                 pol.e0, pol.e1, pol.e2,
     283                 pol2.e0, pol2.e1, pol2.e2,
     284                 inPar[PM_PAR_SXX], inPar[PM_PAR_SXY], inPar[PM_PAR_SYY],
     285                 axes1.major, axes1.minor, axes1.theta*PM_DEG_RAD,
     286                 axes2.major, axes2.minor, axes2.theta*PM_DEG_RAD
     287            );
     288    }
     289    fclose (f);
     290
     291    psphotSaveImage (NULL, readout->image,  "psfstars.fits");
     292    pmSourcesWritePSFs (try->sources, "psfstars.dat");
     293    pmSourcesWriteEXTs (try->sources, "extstars.dat", false);
     294    // XXX need alternative output function
     295    // psMetadata *psfData = pmPSFtoMetadata (NULL, try->psf);
     296    // psMetadataConfigWrite (psfData, "psfmodel.dat");
     297    psLogMsg ("psphot.choosePSF", PS_LOG_INFO, "wrote out psf-subtracted image, psf data, exiting\n");
     298
     299    return true;
     300}
Note: See TracChangeset for help on using the changeset viewer.