IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29448


Ignore:
Timestamp:
Oct 17, 2010, 9:03:30 AM (16 years ago)
Author:
eugene
Message:

for faint sources, use moments for positions, not peak & use fwhm / (2.35*S/N) for position error; updates to fix addstar I/O

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourceIO_CMF_PS1_V3.c

    r29124 r29448  
    6666    psF32 xPos, yPos;
    6767    psF32 xErr, yErr;
    68     psF32 errMag, chisq, apRadius;
     68    psF32 chisq, apRadius;
    6969    psS32 nPix, nDOF;
    7070
     
    8484    }
    8585    float zeroptErr = psMetadataLookupF32 (&status2, imageHeader, "ZPT_ERR");
     86
     87    // we need a measure of the image quality (FWHM) for this image, in order to get the positional errors
     88    float fwhmMajor = psMetadataLookupF32(&status1, readout->analysis, "FWHM_MAJ");
     89    if (!status1) {
     90        fwhmMajor = psMetadataLookupF32(&status1, readout->analysis, "IQ_FW1");
     91    }
     92    float fwhmMinor = psMetadataLookupF32(&status1, readout->analysis, "FWHM_MIN");
     93    if (!status1) {
     94        fwhmMinor = psMetadataLookupF32(&status1, readout->analysis, "IQ_FW2");
     95    }
    8696
    8797    // if the sequence is defined, write these in seq order; otherwise
     
    124134                yErr = dPAR[PM_PAR_YPOS];
    125135            } else {
    126                 // in linear-fit mode, there is no error on the centroid
    127                 xErr = source->peak->dx;
    128                 yErr = source->peak->dy;
     136                xErr = fwhmMajor * source->errMag / 2.35;
     137                yErr = fwhmMinor * source->errMag / 2.35;
    129138            }
    130139            if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {
     
    139148            nPix = model->nPix;
    140149            apRadius = source->apRadius;
    141             errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
    142150        } else {
    143             xPos = source->peak->xf;
    144             yPos = source->peak->yf;
    145             xErr = source->peak->dx;
    146             yErr = source->peak->dy;
     151            bool useMoments = true;
     152            useMoments = (useMoments && source->moments);          // can't if there are no moments
     153            useMoments = (useMoments && source->moments->nPixels); // can't if the moments were not measured
     154            useMoments = (useMoments && !(source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE)); // can't if the moments failed...
     155
     156            if (source->moments) {
     157                xPos = source->moments->Mx;
     158                yPos = source->moments->My;
     159                xErr = fwhmMajor * source->errMag / 2.35;
     160                yErr = fwhmMinor * source->errMag / 2.35;
     161            } else {
     162                xPos = source->peak->xf;
     163                yPos = source->peak->yf;
     164                xErr = source->peak->dx;
     165                yErr = source->peak->dy;
     166            }
    147167            axes.major = NAN;
    148168            axes.minor = NAN;
     
    152172            nPix = 0;
    153173            apRadius = NAN;
    154             errMag = NAN;
    155174        }
    156175
     
    168187        psMetadataAdd (row, PS_LIST_TAIL, "X_PSF",            PS_DATA_F32, "PSF x coordinate",                           xPos);
    169188        psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF",            PS_DATA_F32, "PSF y coordinate",                           yPos);
    170         psMetadataAdd (row, PS_LIST_TAIL, "X_PSF_SIG",        PS_DATA_F32, "Sigma in PSF x coordinate",                  xErr); // XXX this is only measured for non-linear fits
    171         psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr); // XXX this is only measured for non-linear fits
     189        psMetadataAdd (row, PS_LIST_TAIL, "X_PSF_SIG",        PS_DATA_F32, "Sigma in PSF x coordinate",                  xErr);
     190        psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr);
    172191        psMetadataAdd (row, PS_LIST_TAIL, "POSANGLE",         PS_DATA_F32, "position angle at source (degrees)",         posAngle*PS_DEG_RAD);
    173192        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       pltScale*PS_DEG_RAD*3600.0);
    174193        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    175         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        errMag);
     194        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
    176195        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental flux (counts)",         source->psfFlux);
    177196        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
     
    179198        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW",       PS_DATA_F32, "magnitude in reported aperture",             source->apMagRaw);
    180199        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              apRadius);
    181         // XXX need ap_mag error
    182         psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           peakMag);
     200
    183201        psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG",      PS_DATA_F32, "PSF Magnitude using supplied calibration",   calMag);
    184202        psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG",  PS_DATA_F32, "measured scatter of zero point calibration", zeroptErr);
     203       
     204        // NOTE: RA & DEC (both double) need to be on an 8-byte boundary...
    185205        psMetadataAdd (row, PS_LIST_TAIL, "RA_PSF",           PS_DATA_F64, "PSF RA coordinate (degrees)",                ptSky.r*PS_DEG_RAD);
    186206        psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF",          PS_DATA_F64, "PSF DEC coordinate (degrees)",               ptSky.d*PS_DEG_RAD);
     207
     208        psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           peakMag);
    187209        psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",                                  source->sky);
    188210        psMetadataAdd (row, PS_LIST_TAIL, "SKY_SIGMA",        PS_DATA_F32, "Sigma of sky level",                         source->skyErr);
     
    237259        psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                     source->mode);
    238260        psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                     source->mode2);
     261        psMetadataAdd (row, PS_LIST_TAIL, "PADDING2",         PS_DATA_S32, "more padding", 0);
    239262
    240263        // XXX not sure how to get this : need to load Nimages with weight?
Note: See TracChangeset for help on using the changeset viewer.