Changeset 34247
- Timestamp:
- Jul 31, 2012, 11:50:18 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120627/psphot
- Files:
-
- 23 edited
-
. (modified) (1 prop)
-
src (modified) (1 prop)
-
src/psphot.h (modified) (3 diffs)
-
src/psphotChoosePSF.c (modified) (1 diff)
-
src/psphotCullPeaks.c (modified) (3 diffs)
-
src/psphotEfficiency.c (modified) (1 diff)
-
src/psphotExtendedSourceFits.c (modified) (7 diffs)
-
src/psphotFitSourcesLinear.c (modified) (7 diffs)
-
src/psphotForcedReadout.c (modified) (1 diff)
-
src/psphotRadialApertures.c (modified) (1 diff)
-
src/psphotRadialBins.c (modified) (1 diff)
-
src/psphotReadout.c (modified) (4 diffs)
-
src/psphotReadoutForcedKnownSources.c (modified) (1 diff)
-
src/psphotReadoutKnownSources.c (modified) (1 diff)
-
src/psphotReadoutMinimal.c (modified) (1 diff)
-
src/psphotReplaceUnfit.c (modified) (2 diffs)
-
src/psphotSetThreads.c (modified) (1 diff)
-
src/psphotSourceSize.c (modified) (9 diffs)
-
src/psphotStackImageLoop.c (modified) (1 prop)
-
src/psphotStackMatchPSFs.c (modified) (2 diffs)
-
src/psphotStackMatchPSFsNext.c (modified) (2 diffs)
-
src/psphotStackMatchPSFsUtils.c (modified) (2 diffs)
-
src/psphotStackReadout.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120627/psphot
- Property svn:mergeinfo changed
/trunk/psphot merged: 34135-34136,34200-34202,34215,34218,34226
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120627/psphot/src
- Property svn:mergeinfo changed
/trunk/psphot/src merged: 34135-34136,34200-34202,34215,34218,34226
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120627/psphot/src/psphot.h
r34172 r34247 102 102 bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index); 103 103 104 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final );105 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode );104 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final, bool skipNegativeFluxSources); 105 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode, bool skipNegativeFluxSources); 106 106 107 107 bool psphotSourceSize (pmConfig *config, const pmFPAview *view, const char *filerule, bool getPSFsize); … … 265 265 bool psphotEllipticalProfile (pmSource *source, bool RAW_RADIUS); 266 266 bool psphotEllipticalContour (pmSource *source); 267 bool psphotLimitRadialApertures(psMetadata *recipe, long nSources); 267 268 268 269 // psphotVisual functions … … 423 424 // bool loadKernel (pmConfig *config, pmReadout *readoutCnv, psphotStackOptions *options, int index); 424 425 426 bool psphotStackSetInputsToSkip(pmConfig *config, const pmFPAview *view, const char *filerule, bool set) ; 427 425 428 bool psphotStackRenormaliseVariance(const pmConfig *config, pmReadout *readout); 426 429 -
branches/eam_branches/ipp-20120627/psphot/src/psphotChoosePSF.c
r32348 r34247 47 47 if (psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF")) { 48 48 psLogMsg ("psphot", PS_LOG_DETAIL, "psf model supplied for input file %d", index); 49 return true; 50 } 51 52 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 53 psLogMsg ("psphot", PS_LOG_DETAIL, "skipping choose PSF for input file %d", index); 49 54 return true; 50 55 } -
branches/eam_branches/ipp-20120627/psphot/src/psphotCullPeaks.c
r31154 r34247 63 63 # if (PM_PEAKS_CULL_WITH_SMOOTHED_IMAGE) 64 64 psLogMsg ("psphot", PS_LOG_INFO, "Culling peaks from footprints using the smoothed image"); 65 bool setNaNsToZero = psMetadataLookupF32 (&status, recipe, "FOOTPRINT_SET_NANS_TO_ZERO"); 66 if (setNaNsToZero) { 67 // Set NaN pixels to zero so that they do not considered in the footprint analysis 68 // XXX: Currently the caller does nothing further with the significance readout so 69 // modifiying the image does no harm 70 // XXX: Note: signifR->weight is not used by pmFootprintCullPeaks so we don't 71 // need to touch it 72 psImageClipNaN(signifR->image, 0); 73 } 74 75 65 76 # else 66 77 psLogMsg ("psphot", PS_LOG_INFO, "Culling peaks from footprints using the raw (unsmoothed) image"); … … 73 84 74 85 if (fp->npix > 30000) { 75 fprintf (stderr, "big footprint: %f %f to %f %f (%d pix)\n", fp->bbox.x0, fp->bbox.y0, fp->bbox.x1, fp->bbox.y1, fp->npix);86 psLogMsg("psphot.cull.footprints", PS_LOG_WARN, "big footprint: %f %f to %f %f (%d pix)\n", fp->bbox.x0, fp->bbox.y0, fp->bbox.x1, fp->bbox.y1, fp->npix); 76 87 } 77 88 psTimerStart ("psphot.cull.footprints"); … … 97 108 # endif 98 109 110 99 111 float dtime = psTimerMark ("psphot.cull.footprints"); 100 112 if (dtime > 1.0) { 101 fprintf (stderr, "slow cull for %d (%f sec)\n", i, dtime);113 psLogMsg("psphot.cull.footprints", PS_LOG_WARN, "slow cull for %d (%f sec)\n", i, dtime); 102 114 } 103 115 } -
branches/eam_branches/ipp-20120627/psphot/src/psphotEfficiency.c
r34086 r34247 420 420 421 421 // psphotFitSourcesLinearReadout subtracts the model fits 422 if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true, PM_SOURCE_PHOTFIT_CONST )) {422 if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true, PM_SOURCE_PHOTFIT_CONST, false)) { 423 423 psError(PS_ERR_UNKNOWN, false, "Unable to perform linear fit on fake sources."); 424 424 psFree(fakeSources); -
branches/eam_branches/ipp-20120627/psphot/src/psphotExtendedSourceFits.c
r34190 r34247 175 175 psArrayAdd(job->args, 1, cells->data[j]); // sources 176 176 psArrayAdd(job->args, 1, models); 177 // Allocate a metadata iterator here because psMetadataIteratorAlloc/Free are not thread safe 178 psMetadataIterator *iter = psMetadataIteratorAlloc (models, PS_LIST_HEAD, NULL); 179 psArrayAdd(job->args, 1, iter); 177 180 psArrayAdd(job->args, 1, AnalysisRegion); // XXX make a pointer 178 181 … … 203 206 } 204 207 psScalar *scalar = NULL; 205 scalar = job->args->data[ 7];208 scalar = job->args->data[8]; 206 209 Next += scalar->data.S32; 207 scalar = job->args->data[ 8];210 scalar = job->args->data[9]; 208 211 Nconvolve += scalar->data.S32; 209 scalar = job->args->data[ 9];212 scalar = job->args->data[10]; 210 213 NconvolvePass += scalar->data.S32; 211 scalar = job->args->data[1 0];214 scalar = job->args->data[11]; 212 215 Nplain += scalar->data.S32; 213 scalar = job->args->data[1 1];216 scalar = job->args->data[12]; 214 217 NplainPass += scalar->data.S32; 215 scalar = job->args->data[1 2];218 scalar = job->args->data[13]; 216 219 Nfaint += scalar->data.S32; 217 scalar = job->args->data[1 3];220 scalar = job->args->data[14]; 218 221 Nfail += scalar->data.S32; 222 psFree(job->args->data[3]); // iterator allocated above 219 223 psFree(job); 220 224 # endif … … 235 239 } else { 236 240 psScalar *scalar = NULL; 237 scalar = job->args->data[ 7];241 scalar = job->args->data[8]; 238 242 Next += scalar->data.S32; 239 scalar = job->args->data[ 8];243 scalar = job->args->data[9]; 240 244 Nconvolve += scalar->data.S32; 241 scalar = job->args->data[ 9];245 scalar = job->args->data[10]; 242 246 NconvolvePass += scalar->data.S32; 243 scalar = job->args->data[1 0];247 scalar = job->args->data[11]; 244 248 Nplain += scalar->data.S32; 245 scalar = job->args->data[1 1];249 scalar = job->args->data[12]; 246 250 NplainPass += scalar->data.S32; 247 scalar = job->args->data[1 2];251 scalar = job->args->data[13]; 248 252 Nfaint += scalar->data.S32; 249 scalar = job->args->data[1 3];253 scalar = job->args->data[14]; 250 254 Nfail += scalar->data.S32; 255 psFree(job->args->data[3]); // metadata iterator allocated above 251 256 } 252 257 psFree(job); … … 285 290 psArray *sources = job->args->data[1]; 286 291 psMetadata *models = job->args->data[2]; 287 psRegion *region = job->args->data[3]; 288 int psfSize = PS_SCALAR_VALUE(job->args->data[4],S32); 289 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 290 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 292 psMetadataIterator *iter = job->args->data[3]; 293 psRegion *region = job->args->data[4]; 294 int psfSize = PS_SCALAR_VALUE(job->args->data[5],S32); 295 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 296 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[7],PS_TYPE_IMAGE_MASK_DATA); 291 297 292 298 // Define source fitting parameters for extended source fits … … 338 344 339 345 // loop here over the models chosen for each source (exclude by S/N) 340 psMetadataIterator *iter = psMetadataIteratorAlloc (models, PS_LIST_HEAD, NULL); 346 // Reset the iterator 347 psMetadataIteratorSet(iter, PS_LIST_HEAD); 341 348 psMetadataItem *item = NULL; 342 349 while ((item = psMetadataGetAndIncrement (iter)) != NULL) { … … 428 435 psFree (modelFit); 429 436 } 430 psFree (iter);431 437 432 438 // evaluate the relative quality of the models, choose one … … 489 495 490 496 // change the value of a scalar on the array (wrap this and put it in psArray.h) 491 scalar = job->args->data[ 7];497 scalar = job->args->data[8]; 492 498 scalar->data.S32 = Next; 493 499 494 scalar = job->args->data[ 8];500 scalar = job->args->data[9]; 495 501 scalar->data.S32 = Nconvolve; 496 502 497 scalar = job->args->data[ 9];503 scalar = job->args->data[10]; 498 504 scalar->data.S32 = NconvolvePass; 499 505 500 scalar = job->args->data[1 0];506 scalar = job->args->data[11]; 501 507 scalar->data.S32 = Nplain; 502 508 503 scalar = job->args->data[1 1];509 scalar = job->args->data[12]; 504 510 scalar->data.S32 = NplainPass; 505 511 506 scalar = job->args->data[1 2];512 scalar = job->args->data[13]; 507 513 scalar->data.S32 = Nfaint; 508 514 509 scalar = job->args->data[1 3];515 scalar = job->args->data[14]; 510 516 scalar->data.S32 = Nfail; 511 517 -
branches/eam_branches/ipp-20120627/psphot/src/psphotFitSourcesLinear.c
r34086 r34247 13 13 14 14 // for now, let's store the detections on the readout->analysis for each readout 15 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final )15 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final, bool skipNegativeFluxSources) 16 16 { 17 17 bool status = true; … … 51 51 psAssert (readout, "missing readout?"); 52 52 53 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 54 psLogMsg ("psphot", PS_LOG_DETAIL, "skipping fit sources for input file %d", i); 55 continue; 56 } 57 58 53 59 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 54 60 psAssert (detections, "missing detections?"); … … 60 66 psAssert (psf, "missing psf?"); 61 67 62 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1 )) {68 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1, skipNegativeFluxSources)) { 63 69 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i); 64 70 return false; … … 79 85 80 86 // rerun fit with correct fitVarMode 81 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarMode)) { 87 // XXX: does skipNegativeFlux work here? 88 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarMode, skipNegativeFluxSources)) { 82 89 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i); 83 90 return false; … … 130 137 } 131 138 132 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode ) {139 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode, bool skipNegativeFluxSources) { 133 140 bool status; 134 141 float x; … … 177 184 float MIN_VALID_FLUX = psMetadataLookupF32(&status, recipe, "PSF_FIT_MIN_VALID_FLUX"); 178 185 if (!status) { 186 MIN_VALID_FLUX = 0.0; 187 } 188 if (skipNegativeFluxSources && MIN_VALID_FLUX < 0) { 179 189 MIN_VALID_FLUX = 0.0; 180 190 } … … 252 262 if (modelSum < 0.5) continue; // skip sources with no model constraint (somewhat arbitrary limit) 253 263 if (modelSum < 0.8) { 254 fprintf (stderr, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n",264 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n", 255 265 source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux); 256 266 } 257 267 if (maskedSum < 0.5) { 258 fprintf (stderr, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n",268 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n", 259 269 source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux); 260 270 } -
branches/eam_branches/ipp-20120627/psphot/src/psphotForcedReadout.c
r33140 r34247 64 64 65 65 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 66 psphotFitSourcesLinear (config, view, filerule, false );66 psphotFitSourcesLinear (config, view, filerule, false, false); 67 67 68 68 // identify CRs and extended sources -
branches/eam_branches/ipp-20120627/psphot/src/psphotRadialApertures.c
r33089 r34247 71 71 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 72 72 psAssert (readout, "missing readout?"); 73 74 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 75 psLogMsg ("psphot", PS_LOG_DETAIL, "skipping radial aptertures for input file %d", index); 76 return true; 77 } 78 73 79 74 80 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); -
branches/eam_branches/ipp-20120627/psphot/src/psphotRadialBins.c
r28013 r34247 202 202 } 203 203 204 // If the number of sources is large, edit the recipe to remove radial bins beyond 205 // a value specified in the recipe 206 bool psphotLimitRadialApertures(psMetadata *recipe, long nSources) { 207 208 bool status = false; 209 long sourceLimit = psMetadataLookupS32 (&status, recipe, "RADIAL.NUM.SOURCES.LIMIT"); 210 if (!status) { 211 sourceLimit = 50000; 212 } 213 if (nSources < sourceLimit) { 214 return true; 215 } 216 psF32 maxRadius = psMetadataLookupF32 (&status, recipe, "RADIAL.SOURCES.OVER.LIMIT.RADIUS"); 217 if (!status) { 218 maxRadius = 20.0; 219 } 220 psLogMsg ("psphot", PS_LOG_INFO, "Number of objects: %ld is greater than limit %ld. Limiting radial annular bins to %.3f pixels\n", 221 nSources, sourceLimit, maxRadius); 222 223 psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER"); 224 psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER"); 225 if (!radMin || !radMin->n) { 226 psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMin missing or empty)"); 227 return false; 228 } 229 if (!radMax || !radMax->n) { 230 psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMax missing or empty)"); 231 return false; 232 } 233 if (radMax->n != radMin->n) { 234 psError (PSPHOT_ERR_CONFIG, true, "length of radMin %ld and radMax %ld not equal)", radMin->n, radMax->n); 235 return false; 236 } 237 int i = 0; 238 psF32 lastRadius = 0; 239 for (; i < radMax->n; i++) { 240 if (radMax->data.F32[i] > maxRadius) { 241 break; 242 } 243 lastRadius = radMax->data.F32[i]; 244 } 245 if (i == radMax->n) { 246 psLogMsg ("psphot", PS_LOG_INFO, "Radius of all bins is within the limit. lastRadius: %.3f\n", lastRadius); 247 return true; 248 } 249 psLogMsg ("psphot", PS_LOG_INFO, " radius limit exceeded at bin %d of %ld. New max radius is %.3f\n", 250 i, radMax->n, lastRadius); 251 252 psVector *radMinNew = psVectorRealloc(radMin, i); 253 if (radMinNew != radMin) { 254 psMetadataAddVector(recipe, PS_LIST_TAIL, "RADIAL.ANNULAR.BINS.LOWER", PS_META_REPLACE, "", radMinNew); 255 // XXX: I don't need this so I? 256 // psFree(radMinNew); 257 } 258 259 psVector *radMaxNew = psVectorRealloc(radMax, i); 260 if (radMaxNew != radMax) { 261 psMetadataAddVector(recipe, PS_LIST_TAIL, "RADIAL.ANNULAR.BINS.UPPER", PS_META_REPLACE, "", radMaxNew); 262 // XXX: I don't need to free this do I? 263 // psFree(radMaxNew); 264 } 265 266 return true; 267 } 268 204 269 // the area-weighted mean radius is given by: 205 270 -
branches/eam_branches/ipp-20120627/psphot/src/psphotReadout.c
r34086 r34247 185 185 186 186 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 187 psphotFitSourcesLinear (config, view, filerule, false ); // pass 1 (detections->allSources)187 psphotFitSourcesLinear (config, view, filerule, false, false); // pass 1 (detections->allSources) 188 188 189 189 // measure the radial profiles to the sky … … 212 212 // linear fit to include all sources (subtract again) 213 213 // NOTE : apply to ALL sources (extended + psf) 214 psphotFitSourcesLinear (config, view, filerule, true ); // pass 2 (detections->allSources)214 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 2 (detections->allSources) 215 215 216 216 // if we only do one pass, skip to extended source analysis … … 261 261 262 262 // NOTE: apply to ALL sources 263 psphotFitSourcesLinear (config, view, filerule, true ); // pass 3 (detections->allSources)263 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources) 264 264 } 265 265 … … 302 302 303 303 // NOTE: apply to ALL sources 304 psphotFitSourcesLinear (config, view, filerule, true ); // pass 3 (detections->allSources)304 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources) 305 305 } 306 306 -
branches/eam_branches/ipp-20120627/psphot/src/psphotReadoutForcedKnownSources.c
r32996 r34247 45 45 46 46 // linear PSF fit to source peaks 47 psphotFitSourcesLinear (config, view, filerule, false );47 psphotFitSourcesLinear (config, view, filerule, false, false); 48 48 49 49 // calculate source magnitudes -
branches/eam_branches/ipp-20120627/psphot/src/psphotReadoutKnownSources.c
r33692 r34247 57 57 58 58 // linear PSF fit to source peaks 59 psphotFitSourcesLinear (config, view, filerule, false );59 psphotFitSourcesLinear (config, view, filerule, false, false); 60 60 61 61 // measure aperture photometry corrections -
branches/eam_branches/ipp-20120627/psphot/src/psphotReadoutMinimal.c
r34190 r34247 81 81 82 82 // linear PSF fit to source peaks 83 psphotFitSourcesLinear (config, view, filerule, false );83 psphotFitSourcesLinear (config, view, filerule, false, false); 84 84 85 85 // measure the radial profiles to the sky -
branches/eam_branches/ipp-20120627/psphot/src/psphotReplaceUnfit.c
r33980 r34247 55 55 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 56 56 psAssert (readout, "missing readout?"); 57 58 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 59 psLogMsg ("psphot", PS_LOG_DETAIL, "skipping replace all sources for input file %d", index); 60 return true; 61 } 57 62 58 63 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); … … 304 309 psAssert (readout, "missing readout?"); 305 310 311 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 312 psLogMsg ("psphot", PS_LOG_DETAIL, "skipping reset models for input file %d", index); 313 return true; 314 } 315 316 306 317 // XXX the sources have already been copied (merge into here?) 307 318 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); -
branches/eam_branches/ipp-20120627/psphot/src/psphotSetThreads.c
r33964 r34247 40 40 psFree(task); 41 41 42 task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 1 4);42 task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 15); 43 43 task->function = &psphotExtendedSourceFits_Threaded; 44 44 psThreadTaskAdd(task); -
branches/eam_branches/ipp-20120627/psphot/src/psphotSourceSize.c
r34179 r34247 18 18 float sizeLimitCR; 19 19 float magLimitCR; 20 int maxWindowCR; 20 21 } psphotSourceSizeOptions; 21 22 … … 26 27 bool psphotSourceClassRegion (psRegion *region, pmPSFClump *psfClump, psArray *sources, psMetadata *recipe, pmPSF *psf, psphotSourceSizeOptions *options); 27 28 bool psphotSourceSelectCR (pmReadout *readout, psArray *sources, psphotSourceSizeOptions *options); 28 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal );29 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR); 29 30 bool psphotMaskCosmicRayFootprintCheck (psArray *sources); 30 31 int psphotMaskCosmicRayConnected (int xPeak, int yPeak, psImage *mymask, psImage *myvar, psImage *edges, int binning, float sigma_thresh); … … 139 140 if (!status) { 140 141 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CRMASK.APPLY is not defined."); 142 return false; 143 } 144 options.maxWindowCR = psMetadataLookupS32 (&status, recipe, "PSPHOT.CR.MAX.WINDOW"); 145 if (!status) { 146 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CR.MAX.WINDOW is not defined."); 141 147 return false; 142 148 } … … 647 653 psTrace("psphot", 6, "mask cosmic ray at %f, %f\n", source->peak->xf, source->peak->yf); 648 654 if (options->applyCRmask) { 649 psphotMaskCosmicRay(readout, source, options->crMask );655 psphotMaskCosmicRay(readout, source, options->crMask, options->maxWindowCR); 650 656 } else { 651 657 source->mode |= PM_SOURCE_MODE_CR_LIMIT; … … 687 693 // does no repair or recovery of the CR pixels, it only masks them out. My test code can be 688 694 // found at /data/ipp031.0/watersc1/psphot.20091209/algo_check.c 689 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal ) {695 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR) { 690 696 691 697 // Get the actual images and information about the peak. … … 699 705 int ys = footprint->bbox.y0; 700 706 int ye = footprint->bbox.y1 + 1; 707 708 // We occasionally get very large footprints. When the footprint bounding box is large this function will 709 // do an incredible amount of work for no benefit. 710 // Limit the size of the area we examine. 711 if (xe - xs > maxWindowCR) { 712 xs = peak->x - maxWindowCR / 2; 713 xe = xs + maxWindowCR; 714 } 715 if (ye - ys > maxWindowCR) { 716 ys = peak->y - maxWindowCR / 2; 717 ye = ys + maxWindowCR; 718 } 701 719 702 720 LIMIT_XRANGE(xs, mask); … … 741 759 for (int i = 0; i < footprint->spans->n; i++) { 742 760 pmSpan *sp = footprint->spans->data[i]; 743 for (int j = sp->x0; j <= sp->x1; j++) { 744 int y = sp->y - ys; 745 int x = j - xs; 761 int y = sp->y - ys; 762 if (y < 0 || y >= mymask->numRows) { 763 // can we break if y >= numRows? 764 continue; 765 } 766 for (int x = PS_MAX(sp->x0 - xs, 0); x <= PS_MIN(sp->x1 - xs, mymask->numCols-1); x++) { 746 767 mymask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= 0x01; 747 768 } … … 883 904 884 905 bool psphotMaskCosmicRayFootprintCheck (psArray *sources) { 885 906 #ifdef CHECK_FOOTPRINTS 907 // This gets really expensive for complex images 886 908 for (int i = 0; i < sources->n; i++) { 887 909 pmSource *source = sources->data[i]; … … 894 916 } 895 917 } 918 #endif 896 919 return true; 897 920 } -
branches/eam_branches/ipp-20120627/psphot/src/psphotStackImageLoop.c
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/ipp-20120627/psphot/src/psphotStackMatchPSFs.c
r32868 r34247 87 87 } 88 88 89 // copy the header data from Src to Out90 // pmHDU *hduSrc = pmHDUFromReadout(readoutSrc);91 // psAssert (hduSrc, "input missing hdu?");92 93 94 89 // set NAN pixels to 'SAT' 95 90 psImageMaskType maskSat = pmConfigMaskGet("SAT", config); … … 116 111 // save the output fwhm values in the readout->analysis. we may have / will have multiple output PSF sizes, 117 112 // so we save this in a vector. if the vector is not yet defined, create it 113 // Skip this if the readout deconvolution fraction was over the limit. 118 114 // NOTE: fwhmValues as defined here has 1 + nMatched PSF : 0 == unmatched 119 115 psVector *fwhmValues = psVectorAllocEmpty(10, PS_TYPE_F32); 120 116 psVectorAppend(fwhmValues, NAN); // XXX this corresponds to the unmatched image set 121 for (int i = 0; i < options->targetSeeing->n; i++) { 122 psVectorAppend(fwhmValues, options->targetSeeing->data.F32[i]); 117 118 bool overLimit = psMetadataLookupBool(NULL, readoutOut->analysis, "DECONV.OVERLIMIT"); 119 if (!overLimit) { 120 for (int i = 0; i < options->targetSeeing->n; i++) { 121 psVectorAppend(fwhmValues, options->targetSeeing->data.F32[i]); 122 } 123 123 } 124 124 psMetadataAddVector(readoutSrc->analysis, PS_LIST_TAIL, "STACK.PSF.FWHM.VALUES", PS_META_REPLACE, "PSF sizes", fwhmValues); -
branches/eam_branches/ipp-20120627/psphot/src/psphotStackMatchPSFsNext.c
r32996 r34247 7 7 int nRadialEntries = 0; 8 8 9 // find the currently selected readout 10 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest 11 psAssert (file, "missing file?"); 9 // find the numer of fwhmValues in the first non-skipped input 10 int num = psphotFileruleCount(config, filerule); 11 for (int i=0; i<num; i++) { 12 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 13 psAssert (file, "missing file?"); 12 14 13 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 14 psAssert (readout, "missing readout?"); 15 16 bool status = false; 17 psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES"); 18 if (!fwhmValues) { 19 return 1; 15 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 16 psAssert (readout, "missing readout?"); 17 bool status = false; 18 if (!psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 19 psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES"); 20 if (fwhmValues) { 21 nRadialEntries = fwhmValues->n; 22 } else { 23 nRadialEntries = 1; 24 } 25 break; 26 } 20 27 } 21 22 nRadialEntries = fwhmValues->n;23 28 return nRadialEntries; 24 29 } … … 60 65 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 61 66 psAssert (readout, "missing readout?"); 67 68 if (psMetadataLookupBool (&status, readout->analysis, "PSPHOT.SKIP.INPUT")) { 69 psLogMsg("psphot", PS_LOG_INFO, "skipping smooth %d to next psf", index); 70 return true; 71 } 62 72 63 73 psLogMsg("psphot", PS_LOG_INFO, "smooth %d to next psf", index); -
branches/eam_branches/ipp-20120627/psphot/src/psphotStackMatchPSFsUtils.c
r33841 r34247 310 310 float deconv = psMetadataLookupF32(NULL, readoutOut->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction 311 311 if (deconv > deconvLimit) { 312 #if (1) 313 // XXX: don't reject the image set 314 psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image for matched psf analysis%d\n", deconv, deconvLimit, index); 315 psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "DECONV.OVERLIMIT", PS_META_REPLACE, "", true); 316 #else 312 317 psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image %d\n", deconv, deconvLimit, index); 313 318 goto escape; 319 #endif 320 } else { 321 psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "DECONV.OVERLIMIT", PS_META_REPLACE, "", false); 314 322 } 315 323 … … 461 469 return optWidths; 462 470 } 471 472 // Set input to be skipped if the decovolution fraction was overlimit. Use for radial apertures 473 // This interface can be potentiall be extended for other uses 474 bool psphotStackSetInputsToSkip(pmConfig *config, const pmFPAview *view, const char *filerule, bool set) { 475 int num = psphotFileruleCount(config, filerule); 476 bool status; 477 int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM"); 478 if (!status) chisqNum = -1; 479 for (int i = 0; i < num; i++) { 480 if (i == chisqNum) { 481 continue; 482 } 483 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 484 psAssert (file, "missing file?"); 485 486 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 487 psAssert (readout, "missing readout?"); 488 if (set) { 489 bool overLimit = psMetadataLookupBool(&status, readout->analysis, "DECONV.OVERLIMIT"); 490 psMetadataAddBool(readout->analysis, PS_LIST_TAIL, "PSPHOT.SKIP.INPUT", PS_META_REPLACE, "Skip analysis", overLimit); 491 } else { 492 psMetadataAddBool(readout->analysis, PS_LIST_TAIL, "PSPHOT.SKIP.INPUT", PS_META_REPLACE, "Skip analysis", false); 493 } 494 } 495 496 return true; 497 } -
branches/eam_branches/ipp-20120627/psphot/src/psphotStackReadout.c
r33958 r34247 1 1 # include "psphotInternal.h" 2 3 static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule); 2 4 3 5 // we have 3 possible real filesets: … … 67 69 char *STACK_SRC = useRaw ? STACK_RAW : STACK_CNV; 68 70 char *STACK_DET = STACK_RAW; 71 72 // load WCS 73 if (!psphotStackLoadWCS(config, view, STACK_SRC)) { 74 psError (PSPHOT_ERR_CONFIG, false, "trouble loading WCS for %s", STACK_SRC); 75 return false; 76 } 69 77 70 78 // set the photcode for each image … … 179 187 180 188 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 181 psphotFitSourcesLinear (config, view, STACK_SRC, false );189 psphotFitSourcesLinear (config, view, STACK_SRC, false, false); 182 190 psphotStackVisualFilerule(config, view, STACK_SRC); 183 191 … … 207 215 // NOTE : apply to ALL sources (extended + psf) 208 216 // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET 209 psphotFitSourcesLinear (config, view, STACK_SRC, true ); // pass 2 (detections->allSources)217 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 2 (detections->allSources) 210 218 211 219 // NOTE: possibly re-measure background model here with objects subtracted / or masked … … 278 286 } 279 287 288 // gcc doesn't like the label to refer to a declaration so we declare this here 289 bool splitLinearFit; 290 280 291 pass1finish: 292 293 splitLinearFit = psMetadataLookupBool(NULL, recipe, "PSPHOT.STACK.SPLIT.LINEAR.FIT"); 294 if (splitLinearFit) { 295 psLogMsg ("psphot", 3, "splitting fit of detected and matched soures\n"); 296 // Fit the detected sources separately from matched that wea are about to create. 297 // NOTE: apply to ALL sources but only include sources with postitive flux in the fit 298 psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources) 299 } 281 300 282 301 // generate the objects (objects unify the sources from the different images) NOTE: could … … 286 305 psMemDump("matchsources"); 287 306 307 // check the source density. If it too high change the number of radial bins 308 // in the recipe. 309 psphotLimitRadialApertures(recipe, objects->n); 310 288 311 // Construct an initial model for each object, set the radius to fitRadius, set circular 289 312 // fit mask. NOTE: only applied to sources without guess models … … 294 317 psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects); 295 318 296 // NOTE: apply to ALL sources 297 psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources) 319 if (splitLinearFit) { 320 // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will 321 // not be included in this fit. 322 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources) 323 } else { 324 // Fit all sources together 325 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources) 326 } 298 327 299 328 // measure the radial profiles to the sky (only measures new objects) … … 344 373 } 345 374 } 346 psphotRadialApertures (config, view, STACK_CNV, 0); // XXX entry 0 == unmatched?375 psphotRadialApertures (config, view, STACK_CNV, 0); // entry 0 == unmatched 347 376 psMemDump("extmeas"); 348 377 378 // mark any inputs that we want to skip the matched apertures for 379 psphotStackSetInputsToSkip(config, view, STACK_OUT, true); 380 349 381 int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT); 350 351 382 for (int entry = 1; entry < nRadialEntries; entry++) { 352 383 // NOTE: entry 0 is the unmatched image set … … 359 390 360 391 // this is necessary to get the right normalization for the new models 361 psphotFitSourcesLinear (config, view, STACK_OUT, false );392 psphotFitSourcesLinear (config, view, STACK_OUT, false, false); 362 393 363 394 // measure circular, radial apertures (objects sorted by S/N) 364 // entry 0 == unmatched? pass entry + 1?365 395 psphotRadialApertures (config, view, STACK_OUT, entry); 366 396 … … 373 403 } 374 404 } 405 psphotStackSetInputsToSkip(config, view, STACK_OUT, false); 375 406 376 407 // measure aperture photometry corrections … … 413 444 // create the exported-metadata and free local data 414 445 return psphotReadoutCleanup (config, view, STACK_SRC); 446 } 447 448 static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule) { 449 450 int num = psphotFileruleCount(config, filerule); 451 452 for (int i=0; i<num; i++) { 453 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 454 psAssert (file, "missing file?"); 455 456 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 457 psAssert (readout, "missing readout?"); 458 459 pmHDU *hdu = pmHDUFromReadout(readout); 460 psAssert (hdu, "input missing hdu?"); 461 462 if (!pmAstromReadWCS(file->fpa, readout->parent->parent, hdu->header, 1.0)) { 463 psError (PSPHOT_ERR_UNKNOWN, false, "failed to read WCS from header for input %d", i); 464 return false; 465 } 466 } 467 return true; 415 468 } 416 469
Note:
See TracChangeset
for help on using the changeset viewer.
