- Timestamp:
- May 31, 2007 12:58:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Correct.ipf
r47 r116 31 31 //******************************** 32 32 33 34 33 //unused test procedure for Correct() function 35 34 //must be updated to include "mode" parameter before re-use … … 57 56 End 58 57 59 //mode describes the type of subtraction that is to be done60 //1 = both emp and bgd subtraction61 //2 = only bgd subtraction62 //3 = only emp subtraction63 //4 = no subtraction (handled by ExecuteProtocol(), but implemented here as well)64 //65 // + 10 indicates that WORK.DRK is to be used66 //**********unused***********67 //**worse yet, only partially converted to use DRK files!***********68 //69 Function OLD_Correct(mode)70 Variable mode71 72 //Print "mode = ",mode73 if(mode==4)74 Print "no subtraction required - Correct(mode) should not have been called"75 return(1) //error - correct should not have been called76 Endif77 78 // always check for existence of data in SAM79 // if the desired workfile doesn't exist, let the user know, and abort80 String destPath81 String type = "SAM"82 //check for SAM83 destPath = "root:"+Type + ":data"84 if(WaveExists($destpath) == 0)85 Print "There is no work file in "+type+"--Aborting"86 Return(1) //error condition87 else88 //check for log-scaling of the "SAM" data and adjust if necessary89 ConvertFolderToLinearScale(type)90 Wave sam_data = $"root:SAM:data"91 Endif92 93 //check for BGD if mode = 1 or 2 or 11 or 1294 if( (mode ==1) || (mode==2) || (mode==11) || (mode==12) )95 type = "BGD"96 destPath = "root:"+Type + ":data"97 if(WaveExists($destpath) == 0)98 Print "There is no work file in "+type+"--Aborting"99 Return(1) //error condition100 else101 //check for log-scaling of the "BGD" data and adjust if necessary102 ConvertFolderToLinearScale(type)103 Wave bgd_data = $"root:BGD:data"104 Endif105 Endif106 107 // check for EMP data if type 3 or 1 or 13 or 11108 if( (mode==1) || (mode==3) || (mode==11) || (mode==13) )109 type = "EMP"110 destPath = "root:"+Type + ":data"111 if(WaveExists($destpath) == 0)112 Print "There is no work file in "+type+"--Aborting"113 Return(1) //error condition114 else115 //check for log-scaling of the "EMP" data and adjust if necessary116 ConvertFolderToLinearScale(type)117 Wave emp_data = $"root:EMP:data"118 Endif119 Endif120 121 // check for DRK data if type 11,12,13, or 14122 if( (mode==11) || (mode==12) || (mode==13) || (mode==14) )123 type = "DRK"124 destPath = "root:"+Type + ":data"125 if(WaveExists($destpath) == 0)126 Print "There is no work file in "+type+"--Aborting"127 Return(1) //error condition128 else129 //check for log-scaling of the "EMP" data and adjust if necessary130 ConvertFolderToLinearScale(type)131 Wave drk_data = $"root:DRK:data"132 Endif133 Endif134 135 //necessary files exist, proceed136 137 //make needed wave references to other folders138 //NOTE that these references MAY NOT EXIST, depending on the mode139 WAVE sam_reals = $"root:SAM:realsread"140 WAVE sam_ints = $"root:SAM:integersread"141 WAVE/T sam_text = $"root:SAM:textread"142 WAVE/Z emp_reals = $"root:EMP:realsread"143 WAVE/Z emp_ints = $"root:EMP:integersread"144 WAVE/T/Z emp_text = $"root:EMP:textread"145 WAVE/Z bgd_reals = $"root:BGD:realsread"146 WAVE/Z bgd_ints = $"root:BGD:integersread"147 WAVE/T/Z bgd_text = $"root:BGD:textread"148 149 //find the attenuation of the sample (if any)150 Variable SamAttenFactor,lambda,attenNo,err=0151 String samfileStr=""152 samfileStr = sam_text[3]153 lambda = sam_reals[26]154 attenNo = sam_reals[3]155 SamAttenFactor = AttenuationFactor(samFileStr,lambda,AttenNo)156 //if sample trans is zero, do only SAM-BGD subtraction (notify the user)157 Variable sam_trans = sam_reals[4]158 159 //copy SAM information to COR, wiping out the old contents of the COR folder first160 err = CopyWorkContents("SAM","COR")161 if(err==1)162 Abort "No data in SAM, abort from Correct()"163 endif164 165 //now switch to COR folder166 DestPath="root:COR"167 //make appropriate wave references168 WAVE data=$(destPath + ":data") // these wave references point to the SAM data in COR169 WAVE/T textread=$(destPath + ":textread") //that are to be directly operated on170 WAVE integersread=$(destPath + ":integersread")171 WAVE realsread=$(destPath + ":realsRead")172 173 NVAR pixelsX = root:myGlobals:gNPixelsX174 NVAR pixelsY = root:myGlobals:gNPixelsY175 176 //Print "done copying data, starting the correct calculations"177 178 // Start the actual "correct" step here179 Variable wcen=0.001,numsam,tmonsam,tsam,rsam,csam,fsam180 Variable tmonbgd,fbgd,xshift,yshift,rbgd,cbgd,sh_sum,ii,jj,trans,tmonemp,temp,femp181 Variable cemp,remp182 //make temporary waves to hold the intermediate results and the shifted arrays183 Duplicate/O data cor1,cor2184 cor1 = 0 //initialize to zero185 cor2 = 0186 187 //make needed wave references to other folders188 Wave sam_reals = $"root:SAM:realsread"189 Wave bgd_reals = $"root:BGD:realsread"190 Wave emp_reals = $"root:EMP:realsread"191 192 //get counts, trans, etc. from file headers193 numsam = sam_ints[3] //number of runs in SAM file194 tmonsam = sam_reals[0] //monitor count in SAM195 tsam = sam_reals[4] //SAM transmission196 csam = sam_reals[16] //x center197 rsam = sam_reals[17] //beam (x,y) define center of corrected field198 //Print "rsam,csam = ",rsam,csam199 200 //201 //do sam-bgd subtraction if mode (1) or (2)202 //else (mode 3), set cor1 = sam_data203 if( (mode==1) || (mode==2) )204 fsam = 1205 tmonbgd = bgd_reals[0] //monitor count in BGD206 fbgd = tmonsam/tmonbgd //this should be ==1 since normalized files207 208 //set up center shift, relative to SAM209 cbgd = bgd_reals[16]210 rbgd = bgd_reals[17]211 //Print "rbgd,cbgd = ",rbgd,cbgd212 xshift = cbgd-csam213 yshift = rbgd-rsam214 if(abs(xshift) <= wcen)215 xshift = 0216 Endif217 if(abs(yshift) <= wcen)218 yshift = 0219 Endif220 221 If((xshift != 0) || (yshift != 0))222 DoAlert 1,"Do you want to ignore the beam center mismatch?"223 if(V_flag==1) //yes -> just go on224 xshift=0225 yshift=0226 endif227 endif228 //do the sam-bgd subtraction, deposit result in cor1[][]229 If((xshift == 0) && (yshift == 0))230 //great, no shift required231 cor1 = fsam*sam_data - fbgd*bgd_data*SamAttenFactor232 else233 //shift required, very time-consuming234 Print "sam-bgd shift x,y = ",xshift,yshift235 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum()236 ii=0237 do238 jj=0239 do240 //get the contribution of shifted data241 sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd)242 if(noadd[0])243 cor1[ii][jj]=0244 else245 //add the sam_data + shifted sum246 cor1[ii][jj] = fsam*sam_data[ii][jj] - fbgd*sh_sum*SamAttenFactor247 Endif248 jj+=1249 while(jj<pixelsY)250 ii+=1251 while(ii<pixelsX)252 Endif253 else //switch on mode254 cor1 = sam_data //setup for just EMP subtraction255 Endif256 257 //Print "sam-bgd done"258 259 if(mode == 2) //just a BGD subtraction260 //we're done, get out w/no error261 //set the COR data to the result262 data = cor1263 //update COR header264 textread[1] = date() + " " + time() //date + time stamp265 SetDataFolder root:266 KillWaves/Z cor1,cor2267 Return(0)268 Endif269 270 //if mode ==1 (ONLY choice left) do the empty-background subtraction271 //else mode = 3, set cor2 to emp_data272 if(mode==1) //full subtraction273 trans = emp_reals[4] //EMP transmission274 if(trans == 0)275 trans = 1276 DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation"277 endif278 tmonemp = emp_reals[0]279 femp = tmonsam/tmonemp280 temp = trans281 282 //set up center shift, relative to EMP283 cemp = emp_reals[16]284 remp = emp_reals[17]285 //Print "remp,cemp ",remp,cemp286 xshift = cbgd - cemp287 yshift = rbgd - remp288 if(abs(xshift) <= wcen )289 xshift = 0290 endif291 if(abs(yshift) <= wcen)292 yshift = 0293 endif294 295 If((xshift != 0) || (yshift != 0))296 DoAlert 1,"Do you want to ignore the beam center mismatch?"297 if(V_flag==1)298 xshift=0299 yshift=0300 endif301 endif302 //do the emp-bgd subtraction, deposit result in cor2[][]303 If((xshift == 0) && (yshift == 0))304 //great, no shift required, DON'T scale this by the attenuation gfactor305 cor2 = femp*emp_data - fbgd*bgd_data306 else307 //shift required, very time-consuming308 Print "emp-bgd shift x,y = ",xshift,yshift309 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum()310 ii=0311 do312 jj=0313 do314 //get the contribution of shifted data315 sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd)316 if(noadd[0])317 cor2[ii][jj]=0318 else319 //add the sam_data + shifted sum320 cor2[ii][jj] = femp*emp_data[ii][jj] - fbgd*sh_sum321 Endif322 jj+=1323 while(jj<pixelsY)324 ii+=1325 while(ii<pixelsX)326 Endif327 else //switch on mode==1 for full subtraction328 cor2 = emp_data329 //be sure to set the empty center location... for the shift330 trans = emp_reals[4] //EMP transmission331 if(trans == 0)332 trans = 1333 DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation"334 endif335 tmonemp = emp_reals[0]336 femp = tmonsam/tmonemp337 temp = trans338 339 //set up center shift, relative to EMP340 cemp = emp_reals[16]341 remp = emp_reals[17]342 Endif343 344 //Print "emp-bgd done"345 346 //mode 2 exited, either 1 or 3 apply from here, and are setup properly.347 348 //set up for final step, data(COR) = cor1 - Tsam/Temp*cor2349 //set up shift, relative to SAM350 xshift = cemp - csam351 yshift = remp - rsam352 if(abs(xshift) <= wcen )353 xshift = 0354 endif355 if(abs(yshift) <= wcen)356 yshift = 0357 endif358 359 If((xshift != 0) || (yshift != 0))360 DoAlert 1,"Do you want to ignore the beam center mismatch?"361 if(V_flag==1)362 xshift=0363 yshift=0364 endif365 endif366 //do the cor1-a*cor2 subtraction, deposit result in data[][] (in the COR folder)367 If((xshift == 0) && (yshift == 0))368 //great, no shift required369 data = cor1 - (tsam/temp)*cor2*SamAttenFactor370 else371 //shift required, very time-consuming372 Print "sam-emp shift x,y = ",xshift,yshift373 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum()374 ii=0375 do376 jj=0377 do378 //get the contribution of shifted data379 sh_sum = ShiftSum(cor2,ii,jj,xshift,yshift,noadd)380 if(noadd[0])381 data[ii][jj]=0382 else383 //add the sam_data + shifted sum384 data[ii][jj] = cor1[ii][jj] - (tsam/temp)*sh_sum*SamAttenFactor385 Endif386 jj+=1387 while(jj<pixelsY)388 ii+=1389 while(ii<pixelsX)390 Endif391 392 //Print "all done"393 394 //update COR header395 textread[1] = date() + " " + time() //date + time stamp396 397 //clean up398 SetDataFolder root:COR399 SetDataFolder root:400 KillWaves/Z cor1,cor2,noadd401 402 Return(0) //all is ok, if you made it to this point403 End404 58 405 59 //mode describes the type of subtraction that is to be done … … 1385 1039 1386 1040 ////////////////////////// 1041 //**********unused*********** 1042 //mode describes the type of subtraction that is to be done 1043 //1 = both emp and bgd subtraction 1044 //2 = only bgd subtraction 1045 //3 = only emp subtraction 1046 //4 = no subtraction (handled by ExecuteProtocol(), but implemented here as well) 1047 // 1048 // + 10 indicates that WORK.DRK is to be used 1049 //**********unused*********** 1050 //**worse yet, only partially converted to use DRK files!*********** 1051 // 1052 Function OLD_Correct(mode) 1053 Variable mode 1054 1055 //Print "mode = ",mode 1056 if(mode==4) 1057 Print "no subtraction required - Correct(mode) should not have been called" 1058 return(1) //error - correct should not have been called 1059 Endif 1060 1061 // always check for existence of data in SAM 1062 // if the desired workfile doesn't exist, let the user know, and abort 1063 String destPath 1064 String type = "SAM" 1065 //check for SAM 1066 destPath = "root:"+Type + ":data" 1067 if(WaveExists($destpath) == 0) 1068 Print "There is no work file in "+type+"--Aborting" 1069 Return(1) //error condition 1070 else 1071 //check for log-scaling of the "SAM" data and adjust if necessary 1072 ConvertFolderToLinearScale(type) 1073 Wave sam_data = $"root:SAM:data" 1074 Endif 1075 1076 //check for BGD if mode = 1 or 2 or 11 or 12 1077 if( (mode ==1) || (mode==2) || (mode==11) || (mode==12) ) 1078 type = "BGD" 1079 destPath = "root:"+Type + ":data" 1080 if(WaveExists($destpath) == 0) 1081 Print "There is no work file in "+type+"--Aborting" 1082 Return(1) //error condition 1083 else 1084 //check for log-scaling of the "BGD" data and adjust if necessary 1085 ConvertFolderToLinearScale(type) 1086 Wave bgd_data = $"root:BGD:data" 1087 Endif 1088 Endif 1089 1090 // check for EMP data if type 3 or 1 or 13 or 11 1091 if( (mode==1) || (mode==3) || (mode==11) || (mode==13) ) 1092 type = "EMP" 1093 destPath = "root:"+Type + ":data" 1094 if(WaveExists($destpath) == 0) 1095 Print "There is no work file in "+type+"--Aborting" 1096 Return(1) //error condition 1097 else 1098 //check for log-scaling of the "EMP" data and adjust if necessary 1099 ConvertFolderToLinearScale(type) 1100 Wave emp_data = $"root:EMP:data" 1101 Endif 1102 Endif 1103 1104 // check for DRK data if type 11,12,13, or 14 1105 if( (mode==11) || (mode==12) || (mode==13) || (mode==14) ) 1106 type = "DRK" 1107 destPath = "root:"+Type + ":data" 1108 if(WaveExists($destpath) == 0) 1109 Print "There is no work file in "+type+"--Aborting" 1110 Return(1) //error condition 1111 else 1112 //check for log-scaling of the "EMP" data and adjust if necessary 1113 ConvertFolderToLinearScale(type) 1114 Wave drk_data = $"root:DRK:data" 1115 Endif 1116 Endif 1117 1118 //necessary files exist, proceed 1119 1120 //make needed wave references to other folders 1121 //NOTE that these references MAY NOT EXIST, depending on the mode 1122 WAVE sam_reals = $"root:SAM:realsread" 1123 WAVE sam_ints = $"root:SAM:integersread" 1124 WAVE/T sam_text = $"root:SAM:textread" 1125 WAVE/Z emp_reals = $"root:EMP:realsread" 1126 WAVE/Z emp_ints = $"root:EMP:integersread" 1127 WAVE/T/Z emp_text = $"root:EMP:textread" 1128 WAVE/Z bgd_reals = $"root:BGD:realsread" 1129 WAVE/Z bgd_ints = $"root:BGD:integersread" 1130 WAVE/T/Z bgd_text = $"root:BGD:textread" 1131 1132 //find the attenuation of the sample (if any) 1133 Variable SamAttenFactor,lambda,attenNo,err=0 1134 String samfileStr="" 1135 samfileStr = sam_text[3] 1136 lambda = sam_reals[26] 1137 attenNo = sam_reals[3] 1138 SamAttenFactor = AttenuationFactor(samFileStr,lambda,AttenNo) 1139 //if sample trans is zero, do only SAM-BGD subtraction (notify the user) 1140 Variable sam_trans = sam_reals[4] 1141 1142 //copy SAM information to COR, wiping out the old contents of the COR folder first 1143 err = CopyWorkContents("SAM","COR") 1144 if(err==1) 1145 Abort "No data in SAM, abort from Correct()" 1146 endif 1147 1148 //now switch to COR folder 1149 DestPath="root:COR" 1150 //make appropriate wave references 1151 WAVE data=$(destPath + ":data") // these wave references point to the SAM data in COR 1152 WAVE/T textread=$(destPath + ":textread") //that are to be directly operated on 1153 WAVE integersread=$(destPath + ":integersread") 1154 WAVE realsread=$(destPath + ":realsRead") 1155 1156 NVAR pixelsX = root:myGlobals:gNPixelsX 1157 NVAR pixelsY = root:myGlobals:gNPixelsY 1158 1159 //Print "done copying data, starting the correct calculations" 1160 1161 // Start the actual "correct" step here 1162 Variable wcen=0.001,numsam,tmonsam,tsam,rsam,csam,fsam 1163 Variable tmonbgd,fbgd,xshift,yshift,rbgd,cbgd,sh_sum,ii,jj,trans,tmonemp,temp,femp 1164 Variable cemp,remp 1165 //make temporary waves to hold the intermediate results and the shifted arrays 1166 Duplicate/O data cor1,cor2 1167 cor1 = 0 //initialize to zero 1168 cor2 = 0 1169 1170 //make needed wave references to other folders 1171 Wave sam_reals = $"root:SAM:realsread" 1172 Wave bgd_reals = $"root:BGD:realsread" 1173 Wave emp_reals = $"root:EMP:realsread" 1174 1175 //get counts, trans, etc. from file headers 1176 numsam = sam_ints[3] //number of runs in SAM file 1177 tmonsam = sam_reals[0] //monitor count in SAM 1178 tsam = sam_reals[4] //SAM transmission 1179 csam = sam_reals[16] //x center 1180 rsam = sam_reals[17] //beam (x,y) define center of corrected field 1181 //Print "rsam,csam = ",rsam,csam 1182 1183 // 1184 //do sam-bgd subtraction if mode (1) or (2) 1185 //else (mode 3), set cor1 = sam_data 1186 if( (mode==1) || (mode==2) ) 1187 fsam = 1 1188 tmonbgd = bgd_reals[0] //monitor count in BGD 1189 fbgd = tmonsam/tmonbgd //this should be ==1 since normalized files 1190 1191 //set up center shift, relative to SAM 1192 cbgd = bgd_reals[16] 1193 rbgd = bgd_reals[17] 1194 //Print "rbgd,cbgd = ",rbgd,cbgd 1195 xshift = cbgd-csam 1196 yshift = rbgd-rsam 1197 if(abs(xshift) <= wcen) 1198 xshift = 0 1199 Endif 1200 if(abs(yshift) <= wcen) 1201 yshift = 0 1202 Endif 1203 1204 If((xshift != 0) || (yshift != 0)) 1205 DoAlert 1,"Do you want to ignore the beam center mismatch?" 1206 if(V_flag==1) //yes -> just go on 1207 xshift=0 1208 yshift=0 1209 endif 1210 endif 1211 //do the sam-bgd subtraction, deposit result in cor1[][] 1212 If((xshift == 0) && (yshift == 0)) 1213 //great, no shift required 1214 cor1 = fsam*sam_data - fbgd*bgd_data*SamAttenFactor 1215 else 1216 //shift required, very time-consuming 1217 Print "sam-bgd shift x,y = ",xshift,yshift 1218 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum() 1219 ii=0 1220 do 1221 jj=0 1222 do 1223 //get the contribution of shifted data 1224 sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 1225 if(noadd[0]) 1226 cor1[ii][jj]=0 1227 else 1228 //add the sam_data + shifted sum 1229 cor1[ii][jj] = fsam*sam_data[ii][jj] - fbgd*sh_sum*SamAttenFactor 1230 Endif 1231 jj+=1 1232 while(jj<pixelsY) 1233 ii+=1 1234 while(ii<pixelsX) 1235 Endif 1236 else //switch on mode 1237 cor1 = sam_data //setup for just EMP subtraction 1238 Endif 1239 1240 //Print "sam-bgd done" 1241 1242 if(mode == 2) //just a BGD subtraction 1243 //we're done, get out w/no error 1244 //set the COR data to the result 1245 data = cor1 1246 //update COR header 1247 textread[1] = date() + " " + time() //date + time stamp 1248 SetDataFolder root: 1249 KillWaves/Z cor1,cor2 1250 Return(0) 1251 Endif 1252 1253 //if mode ==1 (ONLY choice left) do the empty-background subtraction 1254 //else mode = 3, set cor2 to emp_data 1255 if(mode==1) //full subtraction 1256 trans = emp_reals[4] //EMP transmission 1257 if(trans == 0) 1258 trans = 1 1259 DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 1260 endif 1261 tmonemp = emp_reals[0] 1262 femp = tmonsam/tmonemp 1263 temp = trans 1264 1265 //set up center shift, relative to EMP 1266 cemp = emp_reals[16] 1267 remp = emp_reals[17] 1268 //Print "remp,cemp ",remp,cemp 1269 xshift = cbgd - cemp 1270 yshift = rbgd - remp 1271 if(abs(xshift) <= wcen ) 1272 xshift = 0 1273 endif 1274 if(abs(yshift) <= wcen) 1275 yshift = 0 1276 endif 1277 1278 If((xshift != 0) || (yshift != 0)) 1279 DoAlert 1,"Do you want to ignore the beam center mismatch?" 1280 if(V_flag==1) 1281 xshift=0 1282 yshift=0 1283 endif 1284 endif 1285 //do the emp-bgd subtraction, deposit result in cor2[][] 1286 If((xshift == 0) && (yshift == 0)) 1287 //great, no shift required, DON'T scale this by the attenuation gfactor 1288 cor2 = femp*emp_data - fbgd*bgd_data 1289 else 1290 //shift required, very time-consuming 1291 Print "emp-bgd shift x,y = ",xshift,yshift 1292 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum() 1293 ii=0 1294 do 1295 jj=0 1296 do 1297 //get the contribution of shifted data 1298 sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 1299 if(noadd[0]) 1300 cor2[ii][jj]=0 1301 else 1302 //add the sam_data + shifted sum 1303 cor2[ii][jj] = femp*emp_data[ii][jj] - fbgd*sh_sum 1304 Endif 1305 jj+=1 1306 while(jj<pixelsY) 1307 ii+=1 1308 while(ii<pixelsX) 1309 Endif 1310 else //switch on mode==1 for full subtraction 1311 cor2 = emp_data 1312 //be sure to set the empty center location... for the shift 1313 trans = emp_reals[4] //EMP transmission 1314 if(trans == 0) 1315 trans = 1 1316 DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 1317 endif 1318 tmonemp = emp_reals[0] 1319 femp = tmonsam/tmonemp 1320 temp = trans 1321 1322 //set up center shift, relative to EMP 1323 cemp = emp_reals[16] 1324 remp = emp_reals[17] 1325 Endif 1326 1327 //Print "emp-bgd done" 1328 1329 //mode 2 exited, either 1 or 3 apply from here, and are setup properly. 1330 1331 //set up for final step, data(COR) = cor1 - Tsam/Temp*cor2 1332 //set up shift, relative to SAM 1333 xshift = cemp - csam 1334 yshift = remp - rsam 1335 if(abs(xshift) <= wcen ) 1336 xshift = 0 1337 endif 1338 if(abs(yshift) <= wcen) 1339 yshift = 0 1340 endif 1341 1342 If((xshift != 0) || (yshift != 0)) 1343 DoAlert 1,"Do you want to ignore the beam center mismatch?" 1344 if(V_flag==1) 1345 xshift=0 1346 yshift=0 1347 endif 1348 endif 1349 //do the cor1-a*cor2 subtraction, deposit result in data[][] (in the COR folder) 1350 If((xshift == 0) && (yshift == 0)) 1351 //great, no shift required 1352 data = cor1 - (tsam/temp)*cor2*SamAttenFactor 1353 else 1354 //shift required, very time-consuming 1355 Print "sam-emp shift x,y = ",xshift,yshift 1356 Make/O/N=1 noadd //needed to get noadd condition back from ShiftSum() 1357 ii=0 1358 do 1359 jj=0 1360 do 1361 //get the contribution of shifted data 1362 sh_sum = ShiftSum(cor2,ii,jj,xshift,yshift,noadd) 1363 if(noadd[0]) 1364 data[ii][jj]=0 1365 else 1366 //add the sam_data + shifted sum 1367 data[ii][jj] = cor1[ii][jj] - (tsam/temp)*sh_sum*SamAttenFactor 1368 Endif 1369 jj+=1 1370 while(jj<pixelsY) 1371 ii+=1 1372 while(ii<pixelsX) 1373 Endif 1374 1375 //Print "all done" 1376 1377 //update COR header 1378 textread[1] = date() + " " + time() //date + time stamp 1379 1380 //clean up 1381 SetDataFolder root:COR 1382 SetDataFolder root: 1383 KillWaves/Z cor1,cor2,noadd 1384 1385 Return(0) //all is ok, if you made it to this point 1386 End
Note: See TracChangeset
for help on using the changeset viewer.