Changeset 1055
- Timestamp:
- Jul 20, 2017 3:22:34 PM (6 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf
r1038 r1055 177 177 nPix_X = VCALC_get_nPix_X("FL") 178 178 nPix_Y = VCALC_get_nPix_Y("FL") 179 180 xCtr = nPix_X+(F_LR_sep/2/pixSizeX) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 181 yCtr = nPix_Y/2 179 180 if(kBCTR_CM) 181 xCtr = 0 182 yCtr = 0 //values in cm 183 else 184 xCtr = nPix_X+(F_LR_sep/2/pixSizeX) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 185 yCtr = nPix_Y/2 186 endif 182 187 //put these beam center values into the local folder 183 188 V_putDet_beam_center_x("VCALC","FL",xCtr) … … 215 220 nPix_X = VCALC_get_nPix_X("FR") 216 221 nPix_Y = VCALC_get_nPix_Y("FR") 217 218 xCtr = -(F_LR_sep/2/pixSizeX)-1 219 yCtr = nPix_Y/2 222 223 if(kBCTR_CM) 224 xCtr = 0 225 yCtr = 0 //values in cm 226 else 227 xCtr = -(F_LR_sep/2/pixSizeX)-1 228 yCtr = nPix_Y/2 229 endif 230 220 231 //put these beam center values into the local folder 221 232 V_putDet_beam_center_x("VCALC","FR",xCtr) … … 248 259 nPix_X = VCALC_get_nPix_X("FT") 249 260 nPix_Y = VCALC_get_nPix_Y("FT") 250 251 xCtr = nPix_X/2 252 yCtr = -(F_TB_sep/2/pixSizeY)-1 261 262 if(kBCTR_CM) 263 xCtr = 0 264 yCtr = 0 //values in cm 265 else 266 xCtr = nPix_X/2 267 yCtr = -(F_TB_sep/2/pixSizeY)-1 268 endif 269 253 270 //put these beam center values into the local folder 254 271 V_putDet_beam_center_x("VCALC","FT",xCtr) … … 283 300 nPix_X = VCALC_get_nPix_X("FB") 284 301 nPix_Y = VCALC_get_nPix_Y("FB") 285 286 xCtr = nPix_X/2 287 yCtr = nPix_Y+(F_TB_sep/2/pixSizeY) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 288 //put these beam center values into the local folder 302 303 if(kBCTR_CM) 304 xCtr = 0 305 yCtr = 0 //values in cm 306 else 307 xCtr = nPix_X/2 308 yCtr = nPix_Y+(F_TB_sep/2/pixSizeY) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 309 endif 310 311 //put these beam center values into the local folder 289 312 V_putDet_beam_center_x("VCALC","FB",xCtr) 290 313 V_putDet_beam_center_y("VCALC","FB",yCtr) … … 596 619 nPix_X = VCALC_get_nPix_X("ML") 597 620 nPix_Y = VCALC_get_nPix_Y("ML") 598 599 xCtr = nPix_X+(M_LR_sep/2/pixSizeX) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 600 yCtr = nPix_Y/2 621 622 if(kBCTR_CM) 623 xCtr = 0 624 yCtr = 0 //values in cm 625 else 626 xCtr = nPix_X+(M_LR_sep/2/pixSizeX) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 627 yCtr = nPix_Y/2 628 endif 629 601 630 //put these beam center values into the local folder 602 631 V_putDet_beam_center_x("VCALC","ML",xCtr) … … 637 666 nPix_X = VCALC_get_nPix_X("MR") 638 667 nPix_Y = VCALC_get_nPix_Y("MR") 639 640 xCtr = -(M_LR_sep/2/pixSizeX)-1 641 yCtr = nPix_Y/2 668 669 if(kBCTR_CM) 670 xCtr = 0 671 yCtr = 0 //values in cm 672 else 673 xCtr = -(M_LR_sep/2/pixSizeX)-1 674 yCtr = nPix_Y/2 675 endif 676 677 642 678 //put these beam center values into the local folder 643 679 V_putDet_beam_center_x("VCALC","MR",xCtr) … … 671 707 nPix_X = VCALC_get_nPix_X("MT") 672 708 nPix_Y = VCALC_get_nPix_Y("MT") 673 674 xCtr = nPix_X/2 675 yCtr = -(M_TB_sep/2/pixSizeY)-1 709 710 if(kBCTR_CM) 711 xCtr = 0 712 yCtr = 0 //values in cm 713 else 714 xCtr = nPix_X/2 715 yCtr = -(M_TB_sep/2/pixSizeY)-1 716 endif 717 718 676 719 //put these beam center values into the local folder 677 720 V_putDet_beam_center_x("VCALC","MT",xCtr) … … 706 749 nPix_X = VCALC_get_nPix_X("MB") 707 750 nPix_Y = VCALC_get_nPix_Y("MB") 708 709 xCtr = nPix_X/2 710 yCtr = nPix_Y+(M_TB_sep/2/pixSizeY) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 751 752 if(kBCTR_CM) 753 xCtr = 0 754 yCtr = 0 //values in cm 755 else 756 xCtr = nPix_X/2 757 yCtr = nPix_Y+(M_TB_sep/2/pixSizeY) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 758 endif 759 711 760 //put these beam center values into the local folder 712 761 V_putDet_beam_center_x("VCALC","MB",xCtr) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf
r1051 r1055 227 227 String detStr 228 228 229 String destPath = "root:Packages:NIST:VSANS:RAW" 230 229 String destPath = "root:Packages:NIST:VSANS:VCALC" 230 231 // be sure that the real distance waves exist 232 // TODO -- this may not be the best location? 233 234 // calibration waves do not exist yet, so make some fake ones ' 235 // do I count on the orientation as an input, or do I just figure it out on my own? 236 String orientation 237 Variable dimX,dimY 238 dimX = DimSize(data,0) 239 dimY = DimSize(data,1) 240 if(dimX > dimY) 241 orientation = "horizontal" 242 else 243 orientation = "vertical" 244 endif 245 246 if(cmpstr(orientation,"vertical")==0) 247 Make/O/D/N=(3,48) tmpCalib 248 // for the "tall" L/R banks 249 tmpCalib[0][] = -512 250 tmpCalib[1][] = 8 251 tmpCalib[2][] = 0 252 else 253 Make/O/D/N=(3,48) tmpCalib 254 // for the "short" T/B banks 255 tmpCalib[0][] = -256 256 tmpCalib[1][] = 4 257 tmpCalib[2][] = 0 258 endif 259 // override if back panel 260 if(cmpstr(detStr,"B") == 0) 261 // and for the back detector "B" 262 Make/O/D/N=3 tmpCalib 263 tmpCalib[0] = 1 264 tmpCalib[1] = 1 265 tmpcalib[2] = 10000 266 endif 267 268 // Wave w_calib = V_getDetTube_spatialCalib("VCALC",detStr) 269 Variable tube_width = 8.4 // TODO: Hard-wired value!! 270 if(cmpstr(detStr,"B") == 0) 271 V_NonLinearCorrection_B("VCALC",data,tmpCalib,tmpCalib,detStr,destPath) 272 else 273 V_NonLinearCorrection("VCALC",data,tmpCalib,tube_width,detStr,destPath) 274 endif 275 231 276 Wave/Z data_realDistX = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistX") 232 277 Wave/Z data_realDistY = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistY") 233 278 NVAR gUseNonLinearDet = root:Packages:NIST:VSANS:VCALC:gUseNonLinearDet 234 235 if(gUseNonLinearDet && WaveExists(data_realDistX) && WaveExists(data_realDistY)) 236 // convert the beam centers to mm 237 String orientation 238 Variable dimX,dimY,newX,newY 239 dimX = DimSize(data_realDistX,0) 240 dimY = DimSize(data_realDistX,1) 241 if(dimX > dimY) 242 orientation = "horizontal" 279 280 if(kBCTR_CM) 281 if(gUseNonLinearDet && WaveExists(data_realDistX) && WaveExists(data_realDistY)) 282 // no need to convert the beam centers to real space, just to mm 283 xCtr *= 10 // convert from cm to mm 284 yCtr *= 10 285 // calculate all of the q-values 286 qTot = V_CalcQval(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 287 qx = V_CalcQX(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 288 qy = V_CalcQY(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 289 qz = V_CalcQZ(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 290 291 // Print "det, x_mm, y_mm ",detStr,num2str(newX),num2str(newY) 292 // Print "det, x_pix, y_pix ",detStr,num2str(xCtr),num2str(yCtr) 243 293 else 244 orientation = "vertical" 245 endif 246 247 Variable tube_width = 8.4 //mm 248 249 // 250 if(cmpstr(orientation,"vertical")==0) 251 // this is data dimensioned as (Ntubes,Npix) 252 newX = tube_width*xCtr 253 newY = data_realDistY[0][yCtr] 294 // do the q-calculation using linear detector 295 //VC_Detector_2Q(data,qTot,qx,qy,qz,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 296 qTot = V_CalcQval(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 297 qx = V_CalcQX(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 298 qy = V_CalcQY(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 299 qz = V_CalcQZ(p,q,xCtr,yCtr,sdd,lam,data_realDistX,data_realDistY) 300 endif 301 302 303 else 304 // using the old calculation with beam center in pixels 305 if(gUseNonLinearDet && WaveExists(data_realDistX) && WaveExists(data_realDistY)) 306 // convert the beam centers to mm 307 // String orientation 308 Variable newX,newY 309 dimX = DimSize(data_realDistX,0) 310 dimY = DimSize(data_realDistX,1) 311 if(dimX > dimY) 312 orientation = "horizontal" 313 else 314 orientation = "vertical" 315 endif 316 317 318 // 319 if(cmpstr(orientation,"vertical")==0) 320 // this is data dimensioned as (Ntubes,Npix) 321 newX = tube_width*xCtr 322 newY = data_realDistY[0][yCtr] 323 else 324 // this is data (horizontal) dimensioned as (Npix,Ntubes) 325 newX = data_realDistX[xCtr][0] 326 newY = tube_width*yCtr 327 endif 328 329 //if detector "B", different calculation for the centers (not tubes) 330 if(cmpstr(detStr,"B")==0) 331 newX = data_realDistX[xCtr][0] 332 newY = data_realDistY[0][yCtr] 333 //newX = xCtr 334 //newY = yCtr 335 endif 336 337 // calculate all of the q-values 338 qTot = V_CalcQval(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 339 qx = V_CalcQX(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 340 qy = V_CalcQY(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 341 qz = V_CalcQZ(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 342 343 // Print "det, x_mm, y_mm ",detStr,num2str(newX),num2str(newY) 344 // Print "det, x_pix, y_pix ",detStr,num2str(xCtr),num2str(yCtr) 254 345 else 255 // this is data (horizontal) dimensioned as (Npix,Ntubes) 256 newX = data_realDistX[xCtr][0] 257 newY = tube_width*yCtr 346 // do the q-calculation using linear detector 347 VC_Detector_2Q(data,qTot,qx,qy,qz,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 258 348 endif 259 260 //if detector "B", different calculation for the centers (not tubes) 261 if(cmpstr(detStr,"B")==0) 262 newX = data_realDistX[xCtr][0] 263 newY = data_realDistY[0][yCtr] 264 //newX = xCtr 265 //newY = yCtr 266 endif 267 268 // calculate all of the q-values 269 qTot = V_CalcQval(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 270 qx = V_CalcQX(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 271 qy = V_CalcQY(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 272 qz = V_CalcQZ(p,q,newX,newY,sdd,lam,data_realDistX,data_realDistY) 273 274 // Print "det, x_mm, y_mm ",detStr,num2str(newX),num2str(newY) 275 // Print "det, x_pix, y_pix ",detStr,num2str(xCtr),num2str(yCtr) 276 else 277 // do the q-calculation using linear detector 278 VC_Detector_2Q(data,qTot,qx,qy,qz,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 279 endif 349 350 endif 351 352 KillWaves/Z tmpCalib 280 353 281 354 return(0) … … 296 369 // 297 370 //returned magnitude of Q is in 1/Angstroms 371 // 298 372 // 299 373 Function VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf
r1051 r1055 178 178 // tab(3) - Middle detector panels, initially not visible 179 179 SetVariable VCALCCtrl_3a,pos={30,260},size={150,15},title="L/R Separation (mm)",proc=VC_MDet_LR_SetVarProc 180 SetVariable VCALCCtrl_3a,limits={0,400,1},disable=1,value=_NUM:1 20180 SetVariable VCALCCtrl_3a,limits={0,400,1},disable=1,value=_NUM:100 181 181 SetVariable VCALCCtrl_3b,pos={30,290},size={150,15},title="T/B Separation (mm)",proc=VC_MDet_LR_SetVarProc 182 SetVariable VCALCCtrl_3b,limits={0,400,1},disable=1,value=_NUM:1 20182 SetVariable VCALCCtrl_3b,limits={0,400,1},disable=1,value=_NUM:100 183 183 SetVariable VCALCCtrl_3c,pos={205,290},size={150,15},title="Lateral Offset (mm)" 184 184 SetVariable VCALCCtrl_3c,limits={0,200,0.1},disable=1,value=_NUM:0 185 185 SetVariable VCALCCtrl_3d,pos={205,260},size={230,15},title="Sample to Detector Distance (m)",proc=VC_MDet_SDD_SetVarProc 186 SetVariable VCALCCtrl_3d,limits={8,20,0.1},disable=1,value=_NUM:1 0186 SetVariable VCALCCtrl_3d,limits={8,20,0.1},disable=1,value=_NUM:15 187 187 188 188 // tab(4) - Back detector panel … … 190 190 SetVariable VCALCCtrl_4a,limits={0,200,0.1},disable=1,value=_NUM:0 191 191 SetVariable VCALCCtrl_4b,pos={188,260},size={230,15},title="Sample to Detector Distance (m)",proc=VC_BDet_SDD_SetVarProc 192 SetVariable VCALCCtrl_4b,limits={20,25,0.1},disable=1,value=_NUM:2 2192 SetVariable VCALCCtrl_4b,limits={20,25,0.1},disable=1,value=_NUM:20 193 193 PopupMenu VCALCCtrl_4c,pos={40,260},size={180,20},title="Detector type",disable=1 194 194 PopupMenu VCALCCtrl_4c,mode=1,popvalue="2D",value= root:Packages:NIST:VSANS:VCALC:gBackDetType -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_BeamCenter.ipf
r1043 r1055 639 639 for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 640 640 detStr = StringFromList(ii, ksDetectorListNoB, ";") 641 xCtr = V_getDet_beam_center_x (fname,detStr)642 yCtr = V_getDet_beam_center_y (fname,detStr)641 xCtr = V_getDet_beam_center_x_pix(fname,detStr) 642 yCtr = V_getDet_beam_center_y_pix(fname,detStr) 643 643 V_RescaleToBeamCenter(type,detStr,xCtr,yCtr) 644 644 endfor … … 701 701 detStr = StringFromList(ii, ksDetectorListAll, ";") 702 702 panelW[ii] = detStr 703 xCtr_pix[ii] = V_getDet_beam_center_x (fname,detStr)704 yCtr_pix[ii] = V_getDet_beam_center_y (fname,detStr)703 xCtr_pix[ii] = V_getDet_beam_center_x_pix(fname,detStr) 704 yCtr_pix[ii] = V_getDet_beam_center_y_pix(fname,detStr) 705 705 // TODO 706 706 // and now the mm values -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Correct.ipf
r1024 r1055 317 317 318 318 // to check for beam center mismatch -- simply warn, but do no shift 319 // 319 // NOTE - these are now reading the beam center in cm, not pixels 320 320 321 321 csam = V_getDet_beam_center_x("SAM",detStr) //x center -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r1044 r1055 122 122 // 123 123 // 124 Function V_NonLinearCorrection(dataW,coefW,tube_width,detStr,destPath) 124 Function V_NonLinearCorrection(fname,dataW,coefW,tube_width,detStr,destPath) 125 String fname //can also be a folder such as "RAW" 125 126 Wave dataW,coefW 126 127 Variable tube_width … … 149 150 // the distance perpendicular to the tube is n*(8.4mm) per tube index 150 151 152 // TODO 153 // -- GAP IS HARD-WIRED 154 Variable offset,gap 155 156 // kPanelTouchingGap is in mm 157 gap = kPanelTouchingGap/10 //cm 158 151 159 if(cmpstr(orientation,"vertical")==0) 152 160 // this is data dimensioned as (Ntubes,Npix) … … 154 162 data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 155 163 164 // adjust the x postion based on the beam center being nominally (0,0) in units of cm, not pixels 165 if(cmpstr(fname,"VCALC")== 0 ) 166 offset = VCALC_getPanelSeparation(detStr) 167 offset /= 2 // units of mm 168 else 169 //normal case 170 offset = V_getDet_LateralOffset(fname,detStr) 171 offset *= 10 //convert cm to mm 172 endif 173 174 // calculation is in mm, not cm 175 if(kBCTR_CM) 176 if(cmpstr("L",detStr[1]) == 0) 177 data_realDistX[][] = -offset - (dimX - p)*tube_width // TODO should this be dimX-1-p = 47-p? 178 else 179 data_realDistX[][] += offset + gap + tube_width //add to the Right det, not recalculate 180 endif 181 endif 182 183 156 184 elseif(cmpstr(orientation,"horizontal")==0) 157 185 // this is data (horizontal) dimensioned as (Npix,Ntubes) … … 159 187 data_realDistY[][] = tube_width*q 160 188 189 if(cmpstr(fname,"VCALC")== 0 ) 190 offset = VCALC_getPanelSeparation(detStr) 191 offset /= 2 // units of mm 192 else 193 //normal case 194 offset = V_getDet_VerticalOffset(fname,detStr) 195 offset *= 10 //convert cm to mm 196 endif 197 198 if(kBCTR_CM) 199 if(cmpstr("T",detStr[1]) == 0) 200 data_realDistY[][] += offset + gap + tube_width 201 else 202 data_realDistY[][] = -offset - (dimY - q)*tube_width // TODO should this be dimY-1-q = 47-q? 203 endif 204 endif 205 161 206 else 162 207 DoAlert 0,"Orientation not correctly passed in NonLinearCorrection(). No correction done." 208 return(0) 163 209 endif 164 210 165 211 return(0) 166 212 end 213 214 215 167 216 168 217 // TODO: … … 171 220 // 172 221 // 173 Function V_NonLinearCorrection_B(folder,detStr,destPath) 174 String folder,detStr,destPath 222 Function V_NonLinearCorrection_B(folder,dataW,cal_x,cal_y,detStr,destPath) 223 String folder 224 Wave dataW,cal_x,cal_y 225 String detStr,destPath 175 226 176 227 if(cmpstr(detStr,"B") != 0) … … 181 232 Variable dimX,dimY 182 233 183 Wave dataW = V_getDetectorDataW(folder,detStr)234 // Wave dataW = V_getDetectorDataW(folder,detStr) 184 235 185 236 dimX = DimSize(dataW,0) … … 194 245 195 246 196 Wave cal_x = V_getDet_cal_x(folder,detStr)197 Wave cal_y = V_getDet_cal_y(folder,detStr)247 // Wave cal_x = V_getDet_cal_x(folder,detStr) 248 // Wave cal_y = V_getDet_cal_y(folder,detStr) 198 249 199 250 data_realDistX[][] = cal_x[0]*p … … 262 313 end 263 314 315 // 316 // 317 // TODO 318 // -- VERIFY the calculations 319 // -- verify where this needs to be done (if the beam center is changed) 320 // -- then the q-calculation needs to be re-done 321 // -- the position along the tube length is referenced to tube[0], for no particular reason 322 // It may be better to take an average? but [0] is an ASSUMPTION 323 // -- distance along tube is simple interpolation, or do I use the coefficients to 324 // calculate the actual value 325 // 326 // -- distance in the lateral direction is based on tube width, which is a fixed parameter 327 // 328 // 329 Function V_ConvertBeamCtr_to_pix(folder,detStr,destPath) 330 String folder,detStr,destPath 331 332 Wave data_realDistX = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistX") 333 Wave data_realDistY = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistY") 334 335 String orientation 336 Variable dimX,dimY,xCtr,yCtr 337 dimX = DimSize(data_realDistX,0) 338 dimY = DimSize(data_realDistX,1) 339 if(dimX > dimY) 340 orientation = "horizontal" 341 else 342 orientation = "vertical" 343 endif 344 345 xCtr = V_getDet_beam_center_x(folder,detStr) //these are in cm 346 yCtr = V_getDet_beam_center_y(folder,detStr) 347 348 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_pix") 349 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_pix") 350 WAVE x_pix = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_pix") 351 WAVE y_pix = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_pix") 352 353 Variable tube_width = V_getDet_tubeWidth(folder,detStr) 354 355 variable edge,delta 356 357 // 358 if(cmpstr(orientation,"vertical")==0) 359 // this is data dimensioned as (Ntubes,Npix) 360 361 if(kBCTR_CM) 362 if(cmpstr("L",detStr[1]) == 0) 363 edge = data_realDistX[47][0] //tube 47 364 delta = abs(xCtr*10 - edge) 365 x_pix[0] = dimX-1 + delta/tube_width 366 else 367 // R panel 368 edge = data_realDistX[0][0] 369 delta = abs(xCtr*10 - edge + kPanelTouchingGap) 370 x_pix[0] = -delta/tube_width //since the left edge of the R panel is pixel 0 371 endif 372 endif 373 374 Make/O/D/N=(dimY) tmpTube 375 tmpTube = data_RealDistY[0][p] 376 FindLevel /P/Q tmpTube, yCtr 377 378 y_pix[0] = V_levelX 379 KillWaves/Z tmpTube 380 else 381 // this is data (horizontal) dimensioned as (Npix,Ntubes) 382 383 if(kBCTR_CM) 384 if(cmpstr("T",detStr[1]) == 0) 385 edge = data_realDistY[0][0] //tube 0 386 delta = abs(yCtr*10 - edge + kPanelTouchingGap) 387 y_pix[0] = -delta/tube_width //since the bottom edge of the T panel is pixel 0 388 else 389 // FM(B) panel 390 edge = data_realDistY[0][47] //y tube 47 391 delta = abs(yCtr*10 - edge) 392 y_pix[0] = dimY-1 + delta/tube_width //since the top edge of the B panels is pixel 47 393 endif 394 endif 395 396 397 Make/O/D/N=(dimX) tmpTube 398 tmpTube = data_RealDistX[p][0] 399 FindLevel /P/Q tmpTube, xCtr 400 401 x_pix[0] = V_levelX 402 KillWaves/Z tmpTube 403 404 405 endif 406 407 return(0) 408 end 264 409 265 410 // … … 421 566 sdd = V_getDet_ActualDistance(fname,detStr) //sdd derived, including setback [cm] 422 567 sdd/=100 // sdd reported in cm, pass in m 423 // this is the ctr in pixels 568 // this is the ctr in pixels --xx-- (now it is in cm!) 424 569 // xCtr = V_getDet_beam_center_x(fname,detStr) 425 570 // yCtr = V_getDet_beam_center_y(fname,detStr) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf
r1053 r1055 18 18 19 19 20 // the base data folder path where the raw data is loaded 21 Strconstant ksBaseDFPath = "root:Packages:NIST:VSANS:RawVSANS:" 22 23 // the list of WORK Folders 24 // RawVSANS does not behave as a WORK folder, but it is local. so add it in explicitly to the list if needed 25 // VCALC behaves *almost* as a WORK folder, but it is local. so add it in explicitly to the list if needed 26 //Strconstant ksWorkFolderList = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;VCALC;RawVSANS;" 27 Strconstant ksWorkFolderListShort = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;" 20 28 21 29 22 … … 74 67 Variable err= V_LoadHDF5_NoAtt(file,folder) // reads into current folder 75 68 76 69 if(err) 70 DoAlert 0,"User cancelled or other file read error..." 71 return(1) 72 endif 77 73 78 74 // if RAW data, then generate the errors and linear data copy … … 120 116 Wave w_calib = V_getDetTube_spatialCalib(folder,detStr) 121 117 Variable tube_width = V_getDet_tubeWidth(folder,detStr) 122 V_NonLinearCorrection( w,w_calib,tube_width,detStr,destPath)118 V_NonLinearCorrection(folder,w,w_calib,tube_width,detStr,destPath) 123 119 124 120 … … 126 122 // TODO -- there needs to be a permanent location for these values?? 127 123 // 128 V_ConvertBeamCtr_to_mm(folder,detStr,destPath) 124 125 // TODO 126 // -- the beam center value in mm needs to be present - it is used in calculation of Qvalues 127 // -- but having both the same is wrong... 128 // -- the pixel value is needed for display of the panels 129 if(kBCTR_CM) 130 //V_ConvertBeamCtr_to_mm(folder,detStr,destPath) 131 // 132 133 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_mm") 134 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_mm") 135 WAVE x_mm = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_mm") 136 WAVE y_mm = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_mm") 137 x_mm[0] = V_getDet_beam_center_x(folder,detStr) * 10 // convert cm to mm 138 y_mm[0] = V_getDet_beam_center_y(folder,detStr) * 10 // convert cm to mm 139 140 // TODO::: 141 // now I need to convert the beam center in mm to pixels 142 // and have some rational place to look for it... 143 V_ConvertBeamCtr_to_pix(folder,detStr,destPath) 144 else 145 // beam center is in pixels, so use the old routine 146 V_ConvertBeamCtr_to_mm(folder,detStr,destPath) 147 endif 148 129 149 130 150 // (2.5) Calculate the q-values … … 143 163 144 164 //"B" is separate 145 V_NonLinearCorrection_B(folder,"B",destPath) 165 Wave w = V_getDetectorDataW(folder,"B") 166 Wave cal_x = V_getDet_cal_x(folder,"B") 167 Wave cal_y = V_getDet_cal_y(folder,"B") 168 169 V_NonLinearCorrection_B(folder,w,cal_x,cal_y,"B",destPath) 146 170 V_ConvertBeamCtr_to_mmB(folder,"B",destPath) 147 171 V_Detector_CalcQVals(folder,"B",destPath) … … 400 424 HDF5OpenFile/R/P=catPathName/Z fileID as fileName 401 425 if (V_Flag != 0) 402 return 0426 return 1 403 427 endif 404 428 … … 408 432 if ( fileID == 0 ) 409 433 Print fileName + ": could not open as HDF5 file" 410 return ( 0)434 return (1) 411 435 endif 412 436 … … 507 531 Print fileName + ": could not open as HDF5 file" 508 532 setdatafolder root: 509 return ( 0)533 return (1) 510 534 endif 511 535 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r1053 r1055 1457 1457 End 1458 1458 1459 1459 //TODO 1460 // 1461 // x and y center in pix is currently not part of the Nexus definition 1462 // does it need to be? 1463 // these lookups will fail if they have not been generated locally! 1464 Function V_getDet_beam_center_x_pix(fname,detStr) 1465 String fname,detStr 1466 1467 String path = "entry:instrument:detector_"+detStr+":beam_center_x_pix" 1468 return(V_getRealValueFromHDF5(fname,path)) 1469 End 1470 1471 //TODO 1472 // 1473 // x and y center in pix is currently not part of the Nexus definition 1474 // does it need to be? 1475 // these lookups will fail if they have not been generated locally! 1476 Function V_getDet_beam_center_y_pix(fname,detStr) 1477 String fname,detStr 1478 1479 String path = "entry:instrument:detector_"+detStr+":beam_center_y_pix" 1480 return(V_getRealValueFromHDF5(fname,path)) 1481 End 1460 1482 1461 1483 Function/WAVE V_getDetectorDataW(fname,detStr) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf
r1051 r1055 34 34 35 35 36 Strconstant ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;"37 Strconstant ksBinTrimBegDefault = "B=5;FT=6;FB=6;FL=6;FR=6;MT=6;MB=6;ML=6;MR=6;FTB=7;FLR=7;MTB=7;MLR=7;FLRTB=8;MLRTB=8;"38 Strconstant ksBinTrimEndDefault = "B=10;FT=9;FB=9;FL=9;FR=9;MT=9;MB=9;ML=9;MR=9;FTB=8;FLR=8;MTB=8;MLR=8;FLRTB=7;MLRTB=7;"39 40 41 //////////////////42 Strconstant ksBinTypeStr = "One;Two;Four;Slit Mode;"43 Strconstant ksBinType1 = "B;FT;FB;FL;FR;MT;MB;ML;MR;" //these are the "active" extensions44 Strconstant ksBinType2 = "B;FTB;FLR;MTB;MLR;"45 Strconstant ksBinType3 = "B;FLRTB;MLRTB;"46 Strconstant ksBinType4 = "B;FT;FB;FL;FR;MT;MB;ML;MR;"47 ///////////////////48 36 // 49 37 // NOTE -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf
r1051 r1055 26 26 // TODO -- need to set up a separate file of "constants" or "globals" where the actual numbers are 27 27 //stored. If there are not a lot, that place could be here. InitFacilityGlobals() is currently in NCNR_Utils.ipf 28 29 30 // for the change in July 2017 where the beam center is now defined in cm, rather than pixels. 31 // this need never change from 1 32 Constant kBCTR_CM = 1 //set to 1 to use beam center in cm. O to use pixels 33 Constant kPanelTouchingGap = 4 // TODO -- measure this gap when panels "touch", UNITS OF mm, not cm 34 35 36 // the base data folder path where the raw data is loaded 37 Strconstant ksBaseDFPath = "root:Packages:NIST:VSANS:RawVSANS:" 38 39 40 // the list of WORK Folders 41 // RawVSANS does not behave as a WORK folder, but it is local. so add it in explicitly to the list if needed 42 // VCALC behaves *almost* as a WORK folder, but it is local. so add it in explicitly to the list if needed 43 //Strconstant ksWorkFolderList = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;VCALC;RawVSANS;" 44 Strconstant ksWorkFolderListShort = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;" 45 46 47 // for defining which "bin type" corresponds to which set of extensions for I(q) data 48 ////////////////// 49 Strconstant ksBinTypeStr = "One;Two;Four;Slit Mode;" 50 Strconstant ksBinType1 = "B;FT;FB;FL;FR;MT;MB;ML;MR;" //these are the "active" extensions 51 Strconstant ksBinType2 = "B;FTB;FLR;MTB;MLR;" 52 Strconstant ksBinType3 = "B;FLRTB;MLRTB;" 53 Strconstant ksBinType4 = "B;FT;FB;FL;FR;MT;MB;ML;MR;" 54 /////////////////// 55 56 57 // for looping over each detector 58 Strconstant ksDetectorListNoB = "FL;FR;FT;FB;ML;MR;MT;MB;" 59 Strconstant ksDetectorListAll = "FL;FR;FT;FB;ML;MR;MT;MB;B;" 60 61 62 // for Protocols 63 Constant kNumProtocolSteps = 12 64 // for trimming of the I(q) data sets, and part of the protocol 65 Strconstant ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;" 66 Strconstant ksBinTrimBegDefault = "B=5;FT=6;FB=6;FL=6;FR=6;MT=6;MB=6;ML=6;MR=6;FTB=7;FLR=7;MTB=7;MLR=7;FLRTB=8;MLRTB=8;" 67 Strconstant ksBinTrimEndDefault = "B=10;FT=9;FB=9;FL=9;FR=9;MT=9;MB=9;ML=9;MR=9;FTB=8;FLR=8;MTB=8;MLR=8;FLRTB=7;MLRTB=7;" 28 68 29 69 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf
r1034 r1055 2147 2147 String fname,detStr 2148 2148 2149 Wave xCtr_ pix = root:Packages:NIST:VSANS:Globals:Patch:xCtr_pix2150 Wave yCtr_ pix = root:Packages:NIST:VSANS:Globals:Patch:yCtr_pix2149 Wave xCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:xCtr_cm 2150 Wave yCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:yCtr_cm 2151 2151 Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW 2152 2152 2153 2153 // check the dimensions of the waves (9) 2154 if (DimSize(xCtr_ pix, 0) != 9 || DimSize(yCtr_pix, 0) != 9 || DimSize(panelW, 0) != 9)2154 if (DimSize(xCtr_cm, 0) != 9 || DimSize(yCtr_cm, 0) != 9 || DimSize(panelW, 0) != 9) 2155 2155 Abort "waves are not of proper dimension (9)" 2156 2156 endif … … 2163 2163 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 2164 2164 detStr = panelW[ii] 2165 V_writeDet_beam_center_x(fname,detStr,xCtr_ pix[ii])2166 V_writeDet_beam_center_y(fname,detStr,yCtr_ pix[ii])2165 V_writeDet_beam_center_x(fname,detStr,xCtr_cm[ii]) 2166 V_writeDet_beam_center_y(fname,detStr,yCtr_cm[ii]) 2167 2167 endfor 2168 2168 … … 2183 2183 Variable ii,jj 2184 2184 2185 Wave xCtr_ pix = root:Packages:NIST:VSANS:Globals:Patch:xCtr_pix2186 Wave yCtr_ pix = root:Packages:NIST:VSANS:Globals:Patch:yCtr_pix2185 Wave xCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:xCtr_cm 2186 Wave yCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:yCtr_cm 2187 2187 Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW 2188 2188 … … 2194 2194 detStr = StringFromList(ii, ksDetectorListAll, ";") 2195 2195 panelW[ii] = detStr 2196 xCtr_ pix[ii] = V_getDet_beam_center_x(fname,detStr)2197 yCtr_ pix[ii] = V_getDet_beam_center_y(fname,detStr)2196 xCtr_cm[ii] = V_getDet_beam_center_x(fname,detStr) //these values are in cm, not pixels 2197 yCtr_cm[ii] = V_getDet_beam_center_y(fname,detStr) 2198 2198 endfor 2199 2199 … … 2217 2217 NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch 2218 2218 2219 Make/O/D/N=9 xCtr_ pix,yCtr_pix2219 Make/O/D/N=9 xCtr_cm,yCtr_cm 2220 2220 Make/O/T/N=9 panelW 2221 2221 … … 2248 2248 DrawText 21,258,"Write to all files (inlcusive)" 2249 2249 SetDrawEnv fsize= 14,fstyle= 1 2250 DrawText 262,30,"Beam Center ( pixels)"2250 DrawText 262,30,"Beam Center (cm)" 2251 2251 DrawText 20,133,"Run Number(s)" 2252 2252 … … 2261 2261 SetDataFolder root:Packages:NIST:VSANS:Globals:Patch 2262 2262 // display the wave 2263 Edit/W=(180,40,500,370)/HOST=# panelW,xCtr_ pix,yCtr_pix2263 Edit/W=(180,40,500,370)/HOST=# panelW,xCtr_cm,yCtr_cm 2264 2264 ModifyTable width(Point)=0 2265 2265 ModifyTable width(panelW)=80 2266 ModifyTable width(xCtr_ pix)=1002267 ModifyTable width(yCtr_ pix)=1002266 ModifyTable width(xCtr_cm)=100 2267 ModifyTable width(yCtr_cm)=100 2268 2268 RenameWindow #,T0 2269 2269 SetActiveSubwindow ## -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf
r1051 r1055 50 50 ////////////////////////////////// 51 51 52 Constant kNumProtocolSteps = 1253 52 54 53 //main entry procedure for initialzing and displaying the protocol panel -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_RAW_Data_Panel.ipf
r1053 r1055 165 165 166 166 // on the side 167 Button button_status,pos={607,146},size={70,20},proc=V_StatusButtonProc,title="Status" 167 Button button_status,pos={607,146},size={70,20},proc=V_StatusButtonProc,title="Status",disable=2 168 168 Button button_IvsQ,pos={689,113},size={70,20},proc=V_IvsQPanelButtonProc,title="I vs. Q" 169 169 Button button_file_m,pos={619,55},size={50,20},proc=V_File_minus_ButtonProc,title="File <" … … 181 181 // Button button_tagFile,disable=2 182 182 Button button_saveIQ,pos={603,412},size={120,20},proc=V_SaveIQ_ButtonProc,title="Save I(Q) as ITX" 183 Button button_BeamCtr,pos={603,450},size={110,20},proc=V_BeamCtrButtonProc,title="Beam Center" 183 Button button_BeamCtr,pos={603,450},size={110,20},proc=V_BeamCtrButtonProc,title="Beam Center",disable=2 184 184 Button button_SpreadPanels,pos={603,488},size={100,20},proc=V_SpreadPanelButtonProc,title="Spread Panels" 185 185 Button button_RestorePanels,pos={603,526},size={100,20},proc=V_RestorePanelButtonProc,title="Restore Panels" … … 1060 1060 case 2: // mouse up 1061 1061 // click code here 1062 V_FindBeamCenter() 1062 DoAlert 0,"Beam Center panel is under construction..." 1063 // V_FindBeamCenter() 1063 1064 break 1064 1065 case -1: // control being killed -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf
r1051 r1055 60 60 endif 61 61 62 // returns the total separation (assumed symmetric) in mm 63 val = VCALC_getPanelSeparation(detStr) 64 val /= 2*10 // to get half of the separation, and convert to cm for the data file 65 // it's OK to call both of these. these functions check detStr for the correct value 66 V_writeDet_LateralOffset(fileName,detStr,val) 67 V_writeDet_VerticalOffset(fileName,detStr,val) 68 62 69 // x and y pixel sizes for each detector should be correct in the "base" file - but if not... 63 70 //Function VCALC_getPixSizeX(type) // returns the pixel X size, in [cm] … … 67 74 68 75 // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels() 69 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 70 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 76 if(kBCTR_CM) 77 // -- now write out the beam center in cm, not pixels 78 V_writeDet_beam_center_x(fileName,detStr,0) 79 V_writeDet_beam_center_y(fileName,detStr,0) 80 else 81 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 82 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 83 endif 84 85 if(cmpstr(detStr,"B") == 0) 86 //always write out the center of the detector since this is dummy data 87 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 88 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 89 endif 90 71 91 72 92 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r1051 r1055 28 28 // 29 29 // 30 Strconstant ksDetectorListNoB = "FL;FR;FT;FB;ML;MR;MT;MB;"31 Strconstant ksDetectorListAll = "FL;FR;FT;FB;ML;MR;MT;MB;B;"32 30 33 31 … … 551 549 Wave w_calib = V_getDetTube_spatialCalib(fname,detStr) 552 550 Variable tube_width = V_getDet_tubeWidth(fname,detStr) 553 V_NonLinearCorrection( w,w_calib,tube_width,detStr,destPath)551 V_NonLinearCorrection(fname,w,w_calib,tube_width,detStr,destPath) 554 552 555 553 //(2.4) Convert the beam center values from pixels to mm 556 554 // TODO -- there needs to be a permanent location for these values?? 557 555 // 558 V_ConvertBeamCtr_to_mm(fname,detStr,destPath) 556 // TODO 557 // -- the beam center value in mm needs to be present - it is used in calculation of Qvalues 558 // -- but having both the same is wrong... 559 // -- the pixel value is needed for display of the panels 560 if(kBCTR_CM) 561 //V_ConvertBeamCtr_to_mm(folder,detStr,destPath) 562 // 563 564 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_mm") 565 Make/O/D/N=1 $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_mm") 566 WAVE x_mm = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_x_mm") 567 WAVE y_mm = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_mm") 568 x_mm[0] = V_getDet_beam_center_x(fname,detStr) * 10 // convert cm to mm 569 y_mm[0] = V_getDet_beam_center_y(fname,detStr) * 10 // convert cm to mm 570 571 // TODO::: 572 // now I need to convert the beam center in mm to pixels 573 // and have some rational place to look for it... 574 V_ConvertBeamCtr_to_pix(fname,detStr,destPath) 575 else 576 // beam center is in pixels, so use the old routine 577 V_ConvertBeamCtr_to_mm(fname,detStr,destPath) 578 endif 559 579 560 580 // (2.5) Calculate the q-values … … 573 593 574 594 //"B" is separate 575 V_NonLinearCorrection_B(fname,"B",destPath) 595 Wave w = V_getDetectorDataW(fname,"B") 596 Wave cal_x = V_getDet_cal_x(fname,"B") 597 Wave cal_y = V_getDet_cal_y(fname,"B") 598 V_NonLinearCorrection_B(fname,w,cal_x,cal_y,"B",destPath) 576 599 V_ConvertBeamCtr_to_mmB(fname,"B",destPath) 577 600 V_Detector_CalcQVals(fname,"B",destPath)
Note: See TracChangeset
for help on using the changeset viewer.