IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 17, 2005, 10:26:59 AM (21 years ago)
Author:
eugene
Message:

clean up of small accounting bugs, adding the post-subtraction ApResid

File:
1 edited

Legend:

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

    r5773 r5802  
    370370bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf) {
    371371
    372     double dP, dmag;
     372    double dPos, dMag;
    373373    int i, j;
    374374    FILE *f;
     
    393393        // if (source->mode & PM_SOURCE_POOR) continue;
    394394
    395         model = pmSourceMagnitudes (source, psf, RADIUS, true);
     395        model = pmSourceMagnitudes (source, psf, RADIUS);
    396396        if (model == NULL) continue;
    397397
     
    399399        dPAR = model->dparams->data.F32;
    400400       
    401         // dP is positional error
    402         dP = 0;
    403         dP += PS_SQR(dPAR[2]);
    404         dP += PS_SQR(dPAR[3]);
    405         dP = sqrt (dP);
    406        
    407         dmag = dPAR[1] / PAR[1];
    408 
    409         fprintf (f, "%7.1f %7.1f  %5.1f %7.4f  %7.4f %7.4f  ",
    410                  PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP);
     401        // dPos is positional error, dMag is mag error
     402        dPos = hypot (dPAR[2], dPAR[3]);
     403        dMag = dPAR[1] / PAR[1];
     404
     405        fprintf (f, "%7.1f %7.1f  %5.1f %8.4f  %7.4f %7.4f  ",
     406                 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos);
    411407
    412408        for (j = 4; j < model->params->n; j++) {
     
    417413            fprintf (f, "%9.6f ", dPAR[j]);
    418414        }
    419         fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n",
     415        fprintf (f, ": %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n",
    420416                 source[0].type, source[0].mode,
    421417                 log10(model[0].chisq/model[0].nDOF),
     
    432428bool pmModelWriteFLTs (psArray *sources, char *filename) {
    433429
    434     double dP;
     430    double dPos, dMag;
    435431    int i, j;
    436432    FILE *f;
    437     psVector *params;
    438     psVector *dparams;
     433    psF32 *PAR, *dPAR;
    439434    pmModel  *model;
    440435
     
    450445
    451446        if (source->type != PM_SOURCE_GALAXY) continue;
    452         // if (source->mode & PM_SOURCE_FAIL) continue;
    453         // if (source->mode & PM_SOURCE_POOR) continue;
    454447       
    455         model = pmSourceMagnitudes (source->modelFLT, NULL, model->radius);
    456         if (model == NULL) continue;
     448        if (source->modelFLT == NULL) continue;
     449        model = pmSourceMagnitudes (source, NULL, source->modelFLT->radius);
    457450
    458451        PAR  = model->params->data.F32;
    459452        dPAR = model->dparams->data.F32;
    460453       
    461         // dP is shape error
     454        // dPos is shape error
    462455        // XXX these are hardwired for SGAUSS
    463         dP = 0;
    464         dP += PS_SQR(dPAR[4] / PAR[4]);
    465         dP += PS_SQR(dPAR[5] / PAR[5]);
    466         dP += PS_SQR(dPAR[7] / PAR[7]);
    467         dP = sqrt (dP);
    468 
    469         dmag = dPAR[1] / PAR[1];
    470 
    471         fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f %7.4f  ",
    472                  PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP);
     456        dPos = 0;
     457        dPos += PS_SQR(dPAR[4] / PAR[4]);
     458        dPos += PS_SQR(dPAR[5] / PAR[5]);
     459        // dPos += PS_SQR(dPAR[7] / PAR[7]);
     460        dPos = sqrt (dPos);
     461        dMag = dPAR[1] / PAR[1];
     462
     463        fprintf (f, "%7.1f %7.1f  %7.1f %7.3f  %7.4f %7.4f  ",
     464                 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos);
    473465
    474466        for (j = 4; j < model->params->n; j++) {
     
    479471            fprintf (f, "%9.6f ", dPAR[j]);
    480472        }
    481         fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n",
     473        fprintf (f, ": %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n",
    482474                 source[0].type, source[0].mode,
    483475                 log10(model[0].chisq/model[0].nDOF),
     
    548540    }
    549541
     542    fprintf (stderr, "writing out moments\n");
    550543    for (i = 0; i < sources->n; i++) {
    551544        source = sources->data[i];
    552545        if (source->moments == NULL)
    553546            continue;
    554         fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n",
     547        fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %10.1f %7.1f %7.1f %7.1f  %4d %2d %#5x\n",
    555548                 source->peak->x, source->peak->y, source->peak->counts,
    556549                 source->moments->x, source->moments->y,
     
    558551                 source->moments->Sum, source->moments->Peak,
    559552                 source->moments->Sky, source->moments->SN,
    560                  source->moments->nPixels, source->type);
     553                 source->moments->nPixels, source->type, source->mode);
    561554    }
    562555    fclose (f);
     
    599592
    600593    psRegion region = {x - dx, x + dx, y - dy, y + dy};
    601     psImage *sample = psImageSubset (image, region);
     594    psImage *view = psImageSubset (image, region);
     595    psImage *sample = psImageCopy (NULL, view, PS_TYPE_F32);
    602596    psImageInit (sample, 0);
    603597    modelFLT->params->data.F32[2] = x;
     
    635629    return (TRUE);
    636630}
     631
     632bool psphotDumpMoments (psMetadata *config, psArray *sources) {
     633
     634    bool status;
     635
     636    // optional dump of all rough source data
     637    char *output = psMetadataLookupPtr (&status, config, "MOMENTS_OUTPUT_FILE");
     638    if (!status) return false;
     639    if (output == NULL) return false;
     640    if (output[0] == 0) return false;
     641
     642    pmMomentsWriteText (sources, output);
     643    psFree (output);
     644    return true;
     645}
Note: See TracChangeset for help on using the changeset viewer.