Changeset 24244 for branches/cnb_branches/cnb_branch_20090301/ppMerge/src
- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 10 edited
- 1 copied
-
. (modified) (1 prop)
-
ppMerge/src (modified) (1 prop)
-
ppMerge/src/Makefile.am (modified) (1 diff)
-
ppMerge/src/ppMerge.c (modified) (1 diff)
-
ppMerge/src/ppMergeArguments.c (modified) (4 diffs)
-
ppMerge/src/ppMergeErrorCodes.dat (modified) (1 diff)
-
ppMerge/src/ppMergeErrorCodes.h.in (modified) (1 diff)
-
ppMerge/src/ppMergeLoop.c (modified) (6 diffs)
-
ppMerge/src/ppMergeMask.c (modified) (5 diffs)
-
ppMerge/src/ppMergeVersion.c (modified) (3 diffs)
-
ppMerge/src/ppMergeVersionDefinitions.h.in (copied) (copied from trunk/ppMerge/src/ppMergeVersionDefinitions.h.in )
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppMerge/src
- Property svn:ignore
-
old new 7 7 stamp-h1 8 8 .libs 9 ppMergeVersionDefinitions.h
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/Makefile.am
r23594 r24244 1 1 bin_PROGRAMS = ppMerge 2 2 3 # PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppMergeVersion.c, since it gets the version information 8 # ppMergeVersion.c: FORCE 9 # touch ppMergeVersion.c 10 # FORCE: ; 3 if HAVE_SVNVERSION 4 PPMERGE_VERSION=`$(SVNVERSION) ..` 5 else 6 PPMERGE_VERSION="UNKNOWN" 7 endif 11 8 12 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=$(SVN_VERSION) -DPPMERGE_BRANCH=$(SVN_BRANCH) -DPPMERGE_SOURCE=$(SVN_SOURCE) 9 if HAVE_SVN 10 PPMERGE_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'` 11 PPMERGE_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'` 12 else 13 PPMERGE_BRANCH="UNKNOWN" 14 PPMERGE_SOURCE="UNKNOWN" 15 endif 16 17 # Force recompilation of ppMergeVersion.c, since it gets the version information 18 ppMergeVersion.c: ppMergeVersionDefinitions.h 19 ppMergeVersionDefinitions.h: ppMergeVersionDefinitions.h.in FORCE 20 -$(RM) ppMergeVersionDefinitions.h 21 $(SED) -e "s|@PPMERGE_VERSION@|\"$(PPMERGE_VERSION)\"|" -e "s|@PPMERGE_BRANCH@|\"$(PPMERGE_BRANCH)\"|" -e "s|@PPMERGE_SOURCE@|\"$(PPMERGE_SOURCE)\"|" ppMergeVersionDefinitions.h.in > ppMergeVersionDefinitions.h 22 FORCE: ; 23 24 25 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 13 26 ppMerge_LDFLAGS = $(PPMERGE_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 14 27 -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMerge.c
r23594 r24244 95 95 psFree(statsOut); 96 96 fclose(statsFile); 97 pmConfigRunFilenameAddWrite(config, "STATS", statsName); 97 98 } 98 99 -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeArguments.c
r23594 r24244 156 156 psMetadataAddS32(arguments, PS_LIST_TAIL, "-nkeep", 0, "Minimum number of pixels in stack to keep", 0); 157 157 psMetadataAddBool(arguments, PS_LIST_TAIL, "-variances", 0, "Use image variances in combination?", false); 158 psMetadataAddBool(arguments, PS_LIST_TAIL, "-use-masks", 0, "Use image masks in combination?", false); 158 159 159 160 // XXX EAM : not clear this should be allowed on the command line. … … 179 180 180 181 /** Mask construction parameters */ 181 psMetadataAddF32(arguments, PS_LIST_TAIL, "-mask-suspect ", 0, "Threshold for suspect pixels (sigma)", NAN);182 psMetadataAddF32(arguments, PS_LIST_TAIL, "-mask-suspect-sigma", 0, "Threshold for suspect pixels (sigma)", NAN); 182 183 psMetadataAddF32(arguments, PS_LIST_TAIL, "-mask-bad", 0, "Threshold for bad pixels (sigma)", NAN); 183 184 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-mode", 0, "Mode to identify bad pixels", NULL); … … 308 309 VALUE_ARG_RECIPE_INT("-nkeep", "NKEEP", S32, 0); 309 310 VALUE_ARG_RECIPE_BOOL("-variances", "VARIANCES"); 311 VALUE_ARG_RECIPE_BOOL("-use-masks", "INPUTS.MASKS.USE"); 310 312 311 313 // XXX we do not supply this on the command line … … 329 331 330 332 /** Mask construction parameters */ 331 VALUE_ARG_RECIPE_FLOAT("-mask-suspect", "MASK.SUSPECT", F32); 333 VALUE_ARG_RECIPE_FLOAT("-mask-suspect-sigma", "MASK.SUSPECT.SIGMA", F32); 334 VALUE_ARG_RECIPE_FLOAT("-mask-suspect-min", "MASK.SUSPECT.MIN", F32); 335 VALUE_ARG_RECIPE_FLOAT("-mask-suspect-max", "MASK.SUSPECT.MAX", F32); 336 VALUE_ARG_RECIPE_STR("-mask-mode", "MASK.SUSPECT.MODE"); 332 337 VALUE_ARG_RECIPE_FLOAT("-mask-bad", "MASK.BAD", F32); 333 338 VALUE_ARG_RECIPE_INT("-mask-grow", "MASK.GROW", S32, 0); -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeErrorCodes.dat
r11259 r24244 2 2 # This file is used to generate ppMergeErrorClasses.h 3 3 # 4 BASE = 700 First value we use; lower values belong to psLib4 BASE = 6000 First value we use; lower values belong to psLib 5 5 # these errors correspond to standard exit conditions 6 6 ARGUMENTS Incorrect arguments -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeErrorCodes.h.in
r21244 r24244 21 21 */ 22 22 typedef enum { 23 PPMERGE_ERR_BASE = 512,23 PPMERGE_ERR_BASE = 6000, 24 24 PPMERGE_ERR_${ErrorCode}, 25 25 PPMERGE_ERR_NERROR -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeLoop.c
r23594 r24244 36 36 bool mdok; ///< Status of MD lookup 37 37 bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); // Do we have masks? 38 bool useMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS.USE"); // Do we have masks? 38 39 bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances? 39 40 … … 73 74 74 75 pmCombineParams *combination = pmCombineParamsAlloc(combineStat); ///< Combination parameters 75 combination->maskVal = maskVal;76 combination->maskVal = useMasks ? maskVal : 0; 76 77 combination->blank = pmConfigMaskGet("BLANK", config); 77 78 combination->nKeep = nKeep; … … 149 150 } 150 151 pmCell *outCell; ///< Cell of interest 152 153 // XXX TEST : force a single loop 154 // outCell = pmFPAviewNextCell(view, outFPA, 1); { 155 151 156 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 152 157 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { … … 164 169 pmHDU *hdu = pmHDUGetHighest(outFPA, outChip, outCell); // HDU for file 165 170 if (hdu && hdu != lastHDU) { 171 if (!hdu->header) { 172 hdu->header = psMetadataAlloc(); 173 } 166 174 ppMergeVersionHeader(hdu->header); 167 175 lastHDU = hdu; … … 229 237 psAssert (fileGroups->n > 0, "no valid file groups defined"); 230 238 fileGroup = fileGroups->data[0]; 231 if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, maskVal)) {239 if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, combination->maskVal)) { 232 240 goto ERROR; 233 241 } … … 411 419 } 412 420 413 // calculate CTEMASK after stats so stats reflect median image421 // calculate CTEMASK after stats so stats reflect median image 414 422 if (type == PPMERGE_TYPE_CTEMASK && outRO) { 415 // need to apply range cuts on the output image 416 psAssert (outRO->mask, "mask is not defined"); 417 psAssert (outRO->mask->numCols == outRO->image->numCols, "mismatch between image and mask"); 418 psAssert (outRO->mask->numRows == outRO->image->numRows, "mismatch between image and mask"); 419 420 // CTEMASK parameters 421 float cteMin = psMetadataLookupF32(NULL, arguments, "CTE.MIN"); // Number of fringe points 422 423 char *cteMaskName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 424 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 425 426 psF32 **outputImage = outRO->image->data.F32; 427 psImageMaskType **outputMask = outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA; 428 for (int iy = 0; iy < outRO->image->numRows; iy++) { 429 for (int ix = 0; ix < outRO->image->numCols; ix++) { 430 if (outputImage[iy][ix] < cteMin) { 431 outputMask[iy][ix] |= cteMaskValue; 432 } 433 } 423 // need to apply range cuts on the output image 424 psAssert (outRO->mask, "mask is not defined"); 425 psAssert (outRO->mask->numCols == outRO->image->numCols, "mismatch between image and mask"); 426 psAssert (outRO->mask->numRows == outRO->image->numRows, "mismatch between image and mask"); 427 428 // CTEMASK parameters 429 float cteMin = psMetadataLookupF32(NULL, arguments, "CTE.MIN"); // Number of fringe points 430 431 char *cteMaskName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 432 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 433 434 if (0) { 435 psFits *fits = NULL; 436 fits = psFitsOpen ("combine.fits", "w"); 437 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL); 438 psFitsClose (fits); 439 440 fits = psFitsOpen ("inmask.fits", "w"); 441 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 442 psFitsClose (fits); 434 443 } 444 445 psF32 **outputImage = outRO->image->data.F32; 446 psImageMaskType **outputMask = outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA; 447 for (int iy = 0; iy < outRO->image->numRows; iy++) { 448 for (int ix = 0; ix < outRO->image->numCols; ix++) { 449 if (outputImage[iy][ix] < cteMin) { 450 outputMask[iy][ix] |= cteMaskValue; 451 } 452 } 453 } 454 455 if (0) { 456 psFits *fits = NULL; 457 fits = psFitsOpen ("otmask.fits", "w"); 458 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 459 psFitsClose (fits); 460 } 461 435 462 } 436 463 -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeMask.c
r23352 r24244 31 31 int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); ///< Size of sample for statistics 32 32 bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); ///< Statistics on chip? 33 float maskSuspect = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT"); ///< Threshold for suspect pixels 33 34 char *maskSuspectMode = psMetadataLookupStr(NULL, config->arguments, "MASK.SUSPECT.MODE"); ///< Threshold for suspect pixels 35 if (strcasecmp(maskSuspectMode, "SIGMA") && strcasecmp(maskSuspectMode, "VALUE")) { 36 psError (PS_ERR_UNKNOWN, true, "Invalid choice for MASK.SUSPECT.MODE: %s\n", maskSuspectMode); 37 return false; 38 } 39 float maskSuspectSigma = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.SIGMA"); ///< Threshold for suspect pixels 40 float maskSuspectMin = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.MIN"); ///< Threshold for suspect pixels 41 float maskSuspectMax = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.MAX"); ///< Threshold for suspect pixels 42 34 43 float maskBad = psMetadataLookupF32(NULL, config->arguments, "MASK.BAD"); ///< Threshold for bad pixels 35 44 pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); ///< Mode for identifying bad pixels … … 111 120 } 112 121 113 if (!ppMergeFileOpenInput(config, view, i)) {122 if (!ppMergeFileOpenInput(config, inView, i)) { 114 123 psError(PS_ERR_UNKNOWN, false, "Unable to open file %d", i); 115 124 psFree(inView); … … 154 163 valueIndex = 0; 155 164 } 156 for (int i = 0; i < num; i++) { 157 int pixel = numPix * psRandomUniform(rng); 158 int x = pixel % numCols; 159 int y = pixel / numCols; 160 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue; 161 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue; 162 if (!isfinite(image->data.F32[y][x])) continue; 163 164 values->data.F32[valueIndex++] = image->data.F32[y][x]; 165 } 166 167 if (!chipStats) { 168 values->n = valueIndex; 169 if (!psVectorStats(statistics, values, NULL, NULL, 0)) { 170 psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout."); 171 psFree(inView); 172 psFree(readout); 173 goto MERGE_MASK_ERROR; 174 } 175 176 float mean = psStatsGetValue(statistics, meanStat); 177 float stdev = psStatsGetValue(statistics, stdevStat); 178 179 // this function increments the count for each suspect pixel in each input plane 180 // maskValRaw is used to test for valid input pixels 181 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 182 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 183 psFree(inView); 184 psFree(readout); 185 goto MERGE_MASK_ERROR; 186 } 187 pmCellFreeData(inCell); 188 189 if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) { 190 psFree(inView); 191 psFree(readout); 192 goto MERGE_MASK_ERROR; 193 } 194 } 165 166 if (!strcasecmp(maskSuspectMode, "VALUE")) { 167 // this function increments the count for each suspect pixel in each input plane 168 // maskValRaw is used to test for valid input pixels 169 if (!pmMaskFlagSuspectPixelsByValue(outRO, readout, maskSuspectMin, maskSuspectMax, maskValRaw)) { 170 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 171 psFree(inView); 172 psFree(readout); 173 goto MERGE_MASK_ERROR; 174 } 175 pmCellFreeData(inCell); 176 177 if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) { 178 psFree(inView); 179 psFree(readout); 180 goto MERGE_MASK_ERROR; 181 } 182 } else { 183 // extract a subset of pixels for stats measurement -- don't use pixels which are masked for this calculation 184 for (int i = 0; i < num; i++) { 185 int pixel = numPix * psRandomUniform(rng); 186 int x = pixel % numCols; 187 int y = pixel / numCols; 188 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue; 189 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue; 190 if (!isfinite(image->data.F32[y][x])) continue; 191 192 values->data.F32[valueIndex] = image->data.F32[y][x]; 193 valueIndex++; 194 } 195 196 // for per-readout stats, measure the stats and find the suspect pixels 197 if (!chipStats) { 198 values->n = valueIndex; 199 if (!psVectorStats(statistics, values, NULL, NULL, 0)) { 200 psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout."); 201 psFree(inView); 202 psFree(readout); 203 goto MERGE_MASK_ERROR; 204 } 205 float mean = psStatsGetValue(statistics, meanStat); 206 float stdev = psStatsGetValue(statistics, stdevStat); 207 208 // this function increments the count for each suspect pixel in each input plane 209 // maskValRaw is used to test for valid input pixels 210 if (!pmMaskFlagSuspectPixelsBySigma(outRO, readout, mean, stdev, maskSuspectSigma, maskValRaw)) { 211 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 212 psFree(inView); 213 psFree(readout); 214 goto MERGE_MASK_ERROR; 215 } 216 pmCellFreeData(inCell); 217 218 if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) { 219 psFree(inView); 220 psFree(readout); 221 goto MERGE_MASK_ERROR; 222 } 223 } 224 } 195 225 psFree(readout); 196 226 psFree(outRO); … … 198 228 199 229 // Additional run through cells if we want chip-level statistics 200 if (chipStats && valueIndex > 0) { 230 // only used for MASK.SUSPECT.MODE == SIGMA 231 if (!strcasecmp(maskSuspectMode, "SIGMA") && chipStats && valueIndex > 0) { 201 232 values->n = valueIndex; 202 233 if (!psVectorStats(statistics, values, NULL, NULL, 0)) { … … 221 252 float stdev = psStatsGetValue(statistics, stdevStat); 222 253 223 if (!pmMaskFlagSuspectPixels (outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {254 if (!pmMaskFlagSuspectPixelsBySigma(outRO, readout, mean, stdev, maskSuspectSigma, maskValRaw)) { 224 255 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 225 256 goto MERGE_MASK_ERROR; -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeVersion.c
r23352 r24244 21 21 22 22 #include "ppMergeVersion.h" 23 #include "ppMergeVersionDefinitions.h" 23 24 24 25 #ifndef PPMERGE_VERSION … … 32 33 #endif 33 34 34 #define xstr(s) str(s)35 #define str(s) #s36 37 35 psString ppMergeVersion(void) 38 36 { 39 37 char *value = NULL; 40 psStringAppend(&value, "%s@%s", xstr(PPMERGE_BRANCH), xstr(PPMERGE_VERSION));38 psStringAppend(&value, "%s@%s", PPMERGE_BRANCH, PPMERGE_VERSION); 41 39 return value; 42 40 } … … 44 42 psString ppMergeSource(void) 45 43 { 46 return psStringCopy( xstr(PPMERGE_SOURCE));44 return psStringCopy(PPMERGE_SOURCE); 47 45 } 48 46
Note:
See TracChangeset
for help on using the changeset viewer.
