- Timestamp:
- Dec 4, 2013, 2:00:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceAnalysis.c
r36198 r36342 2 2 void psphotRadialProfileShowSkips (); 3 3 4 // measure the elliptical radial profile and use this to measure thepetrosian parameters for the sources4 // measure the petrosian parameters for the sources 5 5 6 6 // for now, let's store the detections on the readout->analysis for each readout … … 16 16 psAssert (recipe, "missing recipe?"); 17 17 18 // perform full non-linear fits / extended source analysis?19 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ ANALYSIS")) {18 // measure petrosians? 19 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN")) { 20 20 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n"); 21 21 return true; … … 42 42 int Nskip5 = 0; 43 43 int Nskip6 = 0; 44 int Nskip7 = 0;45 int Nskip8 = 0;46 int Nskip9 = 0;47 int Nskip10 = 0;48 int Nskip11 = 0;49 int Nskip12 = 0;50 int Nskip13 = 0;51 int Nskip14 = 0;52 44 53 45 # define SKIP(VALUE) { VALUE++; continue; } … … 57 49 58 50 bool status; 59 int NfaintEXT = 0;60 int NfaintPSF = 0;61 62 51 int Next = 0; 63 52 int Npetro = 0; … … 131 120 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npetro 132 121 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nannuli 133 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for NfaintEXT134 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for NfaintPSF135 122 136 123 // set this to 0 to run without threading … … 154 141 scalar = job->args->data[7]; 155 142 Nannuli += scalar->data.S32; 156 scalar = job->args->data[8];157 NfaintEXT += scalar->data.S32;158 scalar = job->args->data[9];159 NfaintPSF += scalar->data.S32;160 143 psFree(job); 161 144 # endif … … 182 165 scalar = job->args->data[7]; 183 166 Nannuli += scalar->data.S32; 184 scalar = job->args->data[8];185 NfaintEXT += scalar->data.S32;186 scalar = job->args->data[9];187 NfaintPSF += scalar->data.S32;188 167 } 189 168 psFree(job); … … 196 175 psLogMsg ("psphot", PS_LOG_INFO, " %d petrosian\n", Npetro); 197 176 psLogMsg ("psphot", PS_LOG_INFO, " %d annuli\n", Nannuli); 198 psLogMsg ("psphot", PS_LOG_INFO, " skipped: %d EXT, %d PSF\n", NfaintEXT, NfaintPSF);199 177 200 178 fprintf (stderr, "ext analysis skipped @ 1 : %d\n", Nskip1); … … 204 182 fprintf (stderr, "ext analysis skipped @ 5 : %d\n", Nskip5); 205 183 fprintf (stderr, "ext analysis skipped @ 6 : %d\n", Nskip6); 206 fprintf (stderr, "ext analysis skipped @ 7 : %d\n", Nskip7);207 fprintf (stderr, "ext analysis skipped @ 8 : %d\n", Nskip8);208 fprintf (stderr, "ext analysis skipped @ 9 : %d\n", Nskip9);209 fprintf (stderr, "ext analysis skipped @ 10 : %d\n", Nskip10);210 fprintf (stderr, "ext analysis skipped @ 11 : %d\n", Nskip11);211 fprintf (stderr, "ext analysis skipped @ 12 : %d\n", Nskip12);212 fprintf (stderr, "ext analysis skipped @ 13 : %d\n", Nskip13);213 fprintf (stderr, "ext analysis skipped @ 14 : %d\n", Nskip14);214 184 215 185 psphotRadialProfileShowSkips (); … … 217 187 psphotVisualShowResidualImage (readout, false); 218 188 219 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 220 if (doPetrosian) { 221 psphotVisualShowPetrosians (sources); 222 } 189 psphotVisualShowPetrosians (sources); 223 190 224 191 return true; … … 228 195 229 196 bool status; 230 231 int NfaintEXT = 0;232 int NfaintPSF = 0;233 197 234 198 int Next = 0; … … 244 208 float skynoise = PS_SCALAR_VALUE(job->args->data[4],F32); 245 209 246 // S/N limit to perform full non-linear fits247 float SN_LIM = psMetadataLookupF32 (&status, recipe, "EXTENDED_SOURCE_SN_LIM");248 249 // which extended source analyses should we perform?250 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN");251 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI");252 bool doPetroStars = psMetadataLookupBool (&status, recipe, "PETROSIAN_FOR_STARS");253 254 210 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 255 211 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels … … 263 219 Nall ++; 264 220 265 // if we have checked the source validity on the basis of the object set, then 266 // we either skip these tests below or we skip the source completely 267 if (source->tmpFlags & PM_SOURCE_TMPF_PETRO_SKIP) SKIP (Nskip1); 268 if (source->tmpFlags & PM_SOURCE_TMPF_PETRO_KEEP) goto keepSource; 269 270 // skip PSF-like and non-astronomical objects 271 if (source->type == PM_SOURCE_TYPE_DEFECT) SKIP (Nskip2); 272 if (source->type == PM_SOURCE_TYPE_SATURATED) SKIP (Nskip3); 273 if (source->mode & PM_SOURCE_MODE_DEFECT) SKIP (Nskip4); 274 if (source->mode & PM_SOURCE_MODE_SATSTAR) SKIP (Nskip5); 275 276 // skip saturated stars modeled with a radial profile 277 if (source->mode2 & PM_SOURCE_MODE2_SATSTAR_PROFILE) SKIP (Nskip6); 278 279 // optionally allow non-extended objects to get petrosians as well 280 if (!doPetroStars) { 281 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) SKIP (Nskip7); 282 // if (source->type == PM_SOURCE_TYPE_STAR) SKIP (Nskip8); -- XXX this might be set for input lists (instead of EXT_LIMIT) 283 } 284 285 // limit selection to some SN limit 286 // assert (source->peak); // how can a source not have a peak? 287 // limit selection to some SN limit 288 bool skipSource = false; 289 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 290 skipSource = (source->moments->KronFlux < SN_LIM * source->moments->KronFluxErr); 291 NfaintEXT ++; 292 } else { 293 skipSource = (sqrt(source->peak->detValue) < SN_LIM); 294 NfaintPSF ++; 295 } 296 if (skipSource) SKIP (Nskip9); 297 298 // limit selection by analysis region (this automatically apply 299 if (source->peak->x < region->x0) SKIP (Nskip10); 300 if (source->peak->y < region->y0) SKIP (Nskip11); 301 if (source->peak->x > region->x1) SKIP (Nskip12); 302 if (source->peak->y > region->y1) SKIP (Nskip13); 303 304 keepSource: 221 // rules for measuring petrosian parameters for specific objects are set in 222 // psphotChooseAnalysisOptions.c 223 if (!(source->tmpFlags & PM_SOURCE_TMPF_PETRO)) SKIP (Nskip1); 224 225 // limit selection by analysis region (XXX move this into psphotChooseAnalysisOption?) 226 if (source->peak->x < region->x0) SKIP (Nskip2); 227 if (source->peak->y < region->y0) SKIP (Nskip3); 228 if (source->peak->x > region->x1) SKIP (Nskip4); 229 if (source->peak->y > region->y1) SKIP (Nskip5); 305 230 306 231 // replace object in image … … 317 242 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, 1.5*radius); 318 243 319 // if we request any of these measurements, we require the radial profile 320 if (doPetrosian || doAnnuli) { 321 if (!psphotRadialProfile (source, recipe, skynoise, maskVal)) { 322 // all measurements below require the radial profile; skip them all 323 // re-subtract the object, leave local sky 324 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 325 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 326 SKIP (Nskip14); 327 } 328 Nannuli ++; 329 source->mode |= PM_SOURCE_MODE_RADIAL_FLUX; 330 } 244 // measure the radial profile 245 if (!psphotRadialProfile (source, recipe, skynoise, maskVal)) { 246 // re-subtract the object, leave local sky 247 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 248 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 249 SKIP (Nskip6); 250 } 251 252 Nannuli ++; 253 source->mode |= PM_SOURCE_MODE_RADIAL_FLUX; 331 254 332 255 // Petrosian Mags 333 if (doPetrosian) { 334 if (!psphotPetrosian (source, recipe, skynoise, maskVal)) { 335 psTrace ("psphot", 5, "FAILED petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 336 } else { 337 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 338 Npetro ++; 339 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 340 } 256 if (!psphotPetrosian (source, recipe, skynoise, maskVal)) { 257 psTrace ("psphot", 5, "FAILED petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 258 } else { 259 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 260 Npetro ++; 261 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 341 262 } 342 263 … … 362 283 scalar->data.S32 = Nannuli; 363 284 364 scalar = job->args->data[8];365 scalar->data.S32 = NfaintEXT;366 367 scalar = job->args->data[9];368 scalar->data.S32 = NfaintPSF;369 370 285 return true; 371 286 }
Note:
See TracChangeset
for help on using the changeset viewer.
