Changeset 27838 for branches/tap_branches/magic/remove/src/streaksio.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 5 edited
-
. (modified) (1 prop)
-
magic (modified) (1 prop)
-
magic/remove (modified) (1 prop)
-
magic/remove/src (modified) (1 prop)
-
magic/remove/src/streaksio.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/magic
- Property svn:ignore
-
old new 1 1 magic 2 2 ssa-core-cpp 3 Makefile4 3 Makefile.bak
-
- Property svn:ignore
-
branches/tap_branches/magic/remove
-
Property svn:ignore
set to
configure
Makefile.in
Doxyfile
config.log
depcomp
config.status
config.guess
ltmain.sh
config.sub
autom4te.cache
libtool
missing
Makefile
aclocal.m4
install-sh
-
Property svn:ignore
set to
-
branches/tap_branches/magic/remove/src
- Property svn:ignore
-
old new 4 4 streakscompare 5 5 streaksrelease 6 makefile 6 Makefile 7 Makefile.in 8 config.h 9 .deps 10 streaksVersionDefinitions.h 11 config.h.in 12 stamp-h1
-
- Property svn:ignore
-
branches/tap_branches/magic/remove/src/streaksio.c
r25469 r27838 121 121 sf->transparentStreaks = psMetadataLookupF64(&status, config->arguments, "TRANSPARENT_STREAKS"); 122 122 123 sf->stats = psMetadataAlloc(); 124 psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS"); 125 if (statsFileName) { 126 sf->statsFile = fopen(statsFileName, "w"); 127 if (!sf->statsFile) { 128 psError(PS_ERR_IO, true, "failed to open stats file %s", statsFileName); 129 streaksExit("", PS_EXIT_CONFIG_ERROR); 130 } 131 } 132 123 133 return sf; 124 134 } … … 128 138 { 129 139 freeImages(sf); 130 psFree(sf-> warpedPixels);140 psFree(sf->diffedPixels); 131 141 psFree(sf->tiles); 132 142 psFree(sf->view); … … 800 810 return; 801 811 } 812 streaksVersionHeaderFull(sfile->header); 813 802 814 if (!psFitsWriteImage(sfile->fits, sfile->header, sfile->image, 0, extname)) { 803 815 psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d", … … 817 829 return; 818 830 } 831 streaksVersionHeaderFull(sfile->header); 819 832 if (!psFitsWriteImageCube(sfile->fits, sfile->header, imagecube, extname)) { 820 833 psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d", … … 851 864 sfile->header = NULL; 852 865 psFree(sfile->image); 853 sfile-> header= NULL;866 sfile->image = NULL; 854 867 psFree(sfile->imagecube); 855 sfile-> header= NULL;868 sfile->imagecube = NULL; 856 869 } 857 870 … … 859 872 closeImages(streakFiles *sf) 860 873 { 874 if (sf->stage == IPP_STAGE_RAW) { 875 if (sf->view) { 876 sf->view->readout = -1; 877 pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER); 878 sf->view->cell = -1; 879 pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER); 880 sf->view->chip = -1; 881 pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER); 882 } 883 } 861 884 closeImage(sf->inImage); 862 885 closeImage(sf->outImage); … … 913 936 bool free_user_copies = true; 914 937 if (user_copies == NULL) { 915 user_copies = "2";916 free_user_copies = false;938 // input does not have replication requested 939 return true; 917 940 } 918 941 if (!nebSetXattr(server, outFile->name, "user.copies", user_copies, NEB_REPLACE)) { … … 920 943 return false; 921 944 } 922 if (!nebReplicate(server, outFile->name, "any", NULL)) {945 if (!nebReplicate(server, outFile->name, NULL, NULL)) { 923 946 psError(PM_ERR_UNKNOWN, true, "nebReplicate failed for %s\n%s", outFile->name, nebErr(server)); 924 947 return false; … … 1111 1134 1112 1135 psImage *image = sfiles->outImage->image; 1136 int imageType = image->type.type; 1137 double exciseValue = sfiles->inImage->exciseValue; 1138 1113 1139 psImage *mask = sfiles->inMask->image; 1114 1140 psImage *weight = NULL; 1141 int weightType = 0; 1142 double weightExciseValue = NAN; 1115 1143 if (sfiles->outWeight) { 1116 1144 weight = sfiles->outWeight->image; 1117 } 1118 double exciseValue = sfiles->inImage->exciseValue; 1145 weightType = weight->type.type; 1146 weightExciseValue = sfiles->inWeight->exciseValue; 1147 } 1119 1148 1120 1149 if (printCounts) { … … 1126 1155 // these gets are not necessary, we could just set the pixels to nan 1127 1156 // but I want to get the counts 1128 double imageVal = image->data.F32[y][x]; 1129 psU32 maskVal; 1157 double imageVal = 0; // avoid compiler warning 1158 if (imageType == PS_TYPE_F32) { 1159 imageVal = image->data.F32[y][x]; 1160 } else if (imageType == PS_TYPE_S16) { 1161 imageVal = image->data.S16[y][x]; 1162 } else if (imageType == PS_TYPE_U16) { 1163 imageVal = image->data.U16[y][x]; 1164 } else { 1165 psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", 1166 imageType); 1167 streaksExit("", PS_EXIT_PROG_ERROR); 1168 } 1169 psU32 maskVal = 0; 1130 1170 if (sfiles->stage == IPP_STAGE_RAW) { 1131 1171 unsigned int xChip, yChip; … … 1137 1177 if (maskVal & maskMask) { 1138 1178 ++maskedPixels; 1139 if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {1179 if (!isExciseValue(imageVal, exciseValue)) { 1140 1180 ++nandPixels; 1141 image->data.F32[y][x] = exciseValue; 1181 if (imageType == PS_TYPE_F32) { 1182 image->data.F32[y][x] = exciseValue; 1183 } else if (imageType == PS_TYPE_S16) { 1184 image->data.S16[y][x] = exciseValue; 1185 } else if (imageType == PS_TYPE_U16) { 1186 image->data.U16[y][x] = exciseValue; 1187 } else { 1188 psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", 1189 imageType); 1190 streaksExit("", PS_EXIT_PROG_ERROR); 1191 } 1142 1192 } 1143 1193 if (weight) { 1144 double weightVal = weight ? weight->data.F32[y][x] : 0; 1145 if (!isnan(weightVal)) { 1146 ++nandWeights; 1147 weight->data.F32[y][x] = NAN; 1194 if (weightType == PS_TYPE_F32) { 1195 double weightVal = weight->data.F32[y][x]; 1196 if (!isnan(weightVal)) { 1197 ++nandWeights; 1198 weight->data.F32[y][x] = NAN; 1199 } 1200 } else if(weightType == PS_TYPE_S16) { 1201 double weightVal = weight->data.S16[y][x]; 1202 if (!isExciseValue(weightVal, weightExciseValue)) { 1203 ++nandWeights; 1204 image->data.S16[y][x] = weightExciseValue; 1205 } 1206 } else if (weightType == PS_TYPE_U16) { 1207 double weightVal = weight->data.U16[y][x]; 1208 if (!isExciseValue(weightVal, weightExciseValue)) { 1209 ++nandWeights; 1210 image->data.U16[y][x] = weightExciseValue; 1211 } 1212 } else { 1213 psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", 1214 weightType); 1215 streaksExit("", PS_EXIT_PROG_ERROR); 1148 1216 } 1149 1217 } … … 1176 1244 psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535); 1177 1245 psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535); 1178 } else { 1246 } else if (in->image->type.type == PS_TYPE_S16) { 1247 in->exciseValue = 32767; 1248 psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 32767); 1249 psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 32767); 1250 } else if (in->image->type.type == PS_TYPE_F32) { 1179 1251 in->exciseValue = NAN; 1180 } 1181 } 1182 1183 void 1184 strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask) 1185 { 1252 } else { 1253 psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type); 1254 streaksExit("", PS_EXIT_PROG_ERROR); 1255 } 1256 } 1257 1258 // Get the mask values that we need. 1259 // If an input mask file is provided get them from there. 1260 // Otherwise get them from the recipe MASKS 1261 void 1262 strkGetMaskValues(streakFiles *sfiles) 1263 { 1264 if (sfiles->maskStreak) { 1265 // already done 1266 return; 1267 } 1186 1268 if (sfiles->inMask && sfiles->inMask->header) { 1187 1269 if (!pmConfigMaskReadHeader(sfiles->config, sfiles->inMask->header)) { … … 1196 1278 streaksExit("", PS_EXIT_CONFIG_ERROR); 1197 1279 } 1198 *maskStreak = psMetadataLookupU32(&status, masks, "STREAK");1280 sfiles->maskStreak = psMetadataLookupU32(&status, masks, "STREAK"); 1199 1281 if (!status) { 1200 1282 psError(PM_ERR_CONFIG, false, "failed to lookup mask value for STREAK in recipes\n"); … … 1212 1294 } 1213 1295 } 1214 *maskMask = ~convPoor;1296 sfiles->maskMask = ~convPoor; 1215 1297 } 1216 1298
Note:
See TracChangeset
for help on using the changeset viewer.
