source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf @ 995

Last change on this file since 995 was 995, checked in by srkline, 7 years ago

more changes, bug fixes, detector dead time fix

File size: 20.5 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4// TODO
5// -- adjust the guesses to some better starting conditions
6// -- multiple fit options with different things held
7// x- when selecting the detector, set the x/y pixel sizes
8// -- figure out how to re-plot the images when swapping between LR and TB panels
9// -- Modify to accept mm (real space dimensions) rather than pixels
10//    -- or be able to swap the answer to mm for a more natural definition of the beam center
11// -- add method to be able to write the values to the local folder / or better, to file on disk
12// -- graphically show the beam center / radius of where it is in relation to the panel
13
14
15Function V_FindBeamCenter()
16        DoWindow/F PanelFit
17        if(V_flag==0)
18                Execute "DetectorPanelFit()"
19        endif
20End
21//
22// TODO - may need to adjust the display for the different pixel dimensions
23//      ModifyGraph width={Plan,1,bottom,left}
24//
25Proc DetectorPanelFit() : Panel
26        PauseUpdate; Silent 1           // building window...
27
28// plot the default model to be sure some data is present
29        if(exists("xwave_PeakPix2D") == 0)
30                PlotBroadPeak_Pix2D()
31        endif
32
33        NewPanel /W=(662,418,1586,960)/N=PanelFit/K=1
34//      ShowTools/A
35       
36        PopupMenu popup_0,pos={20,50},size={109,20},proc=SetDetPanelPopMenuProc,title="Detector Panel"
37        PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;MR;ML;MT;MB;B;\""
38        PopupMenu popup_1,pos={200,20},size={157,20},proc=DetModelPopMenuProc,title="Model Function"
39        PopupMenu popup_1,mode=1,popvalue="BroadPeak",value= #"\"BroadPeak;other;\""
40        PopupMenu popup_2,pos={20,20},size={109,20},title="Data Source"//,proc=SetFldrPopMenuProc
41        PopupMenu popup_2,mode=1,popvalue="VCALC",value= #"\"RAW;SAM;VCALC;\""
42               
43        Button button_0,pos={486,20},size={80,20},proc=DetFitGuessButtonProc,title="Guess"
44        Button button_1,pos={615,20},size={80,20},proc=DetFitButtonProc,title="Do Fit"
45        Button button_2,pos={744,20},size={80,20},proc=DetFitHelpButtonProc,title="Help"
46        Button button_3,pos={615,400},size={110,20},proc=WriteCtrButtonProc,title="Write Centers"
47        Button button_4,pos={730,400},size={110,20},proc=CtrTableButtonProc,title="Ctr table"
48        Button button_5,pos={730,440},size={110,20},proc=WriteCtrTableButtonProc,title="Write table"
49
50
51
52        duplicate/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL:det_FL curDispPanel
53        SetScale/P x 0,1, curDispPanel
54        SetScale/P y 0,1, curDispPanel
55
56
57        // draw the correct images
58        DrawDetPanel("FL")
59
60       
61////draw the detector panel
62//      Display/W=(20,80,200,600)/HOST=#
63//      AppendImage curDispPanel
64//      ModifyImage curDispPanel ctab= {*,*,ColdWarm,0}
65////    ModifyGraph height={Aspect,2.67}               
66//      Label left "Y pixels"
67//      Label bottom "X pixels"
68//      RenameWindow #,DetData
69//      SetActiveSubwindow ##   
70//     
71////draw the model calculation
72//      Display/W=(220,80,400,600)/HOST=#
73//      AppendImage PeakPix2D_mat
74//      ModifyImage PeakPix2D_mat ctab= {*,*,ColdWarm,0}
75////    ModifyGraph height={Aspect,2.67}               
76////    ModifyGraph width={Aspect,0.375}               
77//      Label left "Y pixels"
78//      Label bottom "X pixels"
79//      RenameWindow #,ModelData
80//      SetActiveSubwindow ##           
81
82
83
84
85// edit the fit coefficients   
86        Edit/W=(550,80,880,370)/HOST=#  parameters_PeakPix2D,coef_PeakPix2D
87        ModifyTable width(Point)=0
88        ModifyTable width(parameters_PeakPix2D)=120
89        ModifyTable width(coef_PeakPix2D)=100
90        RenameWindow #,T0
91        SetActiveSubwindow ##
92
93       
94EndMacro
95
96
97//
98// function to choose which detector panel to display, and then to actually display it
99//
100Function SetDetPanelPopMenuProc(pa) : PopupMenuControl
101        STRUCT WMPopupAction &pa
102
103        switch( pa.eventCode )
104                case 2: // mouse up
105                        Variable popNum = pa.popNum
106                        String popStr = pa.popStr
107                                               
108                        // remove the old image (it may not be the right shape)
109                        // -- but make sure it exists first...
110                        String childList = ChildWindowList("PanelFit")
111                        Variable flag
112                       
113                        flag = WhichListItem("DetData", ChildList)              //returns -1 if not in list, 0+ otherwise
114                        if(flag != -1)
115                                KillWindow PanelFit#DetData
116                        endif
117                       
118                        flag = WhichListItem("ModelData", ChildList)
119                        if(flag != -1)
120                                KillWindow PanelFit#ModelData
121                        endif
122       
123                        // draw the correct images
124                        DrawDetPanel(popStr)
125                       
126                        break
127                case -1: // control being killed
128                        break
129        endswitch
130
131        return 0
132End
133
134
135// TODO - currently is hard-wired for the simulation path!
136//     need to make it more generic, especially for RAW data
137//
138// -- need to adjust the size of the image subwindows to keep the model
139//    calculation from spillon over onto the table (maybe just move the table)
140// -- need to do something for panel "B". currently ignored
141// -- currently the pixel sizes for "real" data is incorrect in the file
142//     and this is why the plots are incorrectly sized
143//
144// draw the selected panel and the model calculation, adjusting for the
145// orientation of the panel and the number of pixels, and pixel sizes
146Function DrawDetPanel(str)
147        String str
148       
149        // from the selection, find the path to the data
150
151
152        Variable xDim,yDim
153        Variable left,top,right,bottom
154        Variable height, width
155        Variable left2,top2,right2,bottom2
156        Variable nPix_X,nPix_Y,pixSize_X,pixSize_Y
157
158       
159        Wave dispW=root:curDispPanel
160        Wave cw = root:coef_PeakPix2D
161
162        Wave xwave_PeakPix2D=root:xwave_PeakPix2D
163        Wave ywave_PeakPix2D=root:ywave_PeakPix2D
164        Wave zwave_PeakPix2D=root:zwave_PeakPix2D
165
166        //plot it in the subwindow with the proper aspect and positioning
167        // for 48x256 (8mm x 4mm), aspect = (256/2)/48 = 2.67 (LR panels)
168        // for 128x48 (4mm x 8 mm), aspect = 48/(128/2) = 0.75 (TB panels)
169       
170       
171        // using two switches -- one to set the panel-specific dimensions
172        // and the other to set the "common" values, some of which are based on the panel dimensions
173
174// set the source of the data. not always VCALC anymore
175        String folder
176        ControlInfo popup_2
177        folder = S_Value
178
179        // TODO -- fix all of this mess
180        if(cmpstr(folder,"VCALC") == 0)
181                // panel-specific values
182                Variable VC_nPix_X = VCALC_get_nPix_X(str)
183                Variable VC_nPix_Y = VCALC_get_nPix_Y(str)
184                Variable VC_pixSize_X = VCALC_getPixSizeX(str)
185                Variable VC_pixSize_Y = VCALC_getPixSizeY(str)
186//              strswitch(str)
187//                      case "FL":
188//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_X
189//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_Y
190//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelX
191//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelY
192//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+str+":det_"+str)
193//                              break
194//                      case "FR":
195//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_X
196//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_Y
197//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelX
198//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelY
199//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str)
200//                              break
201//                      case "ML":
202//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_X
203//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_Y
204//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelX
205//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelY
206//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str)
207//                              break
208//                      case "MR":
209//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_X
210//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_Y
211//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelX
212//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelY
213//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str)
214//                              break   
215//     
216//                      case "FT":
217//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_X
218//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_Y
219//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelX
220//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelY
221//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str)
222//                              break
223//                      case "FB":
224//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_X
225//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_Y
226//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelX
227//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelY
228//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str)
229//                              break
230//                      case "MT":
231//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_X
232//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_Y
233//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelX
234//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelY
235//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str)
236//                              break
237//                      case "MB":
238//                              NVAR VC_nPix_X = root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_X
239//                              NVAR VC_nPix_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_Y
240//                              NVAR VC_pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelX
241//                              NVAR VC_pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelY
242//      //                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str)
243//                              break   
244//                             
245//                      case "B":
246//                              return(0)               //just exit
247//                              break                                           
248//                      default:
249//                              return(0)               //just exit
250//              endswitch
251       
252        // if VCALC declare this way   
253                wave newW = $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+str+":det_"+str)
254                nPix_X = VC_nPix_X
255                nPix_Y = VC_nPix_Y
256                pixSize_X = VC_pixSize_X
257                pixSize_Y = VC_pixSize_Y
258       
259        else
260        // TODO: if real data, need new declaration w/ data as the wave name
261                wave newW = $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+str+":data")
262
263                nPix_X = V_getDet_pixel_num_x(folder,str)
264                nPix_Y = V_getDet_pixel_num_Y(folder,str)
265                pixSize_X = V_getDet_x_pixel_size(folder,str)/10
266                pixSize_Y = V_getDet_y_pixel_size(folder,str)/10
267        endif
268       
269
270        Variable scale = 5
271       
272        // common values (panel position, etc)
273        // TODO -- units are absolute, based on pixels in cm. make sure this is always correct
274        strswitch(str)
275                case "FL":
276                case "FR":
277                case "ML":
278                case "MR":
279                        width = trunc(nPix_X*pixSize_X *scale*1.15)                     //48 tubes @ 8 mm
280                        height = trunc(nPix_Y*pixSize_Y *scale*0.8)                     //128 pixels @ 8 mm
281                       
282                        left = 20
283                        top = 80
284                        right = left+width
285                        bottom = top+height
286                       
287                        left2 = right + 20
288                        right2 = left2 + width
289                        top2 = top
290                        bottom2 = bottom
291                       
292                        break                   
293                case "FT":
294                case "FB":
295                case "MT":
296                case "MB":
297                        width = trunc(nPix_X*pixSize_X *scale*1.)                       //128 pix @ 4 mm
298                        height = trunc(nPix_Y*pixSize_Y *scale)                 // 48 tubes @ 8 mm
299                                               
300                        left = 20
301                        top = 80
302                        right = left+width
303                        bottom = top+height
304                       
305                        left2 = left
306                        right2 = right
307                        top2 = top + height + 20
308                        bottom2 = bottom + height + 20
309                       
310                        break
311                case "B":
312                        return(0)               //just exit
313                        break                                           
314                default:
315                        return(0)               //just exit
316        endswitch
317
318        // set from the detector-specific strswitch
319        cw[7] = pixSize_X*10
320        cw[8] = pixSize_Y*10           
321
322        // generate the new panel display
323        duplicate/O newW curDispPanel
324        SetScale/P x 0,1, curDispPanel
325        SetScale/P y 0,1, curDispPanel
326       
327        //draw the detector panel
328        Display/W=(left,top,right,bottom)/HOST=#
329        AppendImage curDispPanel
330        ModifyImage curDispPanel ctab= {*,*,ColdWarm,0}
331        Label left "Y pixels"
332        Label bottom "X pixels"
333        RenameWindow #,DetData
334        SetActiveSubwindow ##   
335       
336               
337        // re-dimension the model calculation to be the proper dimensions       
338        Redimension/N=(nPix_X*nPix_Y) xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D 
339        FillPixTriplet(xwave_PeakPix2D, ywave_PeakPix2D,zwave_PeakPix2D,nPix_X,nPix_Y)
340        Make/O/D/N=(nPix_X,nPix_Y) PeakPix2D_mat                // use the point scaling of the matrix (=pixels)
341
342        Duplicate/O $"PeakPix2D_mat",$"PeakPix2D_lin"           //keep a linear-scaled version of the data
343
344        //draw the model calculation
345        Display/W=(left2,top2,right2,bottom2)/HOST=#
346        AppendImage PeakPix2D_mat
347        ModifyImage PeakPix2D_mat ctab= {*,*,ColdWarm,0}
348        Label left "Y pixels"
349        Label bottom "X pixels"
350        RenameWindow #,ModelData
351        SetActiveSubwindow ##   
352               
353        DoUpdate
354       
355        return(0)
356End
357
358
359
360
361// TODO:
362// -- allow other model functions as needed.
363//
364// Function to plot the specified 2D model for the detector
365//
366Function DetModelPopMenuProc(pa) : PopupMenuControl
367        STRUCT WMPopupAction &pa
368
369        switch( pa.eventCode )
370                case 2: // mouse up
371                        Variable popNum = pa.popNum
372                        String popStr = pa.popStr
373                       
374                        Execute "PlotBroadPeak_Pix2D()"
375                       
376                        break
377                case -1: // control being killed
378                        break
379        endswitch
380
381        return 0
382End
383
384
385//
386// TODO - make a better guess (how?)
387//
388Function DetFitGuessButtonProc(ba) : ButtonControl
389        STRUCT WMButtonAction &ba
390
391        switch( ba.eventCode )
392                case 2: // mouse up
393                        // click code here
394                        Wave dispW=root:curDispPanel
395                        Wave coefW=root:coef_PeakPix2D
396                       
397                        WaveStats/Q dispW
398                        coefW[2] = V_max
399                        coefW[0] = 1                   
400                       
401                        break
402                case -1: // control being killed
403                        break
404        endswitch
405
406        return 0
407End
408
409//
410// TODO -- currently hard-wired for coefficients from the only fit function
411//
412// -- will need to recalc mm center AND q-values
413Function WriteCtrButtonProc(ba) : ButtonControl
414        STRUCT WMButtonAction &ba
415
416        switch( ba.eventCode )
417                case 2: // mouse up
418                        // click code here
419                        String detStr,fname
420                        Wave coefW=root:coef_PeakPix2D
421                       
422                        ControlInfo popup_0
423                        detStr = S_Value
424                        ControlInfo popup_2
425                        fname = S_Value
426                       
427                        V_putDet_beam_center_x(fname,detStr,coefW[9])
428                        V_putDet_beam_center_y(fname,detStr,coefW[10])
429
430                        DoAlert 0, "-- will need to recalc mm center AND q-values"
431                       
432                        break
433                case -1: // control being killed
434                        break
435        endswitch
436
437        return 0
438End
439
440
441
442// TODO
443// -- there is only a single fitting function available, and it's hard-wired
444// -- what values are held during the fitting are hard-wired
445//
446//
447// function to call the fit function (2D)
448//
449Function DetFitButtonProc(ba) : ButtonControl
450        STRUCT WMButtonAction &ba
451
452        switch( ba.eventCode )
453                case 2: // mouse up
454                        // click code here
455                       
456                        Wave dispW=root:curDispPanel
457                        Wave coefW=root:coef_PeakPix2D
458                       
459                        FuncFitMD/H="11000111100"/NTHR=0 BroadPeak_Pix2D coefW  dispW /D                       
460                       
461                        Wave ws=W_sigma
462                        AppendtoTable/W=PanelFit#T0 ws
463                       
464                        break
465                case -1: // control being killed
466                        break
467        endswitch
468
469        return 0
470End
471
472Function DetFitHelpButtonProc(ba) : ButtonControl
473        STRUCT WMButtonAction &ba
474
475        switch( ba.eventCode )
476                case 2: // mouse up
477                        // click code here
478                       
479                        DoAlert 0,"Help file not written yet..."
480                       
481                        break
482                case -1: // control being killed
483                        break
484        endswitch
485
486        return 0
487End
488
489Function CtrTableButtonProc(ba) : ButtonControl
490        STRUCT WMButtonAction &ba
491
492        switch( ba.eventCode )
493                case 2: // mouse up
494                        // click code here
495                       
496                        V_BCtrTable()
497                       
498                        break
499                case -1: // control being killed
500                        break
501        endswitch
502
503        return 0
504End
505
506Function WriteCtrTableButtonProc(ba) : ButtonControl
507        STRUCT WMButtonAction &ba
508
509        switch( ba.eventCode )
510                case 2: // mouse up
511                        // click code here
512                       
513                        V_BeamCtr_WriteTable()
514                       
515                        break
516                case -1: // control being killed
517                        break
518        endswitch
519
520        return 0
521End
522
523//
524// This sets the scale of the data panels to an approximate detector coordinate system with
525// zero at the center, only for display purposes. It is not exact, and has nothing to do with
526// the calculation of q-values.
527//
528// TODO
529// -- some of this is hard-wired in
530// -- this is still all in terms of pixels, which still may not be what I want
531// -- the x-scale of the T/B panels is artificially compressed to "fake" 4mm per pixel in x-direction
532//
533Function V_RescaleToBeamCenter(folderStr,detStr,xCtr,yCtr)
534        String folderStr,detStr
535        Variable xCtr,yCtr
536       
537        Wave w = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":data")
538       
539        Variable nPix = 128
540        Variable nTubes = 48
541       
542        strswitch(detStr)       // string switch
543                case "MT":              // top panels
544                case "FT":
545//                      SetScale/I x -xCtr,npix-xCtr,"",w
546                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w         // fake 4mm by compressing the scale
547                        SetScale/I y -yCtr,nTubes-yCtr,"",w
548                        break                                           // exit from switch
549                case "MB":              // bottom panels
550                case "FB":
551//                      SetScale/I x -xCtr,npix-xCtr,"",w
552                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w
553                        SetScale/I y -yCtr,nTubes-yCtr,"",w
554                        break                                           // exit from switch
555                case "ML":              // left panels
556                case "FL":
557                        SetScale/I x -xCtr,nTubes-xCtr,"",w
558                        SetScale/I y -yCtr,npix-yCtr,"",w
559                        break                                           // exit from switch
560                case "MR":              // Right panels
561                case "FR":
562                        SetScale/I x -xCtr,nTubes-xCtr,"",w
563                        SetScale/I y -yCtr,npix-yCtr,"",w
564                        break                                           // exit from switch
565                                       
566                default:                                                        // optional default expression executed
567                        Print "Error in V_RescaleToBeamCenter()"
568        endswitch
569       
570        return(0)
571end
572
573// TODO
574// these are "nominal" beam center values in pixels for the default VCALC configuration
575// This function "restores" the data display to the "instrument" conditions where the panels overlap
576// and is intended to be a TRUE view of what the detectors see - that is - the peaks should appear as rings,
577// the view should be symmetric (if the real data is symmetric)
578//
579// -- this is currently linked to the Vdata panel
580// -- will need to remove the hard-wired values and get the proper values from the data
581// -- ?? will the "proper" values be in pixels or distance? All depends on how I display the data...
582// -- may want to keep the nominal scaling values around in case the proper values aren't in the file
583//
584//
585//
586//•print xCtr_pix
587//  xCtr_pix[0]= {64,64,55,-8.1,64,64,55,-8.1,63.4}
588//•print yCtr_pix
589//  yCtr_pix[0]= {-8.7,55,64,64,-8.7,55,64,64,62.7}
590//
591Function V_RestorePanels()
592
593        String fname=""
594        String detStr=""
595        Variable ii,xCtr,yCtr
596
597// this works if the proper centers are in the file - otherwise, it's a mess   
598// "B" is skipped here, as it should be...
599        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType
600
601        fname = type
602        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1)
603                detStr = StringFromList(ii, ksDetectorListNoB, ";")
604                xCtr = V_getDet_beam_center_x(fname,detStr)
605                yCtr = V_getDet_beam_center_y(fname,detStr)
606                V_RescaleToBeamCenter(type,detStr,xCtr,yCtr)
607        endfor
608               
609
610        return(0)
611end
612
613// TODO
614// these are "spread out" values for the data panels
615// This view is meant to spread out the panels so there is (?Less) overlap so the panels can be
616// viewed a bit easier. Isolation may still be preferred for detailed work.
617//
618// -- this is currently linked to the Vdata panel
619// -- will need to remove the hard-wired values and get the proper values from the data
620// -- ?? will the "proper" values be in pixels or distance? All depends on how I display the data...
621//
622Function V_SpreadOutPanels()
623
624        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType
625
626        V_RescaleToBeamCenter(type,"MB",64,78)
627        V_RescaleToBeamCenter(type,"MT",64,-30)
628        V_RescaleToBeamCenter(type,"MR",-30,64)
629        V_RescaleToBeamCenter(type,"ML",78,64)
630        V_RescaleToBeamCenter(type,"FB",64,78)
631        V_RescaleToBeamCenter(type,"FT",64,-30)
632        V_RescaleToBeamCenter(type,"FR",-30,64)
633        V_RescaleToBeamCenter(type,"FL",78,64)
634        return(0)
635end
636
637// function to display the beam center values for all of the detectors
638// opens a separate table with the detector label, and the XY values
639// ? Maybe list the XY pair in pixels and in real distance in the table
640//
641// TODO:
642// -- need a way to use this or another table? as input to put the new/fitted/derived
643//    beam center values into the data folders, and ultimately into the data files on disk
644// -- need read/Write for the XY in pixels, and in real-distance
645// -- where are the temporary waves to be located? root?
646// -- need way to access the Ctr_mm values
647Function V_BCtrTable()
648       
649        // order of the panel names will match the constant string
650        //FT;FB;FL;FR;MT;MB;ML;MR;B;
651        Make/O/T/N=9 panelW
652        Make/O/D/N=9 xCtr_pix,yCtr_pix,xCtr_mm,yCtr_mm
653        DoWindow/F BCtrTable
654        if(V_flag == 0)
655                Edit/W=(547,621,1076,943)/N=BCtrTable panelW,xCtr_pix,yCtr_pix,xCtr_mm,yCtr_mm
656        endif
657       
658        Variable ii
659        String detStr,fname
660       
661        fname = "RAW"
662        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)
663                detStr = StringFromList(ii, ksDetectorListAll, ";")
664                panelW[ii] = detStr
665                xCtr_pix[ii] = V_getDet_beam_center_x(fname,detStr)
666                yCtr_pix[ii] = V_getDet_beam_center_y(fname,detStr)
667                // TODO
668                // and now the mm values
669                xCtr_mm[ii] = V_getDet_beam_center_x_mm(fname,detStr)
670                yCtr_mm[ii] = V_getDet_beam_center_y_mm(fname,detStr)
671               
672        endfor
673        return(0)
674End
675
676//
677// to write the new beam center values to a file on disk:
678// V_writeDet_beam_center_x(fname,detStr,val)
679//
680// to write to a local WORK folder
681// V_putDet_beam_center_x(fname,detStr,val)
682//
683Function V_BeamCtr_WriteTable()
684
685        String folder
686       
687        Variable ii
688        String detStr,fname
689       
690        Wave xCtr_pix = root:xCtr_pix
691        Wave yCtr_pix = root:yCtr_pix
692        Wave/T panelW = root:PanelW
693       
694        ControlInfo popup_2
695        folder = S_Value
696       
697        fname = folder
698        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)
699//              detStr = StringFromList(ii, ksDetectorListAll, ";")
700                detStr = panelW[ii]
701                V_putDet_beam_center_x(fname,detStr,xCtr_pix[ii])
702                V_putDet_beam_center_y(fname,detStr,yCtr_pix[ii])
703               
704                // TODO
705                // and now the mm values
706               
707        endfor
708        return(0)
709       
710End
Note: See TracBrowser for help on using the repository browser.