IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 13, 2005, 10:03:27 AM (21 years ago)
Author:
eugene
Message:

working updates

File:
1 edited

Legend:

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

    r5772 r5773  
    367367}
    368368
    369 // dump the sources to an output file
     369// write the PSF sources to an output file
    370370bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf) {
    371371
     
    389389        pmSource *source = (pmSource *) sources->data[i];
    390390
    391         // write out sources fitted as PSFs
    392391        if (source->type != PM_SOURCE_STAR) continue;
    393         if (source->mode & PM_SOURCE_FAIL) continue;
    394         if (source->mode & PM_SOURCE_POOR) continue;
    395 
    396         model = pmSourceMagnitudes (source, psf, RADIUS);
     392        // if (source->mode & PM_SOURCE_FAIL) continue;
     393        // if (source->mode & PM_SOURCE_POOR) continue;
     394
     395        model = pmSourceMagnitudes (source, psf, RADIUS, true);
    397396        if (model == NULL) continue;
    398397
     
    400399        dPAR = model->dparams->data.F32;
    401400       
     401        // dP is positional error
    402402        dP = 0;
    403403        dP += PS_SQR(dPAR[2]);
     
    410410                 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP);
    411411
    412         for (j = 0; j < model->params->n - 4; j++) {
    413             fprintf (f, "%9.6f ", PAR[j+4]);
     412        for (j = 4; j < model->params->n; j++) {
     413            fprintf (f, "%9.6f ", PAR[j]);
    414414        }
    415415        fprintf (f, " : ");
    416         for (j = 0; j < model->params->n - 4; j++) {
    417             fprintf (f, "%9.6f ", dPAR[j+4]);
     416        for (j = 4; j < model->params->n; j++) {
     417            fprintf (f, "%9.6f ", dPAR[j]);
    418418        }
    419         fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n",
    420                  source[0].type,
     419        fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n",
     420                 source[0].type, source[0].mode,
    421421                 log10(model[0].chisq/model[0].nDOF),
    422422                 source[0].moments->SN,
     
    448448    for (i = 0; i < sources->n; i++) {
    449449        pmSource *source = (pmSource *) sources->data[i];
    450         model = (pmModel  *) source->modelFLT;
     450
     451        if (source->type != PM_SOURCE_GALAXY) continue;
     452        // if (source->mode & PM_SOURCE_FAIL) continue;
     453        // if (source->mode & PM_SOURCE_POOR) continue;
     454       
     455        model = pmSourceMagnitudes (source->modelFLT, NULL, model->radius);
    451456        if (model == NULL) continue;
    452         if (source->type != PM_SOURCE_GALAXY) continue;
    453         if (source->mode & PM_SOURCE_FAIL) continue;
    454         if (source->mode & PM_SOURCE_POOR) continue;
     457
     458        PAR  = model->params->data.F32;
     459        dPAR = model->dparams->data.F32;
    455460       
    456         params = model->params;
    457         dparams = model->dparams;
    458 
    459         // XXX these are hardwired for SGAUSS : this should be pushed into the
    460         // model functions as an abstract function
     461        // dP is shape error
     462        // XXX these are hardwired for SGAUSS
    461463        dP = 0;
    462         dP += PS_SQR(dparams[0].data.F32[4] / params[0].data.F32[4]);
    463         dP += PS_SQR(dparams[0].data.F32[5] / params[0].data.F32[5]);
    464         dP += PS_SQR(dparams[0].data.F32[7] / params[0].data.F32[7]);
     464        dP += PS_SQR(dPAR[4] / PAR[4]);
     465        dP += PS_SQR(dPAR[5] / PAR[5]);
     466        dP += PS_SQR(dPAR[7] / PAR[7]);
    465467        dP = sqrt (dP);
    466468
     469        dmag = dPAR[1] / PAR[1];
     470
    467471        fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f %7.4f  ",
    468                  params[0].data.F32[2],
    469                  params[0].data.F32[3],
    470                  params[0].data.F32[0],
    471                  -2.5*log10(params[0].data.F32[1]),
    472                  (dparams[0].data.F32[1]/params[0].data.F32[1]),
    473                  dP);
     472                 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP);
    474473
    475474        for (j = 4; j < model->params->n; j++) {
    476             fprintf (f, "%9.6f ", params[0].data.F32[j]);
     475            fprintf (f, "%9.6f ", PAR[j]);
    477476        }
    478477        fprintf (f, " : ");
    479478        for (j = 4; j < model->params->n; j++) {
    480             fprintf (f, "%9.6f ", dparams[0].data.F32[j]);
     479            fprintf (f, "%9.6f ", dPAR[j]);
    481480        }
    482         fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n",
    483                  source[0].type, log10(model[0].chisq/model[0].nDOF),
     481        fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n",
     482                 source[0].type, source[0].mode,
     483                 log10(model[0].chisq/model[0].nDOF),
    484484                 source[0].moments->SN,
    485485                 model[0].radius,
     
    497497    int i;
    498498    FILE *f;
     499    pmMoments *moment = NULL;
     500    pmSource *source = NULL;
    499501
    500502    f = fopen (filename, "w");
     
    508510    // write sources with models first
    509511    for (i = 0; i < sources->n; i++) {
    510         pmSource *source = (pmSource *) sources->data[i];
     512        source = sources->data[i];
    511513
    512514        // skip these sources (in PSF or FLT)
    513         if (source->type == PM_SOURCE_STAR) {
    514             if (source->mode & PM_SOURCE_FAIL) goto isNULL;
    515             if (source->mode & PM_SOURCE_POOR) goto isNULL;
    516             continue;
     515        if (source->type == PM_SOURCE_STAR) continue;
     516        if (source->type == PM_SOURCE_GALAXY) continue;
     517           
     518        if (source->moments == NULL) {
     519          moment = empty;
     520        } else {
     521          moment = source->moments;
    517522        }
    518         if (source->type == PM_SOURCE_GALAXY) {
    519             if (source->mode & PM_SOURCE_FAIL) goto isNULL;
    520             if (source->mode & PM_SOURCE_POOR) goto isNULL;
    521             continue;
    522         }
    523            
    524     isNULL:
    525        
    526         if (source->moments == NULL) {
    527           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",
    528                    source->peak->x, source->peak->y, source->peak->counts,
    529                    empty->x, empty->y,
    530                    empty->Sx, empty->Sy,
    531                    empty->Sum, empty->Peak,
    532                    empty->Sky, empty->SN,
    533                    empty->nPixels, source->type);
    534         } else {
    535           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",
    536                    source->peak->x, source->peak->y, source->peak->counts,
    537                    source->moments->x, source->moments->y,
    538                    source->moments->Sx, source->moments->Sy,
    539                    source->moments->Sum, source->moments->Peak,
    540                    source->moments->Sky, source->moments->SN,
    541                    source->moments->nPixels, source->type);
    542         }
     523
     524        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",
     525                 source->peak->x, source->peak->y, source->peak->counts,
     526                 source->moments->x, source->moments->y,
     527                 source->moments->Sx, source->moments->Sy,
     528                 source->moments->Sum, source->moments->Peak,
     529                 source->moments->Sky, source->moments->SN,
     530                 source->moments->nPixels, source->type);
    543531    }
    544532    fclose (f);
     
    552540    int i;
    553541    FILE *f;
    554     pmSource *source;
     542    pmSource *source = NULL;
    555543
    556544    f = fopen (filename, "w");
     
    561549
    562550    for (i = 0; i < sources->n; i++) {
    563         source = (pmSource *) sources->data[i];
     551        source = sources->data[i];
    564552        if (source->moments == NULL)
    565553            continue;
Note: See TracChangeset for help on using the changeset viewer.