IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 17, 2010, 9:57:34 AM (16 years ago)
Author:
eugene
Message:

various modifications to psphotStack: add needed metadata to header; enable multiple PSF-matched images; work to speed up radial aperture photometry; radialAper is now an array (one element per PSF size); better feedback on extended fit skips; clarify processing: main analysis is on the input images (raw or convolved) while radial apertures is on the psf-matched images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psphot/src/psphotRadialAperturesByObject.c

    r29936 r30101  
    33// aperture-like measurements for extended sources
    44// flux in simple, circular apertures
    5 bool psphotRadialAperturesByObject (pmConfig *config, psArray *objects, const pmFPAview *view, const char *filerule) {
     5
     6// **** it looks like this function will re-point the source pixels at the specified FILERULE
     7// **** I need to distinguish PSF-matched images from raw
     8// **** save (somewhere) the PSF-matched PSF values
     9
     10// this function measures the radial aperture fluxes for the set of readouts.  this function
     11// may be called multiple times (presumably with different matched PSF sizes).  we must have
     12// already added an entry to the readout->analysis identifying the FWHM of this version.
     13
     14bool psphotRadialAperturesByObject (pmConfig *config, psArray *objects, const pmFPAview *view, const char *filerule, int nMatchedPSF) {
    615
    716    bool status;
     
    2837    psAssert (radMax, "annular bins (RADIAL.ANNULAR.BINS.UPPER) are not defined in the recipe");
    2938    psAssert (radMax->n, "no valid annular bins (RADIAL.ANNULAR.BINS.UPPER) are define");
     39    float outerRadius = radMax->data.F32[radMax->n - 1];
    3040
    3141    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     
    3949    float SN_LIM = psMetadataLookupF32 (&status, recipe, "RADIAL_APERTURES_SN_LIM");
    4050
     51    // how many target PSFs do we want?
     52    int nPSFsizes = 0;
     53    {
     54        psMetadataLookupF32 (&status, recipe, "PSPHOT.STACK.TARGET.PSF.FWHM");
     55        if (status) {
     56            nPSFsizes = 1;
     57        } else {
     58            psVector *fwhmValues = psMetadataLookupVector(&status, recipe, "PSPHOT.STACK.TARGET.PSF.FWHM"); // Magnitude offsets
     59            psAssert (status, "missing psphot recipe value PSPHOT.STACK.TARGET.PSF.FWHM");
     60            nPSFsizes = fwhmValues->n;
     61        }
     62    }
     63   
    4164    // source analysis is done in S/N order (brightest first)
    4265    objects = psArraySort (objects, pmPhotObjSortBySN);
     
    5376        psAssert (readout, "missing readout?");
    5477
     78        psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES");
     79        if (!fwhmValues) {
     80            psError (PSPHOT_ERR_CONFIG, true, "convolved or measured FWHM is not defined for this readout");
     81            return false;
     82        }
     83        if (fwhmValues->n != nMatchedPSF + 1) {
     84            psError (PSPHOT_ERR_CONFIG, true, "convolved or measured FWHM sequence is inconsistent this readout");
     85            return false;
     86        }
     87        psLogMsg ("psphot", PS_LOG_DETAIL, "PSF FWHM of %s : %f pixels\n", file->name, fwhmValues->data.F32[nMatchedPSF]);
     88
    5589        readouts->data[i] = psMemIncrRefCounter(readout);
    5690    }
    5791
    5892    // process the objects in order. 
    59     for (int i = 0; i < objects->n; i++) {
     93    // XXX TEST: fix this!
     94    for (int i = 0; (i < 50) && (i < objects->n); i++) {
    6095        pmPhotObj *object = objects->data[i];
    6196        if (!object) continue;
     
    77112            if (source->peak->SN < SN_LIM) continue;
    78113
     114            int index = source->imageID;
     115            if (index >= readouts->n) continue; // skip the sources generated by the chisq image
     116            pmReadout *readout = readouts->data[index];
     117
     118            // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index);
     119            // psphotVisualShowImage(readout);
     120
     121            // allocate pmSourceExtendedParameters, if not already defined
     122            if (!source->radialAper) {
     123                source->radialAper = psArrayAlloc(nPSFsizes);
     124            }
     125
    79126            // replace object in image
    80127            if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {
     
    83130            Nradial ++;
    84131
    85             int index = source->imageID;
    86             pmReadout *readout = readouts->data[index];
     132            // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index);
     133            // psphotVisualShowImage(readout);
    87134
    88135            // force source image to be a bit larger...
    89             float radius = source->peak->xf - source->pixels->col0;
    90             radius = PS_MAX (radius, source->peak->yf - source->pixels->row0);
    91             radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0);
    92             radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0);
    93             pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, 1.5*radius);
     136            // float radius = source->peak->xf - source->pixels->col0;
     137            // radius = PS_MAX (radius, source->peak->yf - source->pixels->row0);
     138            // radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0);
     139            // radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0);
     140            pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2);
    94141
    95             if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax)) {
     142            if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax, nMatchedPSF)) {
    96143                psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My);
    97144            } else {
     
    101148            // re-subtract the object, leave local sky
    102149            pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
     150
     151            // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index);
     152            // psphotVisualShowImage(readout);
    103153        }
    104154    }
Note: See TracChangeset for help on using the changeset viewer.