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

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

changes to (mostly) PatchFiles? to be more VSANS-aware, and to update the installed version to report the correct version. Apparently people actually check, and are confused when they don't match.

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