- Timestamp:
- Sep 15, 2009, 4:02:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/magic/remove/src/streaksio.c
r25022 r25406 12 12 // Assumptions about the file structure of non-raw files 13 13 // The 'image' for each file (image, mask weight) is contained in the first 14 // extension. 14 // extension. 15 15 16 16 … … 625 625 streaksExit("", PS_EXIT_DATA_ERROR); 626 626 } 627 627 628 628 bool status; 629 629 in->extname = psMetadataLookupStr(&status, in->header, "EXTNAME"); … … 654 654 streaksExit("", PS_EXIT_DATA_ERROR); 655 655 } 656 psImage *image = (psImage *) (in->imagecube->data[0]); 656 657 // Ensure input is of the expected type 658 psDataType expected = isMask ? PS_TYPE_IMAGE_MASK : PS_TYPE_F32; // Expected type for image 659 for (int i = 0; i < in->imagecube->n; i++) { 660 psImage *image = in->imagecube->data[i]; // Image of interest 661 if (image->type.type != expected) { 662 psImage *temp = psImageCopy(NULL, image, expected); 663 psFree(image); 664 in->imagecube->data[i] = temp; 665 } 666 } 657 667 } 658 668 setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask); … … 671 681 sfile->fits->options = psFitsOptionsAlloc(); 672 682 sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL; 683 sfile->fits->options->fuzz = false; 673 684 sfile->fits->options->bitpix = bitpix; 674 685 sfile->fits->options->bscale = bscale; … … 925 936 replicateOutputs(streakFiles *sfiles) 926 937 { 927 bool status = false;928 929 938 if (!replicate(sfiles->outImage, sfiles->inImage)) { 930 939 psError(PM_ERR_SYS, false, "failed to replicate outImage."); … … 973 982 974 983 if (!nebSwap(server, in->name, out->name)) { 975 psError(PM_ERR_SYS, true, "failed to swap files for : %s.",984 psError(PM_ERR_SYS, true, "failed to swap files for %s: %s.", 976 985 in->name, nebErr(server)); 977 986 return false; … … 1097 1106 setMaskedToNAN(streakFiles *sfiles, psU32 maskMask, bool printCounts) 1098 1107 { 1099 intmaskedPixels = 0;1100 intnandPixels = 0;1101 intnandWeights = 0;1108 long maskedPixels = 0; 1109 long nandPixels = 0; 1110 long nandWeights = 0; 1102 1111 1103 1112 psImage *image = sfiles->outImage->image; … … 1117 1126 // these gets are not necessary, we could just set the pixels to nan 1118 1127 // but I want to get the counts 1119 double imageVal = psImageGet(image, x, y);1128 double imageVal = image->data.F32[y][x]; 1120 1129 psU32 maskVal; 1121 1130 if (sfiles->stage == IPP_STAGE_RAW) { 1122 int xChip, yChip;1131 unsigned int xChip, yChip; 1123 1132 cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y); 1124 maskVal = psImageGet(mask, xChip, yChip);1133 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip]; 1125 1134 } else { 1126 maskVal = psImageGet(mask, x, y);1135 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 1127 1136 } 1128 1137 if (maskVal & maskMask) { … … 1130 1139 if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) { 1131 1140 ++nandPixels; 1132 psImageSet(image, x, y, exciseValue);1141 image->data.F32[y][x] = exciseValue; 1133 1142 } 1134 1143 if (weight) { 1135 double weightVal = weight ? psImageGet(weight, x, y): 0;1144 double weightVal = weight ? weight->data.F32[y][x] : 0; 1136 1145 if (!isnan(weightVal)) { 1137 1146 ++nandWeights; 1138 psImageSet(weight, x, y, NAN);1147 weight->data.F32[y][x] = NAN; 1139 1148 } 1140 1149 } … … 1144 1153 if (printCounts) { 1145 1154 psLogMsg(sfiles->program_name, PS_LOG_INFO, "time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED")); 1146 inttotalPixels = image->numRows * image->numCols;1155 long totalPixels = image->numRows * image->numCols; 1147 1156 psLogMsg(sfiles->program_name, PS_LOG_INFO, "pixels: %10ld\n", totalPixels); 1148 1157 psLogMsg(sfiles->program_name, PS_LOG_INFO, "masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels); … … 1215 1224 if (SFILE_IS_IMAGE(in)) { 1216 1225 // Turn off compression (code adapted from pmFPAWrite) 1217 #ifdef SAVE_AND_RESTORE_COMPRESSION1218 1226 int bitpix = out->fits->options ? out->fits->options->bitpix : 0; // Desired bits per pixel 1219 1227 psFitsCompression *compress = psFitsCompressionGet(out->fits); // Current compression options 1220 #endif1221 1228 if (!psFitsSetCompression(out->fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) { 1222 1229 psError(PM_ERR_UNKNOWN, false, "failed to turn off compression for extension %d\n", extnum); 1223 1230 streaksExit("", PS_EXIT_UNKNOWN_ERROR); 1224 1231 } 1225 #ifdef SAVE_AND_RESTORE_COMPRESSION1226 1232 if (out->fits->options) { 1227 1233 out->fits->options->bitpix = 0; … … 1238 1244 streaksExit("", PS_EXIT_UNKNOWN_ERROR); 1239 1245 } 1240 #endif1241 1246 } else { 1242 1247 copyTable(out, in, extnum);
Note:
See TracChangeset
for help on using the changeset viewer.
