- Timestamp:
- Feb 14, 2011, 1:05:28 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psphot
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psphot/src/psphotRadialAperturesByObject.c
r30118 r30631 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); … … 52 75 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 53 76 psAssert (readout, "missing readout?"); 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]); 54 88 55 89 readouts->data[i] = psMemIncrRefCounter(readout); … … 77 111 if (source->peak->SN < SN_LIM) continue; 78 112 113 int index = source->imageID; 114 if (index >= readouts->n) continue; // skip the sources generated by the chisq image 115 pmReadout *readout = readouts->data[index]; 116 117 // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index); 118 // psphotVisualShowImage(readout); 119 120 // allocate pmSourceExtendedParameters, if not already defined 121 if (source->parent) { 122 if (!source->parent->radialAper) { 123 source->parent->radialAper = psArrayAlloc(nPSFsizes); 124 } 125 } else { 126 if (!source->radialAper) { 127 source->radialAper = psArrayAlloc(nPSFsizes); 128 } 129 } 130 79 131 // replace object in image 80 132 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 81 133 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 82 134 } 135 136 // we need to change the view for the radial aperture analysis, but we want to recover exactly 137 // the original view; the following elements get destroyed by pmSourceRedefinePixels so save them: 138 psImage *oldMaskObj = psMemIncrRefCounter(source->maskObj); 139 psImage *oldModelFlux = psMemIncrRefCounter(source->modelFlux); 140 psImage *oldPSFimage = psMemIncrRefCounter(source->psfImage); 141 psRegion oldRegion = source->region; 142 83 143 Nradial ++; 84 144 85 int index = source->imageID;86 pmReadout *readout = readouts->data[index];145 // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index); 146 // psphotVisualShowImage(readout); 87 147 88 148 // 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);149 // float radius = source->peak->xf - source->pixels->col0; 150 // radius = PS_MAX (radius, source->peak->yf - source->pixels->row0); 151 // radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0); 152 // radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0); 153 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2); 94 154 95 if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax )) {155 if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax, nMatchedPSF)) { 96 156 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 97 157 } else { … … 99 159 } 100 160 161 pmSourceRedefinePixelsByRegion (source, readout, oldRegion); 162 psFree(source->maskObj); source->maskObj = oldMaskObj; 163 psFree(source->modelFlux); source->modelFlux = oldModelFlux; 164 psFree(source->psfImage); source->psfImage = oldPSFimage; 165 101 166 // re-subtract the object, leave local sky 102 167 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 168 169 // psLogMsg("psphot", PS_LOG_INFO, "radial apertures for %d", index); 170 // psphotVisualShowImage(readout); 103 171 } 104 172 }
Note:
See TracChangeset
for help on using the changeset viewer.
