source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Transmission.ipf @ 1129

Last change on this file since 1129 was 1105, checked in by srkline, 5 years ago

updated mask drawing to draw arbitrary shapes, fixing bugs in the operation.

fix operation of popups in transmission panel.

other bug fixes that I don't recall from the past week.

File size: 20.5 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5
6// TODO
7// x- initialization
8// x- link to main panel
9//
10// ?? redesign the panel based on the CATALOG?
11// -- refresh the catalog, then work with those waves?
12//
13// -- this still seems to be very awkward to use. Come up with something better
14//
15// -- need more checks - be sure that the files match
16// -- SDD, wavelength, beam on proper panel, etc.
17//
18// -- need popups (transmission, open) to respond to popup changes and
19//   update their fields, since they may be auto-located incorrectly.
20//
21// to patch the box coordinates
22// err = V_writeBoxCoordinates(fname,V_List2NumWave(str,";","inW"))
23
24
25
26//
27Function V_InitTransmissionPanel()
28       
29        DoWindow/F V_TransmissionPanel
30        if(V_Flag == 0)
31                V_InitTransPanelGlobals()
32                Execute "V_TransmissionPanel()"
33        endif
34End
35
36Function V_InitTransPanelGlobals()
37
38// root:Packages:NIST:VSANS:Globals:Transmission
39        NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Transmission
40        Variable/G gSamGrpID,gTrnGrpID,gTrans,gTransErr
41        String/G gSamLabel="file label",gTransLabel="file label",gEmptyLabel="file label"
42        String/G gEmptyBoxCoord="1;2;3;4;",gEmptyPanel="ENTER PANEL"
43        String/G gSamMatchList = "_none_"
44        String/G gTransMatchList = "_none_"
45
46
47        SetDataFolder root:
48        return(0)
49End
50
51Window V_TransmissionPanel() : Panel
52        PauseUpdate; Silent 1           // building window...
53        NewPanel /W=(1496,366,1974,990) /K=1
54        ModifyPanel cbRGB=(32896,16448,0,19621)
55        DoWindow/C V_TransmissionPanel
56
57//      ShowTools/A
58        PopupMenu popup_0,pos={16.00,359.00},size={104.00,23.00},fstyle=1,fsize=12,proc=V_TSamFilePopMenuProc,title="Sample"
59        PopupMenu popup_0,mode=1,popvalue="_none_",value= #"root:Packages:NIST:VSANS:Globals:Transmission:gSamMatchList"
60        PopupMenu popup_1,pos={12.00,229.00},size={195.00,23.00},fstyle=1,fsize=12,proc=V_TTransmFilePopMenuProc,title="Transmission"
61        PopupMenu popup_1,mode=1,popvalue="_none_",value = #"root:Packages:NIST:VSANS:Globals:Transmission:gTransMatchList"//value= V_getFilePurposeList("TRANSMISSION",0)
62        PopupMenu popup_2,pos={17.00,79.00},size={188.00,23.00},fstyle=1,fsize=12,proc=V_TEmpBeamPopMenuProc,title="Open Beam"
63        PopupMenu popup_2,mode=1,popvalue="sans1.nxs.ngv",value= V_getFileIntentList("OPEN BEAM",0)
64        Button button_0,pos={34.00,499.00},size={100.00,20.00},proc=V_CalcTransmButtonProc,title="Calculate"
65        Button button_2,pos={349.00,13.00},size={30.00,20.00},proc=V_HelpTransmButtonProc,title="?"
66        Button button_3,pos={410.00,13.00},size={50.00,20.00},proc=V_DoneTransmButtonProc,title="Done"
67        Button button_4,pos={164.00,500.00},size={150.00,20.00},proc=V_CalcTransmListButtonProc,title="Calculate All In Popup"
68        SetVariable setvar_0,pos={18.00,390.00},size={300.00,14.00},title="Label:"
69        SetVariable setvar_0,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gSamLabel
70        SetVariable setvar_1,pos={18.00,417.00},size={300.00,14.00},title="Group ID:"
71        SetVariable setvar_1,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gSamGrpID
72        SetVariable setvar_2,pos={15.00,257.00},size={300.00,14.00},title="Label:"
73        SetVariable setvar_2,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTransLabel
74        SetVariable setvar_3,pos={14.00,283.00},size={300.00,14.00},title="Group ID:"
75        SetVariable setvar_3,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTrnGrpID
76        SetVariable setvar_4,pos={18.00,108.00},size={300.00,14.00},title="Label:"
77        SetVariable setvar_4,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyLabel
78        SetVariable setvar_5,pos={18.00,132.00},size={300.00,14.00},title="XY Box:"
79        SetVariable setvar_5,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyBoxCoord
80        SetVariable setvar_6,pos={18.00,157.00},size={300.00,14.00},fstyle=1,fsize=12,title="Panel:"
81        SetVariable setvar_6,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyPanel
82        SetVariable setvar_7,pos={18.00,442.00},size={300.00,14.00},title="Transmission:"
83        SetVariable setvar_7,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTrans
84        SetVariable setvar_8,pos={18.00,467.00},size={300.00,14.00},title="Error:"
85        SetVariable setvar_8,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTransErr
86EndMacro
87
88
89//Window V_TransmissionPanel() : Panel
90//      PauseUpdate; Silent 1           // building window...
91//      NewPanel /W=(1286,328,1764,952)
92//      ModifyPanel cbRGB=(32896,16448,0,19621)
93//      DoWindow/C V_TransmissionPanel
94//
95////    ShowTools/A
96//      PopupMenu popup_0,pos={19.00,55.00},size={86.00,23.00},proc=V_TSamFilePopMenuProc,title="Sample"
97////    PopupMenu popup_0,mode=1,value= V_getFilePurposeList("SCATTERING",0)//+V_getFileIntentList("EMPTY CELL",0)
98//      PopupMenu popup_0,mode=1,value=root:Packages:NIST:VSANS:Globals:Transmission:gSamMatchList
99//      PopupMenu popup_1,pos={102,248},size={72.00,23.00},proc=V_TTransmFilePopMenuProc,title="Transmission"
100//      PopupMenu popup_1,mode=1,value= V_getFilePurposeList("TRANSMISSION",0)
101//      PopupMenu popup_2,pos={164,353},size={72.00,23.00},proc=V_TEmpBeamPopMenuProc,title="Open Beam"
102////    PopupMenu popup_2,mode=1,value= V_getFileIntentList("EMPTY BEAM",0)
103//      PopupMenu popup_2,mode=1,value= V_getFileIntentList("OPEN BEAM",0)
104//      Button button_0,pos={37,193},size={100.00,20.00},proc=V_CalcTransmButtonProc,title="Calculate"
105////    Button button_1,pos={23.00,491.00},size={100.00,20.00},proc=V_WriteTransmButtonProc,title="Write"
106//      Button button_2,pos={349.00,13.00},size={30.00,20.00},proc=V_HelpTransmButtonProc,title="?"
107//      Button button_3,pos={410.00,13.00},size={50.00,20.00},proc=V_DoneTransmButtonProc,title="Done"
108//      SetVariable setvar_0,pos={21.00,86.00},size={300.00,14.00},title="Label:"
109//      SetVariable setvar_0,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gSamLabel
110//      SetVariable setvar_1,pos={21.00,113.00},size={300.00,14.00},title="Group ID:"
111//      SetVariable setvar_1,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gSamGrpID
112//      SetVariable setvar_2,pos={105,276.00},size={300.00,14.00},title="Label:"
113//      SetVariable setvar_2,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTransLabel
114//      SetVariable setvar_3,pos={104,302},size={300.00,14.00},title="Group ID:"
115//      SetVariable setvar_3,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTrnGrpID
116//      SetVariable setvar_4,pos={165,382},size={300.00,14.00},title="Label:"
117//      SetVariable setvar_4,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyLabel
118//      SetVariable setvar_5,pos={165,406},size={300.00,14.00},title="XY Box:"
119//      SetVariable setvar_5,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyBoxCoord
120//      SetVariable setvar_6,pos={165,431},size={300.00,14.00},title="Panel:"
121//      SetVariable setvar_6,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gEmptyPanel
122//      SetVariable setvar_7,pos={21,138},size={300.00,14.00},title="Transmission:"
123//      SetVariable setvar_7,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTrans
124//      SetVariable setvar_8,pos={21,163},size={300.00,14.00},title="Error:"
125//      SetVariable setvar_8,limits={-inf,inf,0},value= root:Packages:NIST:VSANS:Globals:Transmission:gTransErr
126//EndMacro
127
128// TODO
129// -- fill in the details
130// -- currently, I pick these from the Catalog, for speed
131// -- ? is the catalog current?
132// -- T error is not part of the Catalog - is that OK?
133//
134// when the SAM file menu is popped:
135//  fill in the fields:
136// x- label
137// x- group id
138// x- transmission
139// -- T error
140//
141Function V_TSamFilePopMenuProc(pa) : PopupMenuControl
142        STRUCT WMPopupAction &pa
143
144
145// **** TODO
146// short-circuit the switch, and simply report the values
147// -- the TransFile popup now drives the panel
148                SVAR gSamLabel = root:Packages:NIST:VSANS:Globals:Transmission:gSamLabel
149                gSamLabel = V_getSampleDescription(pa.popStr)
150                NVAR gSamGrpID = root:Packages:NIST:VSANS:Globals:Transmission:gSamGrpID
151                gSamGrpID = V_getSample_GroupID(pa.popStr)
152                NVAR gTrans = root:Packages:NIST:VSANS:Globals:Transmission:gTrans
153                gTrans = V_getSampleTransmission(pa.popStr)
154                NVAR gTransErr = root:Packages:NIST:VSANS:Globals:Transmission:gTransErr
155                gTransErr = V_getSampleTransError(pa.popStr)
156
157        return(0)       
158       
159End
160
161// TODO
162//
163// Given the group ID of the sample, try to locate a (the) matching transmission file
164// by locating a matching ID in the list of transmission (intent) files
165//
166// then pop the menu
167//
168//
169Function V_TTransmFilePopMenuProc(pa) : PopupMenuControl
170        STRUCT WMPopupAction &pa
171
172        switch( pa.eventCode )
173                case 2: // mouse up
174                        Variable popNum = pa.popNum
175                        String popStr = pa.popStr
176                       
177                        SVAR gTransLabel = root:Packages:NIST:VSANS:Globals:Transmission:gTransLabel
178                        gTransLabel = V_getSampleDescription(popStr)
179                        NVAR gTrnGrpID = root:Packages:NIST:VSANS:Globals:Transmission:gTrnGrpID
180                        gTrnGrpID = V_getSample_GroupID(popStr)                 
181                       
182//                      SVAR gSamMatchList = root:Packages:NIST:VSANS:Globals:Transmission:gSamMatchList
183//                      String quote = "\""
184//                      gSamMatchList = quote + V_getFileIntentPurposeIDList("SAMPLE","SCATTERING",gTrnGrpID,0) + quote
185                        // this resets a global string, since I can't pass a parameter (only constants) in value=fn()           
186//                      PopupMenu popup_0,mode=1,value=#gSamMatchList
187                        PopupMenu popup_0,mode=1,value=V_getSamListForPopup()
188
189
190// then pop the sample list with the top file to see that it is a match for the transmission file
191                        STRUCT WMPopupAction samPopAct
192                        ControlInfo popup_0
193                        samPopAct.popStr = S_Value              // the top file
194                        V_TSamFilePopMenuProc(samPopAct)
195                       
196                        break
197                case -1: // control being killed
198                        break
199        endswitch
200
201        return 0
202End
203
204Function/S V_getSamListForPopup()
205
206//      String quote = "\""
207        NVAR gTrnGrpID = root:Packages:NIST:VSANS:Globals:Transmission:gTrnGrpID
208
209        String retStr = V_getFileIntentPurposeIDList("SAMPLE","SCATTERING",gTrnGrpID,0)
210
211// and be sure to add in the empty cell, since it's not a "sample"
212        retStr += V_getFileIntentPurposeIDList("EMPTY CELL","SCATTERING",gTrnGrpID,0)
213
214        // now filter through the string to refine the list to only scattering files that match
215        // the transmission file conditions
216        String newList="",item
217        Variable num,ii
218       
219        String transStr
220        ControlInfo popup_1                     //the transmission file popup
221        transStr = S_Value
222       
223        num=ItemsInList(retStr)
224        for(ii=0;ii<num;ii+=1)
225                item = StringFromList(ii, retStr,";")
226                if(V_Scatter_Match_Trans(transStr,item))
227                        newList += item + ";"
228                endif
229        endfor
230
231        SVAR newSamList = root:Packages:NIST:VSANS:Globals:Transmission:gSamMatchList
232        newSamList = newList
233       
234        return(newList)
235End
236
237
238Function/S V_getTransListForPopup()
239
240        String retStr =""
241       
242//      retStr = V_getFilePurposeList("TRANSMISSION",0)
243       
244        retStr = V_getFileIntentPurposeList("Sample","TRANSMISSION",0)
245        retStr += V_getFileIntentPurposeList("Empty Cell","TRANSMISSION",0)
246       
247        // now filter through the string to refine the list to only transmission files that match
248        // the open beam file conditions
249        String newList="",item
250        Variable num,ii
251       
252        String openStr
253        ControlInfo popup_2             //the open beam popup
254        openStr = S_Value
255       
256        num=ItemsInList(retStr)
257        for(ii=0;ii<num;ii+=1)
258                item = StringFromList(ii, retStr,";")
259                if(V_Trans_Match_Open(openStr,item))
260                        newList += item + ";"
261                endif
262        endfor
263
264        SVAR newTransList = root:Packages:NIST:VSANS:Globals:Transmission:gTransMatchList
265        newTransList = newList
266       
267        return(newList)
268       
269End
270
271Function V_TEmpBeamPopMenuProc(pa) : PopupMenuControl
272        STRUCT WMPopupAction &pa
273
274        switch( pa.eventCode )
275                case 2: // mouse up
276                        Variable popNum = pa.popNum
277                        String popStr = pa.popStr
278                       
279                        Print "empty beam match at ",popStr
280                        SetVariable setvar_4,value=_STR:V_getSampleDescription(popStr)
281                       
282
283                        WAVE boxCoord = V_getBoxCoordinates(popStr)
284                        Print boxCoord
285                        SetVariable setvar_5,value=_STR:V_NumWave2List(boxCoord,";")
286                       
287                        String detStr = V_getReduction_BoxPanel(popStr)
288                        SetVariable setvar_6,value =_STR:detStr
289                       
290                        PopupMenu popup_1,mode=1,value=V_getTransListForPopup()
291                       
292                        SVAR newBox = root:Packages:NIST:VSANS:Globals:Transmission:gEmptyBoxCoord
293                        newBox = V_NumWave2List(boxCoord,";")
294                       
295                        break
296                case -1: // control being killed
297                        break
298        endswitch
299
300        return 0
301End
302
303
304// NOTE: DIV is not needed for the transmission calculation, since it's a ratio
305// and the DIV simply drops out. (DIV is needed for ABS scaling calculation of Kappa, since
306// that is not a ratio)
307//
308// TODO
309// -- figure out which detector corrections are necessary to do on loading
310// data for calculation. Then set/reset preferences accordingly
311// (see V_isoCorrectButtonProc() for example of how to do this)
312//
313//  -- DIV (turn off)
314// -- NonLinear (turn off ?)
315// -- solid angle (turn off ?)
316// -- dead time (keep on?)
317//
318// -- once calculated, update the Transmission panel
319// -- update the data file
320// -- update the CATALOG (and/or delete the RawVSANS to force a re-read)
321//
322Function V_CalcTransmButtonProc(ba) : ButtonControl
323        STRUCT WMButtonAction &ba
324
325        switch( ba.eventCode )
326                case 2: // mouse up
327                        // click code here
328
329                        String SamFile,TransFile,EmptyFile
330
331                        ControlInfo/W=V_TransmissionPanel popup_0
332                        SamFile = S_Value
333
334                        ControlInfo/W=V_TransmissionPanel popup_1
335                        TransFile = S_Value             
336               
337                        ControlInfo/W=V_TransmissionPanel popup_2
338                        EmptyFile = S_Value
339               
340                        V_CalcOneTransmission(SamFile,TransFile,EmptyFile)                     
341
342                       
343                        // done
344                        break
345                case -1: // control being killed
346                        break
347        endswitch
348
349
350        return 0
351End
352
353Function V_CalcTransmListButtonProc(ba) : ButtonControl
354        STRUCT WMButtonAction &ba
355
356        switch( ba.eventCode )
357                case 2: // mouse up
358                        // click code here
359
360                        SVAR gSamMatchList = root:Packages:NIST:VSANS:Globals:Transmission:gSamMatchList
361
362                        String SamFile,TransFile,EmptyFile
363
364                        ControlInfo/W=V_TransmissionPanel popup_1
365                        TransFile = S_Value             
366               
367                        ControlInfo/W=V_TransmissionPanel popup_2
368                        EmptyFile = S_Value
369               
370                        String list
371                        list = gSamMatchList
372//                      list = list[1,strlen(list)-1]
373//                      list = list[0,strlen(list)-2]
374                       
375                        Variable num,ii
376                        num = ItemsInList(list, ";")
377                        for(ii=0;ii<num;ii+=1)
378                                SamFile = StringFromList(ii, list, ";")
379                               
380                                if(ii==0)
381                                        // calculate the transmission for the first file
382                                        V_CalcOneTransmission(SamFile,TransFile,EmptyFile)     
383                                else
384                                        // then just write in the values (globals) that V_CalcOne determined
385                                        NVAR gTrans = root:Packages:NIST:VSANS:Globals:Transmission:gTrans
386                                        NVAR gTransErr = root:Packages:NIST:VSANS:Globals:Transmission:gTransErr
387                                       
388                                        // write both out to the sample *scattering* file on disk
389                                        V_writeSampleTransmission(SamFile,gTrans)
390                                        V_writeSampleTransError(SamFile,gTransErr)     
391
392                                endif           
393                        endfor
394                       
395                        Print "Done Processing Transmission List"
396
397                        // done
398                        break
399                case -1: // control being killed
400                        break
401        endswitch
402
403
404        return 0
405End
406
407
408
409Function V_CalcOneTransmission(SamFileName,TransFileName,EmptyFileName)                 
410        String SamFileName,TransFileName,EmptyFileName
411
412                Variable trans,trans_err
413                Variable emptyCts,empty_ct_err,samCts,sam_ct_err
414                String detStr
415               
416               
417                // save preferences for file loading
418                Variable savDivPref,savSAPref
419                NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor
420                savDivPref = gDoDIVCor
421                NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor
422                savSAPref = gDoSolidAngleCor
423               
424                // set local preferences
425                gDoDIVCor = 0
426                gDoSolidAngleCor = 0
427               
428                // check for sample transmission + error
429                // if present -- exit
430               
431                trans = V_getSampleTransmission(samfileName)
432                trans_err = V_getSampleTransError(samfileName)
433//                      // TODO
434//                      // -- this criteria is rather crude. think it through better
435//                      // -- or should I simply let it overwrite? What is the harm in that?
436//                      if(trans != 0 && trans < 1 && trans_err != 0)
437//                              Printf "Sample transmission, error = %g +/- %g   already exists, nothing calculated\r",trans,trans_err
438//                              break
439//                      endif
440               
441        // for empty beam               
442                emptyCts = V_getBoxCounts(emptyFileName)
443                empty_ct_err = V_getBoxCountsError(emptyFileName)
444                WAVE xyBoxW = V_getBoxCoordinates(emptyFileName)
445                // TODO
446                // x- need to get the panel string for the sum.
447                // x- the detector string is currently hard-wired
448                detStr = V_getReduction_BoxPanel(emptyFileName)
449               
450                SVAR gEmptyPanel = root:Packages:NIST:VSANS:Globals:Transmission:gEmptyPanel
451                gEmptyPanel = detStr
452
453               
454                // check for box count + error values
455                // if present, proceed
456                // TODO
457                // -- this criteria is rather crude. think it through better
458                if(emptyCts > 1 && empty_ct_err != 0)
459                        Printf "Empty beam box counts, error = %g +/- %g   already exists, box counts not re-calculated\r",emptyCts,empty_ct_err
460                       
461                else
462                        // else the counts have not been determined
463                        // read in the data file
464                        V_LoadAndPlotRAW_wName(emptyFileName)
465                        // convert raw->SAM
466                        V_Raw_to_work("SAM")
467                        V_UpdateDisplayInformation("SAM")       
468                       
469                        // and determine box sum and error
470                        // store these locally
471                        emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"SAM",detStr)
472       
473                        Print "empty counts = ",emptyCts
474                        Print "empty err/counts = ",empty_ct_err/emptyCts
475                       
476                        // TODO
477                        // write these back to the file
478                        // (write locally?)
479                       
480                endif
481
482        // for Sample Transmission File
483               
484                // check for box count + error values
485                samCts = V_getBoxCounts(TransFileName)
486                sam_ct_err = V_getBoxCountsError(TransFileName)
487                // if present, proceed
488                // TODO
489                // -- this criteria is rather crude. think it through better
490                if(samCts > 1 && sam_ct_err != 0)
491                        Printf "Sam Trans box counts, error = %g +/- %g   already exists, nothing calculated\r",samCts,sam_ct_err
492                       
493                else
494                        // else
495                        // read in the data file
496                        V_LoadAndPlotRAW_wName(TransFileName)
497                        // convert raw->SAM
498                        V_Raw_to_work("SAM")
499                        V_UpdateDisplayInformation("SAM")       
500                       
501                        // get the box coordinates
502                        // and determine box sum and error
503                       
504                        // store these locally
505                        samCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],sam_ct_err,"SAM",detStr)
506       
507                        Print "sam counts = ",samCts
508                        Print "sam err/counts = ",sam_ct_err/samCts
509                       
510                        // TODO
511                        // write these back to the file
512                        // (write locally?)     
513                endif
514               
515        //then calculate the transmission
516                Variable empAttenFactor,emp_atten_err,samAttenFactor,sam_atten_err,attenRatio
517               
518                // get the attenuation factor for the empty beam
519                empAttenFactor = V_getAttenuator_transmission(emptyFileName)
520                emp_atten_err = V_getAttenuator_trans_err(emptyFileName)
521                // get the attenuation factor for the sample transmission
522                samAttenFactor = V_getAttenuator_transmission(TransFileName)
523                sam_atten_err = V_getAttenuator_trans_err(TransFileName)       
524                AttenRatio = empAttenFactor/samAttenFactor             
525                // calculate the transmission
526                // calculate the transmission error
527                trans = samCts/emptyCts * AttenRatio
528                                       
529                // squared, relative error
530                if(AttenRatio == 1)
531                        trans_err = (sam_ct_err/samCts)^2 + (empty_ct_err/emptyCts)^2           //same atten, att_err drops out
532                else
533                        trans_err = (sam_ct_err/samCts)^2 + (empty_ct_err/emptyCts)^2 + (sam_atten_err/samAttenFactor)^2 + (emp_atten_err/empAttenFactor)^2
534                endif
535                trans_err = sqrt(trans_err)
536                trans_err *= trans              // now, one std deviation
537               
538                //write out counts and transmission to history window, showing the attenuator ratio, if it is not unity
539                If(attenRatio==1)
540                        Printf "%s\t\tTrans Counts = %g\tTrans = %g +/- %g\r",SamFileName, samCts,trans,trans_err
541                else
542                        Printf "%s\t\tTrans Counts = %g\tTrans = %g +/- %g\tAttenuatorRatio = %g\r",SamFileName, samCts,trans,trans_err,attenRatio
543                endif
544               
545                // write both out to the sample *scattering* file on disk
546                V_writeSampleTransmission(SamFileName,trans)
547                V_writeSampleTransError(SamFileName,trans_err) 
548               
549                // (DONE)
550                // x- update the value displayed in the panel
551                // (NO) update the local value in the file catalog
552                // x- delete the file from RawVSANS to force a re-read?
553                NVAR gTrans = root:Packages:NIST:VSANS:Globals:Transmission:gTrans
554                gTrans = trans
555                NVAR gTransErr = root:Packages:NIST:VSANS:Globals:Transmission:gTransErr
556                gTransErr = trans_err
557
558                V_KillNamedDataFolder(V_RemoveDotExtension(samFileName))
559
560        // restore preferences on exit
561        gDoDIVCor = savDivPref
562        gDoSolidAngleCor = savSAPref
563
564        return(0)                       
565
566End
567
568
569
570
571
572
573
574Function V_WriteTransmButtonProc(ba) : ButtonControl
575        STRUCT WMButtonAction &ba
576
577        switch( ba.eventCode )
578                case 2: // mouse up
579                        // click code here
580                        break
581                case -1: // control being killed
582                        break
583        endswitch
584
585        return 0
586End
587
588Function V_HelpTransmButtonProc(ba) : ButtonControl
589        STRUCT WMButtonAction &ba
590
591        switch( ba.eventCode )
592                case 2: // mouse up
593                        // click code here
594                       
595                        DoAlert 0,"Transmission Help not written yet"
596                       
597                        break
598                case -1: // control being killed
599                        break
600        endswitch
601
602        return 0
603End
604
605Function V_DoneTransmButtonProc(ba) : ButtonControl
606        STRUCT WMButtonAction &ba
607
608        switch( ba.eventCode )
609                case 2: // mouse up
610                        // click code here
611                        DoWindow/K V_TransmissionPanel
612                        break
613                case -1: // control being killed
614                        break
615        endswitch
616
617        return 0
618End
619
Note: See TracBrowser for help on using the repository browser.