IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 5, 2011, 9:02:13 AM (15 years ago)
Author:
eugene
Message:

major re-work of psphotStackReadout to be more consistent with psphotReadout; psphotRadialApertures now assumes the 0 element is the unconvolved version; for the convolved versions, the vector of target psfs is saved as STACK.PSF.FWHM.VALUES

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psphot/src/psphotRadialApertures.c

    r32238 r32322  
    33bool psphotRadialAperturesSortFlux (psVector *radius, psVector *pixFlux, psVector *pixVar);
    44
     5// this function measures the radial aperture fluxes for the set of readouts.  this function
     6// may be called multiple times, presumably for different versions of PSF-matched or unmatched images. 
     7
    58// for now, let's store the detections on the readout->analysis for each readout
    6 bool psphotRadialApertures (pmConfig *config, const pmFPAview *view, const char *filerule)
     9bool psphotRadialApertures (pmConfig *config, const pmFPAview *view, const char *filerule, int entry)
    710{
    811    bool status = true;
     12
     13    fprintf (stdout, "\n");
     14    psLogMsg ("psphot", PS_LOG_INFO, "--- psphot Radial Apertures ---");
    915
    1016    // select the appropriate recipe information
     
    2228    // loop over the available readouts
    2329    for (int i = 0; i < num; i++) {
    24         if (!psphotRadialAperturesReadout (config, view, filerule, i, recipe)) {
     30        if (!psphotRadialAperturesReadout (config, view, filerule, i, recipe, entry)) {
    2531            psError (PSPHOT_ERR_CONFIG, false, "failed on measure extended source aperture-like parameters for %s entry %d", filerule, i);
    2632            return false;
     
    3238// aperture-like measurements for extended sources
    3339// flux in simple, circular apertures
    34 bool psphotRadialAperturesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe) {
     40// 'entry' tells us which of the matched-PSF images we are working on (0 == unmatched image, also non-stack psphot)
     41bool psphotRadialAperturesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe, int entry) {
    3542
    3643    bool status;
     
    7279    // XXX are we getting the objects out of order? does it matter?
    7380    sources = psArraySort (sources, pmSourceSortByFlux);
     81
     82    // XXX make this consistent with entry 0 == unmatched
     83    int nEntry = 1;
     84    psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES");
     85    if (fwhmValues) {
     86        psAssert (entry < fwhmValues->n, "inconsistent matched-PSF entry");
     87        nEntry = fwhmValues->n;
     88    }
     89    if (entry > 0) {
     90        psLogMsg ("psphot", PS_LOG_DETAIL, "Radial Apertures for matched image %s : PSF FWHM = %f pixels\n", file->name, fwhmValues->data.F32[entry]);
     91    } else {
     92        psLogMsg ("psphot", PS_LOG_DETAIL, "Radial Apertures for unmatched image %s\n", file->name);
     93    }
    7494
    7595    // option to limit analysis to a specific region
     
    98118            psArrayAdd(job->args, 1, AnalysisRegion);
    99119            psArrayAdd(job->args, 1, recipe);
     120
     121            PS_ARRAY_ADD_SCALAR(job->args, entry,  PS_TYPE_S32);
     122            PS_ARRAY_ADD_SCALAR(job->args, nEntry, PS_TYPE_S32);
    100123
    101124            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nradial
     
    115138            }
    116139            psScalar *scalar = NULL;
    117             scalar = job->args->data[4];
     140            scalar = job->args->data[6];
    118141            Nradial += scalar->data.S32;
    119142            psFree(job);
     
    135158            } else {
    136159                psScalar *scalar = NULL;
    137                 scalar = job->args->data[4];
     160                scalar = job->args->data[6];
    138161                Nradial += scalar->data.S32;
    139162            }
     
    159182    psMetadata *recipe      = job->args->data[3];
    160183
     184    int entry               = PS_SCALAR_VALUE(job->args->data[4],S32); // which psf-matched image are we working on? (0 == unmatched)
     185    int nEntry              = PS_SCALAR_VALUE(job->args->data[5],S32); // total number of psf-matched images + 1 unmatched
     186
    161187    // radMax stores the upper bounds of the annuli
    162188    // XXX keep the same name here as for the petrosian / elliptical apertures?
     
    198224
    199225        // allocate pmSourceExtendedParameters, if not already defined
    200         if (!source->radialAper) {
    201             source->radialAper = psArrayAlloc(1);
     226        // XXX check that nPSFsizes is consistent with targets
     227        if (source->parent) {
     228            if (!source->parent->radialAper) {
     229                source->parent->radialAper = psArrayAlloc(nEntry);
     230            }
     231        } else {
     232            if (!source->radialAper) {
     233                source->radialAper = psArrayAlloc(nEntry);
     234            }
    202235        }
    203236
     
    219252        pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2);
    220253
    221         if (!psphotRadialApertureSource (source, recipe, maskVal, radMax, 0)) {
     254        if (!psphotRadialApertureSource (source, recipe, maskVal, radMax, entry)) {
    222255            psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My);
    223256        } else {
     
    233266        pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    234267    }
    235     psScalar *scalar = job->args->data[4];
     268    psScalar *scalar = job->args->data[6];
    236269    scalar->data.S32 = Nradial;
    237270
Note: See TracChangeset for help on using the changeset viewer.