source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_BeamCenter.ipf @ 1037

Last change on this file since 1037 was 1034, checked in by srkline, 6 years ago

re-wrote raw data reader for significant speed boost (mostly by skipping the read of DAS_logs)

added centroid calculation to the Marquee

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