IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5085


Ignore:
Timestamp:
Sep 20, 2005, 8:52:23 PM (21 years ago)
Author:
eugene
Message:

added pmSourceMagnitudes, added elixir/imclean header keywords

Location:
trunk/psphot
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/Makefile

    r5084 r5085  
    3232$(SRC)/psphotSubtractPSF.$(ARCH).o \
    3333$(SRC)/psphotSortBySN.$(ARCH).o    \
    34 $(SRC)/psphotDefinePixels.$(ARCH).o    \
     34$(SRC)/psphotDefinePixels.$(ARCH).o \
     35$(SRC)/psphotMagnitudes.$(ARCH).o  \
    3536$(SRC)/psLibUtils.$(ARCH).o        \
    3637$(SRC)/psLine.$(ARCH).o            \
  • trunk/psphot/src/pmObjects_EAM.h

    r5049 r5085  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-14 02:06:55 $
     7 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-09-21 06:52:23 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    162162    pmModel *modelFLT;                  ///< FLT Model fit (parameters and type).
    163163    pmSourceType type;                  ///< Best identification of object.
     164    float apMag;
     165    float fitMag;
    164166}
    165167pmSource;
  • trunk/psphot/src/psphot.c

    r5058 r5085  
    4646    psphotFitGalaxies (imdata, config, sources, sky);
    4747
     48    psphotMagnitudes (sources);
     49
    4850    // write out data in appropriate format
    4951    psphotOutput (imdata, config, sources, psf, sky);
  • trunk/psphot/src/psphot.h

    r5084 r5085  
    2121eamReadout  *psphotSetup (psMetadata *config);
    2222psStats     *psphotImageStats (eamReadout *imdata, psMetadata *config);
    23 psArray     *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky);
    2423psArray     *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *allpeaks);
    2524pmPSF       *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky);
     
    3332int          psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    3433bool         psphotDefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);
     34
     35psArray     *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky);
     36pmModel     *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius);
     37pmModel     *pmSourceSelectMode (pmSource *source);
    3538
    3639// eamReadout functions
  • trunk/psphot/src/psphotArguments.c

    r5084 r5085  
    5252  psMetadataAdd (config, PS_LIST_HEAD, "PSF_MODEL", PS_META_MULTI, "folder for psf model entries", NULL);
    5353  config = psMetadataConfigParse (config, &Nfail, argv[3], FALSE);
    54   fprintf (stderr, "loaded config...\n");
    5554
    5655  // identify input image & optional weight & mask images
  • trunk/psphot/src/psphotOutput.c

    r5084 r5085  
    7070bool pmSourcesWriteOBJ (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    7171
    72     int i, type, status;
     72    int type;
    7373    pmModel *model;
    7474    psF32 *PAR, *dPAR;
    75     float sky, dmag, apMag, fitMag;
    76     float x, y, rflux;
    77     bool result;
     75    float dmag, apResid;
     76    bool status;
    7877
    7978    psLine *line = psLineAlloc (104);  // 104 is dophot-defined line length
     
    8584    }
    8685
    87     float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    88 
    89     // write sources with models first
    90     for (i = 0; i < sources->n; i++) {
     86    float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS");
     87
     88    // write sources with models
     89    for (int i = 0; i < sources->n; i++) {
    9190        pmSource *source = (pmSource *) sources->data[i];
    9291
    93         // use the correct model
    94         switch (source->type) {
    95 
    96             // use PSF model with stars
    97           case PM_SOURCE_PSFSTAR:
    98           case PM_SOURCE_SATSTAR:
    99           case PM_SOURCE_GOODSTAR:
    100             model = source->modelPSF;
    101             break;
    102 
    103             // use FLT model with galaxies
    104           case PM_SOURCE_GALAXY:
    105             model = source->modelFLT;
    106             break;
    107            
    108             // skip defects and poorly fitted stars or galaxies
    109           case PM_SOURCE_DEFECT:
    110           case PM_SOURCE_SATURATED:
    111           case PM_SOURCE_FAINTSTAR:
    112           case PM_SOURCE_POOR_FIT_PSF:
    113           case PM_SOURCE_POOR_FIT_GAL:
    114           case PM_SOURCE_FAIL_FIT_GAL:
    115           default:
    116             model = NULL;
    117         }
     92        model = pmSourceMagnitudes (source, psf, RADIUS);
    11893        if (model == NULL) continue;
    11994
     
    12196        dPAR = model->dparams->data.F32;
    12297
    123         x = source->peak->x;
    124         y = source->peak->y;
    125 
    126         // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source
    127         // we need to mask pixels to measure the aperture magnitude
    128         // set aperture mask circle of PSF_FIT_RADIUS
    129         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    130 
    131         // save local sky for later
    132         sky = model->params->data.F32[0];
    133 
    134         // replace source flux
    135         // XXX EAM : need to add 'sky' boolean option here
    136         model->params->data.F32[0] = 0;
    137         pmSourceAddModel (source->pixels, source->mask, model, false);
    138         model->params->data.F32[0] = sky;
    139 
    140         // measure object photometry
    141         status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
    142 
    143         // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
    144         rflux   = pow (10.0, 0.4*fitMag);
    145         apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));
    146         fitMag += psf->ApResid;
    147 
    148         // subtract object, leave local sky
    149         // XXX EAM : need to add 'sky' boolean option here
    150         model->params->data.F32[0] = 0;
    151         pmSourceSubModel (source->pixels, source->mask, model, false);
    152         model->params->data.F32[0] = sky;
    153 
    154         // unmask aperture
    155         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    156 
    157         if (status == FALSE) continue;
    158 
    15998        dmag = dPAR[1] / PAR[1];
    16099        type = pmSourceDophotType (source);
     100        apResid = source->apMag - source->fitMag;
     101
    161102        psLineInit (line);
    162         psLineAdd (line, "%3d", source->type);
     103        psLineAdd (line, "%3d",   type);
    163104        psLineAdd (line, "%8.2f", PAR[2]);
    164105        psLineAdd (line, "%8.2f", PAR[3]);
    165         psLineAdd (line, "%8.3f", fitMag);
     106        psLineAdd (line, "%8.3f", source->fitMag);
    166107        psLineAdd (line, "%6.3f", dmag);
    167108        psLineAdd (line, "%9.2f", PAR[0]);
     
    170111        psLineAdd (line, "%7.2f", PAR[6]);
    171112        psLineAdd (line, "%8.3f", 32.0);
    172         psLineAdd (line, "%8.3f", apMag);
    173         psLineAdd (line, "%8.2f\n", apMag - fitMag);
     113        psLineAdd (line, "%8.3f", source->apMag);
     114        psLineAdd (line, "%8.2f\n", apResid);
    174115        fwrite (line->line, 1, line->Nline, f);
    175116    }
     
    181122bool pmSourcesWriteSX (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    182123
    183     int i, status, flags;
    184124    pmModel *model;
    185125    psF32 *PAR, *dPAR;
    186     float sky, dmag, apMag, fitMag;
    187     float x, y, rflux;
    188     bool result;
     126    float dmag;
     127    bool status;
    189128
    190129    psLine *line = psLineAlloc (110);  // 110 is sextractor line length
     
    192131    FILE *f = fopen (filename, "w");
    193132    if (f == NULL) {
    194         psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename);
    195         return false;
    196     }
    197 
    198     // aperture radius for ap magnitude
    199     // XXX EAM I probably need to measure the fit and ap magnitudes at one location elsewhere
    200     //         this would have to happen *after* all objects are detected and subtracted
     133        psLogMsg ("WriteSourceSX", 3, "can't open output file for output %s\n", filename);
     134        return false;
     135    }
     136
    201137    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    202138
    203     // write sources with models first
    204     for (i = 0; i < sources->n; i++) {
     139    // write sources with models
     140    for (int i = 0; i < sources->n; i++) {
    205141        pmSource *source = (pmSource *) sources->data[i];
    206         flags = 0;
    207 
    208         // use the correct model
    209         switch (source->type) {
    210 
    211             // use PSF model with stars
    212           case PM_SOURCE_SATSTAR:
    213             flags = 4;
    214             model = source->modelPSF;
    215             break;
    216 
    217           case PM_SOURCE_PSFSTAR:
    218           case PM_SOURCE_GOODSTAR:
    219             model = source->modelPSF;
    220             break;
    221 
    222             // use FLT model with galaxies
    223           case PM_SOURCE_GALAXY:
    224             model = source->modelFLT;
    225             break;
    226            
    227             // skip defects and poorly fitted stars or galaxies
    228           case PM_SOURCE_DEFECT:
    229           case PM_SOURCE_SATURATED:
    230           case PM_SOURCE_FAINTSTAR:
    231           case PM_SOURCE_POOR_FIT_PSF:
    232           case PM_SOURCE_POOR_FIT_GAL:
    233           case PM_SOURCE_FAIL_FIT_GAL:
    234           default:
    235             model = NULL;
    236         }
     142
     143        model = pmSourceMagnitudes (source, psf, RADIUS);
    237144        if (model == NULL) continue;
    238145
     
    240147        dPAR = model->dparams->data.F32;
    241148
    242         x = source->peak->x;
    243         y = source->peak->y;
    244 
    245         // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source
    246         // we need to mask pixels to measure the aperture magnitude
    247         // set aperture mask circle of PSF_FIT_RADIUS
    248         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    249 
    250         // save local sky for later
    251         sky = model->params->data.F32[0];
    252 
    253         // replace source flux
    254         // XXX EAM : need to add 'sky' boolean option here
    255         model->params->data.F32[0] = 0;
    256         pmSourceAddModel (source->pixels, source->mask, model, false);
    257         model->params->data.F32[0] = sky;
    258 
    259         // measure object photometry
    260         status  = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
    261 
    262         // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
    263         rflux   = pow (10.0, 0.4*fitMag);
    264         apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));
    265         fitMag += psf->ApResid;
    266 
    267         // subtract object, leave local sky
    268         // XXX EAM : need to add 'sky' boolean option here
    269         model->params->data.F32[0] = 0;
    270         pmSourceSubModel (source->pixels, source->mask, model, false);
    271         model->params->data.F32[0] = sky;
    272 
    273         // unmask aperture
    274         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    275 
    276         if (status == FALSE) continue;
    277 
    278         // XXX EAM : fix this to return sextractor type and flags
    279         // type = pmSourceSextractType (source);
     149        // pmSourceSextractType (source, &type, &flags); XXX EAM : implement me...
    280150
    281151        dmag = dPAR[1] / PAR[1];
     152
    282153        psLineInit (line);
    283154        psLineAdd (line, "%5.2f", 0.0); // should be type
    284155        psLineAdd (line, "%11.3f", PAR[2]);
    285156        psLineAdd (line, "%11.3f", PAR[3]);
    286         psLineAdd (line, "%9.4f", fitMag);
     157        psLineAdd (line, "%9.4f", source->fitMag);
    287158        psLineAdd (line, "%9.4f", dmag);
    288159        psLineAdd (line, "%13.4f", PAR[0]);
     
    291162        psLineAdd (line, "%6.1f", 0.0); // should be Theta
    292163        psLineAdd (line, "%9.4f", 32.0); // should be MAG_ISO
    293         psLineAdd (line, "%9.4f", apMag);
     164        psLineAdd (line, "%9.4f", source->apMag);
    294165        psLineAdd (line, "%4d\n", 0); // should be flags
    295166        fwrite (line->line, 1, line->Nline, f);
     
    310181    bool result;
    311182
     183    // find config information for output header
     184    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
     185    float ZERO_POINT = psMetadataLookupF32 (&result, config, "ZERO_POINT");
     186    char *PHOTCODE = psMetadataLookupF32 (&result, config, "PHOTCODE");
     187
     188    // write necessary information to output header
     189    psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS",   PS_META_S32 | PS_META_REPLACE, "NUMBER OF STARS",     sources->n);
     190    psMetadataAdd (imdata->header, PS_LIST_TAIL, "ZERO_PT",  PS_META_F32 | PS_META_REPLACE, "zero point",          ZERO_POINT);
     191    psMetadataAdd (imdata->header, PS_LIST_TAIL, "APMIFIT",  PS_META_F32 | PS_META_REPLACE, "aperture residual",   psf->ApResid);
     192    psMetadataAdd (imdata->header, PS_LIST_TAIL, "dAPMIFIT", PS_META_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
     193    psMetadataAdd (imdata->header, PS_LIST_TAIL, "SKYBIAS",  PS_META_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skyBias);
     194    psMetadataAdd (imdata->header, PS_LIST_TAIL, "PHOTCODE", PS_META_STR | PS_META_REPLACE, "photometry code",     PHOTCODE);
     195    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_X",   PS_META_F32 | PS_META_REPLACE, "PSF FWHM X",          0.0);
     196    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_Y",   PS_META_F32 | PS_META_REPLACE, "PSF FWHM Y",          0.0);
     197    psMetadataAdd (imdata->header, PS_LIST_TAIL, "ANGLE",    PS_META_F32 | PS_META_REPLACE, "PSF ANGLE",           0.0);
     198    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FSATUR",   PS_META_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
     199    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FLIMIT",   PS_META_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
     200
    312201    // create file, write-out header
    313202    unlink (filename);
     
    333222    psLine *line = psLineAlloc (67);  // 66 is imclean-defined line length
    334223
    335     float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    336 
    337     // XXX EAM : need to add these concepts to the header (from psf and config)
    338     // fits_modify (header, "ZERO_PT", "%lf", 1, ZERO_POINT);
    339     // fits_modify (header, "FWHM_X", "%lf", 1, FWHMx);
    340     // fits_modify (header, "FWHM_Y", "%lf", 1, FWHMy);
    341     // fits_modify (header, "ANGLE", "%lf", 1, angle);
    342     // fits_modify (header, "FSATUR", "%lf", 1, saturate);  // can use 0.0
    343     // fits_modify (header, "FLIMIT", "%lf", 1, complete);  // can use 0.0
    344     // fits_modify (header, "NSTARS", "%d", 1, N);
    345 
    346224    // write sources with models first
    347225    for (i = 0; i < sources->n; i++) {
    348226        pmSource *source = (pmSource *) sources->data[i];
    349227
    350         // use the correct model
    351         switch (source->type) {
    352 
    353             // use PSF model with stars
    354           case PM_SOURCE_PSFSTAR:
    355           case PM_SOURCE_SATSTAR:
    356           case PM_SOURCE_GOODSTAR:
    357             model = source->modelPSF;
    358             break;
    359 
    360             // use FLT model with galaxies
    361           case PM_SOURCE_GALAXY:
    362             model = source->modelFLT;
    363             break;
    364            
    365             // skip defects and poorly fitted stars or galaxies
    366           case PM_SOURCE_DEFECT:
    367           case PM_SOURCE_SATURATED:
    368           case PM_SOURCE_FAINTSTAR:
    369           case PM_SOURCE_POOR_FIT_PSF:
    370           case PM_SOURCE_POOR_FIT_GAL:
    371           case PM_SOURCE_FAIL_FIT_GAL:
    372           default:
    373             model = NULL;
    374         }
     228        model = pmSourceMagnitudes (source, psf, RADIUS);
    375229        if (model == NULL) continue;
    376230
     
    378232        dPAR = model->dparams->data.F32;
    379233
    380         x = source->peak->x;
    381         y = source->peak->y;
    382 
    383         // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source
    384         // we need to mask pixels to measure the aperture magnitude
    385         // set aperture mask circle of PSF_FIT_RADIUS
    386         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    387 
    388         // save local sky for later
    389         sky = model->params->data.F32[0];
    390 
    391         // replace source flux
    392         // XXX EAM : need to add 'sky' boolean option here
    393         model->params->data.F32[0] = 0;
    394         pmSourceAddModel (source->pixels, source->mask, model, false);
    395         model->params->data.F32[0] = sky;
    396 
    397         // measure object photometry
    398         status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
    399 
    400         // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
    401         rflux   = pow (10.0, 0.4*fitMag);
    402         apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));
    403         fitMag += psf->ApResid;
    404 
    405         // subtract object, leave local sky
    406         // XXX EAM : need to add 'sky' boolean option here
    407         model->params->data.F32[0] = 0;
    408         pmSourceSubModel (source->pixels, source->mask, model, false);
    409         model->params->data.F32[0] = sky;
    410 
    411         // unmask aperture
    412         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    413 
    414         if (status == FALSE) continue;
    415 
    416234        dmag = dPAR[1] / PAR[1];
    417235        type = pmSourceDophotType (source);
     236        apResid = source->apMag - source->fitMag;
    418237        lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]);
    419238
     
    421240        psLineAdd (line, "%6.1f ", PAR[2]);
    422241        psLineAdd (line, "%6.1f ", PAR[3]);
    423         psLineAdd (line, "%6.3f ", fitMag + 25.0);
     242        psLineAdd (line, "%6.3f ", source->fitMag + ZERO_POINT);
    424243        psLineAdd (line, "%03d ", (int)(1000*dmag));
    425244        psLineAdd (line, "%2d ",   type);
    426245        psLineAdd (line, "%3.1f ", lsky);
    427246        psLineAdd (line, "%6.3f ", 32.0);    // should be 'Mgal
    428         psLineAdd (line, "%6.3f ", apMag + 25.0); // 25.0 should come from config
     247        psLineAdd (line, "%6.3f ", apMag + ZERO_POINT);
    429248        psLineAdd (line, "%6.2f ", PAR[4]);  // should be 'FHWM x'
    430249        psLineAdd (line, "%6.2f ", PAR[5]);  // should be 'FHWM y'
     
    452271    bool result;
    453272
     273    // find config information for output header
     274    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
     275    float ZERO_POINT = psMetadataLookupF32 (&result, config, "ZERO_POINT");
     276    char *PHOTCODE = psMetadataLookupF32 (&result, config, "PHOTCODE");
     277
     278    // write necessary information to output header
     279    psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS",   PS_META_S32 | PS_META_REPLACE, "NUMBER OF STARS",     sources->n);
     280    psMetadataAdd (imdata->header, PS_LIST_TAIL, "ZERO_PT",  PS_META_F32 | PS_META_REPLACE, "zero point",          ZERO_POINT);
     281    psMetadataAdd (imdata->header, PS_LIST_TAIL, "APMIFIT",  PS_META_F32 | PS_META_REPLACE, "aperture residual",   psf->ApResid);
     282    psMetadataAdd (imdata->header, PS_LIST_TAIL, "dAPMIFIT", PS_META_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
     283    psMetadataAdd (imdata->header, PS_LIST_TAIL, "SKYBIAS",  PS_META_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skyBias);
     284    psMetadataAdd (imdata->header, PS_LIST_TAIL, "PHOTCODE", PS_META_STR | PS_META_REPLACE, "photometry code",     PHOTCODE);
     285    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_X",   PS_META_F32 | PS_META_REPLACE, "PSF FWHM X",          0.0);
     286    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_Y",   PS_META_F32 | PS_META_REPLACE, "PSF FWHM Y",          0.0);
     287    psMetadataAdd (imdata->header, PS_LIST_TAIL, "ANGLE",    PS_META_F32 | PS_META_REPLACE, "PSF ANGLE",           0.0);
     288    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FSATUR",   PS_META_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
     289    psMetadataAdd (imdata->header, PS_LIST_TAIL, "FLIMIT",   PS_META_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
     290
    454291    // set NAXIS to 0
    455292    fprintf (stderr, "setting naxis\n");
     
    458295    mdi->type = PS_META_S32;
    459296
    460     // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0);
    461 
    462297    table = psArrayAlloc (sources->n);
    463298    sources->n = 0;
    464299
    465     float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    466 
    467300    for (i = 0; i < sources->n; i++) {
    468301        pmSource *source = (pmSource *) sources->data[i];
    469302
    470         // use the correct model
    471         switch (source->type) {
    472 
    473             // use PSF model with stars
    474           case PM_SOURCE_PSFSTAR:
    475           case PM_SOURCE_SATSTAR:
    476           case PM_SOURCE_GOODSTAR:
    477             model = source->modelPSF;
    478             break;
    479 
    480             // use FLT model with galaxies
    481           case PM_SOURCE_GALAXY:
    482             model = source->modelFLT;
    483             break;
    484            
    485             // skip defects and poorly fitted stars or galaxies
    486           case PM_SOURCE_DEFECT:
    487           case PM_SOURCE_SATURATED:
    488           case PM_SOURCE_FAINTSTAR:
    489           case PM_SOURCE_POOR_FIT_PSF:
    490           case PM_SOURCE_POOR_FIT_GAL:
    491           case PM_SOURCE_FAIL_FIT_GAL:
    492           default:
    493             model = NULL;
    494         }
     303        model = pmSourceMagnitudes (source, psf, RADIUS);
    495304        if (model == NULL) continue;
    496305
    497306        PAR = model->params->data.F32;
    498307        dPAR = model->dparams->data.F32;
    499 
    500         x = source->peak->x;
    501         y = source->peak->y;
    502 
    503         // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source
    504         // we need to mask pixels to measure the aperture magnitude
    505         // set aperture mask circle of PSF_FIT_RADIUS
    506         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    507 
    508         // save local sky for later
    509         sky = model->params->data.F32[0];
    510 
    511         // replace source flux
    512         // XXX EAM : need to add 'sky' boolean option here
    513         model->params->data.F32[0] = 0;
    514         pmSourceAddModel (source->pixels, source->mask, model, false);
    515         model->params->data.F32[0] = sky;
    516 
    517         // measure object photometry
    518         status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
    519 
    520         // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
    521         rflux   = pow (10.0, 0.4*fitMag);
    522         apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));
    523         fitMag += psf->ApResid;
    524 
    525         // subtract object, leave local sky
    526         // XXX EAM : need to add 'sky' boolean option here
    527         model->params->data.F32[0] = 0;
    528         pmSourceSubModel (source->pixels, source->mask, model, false);
    529         model->params->data.F32[0] = sky;
    530 
    531         // unmask aperture
    532         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    533 
    534         if (status == FALSE) continue;
    535308
    536309        dmag = dPAR[1] / PAR[1];
     
    541314        psMetadataAdd (row, PS_LIST_HEAD, "X_PIX",   PS_META_F32, "", PAR[2]);
    542315        psMetadataAdd (row, PS_LIST_HEAD, "Y_PIX",   PS_META_F32, "", PAR[3]);
    543         psMetadataAdd (row, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", fitMag + 25.0);
     316        psMetadataAdd (row, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", source->fitMag + ZERO_POINT);
    544317        psMetadataAdd (row, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag));
    545318        psMetadataAdd (row, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type);
    546319        psMetadataAdd (row, PS_LIST_HEAD, "MAG_AP",  PS_META_F32, "", lsky);
    547320        psMetadataAdd (row, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0);    // should be 'Mgal'
    548         psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X",  PS_META_F32, "", apMag + 25.0); // 25.0 should come from config
     321        psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X",  PS_META_F32, "", apMag + ZERO_POINT);
    549322        psMetadataAdd (row, PS_LIST_HEAD, "FWHM_Y",  PS_META_F32, "", PAR[4]);  // should be 'FHWM x'
    550323        psMetadataAdd (row, PS_LIST_HEAD, "THETA",   PS_META_F32, "", PAR[5]);  // should be 'FHWM y'
Note: See TracChangeset for help on using the changeset viewer.