- Timestamp:
- Dec 17, 2010, 9:57:34 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/psphot/src/psphotRadialAperturesByObject.c
r29936 r30101 3 3 // aperture-like measurements for extended sources 4 4 // 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 14 bool psphotRadialAperturesByObject (pmConfig *config, psArray *objects, const pmFPAview *view, const char *filerule, int nMatchedPSF) { 6 15 7 16 bool status; … … 28 37 psAssert (radMax, "annular bins (RADIAL.ANNULAR.BINS.UPPER) are not defined in the recipe"); 29 38 psAssert (radMax->n, "no valid annular bins (RADIAL.ANNULAR.BINS.UPPER) are define"); 39 float outerRadius = radMax->data.F32[radMax->n - 1]; 30 40 31 41 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 39 49 float SN_LIM = psMetadataLookupF32 (&status, recipe, "RADIAL_APERTURES_SN_LIM"); 40 50 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 41 64 // source analysis is done in S/N order (brightest first) 42 65 objects = psArraySort (objects, pmPhotObjSortBySN); … … 53 76 psAssert (readout, "missing readout?"); 54 77 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 55 89 readouts->data[i] = psMemIncrRefCounter(readout); 56 90 } 57 91 58 92 // 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++) { 60 95 pmPhotObj *object = objects->data[i]; 61 96 if (!object) continue; … … 77 112 if (source->peak->SN < SN_LIM) continue; 78 113 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 79 126 // replace object in image 80 127 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { … … 83 130 Nradial ++; 84 131 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); 87 134 88 135 // 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); 94 141 95 if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax )) {142 if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax, nMatchedPSF)) { 96 143 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 97 144 } else { … … 101 148 // re-subtract the object, leave local sky 102 149 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 150 151 // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index); 152 // psphotVisualShowImage(readout); 103 153 } 104 154 }
Note:
See TracChangeset
for help on using the changeset viewer.
