IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 19, 2005, 12:26:40 PM (21 years ago)
Author:
eugene
Message:

fixing errors related to apResid and skyBias

File:
1 edited

Legend:

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

    r5058 r5068  
    3131 
    3232    if (!strcasecmp (outputMode, "SX")) {
    33         pmSourcesWriteSX (imdata, outputFile, sources, psf, sky);
     33        pmSourcesWriteSX (imdata, config, outputFile, sources, psf, sky);
    3434        return;
    3535    }
     
    159159}
    160160
    161 // elixir/sextractor-style output list with fixed line width
    162 bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
     161// elixir-mode / sextractor-style output list with fixed line width
     162bool pmSourcesWriteSX (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    163163
    164164    int i, status, flags;
     
    166166    psF32 *PAR, *dPAR;
    167167    float sky, dmag, apMag, fitMag;
    168 
    169     psLine *line = psLineAlloc (110);  // 104 is dophot-defined line length
     168    float x, y, rflux;
     169    bool result;
     170
     171    psLine *line = psLineAlloc (110);  // 110 is sextractor line length
    170172
    171173    FILE *f = fopen (filename, "w");
     
    174176        return false;
    175177    }
     178
     179    // aperture radius for ap magnitude
     180    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    176181
    177182    // write sources with models first
     
    214219        dPAR = model->dparams->data.F32;
    215220
     221        x = source->peak->x;
     222        y = source->peak->y;
     223
     224        // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source
     225        // we need to mask pixels to measure the aperture magnitude
     226        // set aperture mask circle of PSF_FIT_RADIUS
     227        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
     228
    216229        // save local sky for later
    217230        sky = model->params->data.F32[0];
     
    224237
    225238        // measure object photometry
    226         status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
     239        status  = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);
     240
     241        // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS
     242        rflux   = pow (10.0, 0.4*fitMag);
     243        apMag  -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));
    227244        fitMag += psf->ApResid;
    228245
     
    232249        pmSourceSubModel (source->pixels, source->mask, model, false);
    233250        model->params->data.F32[0] = sky;
     251
     252        // unmask aperture
     253        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    234254
    235255        if (status == FALSE) continue;
Note: See TracChangeset for help on using the changeset viewer.