Changeset 30707
- Timestamp:
- Feb 19, 2011, 10:40:50 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110213/psphot
- Files:
-
- 11 edited
-
. (modified) (1 prop)
-
src/psphot.h (modified) (1 diff)
-
src/psphotBlendFit.c (modified) (1 diff)
-
src/psphotExtendedSourceAnalysis.c (modified) (9 diffs)
-
src/psphotExtendedSourceFits.c (modified) (3 diffs)
-
src/psphotPetrosianRadialBins.c (modified) (4 diffs)
-
src/psphotPetrosianStats.c (modified) (15 diffs)
-
src/psphotRadialApertures.c (modified) (9 diffs)
-
src/psphotRadialAperturesByObject.c (modified) (2 diffs)
-
src/psphotReadout.c (modified) (1 diff)
-
src/psphotStackMatchPSFsUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/psphot
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/ipp-20110213/psphot/src/psphot.h
r30624 r30707 430 430 bool psphotRadialApertures (pmConfig *config, const pmFPAview *view, const char *filerule); 431 431 bool psphotRadialAperturesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe); 432 bool psphotRadialApertureSource (pmSource *source, psMetadata *recipe, float skynoise,psImageMaskType maskVal, const psVector *radMax, int entry);432 bool psphotRadialApertureSource (pmSource *source, psMetadata *recipe, psImageMaskType maskVal, const psVector *radMax, int entry); 433 433 434 434 bool psphotExtendedSourceAnalysisByObject (pmConfig *config, psArray *objects, const pmFPAview *view, const char *filerule); -
branches/eam_branches/ipp-20110213/psphot/src/psphotBlendFit.c
r30624 r30707 176 176 } 177 177 psFree(job); 178 }178 } 179 179 } 180 180 psFree (cellGroups); -
branches/eam_branches/ipp-20110213/psphot/src/psphotExtendedSourceAnalysis.c
r30624 r30707 1 1 # include "psphotInternal.h" 2 2 3 // ?? these cannot happen here --> we would need to do this in psphotExtendedSourceAnalysis 4 // XXX option to choose a consistent position 5 // XXX option to choose a consistent elliptical contour 6 // XXX SDSS uses the r-band petrosian radius to measure petrosian fluxes in all bands 7 // XXX consistent choice of extendedness... 3 // measure the elliptical radial profile and use this to measure the petrosian parameters for the sources 4 // XXX this function needs to be threaded 8 5 9 6 // for now, let's store the detections on the readout->analysis for each readout … … 40 37 int Next = 0; 41 38 int Npetro = 0; 42 int Nisophot = 0;43 39 int Nannuli = 0; 44 int Nkron = 0;45 40 46 41 psTimerStart ("psphot.extended"); … … 68 63 assert (maskVal); 69 64 70 // XXX require petrosian analysis for non-linear fits? 71 72 // XXX temporary user-supplied systematic sky noise measurement (derive from background model) 73 float skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE"); 65 // get the sky noise from the background analysis; if this is missing, get the user-supplied value 66 float skynoise = psMetadataLookupF32 (&status, readout->analysis, "SKY_STDEV"); 67 if (!status) { 68 skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE"); 69 psWarning ("failed to get sky noise level from background analysis; defaulting to user supplied value of %f\n", skynoise); 70 } 74 71 75 72 // S/N limit to perform full non-linear fits … … 78 75 // which extended source analyses should we perform? 79 76 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 80 bool doIsophotal = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ISOPHOTAL");81 77 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI"); 82 bool doKron = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_KRON"); 83 84 # if (0) 85 // if backModel or backStdev are missing, the values of sky and/or skyErr will be set to NAN 86 // XXX use this to set skynoise 87 pmReadout *backModel = psphotSelectBackground (config, view); 88 pmReadout *backStdev = psphotSelectBackgroundStdev (config, view); 89 # endif 78 bool doPetroStars = psMetadataLookupBool (&status, recipe, "PETROSIAN_FOR_STARS"); 90 79 91 80 // source analysis is done in S/N order (brightest first) … … 103 92 104 93 // skip PSF-like and non-astronomical objects 105 if (source->type == PM_SOURCE_TYPE_STAR) continue;106 94 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 107 95 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 108 96 if (source->mode & PM_SOURCE_MODE_DEFECT) continue; 109 97 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 110 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue; 98 99 // optionally allow non-extended objects to get petrosians as well 100 if (!doPetroStars) { 101 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue; 102 if (source->type == PM_SOURCE_TYPE_STAR) continue; 103 } 111 104 112 105 // limit selection to some SN limit … … 119 112 if (source->peak->x > AnalysisRegion.x1) continue; 120 113 if (source->peak->y > AnalysisRegion.y1) continue; 121 122 // fprintf (stderr, "xsrc: %f, %f : %f\n", source->peak->xf, source->peak->yf, source->peak->SN);123 114 124 115 // replace object in image … … 136 127 137 128 // if we request any of these measurements, we require the radial profile 138 if (doPetrosian || do Isophotal || doAnnuli || doKron) {129 if (doPetrosian || doAnnuli) { 139 130 if (!psphotRadialProfile (source, recipe, skynoise, maskVal)) { 140 131 // all measurements below require the radial profile; skip them all … … 144 135 continue; 145 136 } 137 Nannuli ++; 146 138 source->mode |= PM_SOURCE_MODE_RADIAL_FLUX; 147 139 } … … 169 161 psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next); 170 162 psLogMsg ("psphot", PS_LOG_INFO, " %d petrosian\n", Npetro); 171 psLogMsg ("psphot", PS_LOG_INFO, " %d isophotal\n", Nisophot);172 163 psLogMsg ("psphot", PS_LOG_INFO, " %d annuli\n", Nannuli); 173 psLogMsg ("psphot", PS_LOG_INFO, " %d kron\n", Nkron);174 164 175 165 psphotVisualShowResidualImage (readout, false); -
branches/eam_branches/ipp-20110213/psphot/src/psphotExtendedSourceFits.c
r30624 r30707 178 178 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfain 179 179 180 if (false && !psThreadJobAddPending(job)) { 180 // set this to 0 to run without threading 181 # if (1) 182 if (!psThreadJobAddPending(job)) { 181 183 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 182 184 psFree(AnalysisRegion); 183 185 return false; 184 } else { 185 if (!psphotExtendedSourceFits_Threaded(job)) { 186 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 187 psFree(AnalysisRegion); 188 return false; 189 } 190 psScalar *scalar = NULL; 191 scalar = job->args->data[7]; 192 Next += scalar->data.S32; 193 scalar = job->args->data[8]; 194 Nconvolve += scalar->data.S32; 195 scalar = job->args->data[9]; 196 NconvolvePass += scalar->data.S32; 197 scalar = job->args->data[10]; 198 Nplain += scalar->data.S32; 199 scalar = job->args->data[11]; 200 NplainPass += scalar->data.S32; 201 scalar = job->args->data[12]; 202 Nfaint += scalar->data.S32; 203 psFree(job); 186 } 187 # else 188 if (!psphotExtendedSourceFits_Threaded(job)) { 189 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 190 psFree(AnalysisRegion); 191 return false; 204 192 } 205 } 193 psScalar *scalar = NULL; 194 scalar = job->args->data[7]; 195 Next += scalar->data.S32; 196 scalar = job->args->data[8]; 197 Nconvolve += scalar->data.S32; 198 scalar = job->args->data[9]; 199 NconvolvePass += scalar->data.S32; 200 scalar = job->args->data[10]; 201 Nplain += scalar->data.S32; 202 scalar = job->args->data[11]; 203 NplainPass += scalar->data.S32; 204 scalar = job->args->data[12]; 205 Nfaint += scalar->data.S32; 206 psFree(job); 207 # endif 208 } 206 209 207 210 // wait for the threads to finish and manage results … … 268 271 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 269 272 273 pthread_t tid = pthread_self(); // Thread identifier 274 270 275 // Define source fitting parameters for extended source fits 271 276 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 272 277 fitOptions->mode = PM_SOURCE_FIT_EXT; 278 fitOptions->saveCovariance = true; // XXX make this a user option? 279 273 280 // XXX for now, use the defaults for the rest: 274 281 // fitOptions->nIter = fitIter; … … 296 303 // XXX use the parameters guessed from moments 297 304 // if (source->modelEXT == NULL) continue; 305 306 fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid); 298 307 299 308 // replace object in image -
branches/eam_branches/ipp-20110213/psphot/src/psphotPetrosianRadialBins.c
r28013 r30707 51 51 psVector *binRad = psVectorAllocEmpty(nMax, PS_TYPE_F32); // mean radius of radial bin 52 52 psVector *binArea = psVectorAllocEmpty(nMax, PS_TYPE_F32); // area of radial bin (contiguous, non-overlapping) 53 psVector *binFill = psVectorAllocEmpty(nMax, PS_TYPE_F32); // fraction of radial bin with valid pixels 53 54 54 55 psVectorInit (binSB, 0.0); … … 144 145 binSB->data.F32[nOut] = value; 145 146 binSBstdev->data.F32[nOut] = sqrt(PS_SQR(dvalue) / values->n + skyModelErrorSQ); 147 binFill->data.F32[nOut] = values->n / binArea->data.F32[nOut]; 146 148 147 149 // error in the SB is the stdev per bin / sqrt (number of pixels) … … 176 178 psFree(binRad); 177 179 psFree(binArea); 180 psFree(binFill); 178 181 psFree(radMin); 179 182 psFree(radMax); … … 202 205 psFree(profile->radialBins); 203 206 psFree(profile->area); 207 psFree(profile->binFill); 204 208 205 209 // save the vectors 206 210 profile->radialBins = binRad; 207 211 profile->area = binArea; 212 profile->binFill = binFill; 208 213 profile->binSB = binSB; 209 214 profile->binSBstdev = binSBstdev; -
branches/eam_branches/ipp-20110213/psphot/src/psphotPetrosianStats.c
r28013 r30707 6 6 // generate the Petrosian radius and flux from the mean surface brightness (r_i) 7 7 8 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X); 8 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X); 9 float InterpolateValuesErrX (float X0, float Y0, float X1, float Y1, float X, float dX0, float dX1); 10 float InterpolateValuesErrY (float X0, float Y0, float X1, float Y1, float X, float dY0, float dY1); 9 11 10 12 bool psphotPetrosianStats (pmSource *source) { … … 25 27 psVector *binRad = profile->radialBins; 26 28 psVector *area = profile->area; 29 psVector *binFill = profile->binFill; 27 30 28 31 psVector *fluxSum = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); … … 33 36 psVector *meanSB = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 34 37 psVector *areaSum = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 38 psVector *apixSum = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 35 39 36 40 float petRadius = NAN; 41 float petRadiusErr = NAN; 37 42 float petFlux = NAN; 43 float petFluxErr = NAN; 44 float petArea = NAN; 45 float petApix = NAN; 38 46 39 47 bool anyPetro = false; … … 41 49 bool above = true; 42 50 float Asum = 0.0; 51 float Psum = 0.0; 43 52 float Fsum = 0.0; 44 53 float dFsum2 = 0.0; … … 56 65 57 66 float Area = area->data.F32[i]; 58 Asum += Area; 67 Asum += Area; // Asum is the cumulative area interior to this bin 59 68 Fsum += binSB->data.F32[i] * Area; 60 69 dFsum2 += PS_SQR(binSBstdev->data.F32[i] * Area); 70 Psum += Area*binFill->data.F32[i]; // Psum is the cumulative number of pixels interior to this bin 61 71 62 72 float areaInner = 0.5 * Area; … … 87 97 88 98 psVectorAppend(areaSum, Asum); 99 psVectorAppend(apixSum, Psum); 89 100 psVectorAppend(fluxSum, Fsum); 90 101 psVectorAppend(fluxSumErr2, dFsum2); 91 102 psVectorAppend(refRadius, binRad->data.F32[i]); 92 103 93 psTrace ("psphot", 4, "%3d : %5.2f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.1f %5.1f \n",104 psTrace ("psphot", 4, "%3d : %5.2f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.1f %5.1f %5.1f\n", 94 105 i, refRadius->data.F32[nOut], 95 106 binSB->data.F32[i], binSBstdev->data.F32[i], 96 107 meanSB->data.F32[nOut], meanSBerr, 97 108 petRatio->data.F32[nOut], petRatioErr->data.F32[nOut], 98 fluxSum->data.F32[nOut], sqrt(fluxSumErr2->data.F32[nOut]), areaSum->data.F32[nOut], a reaInner);109 fluxSum->data.F32[nOut], sqrt(fluxSumErr2->data.F32[nOut]), areaSum->data.F32[nOut], apixSum->data.F32[nOut], areaInner); 99 110 100 111 // anytime we transition below the PETROSIAN_RATIO, calculate the radius and flux … … 104 115 if (i == 0) { 105 116 // assume Fmax @ R = 0.0 106 petRadius = InterpolateValues (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 107 } else { 108 petRadius = InterpolateValues (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 117 petRadius = InterpolateValues (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 118 petRadiusErr = InterpolateValuesErrX (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO, 0.0, petRatioErr->data.F32[nOut]); 119 } else { 120 petRadius = InterpolateValues (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 121 petRadiusErr = InterpolateValuesErrX (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO, petRatioErr->data.F32[nOut-1], petRatioErr->data.F32[nOut]); 109 122 } 110 123 above = false; … … 128 141 } 129 142 143 // if we failed to reach the PETROSIAN_RATIO, use the lowest significant ratio instead (flag this!) 130 144 if (!anyPetro) { 131 145 // interpolate Rvec between i-1 and i to PETROSIAN_RATIO to get flux (Fvec) and radius (rvec) 132 146 if (lowestSignificantRadius == 0) { 133 147 // assume Fmax @ R = 0.0 134 petRadius = InterpolateValues (1.0, 0.0, petRatio->data.F32[lowestSignificantRadius], refRadius->data.F32[lowestSignificantRadius], PETROSIAN_RATIO); 148 petRadius = InterpolateValues (1.0, 0.0, petRatio->data.F32[lowestSignificantRadius], refRadius->data.F32[lowestSignificantRadius], PETROSIAN_RATIO); 149 petRadiusErr = InterpolateValuesErrX (1.0, 0.0, petRatio->data.F32[lowestSignificantRadius], refRadius->data.F32[lowestSignificantRadius], PETROSIAN_RATIO, 0.0, petRatioErr->data.F32[lowestSignificantRadius]); 150 135 151 } else { 136 petRadius = InterpolateValues (petRatio->data.F32[lowestSignificantRadius-1], refRadius->data.F32[lowestSignificantRadius-1], petRatio->data.F32[lowestSignificantRadius], refRadius->data.F32[lowestSignificantRadius], PETROSIAN_RATIO); 152 int n0 = lowestSignificantRadius-1; 153 int n1 = lowestSignificantRadius; 154 petRadius = InterpolateValues (petRatio->data.F32[n0], refRadius->data.F32[n0], petRatio->data.F32[n1], refRadius->data.F32[n1], PETROSIAN_RATIO); 155 petRadiusErr = InterpolateValuesErrX (petRatio->data.F32[n0], refRadius->data.F32[n0], petRatio->data.F32[n1], refRadius->data.F32[n1], PETROSIAN_RATIO, petRatioErr->data.F32[n0], petRatioErr->data.F32[n1]); 137 156 } 138 157 } … … 147 166 continue; 148 167 } else { 149 petFlux = InterpolateValues (refRadius->data.F32[i-1], fluxSum->data.F32[i-1], refRadius->data.F32[i], fluxSum->data.F32[i], apRadius); 168 petFlux = InterpolateValues (refRadius->data.F32[i-1], fluxSum->data.F32[i-1], refRadius->data.F32[i], fluxSum->data.F32[i], apRadius); 169 petFluxErr = InterpolateValuesErrY (refRadius->data.F32[i-1], fluxSum->data.F32[i-1], refRadius->data.F32[i], fluxSum->data.F32[i], apRadius, sqrt(fluxSumErr2->data.F32[i-1]), sqrt(fluxSumErr2->data.F32[i])); 170 petArea = InterpolateValues (refRadius->data.F32[i-1], areaSum->data.F32[i-1], refRadius->data.F32[i], areaSum->data.F32[i], apRadius); 171 petApix = InterpolateValues (refRadius->data.F32[i-1], apixSum->data.F32[i-1], refRadius->data.F32[i], apixSum->data.F32[i], apRadius); 150 172 break; 151 173 } … … 158 180 float R50 = NAN; 159 181 float R90 = NAN; 182 float R50err = NAN; 183 float R90err = NAN; 160 184 bool found50 = false; 161 185 bool found90 = false; … … 167 191 continue; 168 192 } else { 169 R50 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux50); 193 R50 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux50); 194 R50err = InterpolateValuesErrX (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux50, sqrt(fluxSumErr2->data.F32[i-1]), sqrt(fluxSumErr2->data.F32[i])); 170 195 found50 = true; 171 196 } … … 176 201 continue; 177 202 } else { 178 R90 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux90); 203 R90 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux90); 204 R90err = InterpolateValuesErrX (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux90, sqrt(fluxSumErr2->data.F32[i-1]), sqrt(fluxSumErr2->data.F32[i])); 179 205 found90 = true; 180 206 } … … 188 214 source->extpars->petrosianR50 = R50; 189 215 source->extpars->petrosianR90 = R90; 216 source->extpars->petrosianFill = petApix / petArea; 190 217 191 218 // XXX add the errors 192 source->extpars->petrosianRadiusErr = NAN;193 source->extpars->petrosianFluxErr = NAN;194 source->extpars->petrosianR50Err = NAN;195 source->extpars->petrosianR90Err = NAN;219 source->extpars->petrosianRadiusErr = petRadiusErr; 220 source->extpars->petrosianFluxErr = petFluxErr; 221 source->extpars->petrosianR50Err = R50err; 222 source->extpars->petrosianR90Err = R90err; 196 223 197 224 // fprintf (stderr, "source @ %f,%f\n", source->peak->xf, source->peak->yf); … … 205 232 psFree(meanSB); 206 233 psFree(areaSum); 234 psFree(apixSum); 207 235 208 236 return true; … … 210 238 211 239 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X) { 212 float Y = Y0 + (Y1 - Y0) * (X - X0) / (X1 - X0); 240 float dydx = (Y1 - Y0) / (X1 - X0); 241 float Y = Y0 + dydx * (X - X0); 213 242 return Y; 214 243 } 215 244 245 float InterpolateValuesErrX (float X0, float Y0, float X1, float Y1, float X, float dX0, float dX1) { 246 247 float dydx = (Y1 - Y0) / (X1 - X0); 248 float dxdx = (X - X0) / (X1 - X0); 249 250 float dY = sqrt(PS_SQR(dX1*dydx*dxdx) + PS_SQR(dX0*dydx*(dxdx - 1.0))); 251 return dY; 252 } 253 254 float InterpolateValuesErrY (float X0, float Y0, float X1, float Y1, float X, float dY0, float dY1) { 255 256 float dxdx = (X - X0) / (X1 - X0); 257 258 float dY = sqrt(PS_SQR(dY1*dxdx) + PS_SQR(dY0*(1.0 - dxdx))); 259 return dY; 260 } 261 -
branches/eam_branches/ipp-20110213/psphot/src/psphotRadialApertures.c
r30624 r30707 37 37 int Nradial = 0; 38 38 39 // perform full non-linear fits / extended source analysis? 40 if (!psMetadataLookupBool (&status, recipe, "RADIAL_APERTURES")) { 41 psLogMsg ("psphot", PS_LOG_INFO, "skipping radial apertures\n"); 42 return true; 43 } 44 39 45 psTimerStart ("psphot.radial"); 40 46 … … 62 68 psAssert (radMax, "annular bins (RADIAL.ANNULAR.BINS.UPPER) are not defined in the recipe"); 63 69 psAssert (radMax->n, "no valid annular bins (RADIAL.ANNULAR.BINS.UPPER) are define"); 70 float outerRadius = radMax->data.F32[radMax->n - 1]; 64 71 65 72 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 66 73 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 67 74 assert (maskVal); 68 69 // XXX temporary user-supplied systematic sky noise measurement (derive from background model)70 float skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE");71 75 72 76 // S/N limit to perform full non-linear fits … … 112 116 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 113 117 } 118 119 // we need to change the view for the radial aperture analysis, but we want to recover exactly 120 // the original view; the following elements get destroyed by pmSourceRedefinePixels so save them: 121 psImage *oldMaskObj = psMemIncrRefCounter(source->maskObj); 122 psImage *oldModelFlux = psMemIncrRefCounter(source->modelFlux); 123 psImage *oldPSFimage = psMemIncrRefCounter(source->psfImage); 124 psRegion oldRegion = source->region; 125 114 126 Nradial ++; 115 127 116 128 // force source image to be a bit larger... 117 float radius = source->peak->xf - source->pixels->col0; 118 radius = PS_MAX (radius, source->peak->yf - source->pixels->row0); 119 radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0); 120 radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0); 121 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, 1.5*radius); 122 123 if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax, 0)) { 129 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2); 130 131 if (!psphotRadialApertureSource (source, recipe, maskVal, radMax, 0)) { 124 132 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 125 133 } else { … … 127 135 } 128 136 137 pmSourceRedefinePixelsByRegion (source, readout, oldRegion); 138 psFree(source->maskObj); source->maskObj = oldMaskObj; 139 psFree(source->modelFlux); source->modelFlux = oldModelFlux; 140 psFree(source->psfImage); source->psfImage = oldPSFimage; 141 129 142 // re-subtract the object, leave local sky 130 143 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); … … 135 148 } 136 149 137 bool psphotRadialApertureSource (pmSource *source, psMetadata *recipe, float skynoise,psImageMaskType maskVal, const psVector *aperRadii, int entry) {150 bool psphotRadialApertureSource (pmSource *source, psMetadata *recipe, psImageMaskType maskVal, const psVector *aperRadii, int entry) { 138 151 139 152 // if we are a child source, save the results to the parent source radial aperture array … … 203 216 psVector *flux = psVectorAlloc(aperRadii->n, PS_TYPE_F32); // surface brightness of radial bin 204 217 psVector *fluxErr = psVectorAlloc(aperRadii->n, PS_TYPE_F32); // surface brightness of radial bin 218 psVector *fluxStd = psVectorAlloc(aperRadii->n, PS_TYPE_F32); // surface brightness of radial bin 205 219 psVector *fill = psVectorAlloc(aperRadii->n, PS_TYPE_F32); // surface brightness of radial bin 206 220 207 221 psVectorInit (flux, 0.0); 222 psVectorInit (fluxStd, 0.0); 208 223 psVectorInit (fluxErr, 0.0); 209 224 psVectorInit (fill, 0.0); … … 215 230 for (int j = 0; (*rPix2 < *aRad2) && (j < aperRadii2->n); j++, aRad2++) { 216 231 flux->data.F32[j] += pixFlux->data.F32[i]; 232 fluxStd->data.F32[j] += PS_SQR(pixFlux->data.F32[i]); 217 233 fluxErr->data.F32[j] += pixVar->data.F32[i]; 218 234 fill->data.F32[j] += 1.0; 219 235 } 220 236 } 237 238 /* for each radial bin, R(i), we measure: 239 1) the flux within that aperture: F(i) = \sum_{r_j<R_i}(F_j) 240 2) the fractional fill factor (count of valid pixels / effective area of the aperture 241 3) the error on the flux within that aperture 242 */ 221 243 222 244 for (int i = 0; i < flux->n; i++) { 223 245 // calculate the total flux for bin 'nOut' 224 246 float Area = M_PI*aperRadii2->data.F32[i]; 225 fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]); 247 248 int nPix = fill->data.F32[i]; 249 float SBmean = flux->data.F32[i] / nPix; 250 float SBstdv = sqrt((fluxStd->data.F32[i] / nPix) - PS_SQR(SBmean)); 251 252 flux->data.F32[i] = SBmean * Area; 253 fluxStd->data.F32[i] = SBstdv * Area; 254 fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]) * Area / nPix; 255 226 256 fill->data.F32[i] /= Area; 227 257 psTrace ("psphot", 5, "radial bins: %3d %5.1f : %8.1f +/- %7.2f : %4.2f %6.1f\n", … … 230 260 231 261 radialAper->flux = flux; 262 radialAper->fluxStdev = fluxStd; 232 263 radialAper->fluxErr = fluxErr; 233 264 radialAper->fill = fill; … … 245 276 static int nPix = 0; 246 277 247 bool psphotRadialApertureSource_With_Sort (pmSource *source, psMetadata *recipe, float skynoise,psImageMaskType maskVal, const psVector *radMax, int entry) {278 bool psphotRadialApertureSource_With_Sort (pmSource *source, psMetadata *recipe, psImageMaskType maskVal, const psVector *radMax, int entry) { 248 279 249 280 psAssert(source->radialAper->data[entry] == NULL, "why is this already defined?"); -
branches/eam_branches/ipp-20110213/psphot/src/psphotRadialAperturesByObject.c
r30624 r30707 42 42 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 43 43 assert (maskVal); 44 45 // XXX temporary user-supplied systematic sky noise measurement (derive from background model)46 float skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE");47 44 48 45 // S/N limit to perform full non-linear fits … … 147 144 148 145 // force source image to be a bit larger... 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 146 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2); 154 147 155 if (!psphotRadialApertureSource (source, recipe, skynoise,maskVal, radMax, nMatchedPSF)) {148 if (!psphotRadialApertureSource (source, recipe, maskVal, radMax, nMatchedPSF)) { 156 149 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 157 150 } else { -
branches/eam_branches/ipp-20110213/psphot/src/psphotReadout.c
r30624 r30707 203 203 psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources) 204 204 psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources) 205 psphotRadialApertures(config, view, filerule); 205 206 206 207 finish: -
branches/eam_branches/ipp-20110213/psphot/src/psphotStackMatchPSFsUtils.c
r30624 r30707 363 363 364 364 // we need to register the FWHM values for use downstream 365 pmSubtractionSetFWHMs(options-> inputSeeing->data.F32[index], options->targetSeeing);365 pmSubtractionSetFWHMs(options->targetSeeing, options->inputSeeing->data.F32[index]); 366 366 367 367 pmSubtractionParamScaleOptions(scale, scaleRef, scaleMin, scaleMax);
Note:
See TracChangeset
for help on using the changeset viewer.
