IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5773


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

working updates

Location:
trunk/psphot/src
Files:
4 edited

Legend:

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

    r5772 r5773  
    7575      case 0:
    7676        psphotEnsemblePSF (imdata, config, sources, psf, sky);
    77         sources = psArraySort (sources, psphotSortBySN);
    7877        psphotFullFit (imdata, config, sources, psf, sky);
    7978//      psphotReplaceUnfit (sources);
     
    9998
    10099    // write out data in appropriate format
     100    // measure aperture correction
     101    // psphotApertureCorrection (sources, config, sky);
    101102    psphotOutput (imdata, config, sources, psf, sky);
    102103    exit (0);
  • trunk/psphot/src/psphotFullFit.c

    r5772 r5773  
    7979            continue;
    8080        }
     81
     82        // add the double-PSF fit mode
     83        // how do we compare the results?  chisq?
    8184       
    8285        // recalculate the source moments using the larger galaxy moments radius
     
    113116        }
    114117
    115         // subtract object, leave local sky
     118        // subtract PSF for object, leave local sky
     119        // XXX : we should keep the non-linear PSF fit if object was marked extended but
     120        //       PSF fit is OK otherwise.
    116121        psFree (source->modelPSF);
    117122        source->modelPSF = save;
  • trunk/psphot/src/psphotMagnitudes.c

    r5772 r5773  
    11# include "psphot.h"
    22
    3 // XXX EAM : this aperture correction business is invalid (& wrong) for galaxies
     3// XXX EAM : the apMag should only be calculated for the brighter sources
     4// XXX EAM : SN limit set by user?
     5// XXX EAM : masked region should be (optionally) elliptical
    46pmModel *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius) {
    57
    68    int status;
    79    float x, y;
    8     float sky, rflux, apMag, fitMag;
     10    float rflux, apMag, fitMag;
     11    pmModel *model;
    912
    1013    // use the correct model (PSF vs FLT)
    11     pmModel *model = pmSourceSelectModel (source);
     14    if (psf != NULL) {
     15      model = source->modelPSF;
     16    } else {
     17      model = source->modelFLT;
     18    }
    1219    if (model == NULL) return NULL;
    1320
     
    2027    psImageKeepCircle (source->mask, x, y, apRadius, "OR", PSPHOT_MASK_MARKED);
    2128
    22     // save local sky for later
    23     sky = model->params->data.F32[0];
    24 
    2529    // replace source flux
    2630    pmSourceAddModel (source->pixels, source->mask, model, false, false);
    2731
    2832    // measure object photometry
    29     status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
     33    status = pmSourcePhotometry (&source->fitMag, &source->apMag, model, source->pixels, source->mask);
    3034
    31     // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
    32     rflux   = pow (10.0, 0.4*fitMag);
    33     source->apMag  = apMag  - rflux * psf->skyBias * (M_PI * PS_SQR(apRadius));
    34     source->fitMag = fitMag + psf->ApResid;
     35    // for PSFs, correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
     36    if (psf != NULL) {
     37      rflux   = pow (10.0, 0.4*source->fitMag);
     38      source->apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(apRadius));
     39      source->fitMag += psf->ApResid;
     40    }
    3541
    3642    // subtract object, leave local sky
  • 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.