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

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

CHANGES to SANS:
Now allow 4 files to be combined in one step. This required modification of one routine in NIST_XML to allow an extra file name, and significant addition to the NSORT panel to allow an (optional) 4th data file. behaviors are still the same as before with 2, 3, or 4 sets being allowed. The "combine table" also allows up to 4 files to be combined (can be mixed, 2, 3, 4 all allowed).

More addtions to VSANS present as well, not specific changes, but in-progress changes to the beam center handling and ciombining data to 1D.

File size: 20.2 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//
25Macro 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: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: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: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: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 the only fit function
411//
412Function WriteCtrButtonProc(ba) : ButtonControl
413        STRUCT WMButtonAction &ba
414
415        switch( ba.eventCode )
416                case 2: // mouse up
417                        // click code here
418                        String detStr,fname
419                        Wave coefW=root:coef_PeakPix2D
420                       
421                        ControlInfo popup_0
422                        detStr = S_Value
423                        ControlInfo popup_2
424                        fname = S_Value
425                       
426                        V_putDet_beam_center_x(fname,detStr,coefW[9])
427                        V_putDet_beam_center_y(fname,detStr,coefW[10])
428
429                        break
430                case -1: // control being killed
431                        break
432        endswitch
433
434        return 0
435End
436
437
438
439// TODO
440// -- there is only a single fitting function available, and it's hard-wired
441// -- what values are held during the fitting are hard-wired
442//
443//
444// function to call the fit fucntion (2D)
445//
446Function DetFitButtonProc(ba) : ButtonControl
447        STRUCT WMButtonAction &ba
448
449        switch( ba.eventCode )
450                case 2: // mouse up
451                        // click code here
452                       
453                        Wave dispW=root:curDispPanel
454                        Wave coefW=root:coef_PeakPix2D
455                       
456                        FuncFitMD/H="11000111100"/NTHR=0 BroadPeak_Pix2D coefW  dispW /D                       
457                       
458                        Wave ws=W_sigma
459                        AppendtoTable/W=PanelFit#T0 ws
460                       
461                        break
462                case -1: // control being killed
463                        break
464        endswitch
465
466        return 0
467End
468
469Function DetFitHelpButtonProc(ba) : ButtonControl
470        STRUCT WMButtonAction &ba
471
472        switch( ba.eventCode )
473                case 2: // mouse up
474                        // click code here
475                       
476                        DoAlert 0,"Help file not written yet..."
477                       
478                        break
479                case -1: // control being killed
480                        break
481        endswitch
482
483        return 0
484End
485
486Function CtrTableButtonProc(ba) : ButtonControl
487        STRUCT WMButtonAction &ba
488
489        switch( ba.eventCode )
490                case 2: // mouse up
491                        // click code here
492                       
493                        V_BCtrTable()
494                       
495                        break
496                case -1: // control being killed
497                        break
498        endswitch
499
500        return 0
501End
502
503Function WriteCtrTableButtonProc(ba) : ButtonControl
504        STRUCT WMButtonAction &ba
505
506        switch( ba.eventCode )
507                case 2: // mouse up
508                        // click code here
509                       
510                        V_BeamCtr_WriteTable()
511                       
512                        break
513                case -1: // control being killed
514                        break
515        endswitch
516
517        return 0
518End
519
520// TODO
521// -- some of this is hard-wired in
522// -- this is still all in terms of pixels, which still may not be what I want
523// -- the x-scale of the T/B panels is artificially compressed to "fake" 4mm per pixel in x-direction
524//
525Function V_RescaleToBeamCenter(folderStr,detStr,xCtr,yCtr)
526        String folderStr,detStr
527        Variable xCtr,yCtr
528       
529        Wave w = $("root:Packages:NIST:VSANS:"+folderStr+":entry:entry:instrument:detector_"+detStr+":data")
530       
531        Variable nPix = 128
532        Variable nTubes = 48
533       
534        strswitch(detStr)       // string switch
535                case "MT":              // top panels
536                case "FT":
537//                      SetScale/I x -xCtr,npix-xCtr,"",w
538                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w         // fake 4mm by compressing the scale
539                        SetScale/I y -yCtr,nTubes-yCtr,"",w
540                        break                                           // exit from switch
541                case "MB":              // bottom panels
542                case "FB":
543//                      SetScale/I x -xCtr,npix-xCtr,"",w
544                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w
545                        SetScale/I y -yCtr,nTubes-yCtr,"",w
546                        break                                           // exit from switch
547                case "ML":              // left panels
548                case "FL":
549                        SetScale/I x -xCtr,nTubes-xCtr,"",w
550                        SetScale/I y -yCtr,npix-yCtr,"",w
551                        break                                           // exit from switch
552                case "MR":              // Right panels
553                case "FR":
554                        SetScale/I x -xCtr,nTubes-xCtr,"",w
555                        SetScale/I y -yCtr,npix-yCtr,"",w
556                        break                                           // exit from switch
557                                       
558                default:                                                        // optional default expression executed
559                        Print "Error in V_RescaleToBeamCenter()"
560        endswitch
561       
562        return(0)
563end
564
565// TODO
566// these are "nominal" beam center values in pixels for the default VCALC configuration
567// This function "restores" the data display to the "instrument" conditions where the panels overlap
568// and is intended to be a TRUE view of what the detectors see - that is - the peaks should appear as rings,
569// the view should be symmetric (if the real data is symmetric)
570//
571// -- this is currently linked to the Vdata panel
572// -- will need to remove the hard-wired values and get the proper values from the data
573// -- ?? will the "proper" values be in pixels or distance? All depends on how I display the data...
574// -- may want to keep the nominal scaling values around in case the proper values aren' in the file
575//
576Function V_RestorePanels()
577
578        String fname=""
579        String detStr=""
580        Variable ii,xCtr,yCtr
581
582//// this works if the proper centers are in the file - otherwise, it's a mess 
583//      fname = "RAW"
584//      for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1)
585//              detStr = StringFromList(ii, ksDetectorListNoB, ";")
586//              xCtr = V_getDet_beam_center_x(fname,detStr)
587//              yCtr = V_getDet_beam_center_y(fname,detStr)
588//              V_RescaleToBeamCenter("RAW",detStr,xCtr,yCtr)
589//      endfor
590               
591               
592                // nominal values... better to use what's in the file
593//
594                V_RescaleToBeamCenter("RAW","MB",64,55)
595                V_RescaleToBeamCenter("RAW","MT",64,-8.7)
596                V_RescaleToBeamCenter("RAW","MR",-8.1,64)
597                V_RescaleToBeamCenter("RAW","ML",55,64)
598                V_RescaleToBeamCenter("RAW","FB",64,55)
599                V_RescaleToBeamCenter("RAW","FT",64,-8.7)
600                V_RescaleToBeamCenter("RAW","FR",-8.1,64)
601                V_RescaleToBeamCenter("RAW","FL",55,64)
602        return(0)
603end
604
605// TODO
606// these are "spread out" values for the data panels
607// This view is meant to spread out the panels so there is (?Less) overlap so the panels can be
608// viewed a bit easier. Isolation may still be preferred for detailed work.
609//
610// -- this is currently linked to the Vdata panel
611// -- will need to remove the hard-wired values and get the proper values from the data
612// -- ?? will the "proper" values be in pixels or distance? All depends on how I display the data...
613//
614Function V_SpreadOutPanels()
615
616        V_RescaleToBeamCenter("RAW","MB",64,78)
617        V_RescaleToBeamCenter("RAW","MT",64,-30)
618        V_RescaleToBeamCenter("RAW","MR",-30,64)
619        V_RescaleToBeamCenter("RAW","ML",78,64)
620        V_RescaleToBeamCenter("RAW","FB",64,78)
621        V_RescaleToBeamCenter("RAW","FT",64,-30)
622        V_RescaleToBeamCenter("RAW","FR",-30,64)
623        V_RescaleToBeamCenter("RAW","FL",78,64)
624        return(0)
625end
626
627// function to display the beam center values for all of the detectors
628// opens a separate table with the detector label, and the XY values
629// ? Maybe list the XY pair in pixels and in real distance in the table
630//
631// TODO:
632// -- need a way to use this or another table? as input to put the new/fitted/derived
633//    beam center values into the data folders, and ultimately into the data files on disk
634// -- need read/Write for the XY in pixels, and in real-distance
635// -- where are the temporary waves to be located? root?
636// -- need way to access the Ctr_mm values
637Function V_BCtrTable()
638       
639        // order of the panel names will match the constant string
640        //FT;FB;FL;FR;MT;MB;ML;MR;B;
641        Make/O/T/N=9 panelW
642        Make/O/D/N=9 xCtr_pix,yCtr_pix,xCtr_mm,yCtr_mm
643        DoWindow/F BCtrTable
644        if(V_flag == 0)
645                Edit/W=(547,621,1076,943)/N=BCtrTable panelW,xCtr_pix,yCtr_pix,xCtr_mm,yCtr_mm
646        endif
647       
648        Variable ii
649        String detStr,fname
650       
651        fname = "RAW"
652        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)
653                detStr = StringFromList(ii, ksDetectorListAll, ";")
654                panelW[ii] = detStr
655                xCtr_pix[ii] = V_getDet_beam_center_x(fname,detStr)
656                yCtr_pix[ii] = V_getDet_beam_center_y(fname,detStr)
657                // TODO
658                // and now the mm values
659               
660        endfor
661        return(0)
662End
663
664//
665// to write the new beam center values to a file on disk:
666// V_writeDet_beam_center_x(fname,detStr,val)
667//
668// to write to a local WORK folder
669// V_putDet_beam_center_x(fname,detStr,val)
670//
671Function V_BeamCtr_WriteTable()
672
673        String folder
674       
675        Variable ii
676        String detStr,fname
677       
678        Wave xCtr_pix = root:xCtr_pix
679        Wave yCtr_pix = root:yCtr_pix
680        Wave/T panelW = root:PanelW
681       
682        ControlInfo popup_2
683        folder = S_Value
684       
685        fname = folder
686        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)
687//              detStr = StringFromList(ii, ksDetectorListAll, ";")
688                detStr = panelW[ii]
689                V_putDet_beam_center_x(fname,detStr,xCtr_pix[ii])
690                V_putDet_beam_center_y(fname,detStr,yCtr_pix[ii])
691               
692                // TODO
693                // and now the mm values
694               
695        endfor
696        return(0)
697       
698End
Note: See TracBrowser for help on using the repository browser.