- Timestamp:
- Jul 3, 2018 2:30:41 PM (5 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf
r1108 r1109 95 95 96 96 // do the q-binning for each of the panels to get I(Q) 97 BinAllFrontPanels() 98 97 // BinAllFrontPanels() 98 String popStr 99 String collimationStr = "pinhole" 100 ControlInfo/W=VCALC popup_b 101 popStr = S_Value // 102 V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr) 99 103 100 104 // plot the results 101 105 String type = "VCALC" 102 String str,winStr="VCALC#Panels_IQ",workTypeStr ,popStr106 String str,winStr="VCALC#Panels_IQ",workTypeStr 103 107 workTypeStr = "root:Packages:NIST:VSANS:"+type 104 108 … … 627 631 628 632 // do the q-binning for each of the panels to get I(Q) 629 BinAllMiddlePanels() 633 // BinAllMiddlePanels() 634 String popStr 635 String collimationStr = "pinhole" 636 ControlInfo/W=VCALC popup_b 637 popStr = S_Value // 638 V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr) 630 639 631 640 // plot the results 632 641 String type = "VCALC" 633 String str,winStr="VCALC#Panels_IQ",workTypeStr ,popStr642 String str,winStr="VCALC#Panels_IQ",workTypeStr 634 643 workTypeStr = "root:Packages:NIST:VSANS:"+type 635 644 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf
r1100 r1109 179 179 nYpix = DimSize(inten,1) 180 180 181 for(ii=0;ii<ntube;ii+=1) 181 for(ii=0;ii<ntube;ii+=1) //for each tube... 182 182 sum_inten = 0 // initialize the sum 183 183 sum_n = 0 184 184 sum_inten2 = 0 185 185 186 for(jj=0;jj<nYpix;jj+=1) 186 for(jj=0;jj<nYpix;jj+=1) //sum along y... 187 187 val = inten[ii][jj] 188 188 if(isVCALC || maskMissing) // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point … … 199 199 iBin_qxqy[ii] = sum_inten/sum_n //the average value 200 200 201 // if(numtype(iBin_qxqy[ii]) == 2) 202 // print "asdfasdf" 203 // endif 204 201 205 202 avesq = (sum_inten/sum_n)^2 206 203 aveisq = sum_inten2/sum_n … … 214 211 endfor 215 212 216 // TODO:use only the Qx component in the y-center of the detector, not Qtotal213 // x- use only the Qx component in the y-center of the detector, not Qtotal 217 214 // if the detectors are "L", then the values are all negative, so take the absolute value here 218 215 qBin_qxqy = abs(qx[p][nYpix/2]) 216 219 217 220 218 // for the L panels, sort the q-values (and data) after the abs() step, otherwise the data is reversed … … 222 220 Sort qBin_qxqy, qBin_qxqy,iBin_qxqy,eBin_qxqy 223 221 222 // average and get rid of the duplicate q-values from the L and R sides 223 Variable q1,q2,tol 224 tol = 0.001 // 0.1 % 225 q1 = qBin_qxqy[0] 226 ii=0 227 do 228 q2 = qBin_qxqy[ii+1] 229 if(V_CloseEnough(q1,q2,q1*tol)) 230 // check to be sure that both values are actually real numbers before trying to average 231 if(numtype(iBin_qxqy[ii])==0 && numtype(iBin_qxqy[ii+1])==0) //==0 => real number 232 iBin_qxqy[ii] = (iBin_qxqy[ii] + iBin_qxqy[ii+1])/2 //both OK 233 endif 234 if(numtype(iBin_qxqy[ii])==0 && numtype(iBin_qxqy[ii+1])!=0) //==0 => real number 235 iBin_qxqy[ii] = iBin_qxqy[ii] //one OK 236 endif 237 if(numtype(iBin_qxqy[ii])!=0 && numtype(iBin_qxqy[ii+1])==0) //==0 => real number 238 iBin_qxqy[ii] = iBin_qxqy[ii+1] //other OK 239 endif 240 if(numtype(iBin_qxqy[ii])!=0 && numtype(iBin_qxqy[ii+1])!=0) //==0 => real number 241 iBin_qxqy[ii] = (iBin_qxqy[ii]) // both NaN, get rid of it later 242 endif 243 244 if(numtype(eBin_qxqy[ii])==0 && numtype(eBin_qxqy[ii+1])==0) //==0 => real number 245 eBin_qxqy[ii] = sqrt(eBin_qxqy[ii]^2 + eBin_qxqy[ii+1]^2) //both OK 246 endif 247 if(numtype(eBin_qxqy[ii])==0 && numtype(eBin_qxqy[ii+1])!=0) //==0 => real number 248 eBin_qxqy[ii] = eBin_qxqy[ii] //one OK 249 endif 250 if(numtype(eBin_qxqy[ii])!=0 && numtype(eBin_qxqy[ii+1])==0) //==0 => real number 251 eBin_qxqy[ii] = eBin_qxqy[ii+1] //other OK 252 endif 253 if(numtype(eBin_qxqy[ii])!=0 && numtype(eBin_qxqy[ii+1])!=0) //==0 => real number 254 eBin_qxqy[ii] = (eBin_qxqy[ii]) // both NaN, get rid of it later 255 endif 256 257 DeletePoints ii+1, 1, qBin_qxqy,iBin_qxqy,eBin_qxqy,iBin2_qxqy,nBin_qxqy,eBin2D_qxqy 258 else 259 ii+=1 260 q1 = q2 261 endif 262 while(ii<numpnts(qBin_qxqy)-2) 224 263 225 264 // TODO: do I use dQ for the height of the panel? 226 // TODO : do I use 1/2 of dQ due to the symmetry of my smearing calculation? 227 delQy = abs(qy[0][nYpix-1] - qy[0][0]) 265 // TODO : do I use 1/2 of dQ due to the symmetry of my smearing calculation? 266 267 // TODO: use only dQy for the portion of the detector that was not masked! 268 269 ii = trunc(ntube/4) //random tube number 270 271 Make/O/D/N=(nYpix) tmpTube,tmpMaskTube 272 tmpTube = qy[ii][p] 273 tmpMaskTube = mask[ii][p] 274 275 // along the tube, keep the value, or set to NaN if masked 276 tmpTube = tmpMaskTube == 0 ? tmpTube : NaN 277 WaveStats/Q tmpTube 278 // Print V_max 279 // Print V_min 280 281 delQy = abs(V_max - V_min) 282 //print delQy 283 284 // not quite correct - this uses the whole detector height, but there is some masked out 285 // delQy = abs(qy[0][nYpix-1] - qy[0][0]) 228 286 229 287 // iBin_qxqy *= delQy -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf
r1108 r1109 482 482 SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda 483 483 DLStr = "0.12;" 484 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 484 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 485 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12" 485 486 486 487 // wavelength … … 497 498 return(0) 498 499 End 500 501 502 // White beam preset 503 // - set monochromator (this sets lam, delLam) 504 // - disregard the back detector (set as front/middle) 505 // 506 Function VC_WhiteBeamPreset() 507 508 VC_FrontMiddlePreset() // moves Middle into contact (but w/ wrong lambda) 509 // monochromator 510 PopupMenu VCALCCtrl_0c,mode=1,popvalue="White Beam" 511 512 // wavelength spread 513 SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda 514 DLStr = "0.40;" 515 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 516 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40" 517 518 // wavelength 519 SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=0 ,noedit=0 // allow user editing again 520 521 return(0) 522 end 523 524 525 // Graphite - high resolution beam preset 526 // - set monochromator (this sets lam, delLam) 527 // - uses the back detector (set as front/middle) 528 // 529 Function VC_GraphiteMonoPreset() 530 531 // front carriage 532 SetVariable VCALCCtrl_2a,value=_NUM:-20 //Left offset 533 SetVariable VCALCCtrl_2aa,value=_NUM:20 //Right offset 534 SetVariable VCALCCtrl_2b,value=_NUM:4 //Top offset 535 SetVariable VCALCCtrl_2bb,value=_NUM:-4 //Bottom offset 536 537 SetVariable VCALCCtrl_2d,value=_NUM:120 //SDD 538 539 // middle carriage 540 SetVariable VCALCCtrl_3a,value=_NUM:-8 //Left offset 541 SetVariable VCALCCtrl_3aa,value=_NUM:08 //Right offset 542 SetVariable VCALCCtrl_3b,value=_NUM:18 //Top offset (doesn't matter) 543 SetVariable VCALCCtrl_3bb,value=_NUM:-18 //Bottom offset (doesn't matter) 544 545 SetVariable VCALCCtrl_3d,value=_NUM:1500 //SDD 546 547 // back carriage 548 SetVariable VCALCCtrl_4b,value=_NUM:2300 //SDD 549 550 // monochromator 551 PopupMenu VCALCCtrl_0c,mode=1,popvalue="Graphite" 552 553 // wavelength spread 554 SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda 555 DLStr = "0.01;" 556 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 557 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01" 558 559 // wavelength 560 SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=0 ,noedit=0 // allow user editing again 561 562 //number of guides 563 Slider VCALCCtrl_0a,value= 0 564 565 566 // binning mode 567 PopupMenu popup_b,mode=1,popValue="F4-M4-B" 568 569 return(0) 570 end 571 499 572 500 573 // … … 596 669 // other values are changed in the initialization routines 597 670 // 598 Function beamIntensity()671 Function V_beamIntensity() 599 672 600 673 Variable alpha,f,t,t4,t5,t6,as,solid_angle,l1,d2_phi … … 670 743 Function VC_figureOfMerit() 671 744 672 Variable bi = beamIntensity()745 Variable bi = V_beamIntensity() 673 746 Variable lambda = VCALC_getWavelength() 674 747 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf
r1108 r1109 230 230 fPlotFrontPanels() 231 231 232 Print "Beam Intensity = ",beamIntensity()232 V_beamIntensity() 233 233 234 234 return(0) … … 402 402 case "Velocity Selector": 403 403 DLStr = "0.12;" 404 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 404 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 405 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12" 405 406 406 407 SetVariable VCALCCtrl_0b,disable=0,noedit=0 // allow user editing again … … 409 410 case "Graphite": 410 411 DLStr = "0.01;" 411 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 412 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 413 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01" 412 414 413 415 SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=2 // wavelength … … 415 417 case "White Beam": 416 418 DLStr = "0.40;" 417 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 419 // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda 420 PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40" 418 421 419 422 SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=2 //wavelength … … 445 448 String popStr = pa.popStr 446 449 450 String BinStr = "F2-M2xTB-B" 447 451 448 452 strswitch(popStr) … … 454 458 break 455 459 case "White Beam": 456 460 VC_WhiteBeamPreset() 461 binStr = "F4-M4-B" 457 462 break 463 case "Graphite": 464 VC_GraphiteMonoPreset() 465 binStr = "F4-M4-B" 466 break 458 467 case "Narrow Slit": 459 468 … … 461 470 case "Front+Middle Only": 462 471 VC_FrontMiddlePreset() 463 472 binStr = "F2-M2xTB-B" 464 473 break 465 474 case "Converging Pinholes": … … 481 490 Recalculate_AllDetectors() 482 491 483 492 // re-bin the data? 493 VC_RebinIQ_PopProc("",0,binStr) 494 484 495 break 485 496 case -1: // control being killed … … 1078 1089 // to fill in: 1079 1090 // values for always-visible items 1080 String/G gPresetPopStr = "Low Q;High Q;Front+Middle Only;Converging Pinholes;Narrow Slit;White Beam; Polarizer;"1091 String/G gPresetPopStr = "Low Q;High Q;Front+Middle Only;Converging Pinholes;Narrow Slit;White Beam;Graphite;Polarizer;" 1081 1092 String/G gBinTypeStr = ksBinTypeStr 1082 1093 Variable/G gBeamIntensity= 0 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r1101 r1109 965 965 966 966 967 ////////////968 // TODO: all of below is untested code969 // copied from SANS970 //971 //972 // NOV 2017973 // Currently, this is not called from any VSANS routines. it is only referenced974 // from V_Add_raw_to_work(), which would add two VSANS raw data files together. This has975 // not yet been implemented. I am only keeping this function around to be sure that976 // if/when V_Add_raw_to_work() is implemented, all of the functionality of V_DetCorr() is977 // properly duplicated.978 //979 //980 //981 //performs solid angle and non-linear detector corrections to raw data as it is "added" to a work folder982 //function is called by Raw_to_work() and Add_raw_to_work() functions983 //works on the actual data array, assumes that is is already on LINEAR scale984 //985 Function V_DetCorr(data,data_err,realsread,doEfficiency,doTrans)986 Wave data,data_err,realsread987 Variable doEfficiency,doTrans988 989 DoAlert 0,"This has not yet been updated for VSANS"990 991 Variable xcenter,ycenter,x0,y0,sx,sx3,sy,sy3,xx0,yy0992 Variable ii,jj,dtdist,dtdis2993 Variable xi,xd,yd,rad,ratio,domega,xy994 Variable lambda,trans,trans_err,lat_err,tmp_err,lat_corr995 996 // Print "...doing jacobian and non-linear corrections"997 998 NVAR pixelsX = root:myGlobals:gNPixelsX999 NVAR pixelsY = root:myGlobals:gNPixelsY1000 1001 //set up values to send to auxiliary trig functions1002 xcenter = pixelsX/2 + 0.5 // == 64.5 for 128x128 Ordela1003 ycenter = pixelsY/2 + 0.5 // == 64.5 for 128x128 Ordela1004 1005 x0 = realsread[16]1006 y0 = realsread[17]1007 sx = realsread[10]1008 sx3 = realsread[11]1009 sy = realsread[13]1010 sy3 = realsread[14]1011 1012 dtdist = 1000*realsread[18] //sdd in mm1013 dtdis2 = dtdist^21014 1015 lambda = realsRead[26]1016 trans = RealsRead[4]1017 trans_err = RealsRead[41] //new, March 20111018 1019 1020 //waves to contain repeated function calls1021 Make/O/N=(pixelsX) fyy,xx,yy //Assumes square detector !!!1022 ii=01023 do1024 xi = ii1025 // fyy[ii] = dc_fy(ii+1,sy,sy3,ycenter)1026 // xx[ii] = dc_fxn(ii+1,sx,sx3,xcenter)1027 // yy[ii] = dc_fym(ii+1,sy,sy3,ycenter)1028 ii+=11029 while(ii<pixelsX)1030 1031 Make/O/N=(pixelsX,pixelsY) SolidAngle // testing only1032 1033 ii=01034 do1035 xi = ii1036 // xd = dc_fx(ii+1,sx,sx3,xcenter)-xx01037 jj=01038 do1039 yd = fyy[jj]-yy01040 //rad is the distance of pixel ij from the sample1041 //domega is the ratio of the solid angle of pixel ij versus center pixel1042 // product xy = 1 for a detector with a linear spatial response (modern Ordela)1043 // solid angle calculated, dW^3 >=1, so multiply data to raise measured values to correct values.1044 rad = sqrt(dtdis2 + xd^2 + yd^2)1045 domega = rad/dtdist1046 ratio = domega^31047 xy = xx[ii]*yy[jj]1048 1049 data[ii][jj] *= xy*ratio1050 1051 solidAngle[ii][jj] = xy*ratio //testing only1052 data_err[ii][jj] *= xy*ratio //error propagation assumes that SA and Jacobian are exact, so simply scale error1053 1054 1055 // correction factor for detector efficiency JBG memo det_eff_cor2.doc 3/20/071056 // correction inserted 11/2007 SRK1057 // large angle detector efficiency is >= 1 and will "bump up" the measured value at the highest angles1058 // so divide here to get the correct answer (5/22/08 SRK)1059 if(doEfficiency)1060 // data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)1061 // data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)1062 // solidAngle[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd) //testing only1063 endif1064 1065 // large angle transmission calculation is <= 1 and will "bump down" the measured value at the highest angles1066 // so divide here to get the correct answer1067 if(doTrans)1068 1069 if(trans<0.1 && ii==0 && jj==0)1070 Print "***transmission is less than 0.1*** and is a significant correction"1071 endif1072 1073 if(trans==0)1074 if(ii==0 && jj==0)1075 Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation"1076 endif1077 trans = 11078 endif1079 1080 // pass in the transmission error, and the error in the correction is returned as the last parameter1081 1082 // lat_corr = V_LargeAngleTransmissionCorr(trans,dtdist,xd,yd,trans_err,lat_err) //moved from 1D avg SRK 11/20071083 1084 data[ii][jj] /= lat_corr //divide by the correction factor1085 //1086 //1087 //1088 // relative errors add in quadrature1089 tmp_err = (data_err[ii][jj]/lat_corr)^2 + (lat_err/lat_corr)^2*data[ii][jj]*data[ii][jj]/lat_corr^21090 tmp_err = sqrt(tmp_err)1091 1092 data_err[ii][jj] = tmp_err1093 1094 // solidAngle[ii][jj] = lat_err1095 1096 1097 //solidAngle[ii][jj] = LargeAngleTransmissionCorr(trans,dtdist,xd,yd) //testing only1098 endif1099 1100 jj+=11101 while(jj<pixelsX)1102 ii+=11103 while(ii<pixelsX)1104 1105 //clean up waves1106 1107 Return(0)1108 End1109 967 1110 968 … … 1259 1117 //w_ is the "work" file 1260 1118 //both are work files and should already be normalized to 10^8 monitor counts 1261 Function V_Absolute_Scale(type,w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err) 1262 String type 1119 Function V_Absolute_Scale(type,absStr) 1120 String type,absStr 1121 1122 1263 1123 Variable w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err 1264 1265 1124 1266 1125 Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 … … 1283 1142 1284 1143 w_moncount = V_getBeamMonNormData(type) 1285 1286 1144 1287 1145 if(w_moncount == 0) 1288 1146 //zero monitor counts will give divide by zero --- … … 1290 1148 Return(1) //report error 1291 1149 Endif 1150 1151 w_trans = V_getSampleTransmission(type) //sample transmission 1152 w_thick = V_getSampleThickness(type) //sample thickness 1153 trans_err = V_getSampleTransError(type) 1154 1155 1156 //get the parames from the list 1157 s_trans = NumberByKey("TSTAND", absStr, "=", ";") //parse the list of values 1158 s_thick = NumberByKey("DSTAND", absStr, "=", ";") 1159 s_izero = NumberByKey("IZERO", absStr, "=", ";") 1160 s_cross = NumberByKey("XSECT", absStr, "=", ";") 1161 kappa_err = NumberByKey("SDEV", absStr, "=", ";") 1162 1292 1163 1293 1164 //calculate scale factor … … 1298 1169 scale = s1*s2*s3*s4 1299 1170 1300 trans_err = V_getSampleTransError(type)1301 1171 1302 1172 // kappa comes in as s_izero, so be sure to use 1/kappa_err … … 1304 1174 // and now loop through all of the detectors 1305 1175 //do the actual absolute scaling here, modifying the data in ABS 1306 for(ii=0;ii<ItemsInList(ksDetectorList All);ii+=1)1307 detStr = StringFromList(ii, ksDetectorList All, ";")1176 for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 1177 detStr = StringFromList(ii, ksDetectorListNoB, ";") 1308 1178 Wave data = V_getDetectorDataW("ABS",detStr) 1309 1179 Wave data_err = V_getDetectorDataErrW("ABS",detStr) … … 1312 1182 data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 1313 1183 endfor 1184 1185 // do the back detector separately, if it is set to be used 1186 NVAR gIgnoreDetB = root:Packages:NIST:VSANS:Globals:gIgnoreDetB 1187 if(gIgnoreDetB == 0) 1188 detStr = "B" 1189 Wave data = V_getDetectorDataW("ABS",detStr) 1190 Wave data_err = V_getDetectorDataErrW("ABS",detStr) 1191 1192 //get the parames from the list 1193 s_trans = NumberByKey("TSTAND_B", absStr, "=", ";") //parse the list of values 1194 s_thick = NumberByKey("DSTAND_B", absStr, "=", ";") 1195 s_izero = NumberByKey("IZERO_B", absStr, "=", ";") 1196 s_cross = NumberByKey("XSECT_B", absStr, "=", ";") 1197 kappa_err = NumberByKey("SDEV_B", absStr, "=", ";") 1198 1199 //calculate scale factor 1200 s1 = defmon/w_moncount // monitor count (s1 should be 1) 1201 s2 = s_thick/w_thick 1202 s3 = s_trans/w_trans 1203 s4 = s_cross/s_izero 1204 scale = s1*s2*s3*s4 1205 1206 data *= scale 1207 data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 1208 endif 1314 1209 1315 1210 //********* 15APR02 … … 1476 1371 1477 1372 ////////////////////////// 1373 // detector corrections to stitch the back detector into one proper image 1374 // 1375 // 1376 // 1377 1378 1379 // 1380 // to register the image on the back detector panel 1381 // 1382 // middle portion (552 pix in Y) is held fixed 1383 // top portion of image is shifted right and down 1384 // bottom portion of image is shifted right and up 1385 // 1386 // remainder of image is filled with Zero (NaN causes problems converting to WORK) 1387 // 1388 // currently, data is not added together and averaged, but it could be 1389 // 1390 Function V_ShiftBackDetImage(w,adjW) 1391 Wave w,adjW 1392 1393 adjW=0 1394 1395 Variable topX,bottomX 1396 Variable topY,bottomY 1397 1398 topX = 7 1399 topY = 105 1400 1401 bottomX = 7 1402 bottomY = 35 1403 1404 // middle 1405 adjW[][552,552+552] = w[p][q] 1406 1407 //top 1408 adjW[0+topX,679][552+552,1655-topY] = w[p-topX][q+topY] 1409 1410 //bottom 1411 adjW[0+bottomX,679][0+bottomY,551] = w[p-bottomX][q-bottomY] 1412 1413 return(0) 1414 End 1415 1416 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf
r1101 r1109 77 77 // 78 78 string tmpStr = "root:Packages:NIST:VSANS:RAW:entry:instrument:" 79 80 // if the data is DIV, then handle the data errors differently since they are already part of the data file 81 // root:Packages:NIST:VSANS:DIV:entry:instrument:detector_B: 82 if(cmpstr(folder,"DIV")==0) 83 // makes data error and linear copy -- DP waves if V_MakeDataWaves_DP() called above 84 tmpStr = "root:Packages:NIST:VSANS:DIV:entry:instrument:" 85 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 86 detStr = StringFromList(ii, ksDetectorListAll, ";") 87 SetDataFolder $(tmpStr+"detector_"+detStr) 88 //V_MakeDataError(tmpStr+"detector_"+detStr) 89 Wave data=data 90 Duplicate/O data $(tmpStr+"detector_"+detStr+":linear_data") 91 Wave linear_data_error=linear_data_error 92 Duplicate/O linear_data_error $(tmpStr+"detector_"+detStr+":data_error") 93 SetDataFolder root: 94 endfor 95 endif 96 97 98 79 99 80 100 if(cmpstr(folder,"RAW")==0) … … 200 220 endif 201 221 202 222 223 // shift the detector image on the back detector to get the three CCD images to match up 224 // in real space. the distance matrices x and y still apply. be sure to mask out the chunks 225 // that were lost in the shift 226 227 // the data wave is altered 228 // the linear_data wave is not altered 229 230 Wave adjW = V_getDetectorDataW(folder,"B") 231 Wave w = V_getDetectorLinearDataW(folder,"B") 232 V_ShiftBackDetImage(w,adjW) 233 234 // and repeat for the error wave 235 Wave adjW = V_getDetectorDataErrW(folder,"B") 236 Wave w = V_getDetectorLinearDataErrW(folder,"B") 237 V_ShiftBackDetImage(w,adjW) 238 239 240 203 241 /// END DATA CORRECTIONS FOR LOADER 204 242 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r1106 r1109 1499 1499 End 1500 1500 1501 // NOTE - this is not part of the file as written 1502 // it is generated when the RAW data is loaded (when the error wave is generated) 1503 Function/WAVE V_getDetectorLinearDataW(fname,detStr) 1504 String fname,detStr 1505 1506 String path = "entry:instrument:detector_"+detStr+":linear_data" 1507 WAVE w = V_getRealWaveFromHDF5(fname,path) 1508 1509 return w 1510 End 1511 1501 1512 // 1502 1513 // TODO -- this does not exist in the raw data, but does in the processed data 1503 1514 // !!! how to handle this?? Binning routines need the error wave 1504 1515 // 1516 Function/WAVE V_getDetectorLinearDataErrW(fname,detStr) 1517 String fname,detStr 1518 1519 String path = "entry:instrument:detector_"+detStr+":linear_data_error" 1520 WAVE w = V_getRealWaveFromHDF5(fname,path) 1521 1522 return w 1523 End 1524 1525 1526 // 1527 // TODO -- this does not exist in the raw data, but does in the processed data 1528 // !!! how to handle this?? Binning routines need the error wave 1529 // 1505 1530 Function/WAVE V_getDetectorDataErrW(fname,detStr) 1506 1531 String fname,detStr 1507 1532 1508 String path = "entry:instrument:detector_"+detStr+": linear_data_error"1533 String path = "entry:instrument:detector_"+detStr+":data_error" 1509 1534 WAVE w = V_getRealWaveFromHDF5(fname,path) 1510 1535 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf
r1106 r1109 216 216 // endif 217 217 return(err) 218 End 219 220 // fname is a local WORK folder 221 Function V_putCollectionTime(fname,val) 222 String fname 223 Variable val 224 225 //root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x 226 String path = "root:Packages:NIST:VSANS:"+fname+":" 227 path += "entry:collection_time" 228 229 Wave/Z w = $path 230 if(waveExists(w) == 0) 231 return(1) 232 else 233 w[0] = val 234 return(0) 235 endif 236 218 237 End 219 238 … … 748 767 end 749 768 769 // fname is a local WORK folder 770 Function V_putDetector_counts(fname,val) 771 String fname 772 Variable val 773 774 //root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x 775 String path = "root:Packages:NIST:VSANS:"+fname+":" 776 path += "entry:control:detector_counts" 777 778 Wave/Z w = $path 779 if(waveExists(w) == 0) 780 return(1) 781 else 782 w[0] = val 783 return(0) 784 endif 785 786 End 750 787 751 788 Function V_writeDetector_preset(fname,val) … … 852 889 return(err) 853 890 end 891 892 // fname is a local WORK folder 893 Function V_putControlMonitorCount(fname,val) 894 String fname 895 Variable val 896 897 //root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x 898 String path = "root:Packages:NIST:VSANS:"+fname+":" 899 path += "entry:control:monitor_counts" 900 901 Wave/Z w = $path 902 if(waveExists(w) == 0) 903 return(1) 904 else 905 w[0] = val 906 return(0) 907 endif 908 909 End 854 910 855 911 //integer value … … 3236 3292 End 3237 3293 3294 // fname is a local WORK folder 3295 Function V_putBeamMonNormSaved_count(fname,val) 3296 String fname 3297 Variable val 3298 3299 String path = "root:Packages:NIST:VSANS:"+fname+":" 3300 path += "entry:instrument:beam_monitor_norm:saved_count" 3301 3302 Wave/Z w = $path 3303 if(waveExists(w) == 0) 3304 return(1) 3305 else 3306 w[0] = val 3307 return(0) 3308 endif 3309 3310 End 3311 3312 3313 3238 3314 Function V_writeBeamMonNormType(fname,str) 3239 3315 String fname,str … … 4367 4443 // endif 4368 4444 return(err) 4445 End 4446 4447 // fname is a local WORK folder 4448 Function V_putDet_IntegratedCount(fname,detStr,val) 4449 String fname,detStr 4450 Variable val 4451 4452 //root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x 4453 String path = "root:Packages:NIST:VSANS:"+fname+":" 4454 path += "entry:instrument:detector_"+detStr+":integrated_count" 4455 4456 Wave/Z w = $path 4457 if(waveExists(w) == 0) 4458 return(1) 4459 else 4460 w[0] = val 4461 return(0) 4462 endif 4463 4369 4464 End 4370 4465 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf
r1104 r1109 352 352 String/G root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr="" 353 353 String/G root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr="" 354 String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="" 354 355 355 356 Return(0) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Marquee_Operations.ipf
r1097 r1109 221 221 End 222 222 223 224 //sums the data counts in the box specified by (x1,y1) to (x2,y2) 225 //assuming that x1<x2, and y1<y2 226 //the x,y values must also be in array coordinates[0] NOT scaled detector coords. 227 // 228 // accepts arbitrary detector coordinates. calling function is responsible for 229 // keeping selection in bounds 230 // 231 // basically the same as V_SumCountsInBox, except the PBR value has been removed so that the 232 // function can be used from the command line 233 // 234 Function V_SumCountsInBox_Cmd(x1,x2,y1,y2,type,detStr) 235 Variable x1,x2,y1,y2 236 String type,detStr 237 238 Variable counts = 0,ii,jj,err2_sum,ct_err 239 240 // get the waves of the data and the data_err 241 Wave w = V_getDetectorDataW(type,detStr) 242 Wave data_err = V_getDetectorDataErrW(type,detStr) 243 244 245 err2_sum = 0 // running total of the squared error 246 ii=x1 247 jj=y1 248 do 249 do 250 counts += w[ii][jj] 251 err2_sum += data_err[ii][jj]*data_err[ii][jj] 252 jj+=1 253 while(jj<=y2) 254 jj=y1 255 ii+=1 256 while(ii<=x2) 257 258 err2_sum = sqrt(err2_sum) 259 ct_err = err2_sum 260 261 Print "sum of counts = ",counts 262 Print "error = ",ct_err 263 Print "error/counts = ",ct_err/counts 264 265 Return (counts) 266 End 267 268 Proc pV_SumCountsInBox_Cmd(x1,x2,y1,y2,type,detStr) : GraphMarquee 269 Variable x1=280,x2=430,y1=350,y2=1020 270 String type="RAW",detStr="B" 271 272 V_SumCountsInBox_Cmd(x1,x2,y1,y2,type,detStr) 273 End 223 274 224 275 Function V_FindCentroid() : GraphMarquee -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf
r1106 r1109 525 525 526 526 //w[9] 527 //c urrently unused527 //collimation type (filled in at averaging?) 528 528 w[9] = "" 529 529 //w[10] … … 794 794 795 795 String list="",item="",fname,newList,intent 796 Variable ii,num 796 Variable ii,num,val 797 797 798 798 PathInfo catPathName … … 800 800 801 801 newList = V_Get_NotRawDataFileList() 802 newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files803 newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files804 newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files805 newList = V_RemoveEXTFromList(newlist,"phi") // remove the phi files806 newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files807 newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only)802 // newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files 803 // newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files 804 // newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files 805 // newList = V_RemoveEXTFromList(newlist,"phi") // remove the phi files 806 // newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files 807 // newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only) 808 808 809 809 num=ItemsInList(newList) 810 810 811 // keep only DIV files in the list 812 num=ItemsInList(newList) 813 814 String matchStr="*_DIV_*" // this is part of the title of a VSANS _DIV_ file 815 for(ii=0;ii<num;ii+=1) 816 item=StringFromList(ii, newList , ";") 817 val = stringmatch(item,matchStr) 818 if( val ) // true if the string did match 819 list += item + ";" 820 endif 821 822 endfor 823 824 List = SortList(List,";",0) 825 826 // 827 // String match="DIV" 811 828 // for(ii=0;ii<num;ii+=1) 812 829 // item=StringFromList(ii, newList , ";") 813 // fname = path + item 814 // intent = V_getReduction_intent(fname) 815 // if(cmpstr(intent,"SENSITIVITY") == 0) 816 // list += item + ";" 830 // Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item 831 //// Grep/P=catPathName/Q/E=("(?i)"+match) item 832 // if( V_value ) // at least one instance was found 833 //// Print "found ", item,ii 834 //// if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) 835 // list += item + ";" 836 //// endif 817 837 // endif 818 //819 838 // endfor 820 821 String match="DIV" 839 // 840 841 return(list) 842 end 843 844 845 Function/S V_GetMSKList() 846 847 String list="",item="",fname,newList,intent 848 Variable ii,num,val 849 850 PathInfo catPathName 851 String path = S_path 852 853 newList = V_Get_NotRawDataFileList() 854 // newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files 855 // newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files 856 // newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files 857 // newList = V_RemoveEXTFromList(newlist,"phi") // remove the phi files 858 // newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files 859 // newList = V_RemoveEXTFromList(newlist,"png") // remove the png files 860 // newList = V_RemoveEXTFromList(newlist,"jpg") // remove the jpg files 861 // newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only) 862 863 // keep only MASK files in the list 864 num=ItemsInList(newList) 865 866 String matchStr="*_MASK_*" // this is part of the title of a VSANS _MASK_ file 822 867 for(ii=0;ii<num;ii+=1) 823 868 item=StringFromList(ii, newList , ";") 824 Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item 825 // Grep/P=catPathName/Q/E=("(?i)"+match) item 826 if( V_value ) // at least one instance was found 827 // Print "found ", item,ii 828 // if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) 869 val = stringmatch(item,matchStr) 870 if( val ) // true if the string did match 829 871 list += item + ";" 830 // endif831 872 endif 873 832 874 endfor 833 875 834 876 List = SortList(List,";",0) 835 836 return(list) 837 end 838 839 840 Function/S V_GetMSKList() 841 842 String list="",item="",fname,newList,intent 843 Variable ii,num 844 845 PathInfo catPathName 846 String path = S_path 847 848 newList = V_Get_NotRawDataFileList() 849 newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files 850 newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files 851 newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files 852 newList = V_RemoveEXTFromList(newlist,"phi") // remove the phi files 853 newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files 854 newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only) 855 856 num=ItemsInList(newList) 857 877 878 879 // 880 //// String match="MASK" // this is part of the title of a VSANS MASK file 881 // String match="VSANS_MASK" // this is part of the title of a VSANS MASK file 858 882 // for(ii=0;ii<num;ii+=1) 859 883 // item=StringFromList(ii, newList , ";") 860 // fname = path + item 861 // intent = V_getReduction_intent(fname) 862 // if(cmpstr(intent,"SENSITIVITY") == 0) 863 // list += item + ";" 884 // Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item 885 //// Grep/P=catPathName/Q/E=("(?i)"+match) item 886 // if( V_value ) // at least one instance was found 887 //// Print "found ", item,ii 888 //// if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) 889 // list += item + ";" 890 //// endif 864 891 // endif 865 892 // 866 893 // endfor 867 868 // String match="MASK" // this is part of the title of a VSANS MASK file 869 String match="VSANS_MASK" // this is part of the title of a VSANS MASK file 870 for(ii=0;ii<num;ii+=1) 871 item=StringFromList(ii, newList , ";") 872 Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item 873 // Grep/P=catPathName/Q/E=("(?i)"+match) item 874 if( V_value ) // at least one instance was found 875 // Print "found ", item,ii 876 // if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) 877 list += item + ";" 878 // endif 879 endif 880 881 endfor 882 894 // 895 896 883 897 List = SortList(List,";",0) 884 898 … … 1003 1017 1004 1018 //will prompt for a list of ABS parameters (4) through a global string variable 1005 1006 Execute "V_AskForAbsoluteParams_Quest()" 1007 1019 if(cmpstr(ctrlName,"pick_ABS_B") == 0) 1020 Execute "V_AskForAbsoluteParams_Quest(1)" 1021 else 1022 Execute "V_AskForAbsoluteParams_Quest(0)" 1023 endif 1008 1024 End 1009 1025 … … 1078 1094 // Button pick_DIV,pos={214,173},size={70,20},proc=V_PickDIVButton,title="set DIV" 1079 1095 // Button pick_DIV,help={"This button will set the file selected in the File Catalog table to be the sensitivity file."} 1080 Button pick_ABS,pos={264,308},size={ 70,20},proc=V_SetABSParamsButton,title="set ABS"1096 Button pick_ABS,pos={264,308},size={80,20},proc=V_SetABSParamsButton,title="set ABS MF" 1081 1097 Button pick_ABS,help={"This button will prompt the user for absolute scaling parameters"} 1098 1099 Button pick_ABS_B,pos={264,330},size={80,20},proc=V_SetABSParamsButton,title="set ABS B" 1100 Button pick_ABS_B,help={"This button will prompt the user for absolute scaling parameters"} 1082 1101 // Button pick_MASK,pos={214,266},size={70,20},proc=V_PickMASKButton,title="set MASK" 1083 1102 // Button pick_MASK,help={"This button will set the file selected in the File Catalog table to be the mask file."} … … 2266 2285 //values are passed back as a global string variable (keyword=value) 2267 2286 // 2268 Proc V_AskForAbsoluteParams(c2,c3,c4,c5,I_err )2287 Proc V_AskForAbsoluteParams(c2,c3,c4,c5,I_err,back_values) 2269 2288 Variable c2=1,c3=1,c4=1e8,c5=1,I_err=1 2289 String back_values="no" 2270 2290 Prompt c2, "Standard Transmission" 2271 2291 Prompt c3, "Standard Thickness (cm)" … … 2273 2293 Prompt c5, "Standard Cross-Section (cm-1)" 2274 2294 Prompt I_err, "error in I(q=0) (one std dev)" 2275 2276 String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="" 2277 2278 root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "TSTAND="+num2str(c2) 2279 root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "DSTAND="+num2str(c3) 2280 root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "IZERO="+num2str(c4) 2281 root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "XSECT="+num2str(c5) 2282 root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "SDEV="+num2str(I_err) 2283 2295 prompt back_values, "are these values for the back detector (yes/no)?" 2296 2297 SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols 2298 2299 if(cmpstr(back_values,"no")==0) 2300 gAbsStr = ReplaceStringByKey("TSTAND",gAbsStr,num2str(c2),"=",";") 2301 gAbsStr = ReplaceStringByKey("DSTAND",gAbsStr,num2str(c3),"=",";") 2302 gAbsStr = ReplaceStringByKey("IZERO",gAbsStr,num2str(c4),"=",";") 2303 gAbsStr = ReplaceStringByKey("XSECT",gAbsStr,num2str(c5),"=",";") 2304 gAbsStr = ReplaceStringByKey("SDEV",gAbsStr,num2str(I_err),"=",";") 2305 else 2306 gAbsStr = ReplaceStringByKey("TSTAND_B",gAbsStr,num2str(c2),"=",";") 2307 gAbsStr = ReplaceStringByKey("DSTAND_B",gAbsStr,num2str(c3),"=",";") 2308 gAbsStr = ReplaceStringByKey("IZERO_B",gAbsStr,num2str(c4),"=",";") 2309 gAbsStr = ReplaceStringByKey("XSECT_B",gAbsStr,num2str(c5),"=",";") 2310 gAbsStr = ReplaceStringByKey("SDEV_B",gAbsStr,num2str(I_err),"=",";") 2311 endif 2312 2313 2314 SetDataFolder root: 2284 2315 End 2285 2316 … … 2296 2327 //in either case, the global keyword=value string is set. 2297 2328 // 2298 Function V_AskForAbsoluteParams_Quest() 2329 // 2330 // if isBack == 1, then the values are for the back panel 2331 // AND there are different steps that must be done to subtract off 2332 // the read noise of the CCDs 2333 // 2334 Function V_AskForAbsoluteParams_Quest(isBack) 2335 Variable isBack 2299 2336 2300 2337 Variable err,loc,refnum … … 2374 2411 2375 2412 V_LoadAndPlotRAW_wName(emptyFileName) 2376 // convert raw->SAM 2377 // V_Raw_to_work("SAM") 2378 // V_UpdateDisplayInformation("SAM") 2413 2379 2414 V_UpdateDisplayInformation("RAW") 2380 2415 … … 2404 2439 // detStr = "MR" 2405 2440 2441 2406 2442 emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"RAW",detPanel_toSum) 2407 2443 2408 2444 Print "empty counts = ",emptyCts 2409 2445 Print "empty err/counts = ",empty_ct_err/emptyCts 2446 2447 // if it's the back panel, find the read noise to subtract 2448 // shift the marquee to the right to (hopefully) a blank spot 2449 Variable noiseCts,noiseCtsErr,delta 2450 if(isBack) 2451 delta = xyBoxW[1] - xyBoxW[0] 2452 noiseCts = V_SumCountsInBox(xyBoxW[1],xyBoxW[1]+delta,xyBoxW[2],xyBoxW[3],noiseCtsErr,"RAW",detPanel_toSum) 2453 2454 print "average read noise per pixel = ",noiseCts/(xyBoxW[1]-xyBoxW[0])/(xyBoxW[3]-xyBoxW[2]) 2455 Print "read noise counts = ",noiseCts 2456 Print "read noise err/counts = ",noiseCtsErr/noiseCts 2457 2458 emptyCts -= noiseCts 2459 empty_ct_err = sqrt(empty_ct_err^2 + noiseCtsErr^2) 2460 2461 Print "adjusted empty counts = ",emptyCts 2462 Print "adjusted err/counts = ",empty_ct_err/emptyCts 2463 endif 2410 2464 2411 2465 // … … 2446 2500 junkStr = num2str(kappa) 2447 2501 errStr = num2Str(kappa_err) 2448 Execute "V_AskForAbsoluteParams(1,1,"+junkStr+",1,"+errStr+")" //no missing parameters, no dialog 2449 2502 2503 String strToExecute="" 2504 2505 if(isBack) 2506 sprintf strToExecute, "V_AskForAbsoluteParams(1,1,%g,1,%g,\"%s\")",kappa,kappa_err,"yes" //no missing parameters, no dialog 2507 else 2508 sprintf strToExecute, "V_AskForAbsoluteParams(1,1,%g,1,%g,\"%s\")",kappa,kappa_err,"no" //no missing parameters, no dialog 2509 endif 2510 // print strToExecute 2511 Execute strToExecute 2450 2512 2451 2513 Printf "Kappa was successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 … … 2861 2923 Variable c2,c3,c4,c5,kappa_err,err 2862 2924 //do absolute scaling if desired 2863 // DoAlert 0,"Abs step incomplete"2864 2925 2865 2926 if(cmpstr("none",absStr)!=0) 2866 2927 if(cmpstr("ask",absStr)==0) 2867 //get the params from the user2868 Execute "V_AskForAbsoluteParams_Quest()"2869 //then from the list2870 SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr2871 c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";") //parse the list of values2872 c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";")2873 c4 = NumberByKey("IZERO", junkAbsStr, "=", ";")2874 c5 = NumberByKey("XSECT", junkAbsStr, "=", ";")2875 kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";")2928 // //get the params from the user 2929 // Execute "V_AskForAbsoluteParams_Quest()" 2930 // //then from the list 2931 // SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr 2932 // c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";") //parse the list of values 2933 // c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";") 2934 // c4 = NumberByKey("IZERO", junkAbsStr, "=", ";") 2935 // c5 = NumberByKey("XSECT", junkAbsStr, "=", ";") 2936 // kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";") 2876 2937 else 2877 2938 //get the parames from the list … … 2883 2944 Endif 2884 2945 //get the sample trans and thickness from the activeType folder 2885 Variable c0 = V_getSampleTransmission(activeType) //sample transmission2886 Variable c1 = V_getSampleThickness(activeType) //sample thickness2887 2888 err = V_Absolute_Scale(activeType, c0,c1,c2,c3,c4,c5,kappa_err)2946 // Variable c0 = V_getSampleTransmission(activeType) //sample transmission 2947 // Variable c1 = V_getSampleThickness(activeType) //sample thickness 2948 2949 err = V_Absolute_Scale(activeType,absStr) 2889 2950 if(err) 2890 2951 return(err) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf
r1075 r1109 95 95 Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 1 96 96 97 DoAlert 0,"The Back detector will be ignored. This can be changed in the Preferences Panel" 97 DoAlert 1,"Are you using the back detector? (This can be changed later in the Preferences Panel)" 98 if(V_flag == 1) 99 // yes 100 Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 0 101 endif 98 102 99 103 // flag to allow adding raw data files with different attenuation (normally not done) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r1106 r1109 107 107 // need to do this the hard way, duplicate/O recursively 108 108 // see V_CopyToWorkFolder() 109 109 110 // gFileList is above "entry" which is my additions 111 SVAR fileList_dest = $("root:Packages:NIST:VSANS:"+toStr+":gFileList") 112 SVAR fileList_tmp = $("root:Packages:NIST:VSANS:"+fromStr+":gFileList") 113 fileList_dest = fileList_tmp 114 110 115 // everything on the top level 111 116 V_DuplicateDataFolder($(fromDF+":entry"),fromStr,toStr,0,"",0) //no recursion here … … 402 407 // for S = 1 in eq (7), this corresponds to one sigma error bars 403 408 Duplicate/O linear_data linear_data_error 404 linear_data_error = 1 + sqrt(linear_data + 0.75) 409 linear_data_error = 1 + sqrt(linear_data + 0.75) 410 411 Duplicate/O linear_data_error data_error 405 412 // 406 413 … … 435 442 else 436 443 //yes, add RAW to the current work folder contents 437 Abort "Adding RAW data files is currently unsupported"444 //Abort "Adding RAW data files is currently unsupported" 438 445 err = V_Add_raw_to_work(newtype) 439 446 endif … … 778 785 NVAR doEfficiency = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor 779 786 780 //781 ///// these lines are if files are added together, not done (yet) for VSANS782 //783 //update totals to put in the work header (at the end of the function)784 // total_mon += realsread[0]785 //786 // total_det += dscale*realsread[2]787 //788 // total_trn += realsread[39]789 // total_rtime += integersread[2]790 // total_numruns +=1791 //792 793 787 // 794 788 //reset the current displaytype to "newtype" … … 801 795 End 802 796 803 797 // 804 798 //will "ADD" the current contents of the RAW folder to the newType work folder 805 // and will ADD the RAW contents to the existing content of the newType folder799 // 806 800 // - used when adding multiple runs together 807 //(the function Raw_to_work(type) makes a fresh workfile)801 //(the function V_Raw_to_work(type) makes a fresh workfile) 808 802 // 809 803 //the current display type is updated to newType (global) … … 811 805 String newType 812 806 813 // NEW OCT 2014814 // this corrects for adding raw data files with different attenuation815 // does nothing if the attenuation of RAW and destination are the same816 NVAR doAdjustRAW_Atten = root:Packages:NIST:gDoAdjustRAW_Atten817 if(doAdjustRAW_Atten)818 V_Adjust_RAW_Attenuation(newType)819 endif820 821 807 String destPath="" 822 823 808 // if the desired workfile doesn't exist, let the user know, and just make a new one 824 if(WaveExists($("root:Packages:NIST: "+newType + ":data")) == 0)809 if(WaveExists($("root:Packages:NIST:VSANS:"+newType + ":entry:instrument:detector_FL:data")) == 0) 825 810 Print "There is no old work file to add to - a new one will be created" 826 //call Raw_to_work(), then return from this function811 //call V_Raw_to_work(), then return from this function 827 812 V_Raw_to_Work(newType) 828 813 Return(0) //does not generate an error - a single file was converted to work.newtype 829 814 Endif 830 831 NVAR pixelsX = root:myGlobals:gNPixelsX 832 NVAR pixelsY = root:myGlobals:gNPixelsY 833 815 816 817 // convert the RAW data to a WORK file. 818 // this will do all of the necessary corrections to the data 819 // put this in some separate work folder that can be cleaned out at the end (ADJ) 820 String tmpType="ADJ" 821 V_Raw_to_Work(tmpType) 822 834 823 //now make references to data in newType folder 835 DestPath="root:Packages:NIST:"+newType 836 WAVE data=$(destPath +":linear_data") // these wave references point to the EXISTING work data 837 WAVE data_copy=$(destPath +":data") // these wave references point to the EXISTING work data 838 WAVE dest_data_err=$(destPath +":linear_data_error") // these wave references point to the EXISTING work data 839 WAVE/T textread=$(destPath + ":textread") 840 WAVE integersread=$(destPath + ":integersread") 841 WAVE realsread=$(destPath + ":realsread") 842 843 Variable deadTime,defmon,total_mon,total_det,total_trn,total_numruns,total_rtime 844 Variable ii,jj,itim,cntrate,dscale,scale,uscale,wrk_beamx,wrk_beamy,xshift,yshift 845 846 847 defmon=1e8 //default monitor counts 848 849 //Yes, add to previous run(s) in work, that does exist 850 //use the actual monitor count run.savmon rather than the normalized monitor count 851 //in run.moncnt and unscale the work data 852 853 total_mon = realsread[1] //saved monitor count 854 uscale = total_mon/defmon //unscaling factor 855 total_det = uscale*realsread[2] //unscaled detector count 856 total_trn = uscale*realsread[39] //unscaled trans det count 857 total_numruns = integersread[3] //number of runs in workfile 858 total_rtime = integersread[2] //total counting time in workfile 859 //retrieve workfile beamcenter 860 wrk_beamx = realsread[16] 861 wrk_beamy = realsread[17] 862 //unscale the workfile data in "newType" 863 // 864 //check for log-scaling and adjust if necessary 865 // should not be needed now - using display flag instead 866 // ConvertFolderToLinearScale(newType) 867 // 868 //then unscale the data array 869 data *= uscale 870 dest_data_err *= uscale 871 872 //DetCorr() has not been applied to the data in RAW , do it now in a local reference to the raw data 873 WAVE raw_data = $"root:Packages:NIST:RAW:linear_data" 874 WAVE raw_data_err = $"root:Packages:NIST:RAW:linear_data_error" 875 WAVE raw_reals = $"root:Packages:NIST:RAW:realsread" 876 WAVE/T raw_text = $"root:Packages:NIST:RAW:textread" 877 WAVE raw_ints = $"root:Packages:NIST:RAW:integersread" 878 879 //check for log-scaling of the raw data - make sure it's linear 880 // should not be needed now - using display flag instead 881 // ConvertFolderToLinearScale("RAW") 882 883 // switches to control what is done, don't do the transmission correction for the BGD measurement 884 NVAR doEfficiency = root:Packages:NIST:gDoDetectorEffCor 885 NVAR gDoTrans = root:Packages:NIST:gDoTransmissionCor 886 Variable doTrans = gDoTrans 887 if(cmpstr("BGD",newtype) == 0) 888 doTrans = 0 //skip the trans correction for the BGD file but don't change the value of the global 889 endif 890 891 V_DetCorr(raw_data,raw_data_err,raw_reals,doEfficiency,doTrans) //applies correction to raw_data, and overwrites it 892 893 //deadtime corrections to raw data 894 // TODO - do the tube correction for dead time now 895 deadTime = 1//DetectorDeadtime(raw_text[3],raw_text[9],dateAndTimeStr=raw_text[1],dtime=raw_reals[48]) //pick the correct detector deadtime, switch on date too 896 itim = raw_ints[2] 897 cntrate = sum(raw_data,-inf,inf)/itim //080802 use data sum, rather than scaler value 898 dscale = 1/(1-deadTime*cntrate) 899 900 #if (exists("ILL_D22")==6) 901 Variable tubeSum 902 // for D22 detector might need to use cntrate/128 as it is the tube response 903 for(ii=0;ii<pixelsX;ii+=1) 904 //sum the counts in each tube 905 tubeSum = 0 906 for(jj=0;jj<pixelsY;jj+=1) 907 tubeSum += data[jj][ii] 908 endfor 909 // countrate in tube ii 910 cntrate = tubeSum/itim 911 // deadtime scaling in tube ii 912 dscale = 1/(1-deadTime*cntrate) 913 // multiply data[ii][] by the dead time 914 raw_data[][ii] *= dscale 915 raw_data_err[][ii] *= dscale 824 DestPath="root:Packages:NIST:VSANS:"+newType 825 826 827 ///////////////// 828 //fields that need to be added together 829 // entry block 830 // collection_time V_getCollectionTime(fname) V_putCollectionTime(fname,val) 831 832 // instrument block 833 // beam_monitor_norm 834 // data (this will be 1e8) V_getBeamMonNormData(fname) V_putBeamMonNormData(fname,val) 835 // saved_count (this is the original monitor count) V_getBeamMonNormSaved_count(fname) V_putBeamMonNormSaved_count(fname,val) 836 837 // for each detector 838 // data V_getDetectorDataW(fname,detStr) 839 // integrated_count V_getDet_IntegratedCount(fname,detStr) V_putDet_IntegratedCount(fname,detStr,val) 840 // linear_data V_getDetectorLinearDataW(fname,detStr) 841 // RECALCULATE (or add properly) linear_data_error V_getDetectorDataErrW(fname,detStr) 842 843 844 // control block (these may not actually be used?) 845 // count_time V_getCount_time(fname) V_putCount_time(fname,val) 846 // detector_counts V_getDetector_counts(fname) V_putDetector_counts(fname,val) 847 // monitor_counts V_getControlMonitorCount(fname) V_putControlMonitorCount(fname,val) 848 849 // sample block - nothing 850 // reduction block - nothing 851 // user block - nothing 852 853 // ?? need to add the file name to a list of what was actually added - so it will be saved with I(q) 854 // 855 //////////////////// 856 857 // total_mon = realsread[1] //saved monitor count 858 // uscale = total_mon/defmon //unscaling factor 859 // total_det = uscale*realsread[2] //unscaled detector count 860 // total_trn = uscale*realsread[39] //unscaled trans det count 861 // total_numruns = integersread[3] //number of runs in workfile 862 // total_rtime = integersread[2] //total counting time in workfile 863 864 865 String detStr 866 867 Variable saved_mon_dest,scale_dest,saved_mon_tmp,scale_tmp 868 Variable collection_time_dest,collection_time_tmp,count_time_dest,count_time_tmp 869 Variable detCount_dest,detCount_tmp,det_integrated_ct_dest,det_integrated_ct_tmp 870 Variable ii,new_scale,defMon 871 872 defMon=1e8 //default monitor counts 873 874 // find the scaling factors, one for each folder 875 saved_mon_dest = V_getBeamMonNormSaved_count(newType) 876 scale_dest = saved_mon_dest/defMon //un-scaling factor 877 878 saved_mon_tmp = V_getBeamMonNormSaved_count(tmpType) 879 scale_tmp = saved_mon_dest/defMon //un-scaling factor 880 881 new_scale = defMon / (saved_mon_dest+saved_mon_tmp) 882 883 884 // get the count time for each (two locations) 885 collection_time_dest = V_getCollectionTime(newType) 886 collection_time_tmp = V_getCollectionTime(tmpType) 887 888 count_time_dest = V_getCount_time(newType) 889 count_time_tmp = V_getCount_time(tmpType) 890 891 detCount_dest = V_getDetector_counts(newType) 892 detCount_tmp = V_getDetector_counts(tmpType) 893 894 // update the fields that are not in the detector blocks 895 // in entry 896 V_putCollectionTime(newType,collection_time_dest+collection_time_tmp) 897 898 // in control block 899 V_putCount_time(newType,count_time_dest+count_time_tmp) 900 V_putDetector_counts(newType,detCount_dest+detCount_tmp) 901 V_putControlMonitorCount(newType,saved_mon_dest+saved_mon_tmp) 902 903 904 // now loop over all of the detector panels 905 // data 906 // data_err 907 // integrated count 908 // linear_data 909 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 910 detStr = StringFromList(ii, ksDetectorListAll, ";") 911 912 Wave data_dest = V_getDetectorDataW(newType,detStr) 913 Wave data_err_dest = V_getDetectorDataErrW(newType,detStr) 914 Wave linear_data_dest = V_getDetectorLinearDataW(newType,detStr) 915 det_integrated_ct_dest = V_getDet_IntegratedCount(newType,detStr) 916 917 Wave data_tmp = V_getDetectorDataW(tmpType,detStr) 918 Wave data_err_tmp = V_getDetectorDataErrW(tmpType,detStr) 919 Wave linear_data_tmp = V_getDetectorLinearDataW(tmpType,detStr) 920 det_integrated_ct_tmp = V_getDet_IntegratedCount(tmpType,detStr) 921 922 // unscale the data arrays 923 data_dest *= scale_dest 924 data_err_dest *= scale_dest 925 linear_data_dest *= scale_dest 926 927 data_tmp *= scale_tmp 928 data_err_tmp *= scale_tmp 929 linear_data_tmp *= scale_tmp 930 931 // add them together, the dest is a wave so it is automatically changed in the "dest" folder 932 V_putDet_IntegratedCount(tmpType,detStr,det_integrated_ct_dest+det_integrated_ct_tmp) 933 data_dest += data_tmp 934 data_err_dest = sqrt(data_err_dest^2 + data_err_tmp^2) // add in quadrature 935 linear_data_dest += linear_data_tmp 936 937 // now rescale the data_dest to the monitor counts 938 data_dest *= new_scale 939 data_err_dest *= new_scale 940 linear_data_dest *= new_scale 941 916 942 endfor 917 #else 918 // dead time correction on all other RAW data, including NCNR 919 raw_data *= dscale 920 raw_data_err *= dscale 921 #endif 922 923 //update totals by adding RAW values to the local ones (write to work header at end of function) 924 total_mon += raw_reals[0] 925 926 total_det += dscale*raw_reals[2] 927 928 total_trn += raw_reals[39] 929 total_rtime += raw_ints[2] 930 total_numruns +=1 931 932 //do the beamcenter shifting if there is a mismatch 933 //and then add the two data sets together, changing "data" since it is the workfile data 934 xshift = raw_reals[16] - wrk_beamx 935 yshift = raw_reals[17] - wrk_beamy 936 937 If((xshift != 0) || (yshift != 0)) 938 DoAlert 1,"Do you want to ignore the beam center mismatch?" 939 if(V_flag==1) 940 xshift=0 941 yshift=0 942 endif 943 endif 944 945 If((xshift == 0) && (yshift == 0)) //no shift, just add them 946 data += raw_data //deadtime correction has already been done to the raw data 947 dest_data_err = sqrt(dest_data_err^2 + raw_data_err^2) // error of the sum 948 Endif 949 950 //scale the data to the default montor counts 951 scale = defmon/total_mon 952 data *= scale 953 dest_data_err *= scale 954 955 // keep "data" and linear_data in sync in the destination folder 956 data_copy = data 957 958 //all is done, except for the bookkeeping of updating the header info in the work folder 959 textread[1] = date() + " " + time() //date + time stamp 960 integersread[3] = total_numruns //numruns = more than one 961 realsread[1] = total_mon //save the true monitor count 962 realsread[0] = defmon //monitor ct = defmon 963 integersread[2] = total_rtime // total counting time 964 realsread[2] = scale*total_det //scaled detector counts 965 realsread[39] = scale*total_trn //scaled transmission counts 943 966 944 967 945 //Add the added raw filename to the list of files in the workfile 968 String newfile = ";" + raw_text[0] 969 SVAR oldList = $(destPath + ":fileList") 970 String/G $(destPath + ":fileList") = oldList + newfile 946 SVAR fileList_dest = $("root:Packages:NIST:VSANS:"+newType+":gFileList") 947 SVAR fileList_tmp = $("root:Packages:NIST:VSANS:"+tmpType+":gFileList") 948 949 fileList_dest += ";" + fileList_tmp 971 950 972 951 //reset the current display type to "newtype"
Note: See TracChangeset
for help on using the changeset viewer.