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

Last change on this file since 1242 was 1242, checked in by srkline, 2 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

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