- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
magic/remove/src/streaksio.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/magic/remove/src/streaksio.c
r21481 r24244 6 6 static void streakFilesFree(streakFiles *sf); 7 7 static void freeImages(streakFiles *); 8 static void setExciseValue(sFile *in); 8 9 9 10 static nebServer *ourNebServer = NULL; … … 12 13 // if remove is true the calling program is streaksremove and the recovery files are outputs 13 14 // if false the recovery files are inputs 14 streakFiles *openFiles(pmConfig *config, bool remove )15 streakFiles *openFiles(pmConfig *config, bool remove, char *program_name) 15 16 { 16 17 bool status; … … 20 21 21 22 sf->config = config; 23 sf->program_name = basename(program_name); 22 24 23 25 // error checking is done by sFileOpen. If a file can't be opened we just exit … … 471 473 sf->inImage->numCols = readout->image->numCols; 472 474 sf->inImage->numRows = readout->image->numRows; 475 setExciseValue(sf->inImage); 473 476 } 474 477 … … 545 548 streaksExit("", PS_EXIT_DATA_ERROR); 546 549 } 547 if (in->image->type.type == PS_TYPE_U16) { 548 in->exciseValue = 65535; 549 psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535); 550 psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535); 551 } else { 552 in->exciseValue = NAN; 553 } 550 setExciseValue(in); 554 551 } else { 555 552 if (stage != IPP_STAGE_RAW) { … … 613 610 614 611 #ifdef STREAKS_COMPRESS_OUTPUT 612 // Paul says that I should be able to leave this blank 613 bitpix = 0; 615 614 setFitsOptions(out, bitpix, bscale, bzero); 616 615 setFitsOptions(rec, bitpix, bscale, bzero); … … 916 915 deleteFile(sFile *sfile) 917 916 { 918 919 917 if (sfile->inNebulous) { 920 918 nebServer *server = getNebServer(NULL); … … 970 968 971 969 void 972 setMaskedToNAN(streakFiles *sfiles, psU 8maskMask, bool printCounts)970 setMaskedToNAN(streakFiles *sfiles, psU32 maskMask, bool printCounts) 973 971 { 974 972 int maskedPixels = 0; … … 993 991 // but I want to get the counts 994 992 double imageVal = psImageGet(image, x, y); 995 psU 8maskVal;993 psU32 maskVal; 996 994 if (sfiles->stage == IPP_STAGE_RAW) { 997 995 int xChip, yChip; … … 1018 1016 } 1019 1017 if (printCounts) { 1020 p rintf("time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED"));1018 psLogMsg(sfiles->program_name, PS_LOG_INFO, "time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED")); 1021 1019 int totalPixels = image->numRows * image->numCols; 1022 p rintf("pixels: %10ld\n", totalPixels);1023 p rintf("masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels);1024 p rintf("nand pixels: %10ld %4.2f%%\n", nandPixels, 100. * nandPixels / totalPixels);1020 psLogMsg(sfiles->program_name, PS_LOG_INFO, "pixels: %10ld\n", totalPixels); 1021 psLogMsg(sfiles->program_name, PS_LOG_INFO, "masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels); 1022 psLogMsg(sfiles->program_name, PS_LOG_INFO, "nand pixels: %10ld %4.2f%%\n", nandPixels, 100. * nandPixels / totalPixels); 1025 1023 if (weight) { 1026 p rintf("nand weights: %10ld %4.2f%%\n", nandWeights, 100. * nandWeights / totalPixels);1024 psLogMsg(sfiles->program_name, PS_LOG_INFO, "nand weights: %10ld %4.2f%%\n", nandWeights, 100. * nandWeights / totalPixels); 1027 1025 } 1028 1026 } … … 1035 1033 ourNebServer = NULL; 1036 1034 } 1035 static void 1036 setExciseValue(sFile *in) 1037 { 1038 if (in->image->type.type == PS_TYPE_U16) { 1039 in->exciseValue = 65535; 1040 psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535); 1041 psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535); 1042 } else { 1043 in->exciseValue = NAN; 1044 } 1045 } 1046 1047 void 1048 strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask) 1049 { 1050 if (sfiles->inMask && sfiles->inMask->header) { 1051 if (!pmConfigMaskReadHeader(sfiles->config, sfiles->inMask->header)) { 1052 streaksExit("failed to read mask values from file", PS_EXIT_CONFIG_ERROR); 1053 } 1054 } 1055 1056 bool status; 1057 psMetadata *masks = psMetadataLookupMetadata(&status, sfiles->config->recipes, "MASKS"); 1058 if (!status) { 1059 psError(PM_ERR_CONFIG, false, "failed to lookup MASKS in recipes\n"); 1060 streaksExit("", PS_EXIT_CONFIG_ERROR); 1061 } 1062 *maskStreak = psMetadataLookupU32(&status, masks, "STREAK"); 1063 if (!status) { 1064 psError(PM_ERR_CONFIG, false, "failed to lookup mask value for STREAK in recipes\n"); 1065 streaksExit("", PS_EXIT_CONFIG_ERROR); 1066 } 1067 1068 // optionally setting pixels with any mask bits execpt CONV.POOR to NAN 1069 // check old name first 1070 psU32 convPoor = (double) psMetadataLookupU32(&status, masks, "POOR.WARP"); 1071 if (!status) { 1072 convPoor = (double) psMetadataLookupU32(&status, masks, "CONV.POOR"); 1073 if (!status) { 1074 psError(PM_ERR_CONFIG, false, "failed to lookup mask value for CONV.POOR in recipes\n"); 1075 streaksExit("", PS_EXIT_CONFIG_ERROR); 1076 } 1077 } 1078 *maskMask = ~convPoor; 1079 }
Note:
See TracChangeset
for help on using the changeset viewer.
