Changeset 42293
- Timestamp:
- Sep 27, 2022, 5:08:10 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
-
ippconfig/gpc2/pswarp.config (added)
-
ippconfig/recipes/ppImage.config (modified) (1 diff)
-
ippconfig/recipes/pswarp.config (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (1 diff)
-
ppImage/src/ppImageSetMaskBits.c (modified) (2 diffs)
-
ppSub/src/ppSubSetMasks.c (modified) (1 diff)
-
psModules/src/objects/pmSourceMasks.h (modified) (1 diff)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (8 diffs)
-
psastro/src/psastroConvert.c (modified) (5 diffs)
-
pswarp/src/pswarpSetMaskBits.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippconfig/recipes/ppImage.config
r41898 r42293 21 21 APPLY.BURNTOOL BOOL FALSE # apply burntool coorection 22 22 APPLY.PIXELZERO BOOL FALSE # apply zero'ing of pixels underneath masks 23 DETECT.CTE BOOL FALSE # perform object detections in the CTE regions 23 24 VARIANCE.BUILD BOOL FALSE # Build internal variance image 24 25 ADDNOISE BOOL FALSE # Add noise to degrade an MD image to a 3pi image? -
trunk/ippconfig/recipes/pswarp.config
r42100 r42293 13 13 SOURCES BOOL TRUE # Write source list for warped image? 14 14 APPLY.PIXELNAN BOOL FALSE # Apply NAN'ing of pixels underneath masks 15 DETECT.CTE BOOL FALSE # perform object detections in the CTE regions 15 16 16 17 # as of r41891, dvoImageOverlaps compares the header keyword CERSTD to MAX.CERROR -
trunk/ppImage/src/ppImage.h
r41894 r42293 156 156 ppImageOptions *ppImageParseCamera(pmConfig *config); 157 157 bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options); 158 bool ppImageMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned 159 psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned 160 psMetadata *source // Source of mask bits 161 ); 158 162 159 163 // apply the cell flips to the input data before analysis -
trunk/ppImage/src/ppImageSetMaskBits.c
r37406 r42293 5 5 #include "ppImage.h" 6 6 7 // Structure to hold the properties of a mask value 8 typedef struct { 9 char *badMaskName; // name for "bad" (i.e., mask me please) pixels 10 char *fallbackName; // Fallback name in case a bad mask name is not defined 11 psImageMaskType defaultMaskValue; // Default value in case a bad mask name and its fallback are not defined 12 bool isBad; // include this value as part of the MASK.VALUE entry (generically bad) 13 } pmConfigMaskInfo; 14 15 static pmConfigMaskInfo ppimagemasks[] = { 16 // Features of the detector 17 { "DETECTOR", NULL, 0x01, true }, // Something is wrong with the detector 18 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 19 { "DARK", "DETECTOR", 0x01, true }, // Pixel doesn't dark-subtract properly 20 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 21 { "CTE", "DETECTOR", 0x01, false }, // Pixel has poor CTE 22 { "BURNTOOL", NULL, 0x04, false }, // Pixel has been touched by burntool 23 // Invalid signal ranges 24 { "SAT", NULL, 0x02, true }, // Pixel is saturated or non-linear 25 { "LOW", "SAT", 0x02, true }, // Pixel is low 26 { "SUSPECT", NULL, 0x04, false }, // Pixel is suspected of being bad 27 // Non-astronomical structures 28 { "CR", NULL, 0x08, true }, // Pixel contains a cosmic ray 29 { "SPIKE", NULL, 0x08, false }, // Pixel contains a diffraction spike 30 { "GHOST", NULL, 0x08, false }, // Pixel contains an optical ghost 31 { "STREAK", NULL, 0x08, false }, // Pixel contains a streak 32 { "CROSSTALK", NULL, 0x08, false }, // Pixel contains crosstalk data 33 { "STARCORE", NULL, 0x08, false }, // Pixel contains a bright star core 34 // Effects of convolution and interpolation 35 { "CONV.BAD", NULL, 0x02, true }, // Pixel is bad after convolution with a bad pixel 36 { "CONV.POOR", NULL, 0x04, false }, // Pixel is poor after convolution with a bad pixel 37 }; 38 7 39 bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options) { 8 40 9 if (!pmConfigMaskSetBits(&options->maskValue, &options->markValue, config)) { 10 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 11 return false; 41 42 // Look up recipe values 43 psMetadata *pprecipe = psMetadataLookupMetadata(NULL, config->recipes, RECIPE_NAME); 44 45 psAssert(pprecipe, "We checked this earlier, so it should be here."); 46 bool doDetectCTE = psMetadataLookupBool(NULL, pprecipe, "DETECT.CTE"); // Do detections on pixels underneath CTE masks 47 48 // this function sets the required single-image mask bits 49 if(!doDetectCTE) { 50 if (!pmConfigMaskSetBits (&options->maskValue, &options->markValue, config)) { 51 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 52 return false; 53 } 54 } else { 55 psMetadata *maskrecipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 56 if (!maskrecipe) { 57 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 58 return false; 59 } 60 if (!ppImageMaskSetInMetadata(&options->maskValue, &options->markValue, maskrecipe)) { 61 psError (PS_ERR_UNKNOWN, true, "Unable to determine the mask value"); 62 return false; 63 } 12 64 } 13 65 … … 63 115 return true; 64 116 } 117 118 119 bool ppImageMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned 120 psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned 121 psMetadata *source // Source of mask bits 122 ) 123 { 124 PS_ASSERT_METADATA_NON_NULL(source, false); 125 126 // Ensure all the bad mask names exist, and set the value to catch all bad pixels 127 psImageMaskType maskValue = 0; // Value to mask to catch all the bad pixels 128 psImageMaskType allMasks = 0; // Value to mask to catch all masked bits (to set MARK) 129 130 int nMasks = sizeof (ppimagemasks) / sizeof (pmConfigMaskInfo); 131 132 for (int i = 0; i < nMasks; i++) { 133 bool mdok; // Status of MD lookup 134 psImageMaskType value = psMetadataLookupImageMaskFromGeneric(&mdok, source, ppimagemasks[i].badMaskName); // Value of mask 135 if (!mdok) { 136 psWarning ("problem with mask value %s\n", ppimagemasks[i].badMaskName); 137 } 138 139 if (!value) { 140 if (ppimagemasks[i].fallbackName) { 141 value = psMetadataLookupImageMaskFromGeneric(&mdok, source, ppimagemasks[i].fallbackName); 142 } 143 if (!value) { 144 value = ppimagemasks[i].defaultMaskValue; 145 } 146 psMetadataAddImageMask(source, PS_LIST_TAIL, ppimagemasks[i].badMaskName, PS_META_REPLACE, NULL, value); 147 } 148 if (ppimagemasks[i].isBad) { 149 maskValue |= value; 150 } 151 allMasks |= value; 152 } 153 154 // search for an unset bit to use for MARK: 155 psImageMaskType markValue = 0x00; 156 psImageMaskType markTrial = 0x01; 157 158 int nBits = sizeof(psImageMaskType) * 8; 159 for (int i = 0; !markValue && (i < nBits); i++) { 160 if (allMasks & markTrial) { 161 markTrial <<= 1; 162 } else { 163 markValue = markTrial; 164 } 165 } 166 if (!markValue) { 167 psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!"); 168 return false; 169 } 170 171 // update the list with the results 172 psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue); 173 psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue); 174 175 if (outMaskValue) { 176 *outMaskValue = maskValue; 177 } 178 if (outMarkValue) { 179 *outMarkValue = markValue; 180 } 181 182 return true; 183 } 184 -
trunk/ppSub/src/ppSubSetMasks.c
r41707 r42293 32 32 static pmConfigMaskInfo skycellmasks[] = { 33 33 // Features of the detector 34 { "DETECTOR", NULL, 0x01, false }, // Something is wrong with the detector35 { "FLAT", "DETECTOR", 0x01, false }, // Pixel doesn't flat-field properly36 { "DARK", "DETECTOR", 0x01, false }, // Pixel doesn't dark-subtract properly34 { "DETECTOR", NULL, 0x01, true }, // Something is wrong with the detector 35 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 36 { "DARK", "DETECTOR", 0x01, true }, // Pixel doesn't dark-subtract properly 37 37 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 38 38 { "CTE", "DETECTOR", 0x01, false }, // Pixel has poor CTE -
trunk/psModules/src/objects/pmSourceMasks.h
r41705 r42293 72 72 PM_SOURCE_MODE2_ON_GHOST = 0x00800000, ///< > 25% of (PSF-weighted) pixels land on ghost 73 73 PM_SOURCE_MODE2_ON_CROSSTALK = 0x01000000, ///< peaks land on electronic crostalk 74 PM_SOURCE_MODE2_ON_CTE = 0x02000000, ///< peaks land on CTE region 74 75 75 76 -
trunk/psModules/src/objects/pmSourcePhotometry.c
r41705 r42293 53 53 54 54 // make this a bit more clever and dynamic 55 static psImageMaskType maskSuspect = 0; 56 static psImageMaskType maskSpike = 0; 57 static psImageMaskType maskStarCore = 0; 58 static psImageMaskType maskBurntool = 0; 59 static psImageMaskType maskConvPoor = 0; 60 static psImageMaskType maskGhost = 0; 61 static psImageMaskType maskGlint = 0; 62 static psImageMaskType maskCrosstalk = 0; 55 static psImageMaskType maskSuspect = 0; 56 static psImageMaskType maskSpike = 0; 57 static psImageMaskType maskStarCore = 0; 58 static psImageMaskType maskBurntool = 0; 59 static psImageMaskType maskConvPoor = 0; 60 static psImageMaskType maskGhost = 0; 61 static psImageMaskType maskGlint = 0; 62 static psImageMaskType maskCrosstalk = 0; 63 static psImageMaskType maskCTE = 0; 63 64 64 65 bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe) … … 69 70 // we are going to test specially against these poor values 70 71 if (config) { 71 maskSpike = pmConfigMaskGet("SPIKE", config); 72 maskStarCore = pmConfigMaskGet("STARCORE", config); 73 maskBurntool = pmConfigMaskGet("BURNTOOL", config); 74 maskConvPoor = pmConfigMaskGet("CONV.POOR", config); 75 maskGhost = pmConfigMaskGet("GHOST", config); 76 maskGlint = pmConfigMaskGet("GHOST", config); 77 maskCrosstalk = pmConfigMaskGet("CROSSTALK", config); 78 maskSuspect = maskSpike | maskStarCore | maskBurntool | maskConvPoor; 72 maskSpike = pmConfigMaskGet("SPIKE", config); 73 maskStarCore = pmConfigMaskGet("STARCORE", config); 74 maskBurntool = pmConfigMaskGet("BURNTOOL", config); 75 maskConvPoor = pmConfigMaskGet("CONV.POOR", config); 76 maskGhost = pmConfigMaskGet("GHOST", config); 77 maskGlint = pmConfigMaskGet("GHOST", config); 78 maskCrosstalk = pmConfigMaskGet("CROSSTALK", config); 79 maskCTE = pmConfigMaskGet("CTE", config); 80 maskSuspect = maskSpike | maskStarCore | maskBurntool | maskConvPoor; 79 81 } 80 82 … … 440 442 float convpoorSum = 0; 441 443 float ghostSum = 0; 444 float cteSum = 0; 442 445 443 446 int Xo, Yo, dP; … … 534 537 convpoorSum += value; 535 538 } 539 // count pixels which are masked with an mask bit (bad or poor) 540 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskCTE) { 541 cteSum += value; 542 } 543 536 544 } 537 545 } … … 555 563 if ((convpoorSum/modelSum) > 0.25) { 556 564 source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR; 565 } 566 if ((cteSum/modelSum) > 0.25) { 567 source->mode2 |= PM_SOURCE_MODE2_ON_CTE; 557 568 } 558 569 … … 614 625 float convpoorSum = 0; 615 626 float ghostSum = 0; 627 float cteSum = 0; 616 628 617 629 int Xo, Yo, dP; … … 683 695 convpoorSum += 1.; 684 696 } 697 // count pixels which are masked with an mask bit (bad or poor) 698 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskCTE) { 699 cteSum += 1.; 700 } 685 701 } 686 702 } … … 701 717 if ((convpoorSum/modelSum) > 0.25) { 702 718 source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR; 719 } 720 if ((cteSum/modelSum) > 0.25) { 721 source->mode2 |= PM_SOURCE_MODE2_ON_CTE; 703 722 } 704 723 -
trunk/psastro/src/psastroConvert.c
r41895 r42293 18 18 # define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_BLEND | PM_SOURCE_MODE_BADPSF | \ 19 19 PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT | \ 20 PM_SOURCE_MODE_POOR ) // Mask to apply to sources for rejection20 PM_SOURCE_MODE_POOR ) // Mask to apply to sources for rejection 21 21 22 22 static psArray *chooseStars(psArray *inStars, char *listName, psArray *sources, psVector *index, int nMax, float iMagMin, float iMagMax, pmSourceMode skip); … … 193 193 int nBrightSkip = 0; 194 194 int nInfSkip = 0; 195 int nCTESkip = 0; 195 196 196 197 for (int i = 0; (i < inStars->n) && (j < rawStars->n); i++) { … … 217 218 continue; 218 219 } 220 //Also kick out stars that touch the CTE region 221 if (source->mode2 & PM_SOURCE_MODE2_ON_CTE) { 222 nCTESkip ++; 223 continue; 224 } 225 219 226 mMin = PS_MIN (mMin, source->psfMag); 220 227 mMax = PS_MAX (mMax, source->psfMag); … … 225 232 226 233 psLogMsg ("psastro", 4, "loaded %ld %ssources, using %ld of %ld good sources (inst mag: %f to %f)\n", sources->n, listName, rawStars->n, inStars->n, mMin, mMax); 227 psLogMsg ("psastro", 4, "skip reasons: mode: %d, faint: %d, bright: %d, inf: %d \n", nModeSkip, nFaintSkip, nBrightSkip, nInfSkip);234 psLogMsg ("psastro", 4, "skip reasons: mode: %d, faint: %d, bright: %d, inf: %d, CTE: %d\n", nModeSkip, nFaintSkip, nBrightSkip, nInfSkip,nCTESkip); 228 235 229 236 return rawStars; … … 509 516 float myPltScale = fabs(pltScale[chipID]); 510 517 518 psLogMsg ("psastro.correctKH", PS_LOG_INFO, "applying KH correction to %s (%d)\n", chipName, chipID); 519 511 520 // apply the correction to the detections 512 521 for (int i = 0; i < inStars->n; i++) { -
trunk/pswarp/src/pswarpSetMaskBits.c
r27096 r42293 20 20 * updated in the config metadata. 21 21 */ 22 22 23 bool pswarpSetMaskBits (pmConfig *config) 23 24 { … … 26 27 psImageMaskType maskOut = 0x00; // mask for the output image 27 28 29 // Look up recipe values 30 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PSWARP_RECIPE); // Recipe for ppSim 31 psAssert(recipe, "We checked this earlier, so it should be here."); 32 bool doDetectCTE = psMetadataLookupBool(NULL, recipe, "DETECT.CTE"); // Do detections on pixels underneath CTE masks 33 28 34 // this function sets the required single-image mask bits 29 if (!pmConfigMaskSetBits (&maskIn, &markIn, config)) { 30 psError (psErrorCodeLast(), false, "Unable to define the mask bit values"); 31 return false; 35 if(!doDetectCTE) { 36 if (!pmConfigMaskSetBits (&maskIn, &markIn, config)) { 37 psError (psErrorCodeLast(), false, "Unable to define the mask bit values"); 38 return false; 39 } 40 } else { 41 psMetadata *maskrecipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 42 if (!maskrecipe) { 43 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 44 return false; 45 } 46 if (!pswarpMaskSetInMetadata(&maskIn, &markIn, maskrecipe)) { 47 psError (psErrorCodeLast(), false, "Unable to determine the mask value"); 48 return false; 49 } 32 50 } 33 51 34 52 // mask for non-linear flat regions (default to DETECTOR if not defined) 35 53 psImageMaskType badMask = pmConfigMaskGet("CONV.BAD", config);
Note:
See TracChangeset
for help on using the changeset viewer.
