Changeset 26793
- Timestamp:
- Feb 5, 2010, 3:11:11 PM (16 years ago)
- Location:
- branches/eam_branches/20091201
- Files:
-
- 4 edited
-
ppImage/src/ppImageBurntoolMask.c (modified) (5 diffs)
-
psphot/src/psphotLoadPSF.c (modified) (4 diffs)
-
psphot/src/psphotMergeSources.c (modified) (11 diffs)
-
psphot/src/psphotReadout.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppImage/src/ppImageBurntoolMask.c
r26765 r26793 3 3 #endif 4 4 5 #define PPIMAGE_BURNTOOL_DEBUG 15 #define PPIMAGE_BURNTOOL_DEBUG 0 6 6 7 7 #include "ppImage.h" … … 23 23 return(false); 24 24 } 25 long Nrows = psFitsTableSize(fits); 25 long Nrows = psFitsTableSize(fits); 26 26 27 27 long row = 0; … … 33 33 psImage *image = mask->mask; 34 34 35 35 36 36 /* Set the maskValue from the recipes. */ 37 37 psImageMaskType maskValue = options->burntoolMask; 38 #if defPPIMAGE_BURNTOOL_DEBUG38 #if PPIMAGE_BURNTOOL_DEBUG 39 39 psLogMsg("ppImageBurntoolMask", 4, "Status: %ld %d\n",Nrows,maskValue); 40 40 #endif … … 48 48 if (psMetadataLookupS32(&status,rowMD,"cell") == burntool_cell) { 49 49 if (((options->burntoolTrails & 0x01)&&(psMetadataLookupS32(&status,rowMD,"func") == 4))|| 50 (((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||51 ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)))) {52 /* If the fit fails, burntool reports zero here. This53 signifies that it expected to see a trail (else why54 fit) but did not find it when it attempted to55 correct. */56 #if defPPIMAGE_BURNTOOL_DEBUG57 psLogMsg ("ppImageBurntoolMask", 4, "Masking! %d (%d %d %d) %d %d",58 psMetadataLookupS32(&status,rowMD,"cell"),59 ((options->burntoolTrails & 0x0001)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0)),60 ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1)),61 ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)),62 options->burntoolTrails,63 maskValue64 );50 (((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))|| 51 ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)))) { 52 /* If the fit fails, burntool reports zero here. This 53 signifies that it expected to see a trail (else why 54 fit) but did not find it when it attempted to 55 correct. */ 56 #if PPIMAGE_BURNTOOL_DEBUG 57 psLogMsg ("ppImageBurntoolMask", 4, "Masking! %d (%d %d %d) %d %d", 58 psMetadataLookupS32(&status,rowMD,"cell"), 59 ((options->burntoolTrails & 0x0001)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0)), 60 ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1)), 61 ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)), 62 options->burntoolTrails, 63 maskValue 64 ); 65 65 #endif 66 for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");67 i <= psMetadataLookupS32(&status,rowMD,"exfit");68 i++) {66 for (int i = psMetadataLookupS32(&status,rowMD,"sxfit"); 67 i <= psMetadataLookupS32(&status,rowMD,"exfit"); 68 i++) { 69 69 70 if (psMetadataLookupS32(&status,rowMD,"up") == 0) {71 for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {72 #if defPPIMAGE_BURNTOOL_DEBUG73 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",74 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);70 if (psMetadataLookupS32(&status,rowMD,"up") == 0) { 71 for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) { 72 #if PPIMAGE_BURNTOOL_DEBUG 73 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 74 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 75 75 #endif 76 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;77 }78 }79 else {80 for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {81 #if defPPIMAGE_BURNTOOL_DEBUG82 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",83 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);76 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 77 } 78 } 79 else { 80 for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) { 81 #if PPIMAGE_BURNTOOL_DEBUG 82 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 83 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 84 84 #endif 85 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;86 }87 }88 }85 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 86 } 87 } 88 } 89 89 90 90 } … … 95 95 return(status); 96 96 } 97 98 99 100 -
branches/eam_branches/20091201/psphot/src/psphotLoadPSF.c
r26788 r26793 17 17 // find the currently selected readout 18 18 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 19 psAssert (file, "missing file?"); 19 if (file == NULL) { 20 psLogMsg ("psphot", 3, "no psf supplied for this chip"); 21 return true; 22 } 20 23 21 24 // find the currently selected chip … … 35 38 36 39 if (!psphotPSFstats (readout, psf)) { 37 psAbort("cannot measure PSF shape terms");40 psAbort("cannot measure PSF shape terms"); 38 41 } 39 42 … … 42 45 // save PSF on readout->analysis 43 46 if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", psf)) { 44 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");47 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout"); 45 48 return false; 46 49 } … … 60 63 for (int i = 0; i < num; i++) { 61 64 62 // Generate the mask and weight images, including the user-defined analysis region of interest63 if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) {65 // Generate the mask and weight images, including the user-defined analysis region of interest 66 if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) { 64 67 psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i); 65 return false;66 }68 return false; 69 } 67 70 } 68 71 return true; -
branches/eam_branches/20091201/psphot/src/psphotMergeSources.c
r26788 r26793 15 15 // loop over the available readouts 16 16 for (int i = 0; i < num; i++) { 17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) { 18 18 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i); 19 return false;20 }19 return false; 20 } 21 21 } 22 22 return true; … … 43 43 // XXX TEST: 44 44 if (detections->allSources) { 45 psphotMaskCosmicRayFootprintCheck(detections->allSources);45 psphotMaskCosmicRayFootprintCheck(detections->allSources); 46 46 } 47 47 if (detections->newSources) { 48 psphotMaskCosmicRayFootprintCheck(detections->newSources);48 psphotMaskCosmicRayFootprintCheck(detections->newSources); 49 49 } 50 50 51 51 if (!detections->allSources) { 52 detections->allSources = psArrayAllocEmpty(newSources->n);52 detections->allSources = psArrayAllocEmpty(newSources->n); 53 53 } 54 54 psArray *allSources = detections->allSources; … … 87 87 psAssert (detections, "missing detections?"); 88 88 89 // XXX allSources o fnewSources?89 // XXX allSources or newSources? 90 90 psArray *sources = detections->allSources; 91 91 psAssert (sources, "missing sources?"); … … 96 96 if (!readoutCMF) goto loadTXT; 97 97 98 extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");99 if (extCMF) {100 for (int i = 0; i < extCMF->allSources->n; i++) {101 pmSource *source = extCMF->allSources->data[i];102 source->mode |= PM_SOURCE_MODE_EXTERNAL;98 extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS"); 99 if (extCMF) { 100 for (int i = 0; i < extCMF->allSources->n; i++) { 101 pmSource *source = extCMF->allSources->data[i]; 102 source->mode |= PM_SOURCE_MODE_EXTERNAL; 103 103 104 104 // the supplied peak flux needs to be re-normalized … … 106 106 source->peak->value = 1.0; 107 107 108 // drop the loaded source modelPSF109 psFree (source->modelPSF);110 source->modelPSF = NULL;111 112 psArrayAdd (detections->allSources, 100, source);113 }114 }108 // drop the loaded source modelPSF 109 psFree (source->modelPSF); 110 source->modelPSF = NULL; 111 112 psArrayAdd (detections->allSources, 100, source); 113 } 114 } 115 115 } 116 116 … … 128 128 source->mode |= PM_SOURCE_MODE_EXTERNAL; 129 129 130 // drop the loaded source modelPSF131 psFree (source->modelPSF);132 source->modelPSF = NULL;133 134 psArrayAdd (detections->allSources, 100, source);135 }136 }130 // drop the loaded source modelPSF 131 psFree (source->modelPSF); 132 source->modelPSF = NULL; 133 134 psArrayAdd (detections->allSources, 100, source); 135 } 136 } 137 137 } 138 138 … … 168 168 if (!detections) { 169 169 psLogMsg ("psphot", 3, "no psf sources for this readout"); 170 return NULL;170 return NULL; 171 171 } 172 172 … … 174 174 if (!sources) { 175 175 psLogMsg ("psphot", 3, "no psf sources for this readout"); 176 return NULL;176 return NULL; 177 177 } 178 178 … … 212 212 213 213 // generate the detection structure for the supplied array of sources 214 // XXX this currently assumes there is a single input file 214 // XXX this currently assumes there is a single input file 215 215 bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, psArray *sources) { 216 216 … … 274 274 // save detections on the readout->analysis 275 275 if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detectinos", detections)) { 276 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");277 return false;276 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 277 return false; 278 278 } 279 279 psFree (detections); … … 343 343 344 344 if (sources->n) { 345 // the user wants to make the psf from these stars; define them as psf stars:346 for (int i = 0; i < sources->n; i++) {347 pmSource *source = sources->data[i];348 source->mode |= PM_SOURCE_MODE_PSFSTAR;349 }350 // force psphotChoosePSF to use all loaded sources351 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);352 353 // measure stats of externally specified sources354 if (!psphotSourceStatsUpdate (sources, config, readout)) {355 psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");356 return false;357 }345 // the user wants to make the psf from these stars; define them as psf stars: 346 for (int i = 0; i < sources->n; i++) { 347 pmSource *source = sources->data[i]; 348 source->mode |= PM_SOURCE_MODE_PSFSTAR; 349 } 350 // force psphotChoosePSF to use all loaded sources 351 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n); 352 353 // measure stats of externally specified sources 354 if (!psphotSourceStatsUpdate (sources, config, readout)) { 355 psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources"); 356 return false; 357 } 358 358 } else { 359 359 360 // find the detections (by peak and/or footprint) in the image.361 if (!psphotFindDetections (config, view, true)) {362 psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");363 return psphotReadoutCleanup (config, view);364 }365 366 // construct sources and measure basic stats367 psphotSourceStats (config, view, true);368 369 // find blended neighbors of very saturated stars370 psphotDeblendSatstars (config, view);371 372 // mark blended peaks PS_SOURCE_BLEND373 if (!psphotBasicDeblend (config, view)) {374 psLogMsg ("psphot", 3, "failed on deblend analysis");375 return psphotReadoutCleanup (config, view);376 }377 378 // classify sources based on moments, brightness379 if (!psphotRoughClass (config, view)) {380 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");381 return psphotReadoutCleanup (config, view);382 }383 } 384 385 return true; 386 } 360 // find the detections (by peak and/or footprint) in the image. 361 if (!psphotFindDetections (config, view, true)) { 362 psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image"); 363 return psphotReadoutCleanup (config, view); 364 } 365 366 // construct sources and measure basic stats 367 psphotSourceStats (config, view, true); 368 369 // find blended neighbors of very saturated stars 370 psphotDeblendSatstars (config, view); 371 372 // mark blended peaks PS_SOURCE_BLEND 373 if (!psphotBasicDeblend (config, view)) { 374 psLogMsg ("psphot", 3, "failed on deblend analysis"); 375 return psphotReadoutCleanup (config, view); 376 } 377 378 // classify sources based on moments, brightness 379 if (!psphotRoughClass (config, view)) { 380 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 381 return psphotReadoutCleanup (config, view); 382 } 383 } 384 385 return true; 386 } -
branches/eam_branches/20091201/psphot/src/psphotReadout.c
r26788 r26793 56 56 return psphotReadoutCleanup (config, view); 57 57 } 58 58 59 59 // find the detections (by peak and/or footprint) in the image. 60 60 if (!psphotFindDetections (config, view, true)) { // pass 1 61 // this only happens if we had an error in psphotFindDetections61 // this only happens if we had an error in psphotFindDetections 62 62 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 63 63 return psphotReadoutCleanup (config, view); … … 104 104 // this step is skipped 105 105 if (!psphotChoosePSF (config, view)) { // pass 1 106 psLogMsg ("psphot", 3, "failure to construct a psf model");107 return psphotReadoutCleanup (config, view);106 psLogMsg ("psphot", 3, "failure to construct a psf model"); 107 return psphotReadoutCleanup (config, view); 108 108 } 109 109 if (!strcasecmp (breakPt, "PSFMODEL")) { … … 113 113 // include externally-supplied sources 114 114 // XXX fix this in the new multi-input context 115 psphotLoadExtSources (config, view); // pass 1115 // psphotLoadExtSources (config, view); // pass 1 116 116 117 117 // construct an initial model for each object, set the radius to fitRadius, set circular … … 121 121 // merge the newly selected sources into the existing list 122 122 // NOTE: merge OLD and NEW 123 psphotMergeSources (config, view); 123 psphotMergeSources (config, view); 124 124 125 125 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
Note:
See TracChangeset
for help on using the changeset viewer.
