 Timestamp:
 Sep 23, 2015 8:24:30 AM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf
r958 r963 6 6 //  multiple fit options with different things held 7 7 // x when selecting the detector, set the x/y pixel sizes 8 // x figure out how to replot the images when swapping between LR and TB panels8 //  figure out how to replot the images when swapping between LR and TB panels 9 9 // 10 10 … … 14 14 // ModifyGraph width={Plan,1,bottom,left} 15 15 // 16 WindowDetectorPanelFit() : Panel16 Macro DetectorPanelFit() : Panel 17 17 PauseUpdate; Silent 1 // building window... 18 18 … … 22 22 endif 23 23 24 NewPanel /W=(662,418,1586, 1108)/N=PanelFit/K=124 NewPanel /W=(662,418,1586,960)/N=PanelFit/K=1 25 25 // ShowTools/A 26 26 … … 38 38 SetScale/P x 0,1, curDispPanel 39 39 SetScale/P y 0,1, curDispPanel 40 41 //draw the detector panel 42 Display/W=(20,80,180,600)/HOST=# 43 AppendImage curDispPanel 44 ModifyImage curDispPanel ctab= {*,*,ColdWarm,0} 45 // ModifyGraph width={Plan,1,bottom,left} 46 Label left "Y pixels" 47 Label bottom "X pixels" 48 RenameWindow #,DetData 49 SetActiveSubwindow ## 50 51 //draw the model calculation 52 Display/W=(200,80,360,600)/HOST=# 53 AppendImage PeakPix2D_mat 54 ModifyImage PeakPix2D_mat ctab= {*,*,ColdWarm,0} 55 // ModifyGraph width={Plan,1,bottom,left} 56 Label left "Y pixels" 57 Label bottom "X pixels" 58 RenameWindow #,ModelData 59 SetActiveSubwindow ## 40 41 42 // draw the correct images 43 DrawDetPanel("FL") 44 45 46 ////draw the detector panel 47 // Display/W=(20,80,200,600)/HOST=# 48 // AppendImage curDispPanel 49 // ModifyImage curDispPanel ctab= {*,*,ColdWarm,0} 50 //// ModifyGraph height={Aspect,2.67} 51 // Label left "Y pixels" 52 // Label bottom "X pixels" 53 // RenameWindow #,DetData 54 // SetActiveSubwindow ## 55 // 56 ////draw the model calculation 57 // Display/W=(220,80,400,600)/HOST=# 58 // AppendImage PeakPix2D_mat 59 // ModifyImage PeakPix2D_mat ctab= {*,*,ColdWarm,0} 60 //// ModifyGraph height={Aspect,2.67} 61 //// ModifyGraph width={Aspect,0.375} 62 // Label left "Y pixels" 63 // Label bottom "X pixels" 64 // RenameWindow #,ModelData 65 // SetActiveSubwindow ## 66 67 68 60 69 61 70 // edit the fit coefficients … … 67 76 SetActiveSubwindow ## 68 77 69 70 78 71 79 EndMacro … … 81 89 Variable popNum = pa.popNum 82 90 String popStr = pa.popStr 83 91 92 // remove the old image (it may not be the right shape) 93 //  but make sure it exists first... 94 String childList = ChildWindowList("PanelFit") 95 Variable flag 96 97 flag = WhichListItem("DetData", ChildList) //returns 1 if not in list, 0+ otherwise 98 if(flag != 1) 99 KillWindow PanelFit#DetData 100 endif 101 102 flag = WhichListItem("ModelData", ChildList) 103 if(flag != 1) 104 KillWindow PanelFit#ModelData 105 endif 106 107 // draw the correct images 84 108 DrawDetPanel(popStr) 85 109 … … 93 117 94 118 95 // duplicate/O root:Packages:NIST:VSANS:VCALC:Front:det_FL curDispPanel 96 // SetScale/P x 0,1, curDispPanel 97 // SetScale/P y 0,1, curDispPanel 98 99 // draws a single panel from the set of detectors 119 // draw the selected panel and the model calculation, adjusting for the 120 // orientation of the panel and the number of pixels, and pixel sizes 100 121 Function DrawDetPanel(str) 101 122 String str … … 106 127 107 128 Variable xDim,yDim 129 Variable left,top,right,bottom 130 Variable height, width 131 Variable left2,top2,right2,bottom2 108 132 Wave dispW=root:curDispPanel 109 133 Wave cw = root:coef_PeakPix2D 110 134 111 cw[7] = 4112 cw[8] = 8113 114 135 Wave xwave_PeakPix2D=root:xwave_PeakPix2D 115 136 Wave ywave_PeakPix2D=root:ywave_PeakPix2D 116 137 Wave zwave_PeakPix2D=root:zwave_PeakPix2D 117 138 118 //plot it in the subwindow with the proper aspect and positioning 139 //plot it in the subwindow with the proper aspect and positioning 140 // for 48x256 (8mm x 4mm), aspect = (256/2)/48 = 2.67 (LR panels) 141 // for 128x48 (4mm x 8 mm), aspect = 48/(128/2) = 0.75 (TB panels) 142 143 144 // using two switches  one to set the panelspecific dimensions 145 // and the other to set the "common" values, some of which are based on the panel dimensions 146 147 // panelspecific values 119 148 strswitch(str) 120 149 case "FL": 121 xDim=48 122 yDim=256 123 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,180,600) 124 MoveSubWindow/W=PanelFit#ModelData fnum=(200,80,360,600) 125 cw[7] = 8 126 cw[8] = 4 127 wave newW = root:Packages:NIST:VSANS:VCALC:Front:det_FL 150 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_X 151 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_Y 152 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelX 153 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelY 154 wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 128 155 break 129 156 case "FR": 130 xDim=48 131 yDim=256 132 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,180,600) 133 MoveSubWindow/W=PanelFit#ModelData fnum=(200,80,360,600) 134 cw[7] = 8 135 cw[8] = 4 136 wave newW = root:Packages:NIST:VSANS:VCALC:Front:det_FR 137 break 157 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_X 158 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_Y 159 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelX 160 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelY 161 wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 162 break 163 case "ML": 164 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_X 165 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_Y 166 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelX 167 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelY 168 wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 169 break 170 case "MR": 171 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_X 172 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_Y 173 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelX 174 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelY 175 wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 176 break 177 138 178 case "FT": 139 xDim=128 140 yDim=48 141 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,464,235) 142 MoveSubWindow/W=PanelFit#ModelData fnum=(20,280,464,435) 143 cw[7] = 4 144 cw[8] = 8 145 wave newW = root:Packages:NIST:VSANS:VCALC:Front:det_FT 179 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_X 180 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_Y 181 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelX 182 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelY 183 wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 146 184 break 147 185 case "FB": 148 xDim=128 149 yDim=48 150 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,464,235) 151 MoveSubWindow/W=PanelFit#ModelData fnum=(20,280,464,435) 152 cw[7] = 4 153 cw[8] = 8 154 wave newW = root:Packages:NIST:VSANS:VCALC:Front:det_FB 155 break 156 case "ML": 157 xDim=48 158 yDim=256 159 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,180,600) 160 MoveSubWindow/W=PanelFit#ModelData fnum=(200,80,360,600) 161 cw[7] = 8 162 cw[8] = 4 163 wave newW = root:Packages:NIST:VSANS:VCALC:Middle:det_ML 164 break 165 case "MR": 166 xDim=48 167 yDim=256 168 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,180,600) 169 MoveSubWindow/W=PanelFit#ModelData fnum=(200,80,360,600) 170 cw[7] = 8 171 cw[8] = 4 172 wave newW = root:Packages:NIST:VSANS:VCALC:Middle:det_MR 186 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_X 187 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_Y 188 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelX 189 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelY 190 wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 173 191 break 174 192 case "MT": 175 xDim=128 176 yDim=48 177 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,464,235) 178 MoveSubWindow/W=PanelFit#ModelData fnum=(20,280,464,435) 179 cw[7] = 4 180 cw[8] = 8 181 wave newW = root:Packages:NIST:VSANS:VCALC:Middle:det_MT 193 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_X 194 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_Y 195 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelX 196 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelY 197 wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 182 198 break 183 199 case "MB": 184 xDim=128 185 yDim=48 186 MoveSubWindow/W=PanelFit#DetData fnum=(20,80,464,235) 187 MoveSubWindow/W=PanelFit#ModelData fnum=(20,280,464,435) 188 cw[7] = 4 189 cw[8] = 8 190 wave newW = root:Packages:NIST:VSANS:VCALC:Middle:det_MB 191 break 200 NVAR nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_X 201 NVAR nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_Y 202 NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelX 203 NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelY 204 wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 205 break 206 192 207 case "B": 193 194 208 return(0) //just exit 195 209 break … … 197 211 return(0) //just exit 198 212 endswitch 199 200 // set the simulated detector data to be pointscaling for display and fitting, not qscaling 201 duplicate/O newW dispW 202 SetScale/P x 0,1, dispW 203 SetScale/P y 0,1, dispW 213 214 215 216 217 Variable scale = 5 218 219 // common values (panel position, etc) 220 strswitch(str) 221 case "FL": 222 case "FR": 223 case "ML": 224 case "MR": 225 width = trunc(nPix_X*pixSize_X *scale*1.15) //48 tubes @ 8 mm 226 height = trunc(nPix_Y*pixSize_Y *scale*0.8) //128 pixels @ 8 mm 227 228 left = 20 229 top = 80 230 right = left+width 231 bottom = top+height 232 233 left2 = right + 20 234 right2 = left2 + width 235 top2 = top 236 bottom2 = bottom 237 238 break 239 case "FT": 240 case "FB": 241 case "MT": 242 case "MB": 243 width = trunc(nPix_X*pixSize_X *scale*1.) //128 pix @ 4 mm 244 height = trunc(nPix_Y*pixSize_Y *scale) // 48 tubes @ 8 mm 245 246 left = 20 247 top = 80 248 right = left+width 249 bottom = top+height 250 251 left2 = left 252 right2 = right 253 top2 = top + height + 20 254 bottom2 = bottom + height + 20 255 256 break 257 case "B": 258 return(0) //just exit 259 break 260 default: 261 return(0) //just exit 262 endswitch 263 264 // set from the detectorspecific strswitch 265 cw[7] = pixSize_X*10 266 cw[8] = pixSize_Y*10 267 268 // generate the new panel display 269 duplicate/O newW curDispPanel 270 SetScale/P x 0,1, curDispPanel 271 SetScale/P y 0,1, curDispPanel 272 273 //draw the detector panel 274 Display/W=(left,top,right,bottom)/HOST=# 275 AppendImage curDispPanel 276 ModifyImage curDispPanel ctab= {*,*,ColdWarm,0} 277 Label left "Y pixels" 278 Label bottom "X pixels" 279 RenameWindow #,DetData 280 SetActiveSubwindow ## 281 204 282 205 206 283 // redimension the model calculation to be the proper dimensions 207 Redimension/N=(xDim*yDim) xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D 208 FillPixTriplet(xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D,xDim,yDim) 209 Make/O/D/N=(xDim,yDim) PeakPix2D_mat // use the point scaling of the matrix (=pixels) 284 Redimension/N=(nPix_X*nPix_Y) xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D 285 FillPixTriplet(xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D,nPix_X,nPix_Y) 286 Make/O/D/N=(nPix_X,nPix_Y) PeakPix2D_mat // use the point scaling of the matrix (=pixels) 287 210 288 Duplicate/O $"PeakPix2D_mat",$"PeakPix2D_lin" //keep a linearscaled version of the data 289 290 //draw the model calculation 291 Display/W=(left2,top2,right2,bottom2)/HOST=# 292 AppendImage PeakPix2D_mat 293 ModifyImage PeakPix2D_mat ctab= {*,*,ColdWarm,0} 294 Label left "Y pixels" 295 Label bottom "X pixels" 296 RenameWindow #,ModelData 297 SetActiveSubwindow ## 298 299 DoUpdate 211 300 212 301 return(0) … … 236 325 237 326 238 239 327 // 328 // TODO  make a better guess (how?) 329 // 240 330 Function DetFitGuessButtonProc(ba) : ButtonControl 241 331 STRUCT WMButtonAction &ba
Note: See TracChangeset
for help on using the changeset viewer.