source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProDiv.ipf @ 794

Last change on this file since 794 was 794, checked in by srkline, 12 years ago

Lots of changes:
-2D resolution smearing
-2D error propagation

1) 2D resolution smearing has been corrected to use sigma (perp) correctly
rather than phi. This shows up in the quadrature loop in all of the 2D models
and in the Smear_2D "generic" function.

2) 1D resolutionn smearing is now corrected to account for the integration
range of +/- 3 sigma (99.73% of distribution). Now the result is divided by
0.9973 to rescale it to the correct value.

3) Smeared models are now AAO to improve speed and to allow easier use with
functions that are inherently AAO. No changes are needed, since the call is
behind the scenes, replacing Smear_Model_N() with Smear_Model_N_AAO().

4) in PlotUtils_2D added functions to re-bin the QxQy? data into a 1D format
BinQxQy_to_1D(). This also re-bins the errors in two ways, adding the per-pixel
errors in quadrature, or the deviation from the mean of the intensity. Manually
editing the intensity declaration allows 2D->1D binning of smeared models.

5) Per-pixel propagation of errors has been added through the entire data
reduction sequence. Data errors are generated on loading using Poisson
statistics (specifically tailored for accuracy at low counts) and then is
propagated through each manipulation of the data using standard error
propagation. The error matrix is linear_data_error. As a by-product, all of
the math operations on data are explicitly done on linear_data, to avoid
any potential mistakes of log/linear scaling. Results of this propagation
largely match J. Barker's /ERROR routines from the VAX, with some differences
at low data count values (as expected) and at higher count values near the
beam stop (somewhat unexpected). This per-pixel error is ouput in the QxQy_ASCII
data files. NO CHANGE has been made to the 1D data, which uses the deviation from
the mean as the error - since this is correct.

6) Added tables for the uncertainty in attenuator transmission (from JGB)

7) added two more REAL values to the VAX header to store information
necessary for error propagation. These are couting error that are part of
the transmission error and of the absolute scaling error. These add Read/Write?
functions in NCNR_DataReadWrite

The transmission error (one standard deviation) is written at byte 396 (4 bytes)

RealsRead?[41]

The Box Sum error (one standard deviation) is written at byte 400 (4 bytes)

RealsRead?[42]

File size: 17.8 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5
6//********************
7// Vers. 1.2 092101
8//
9// Procedures to create a "DIV" file for use as a detector sensitivity file
10// Follows the same procedure as PRODIV on the VAX
11// -requires two "full" reduced runs from plexiglass or water
12// -prompts the user for the locations of the offset and no-offset files
13// and for the range of data to replace
14// - then writes of the "div" file and fake-VAX format, which is rather ugly
15// since the DIV file is floating point...
16//
17//
18// 08 AUG 03
19// allowed for creation of DIV files on 8m SANS with two beamstops
20//
21// JAN2006 - not modified! still hard-wired to take a 128x128 detector image
22//
23// Oct 2009 - SRK - pulled out the writing of the data file to NCNR_DataReadWrite.ipf
24//      leaving a stub Write_DIV_File() for the writer. Fully corrected, patched, and normalized DIV data
25//      is written out from "type" folder. The DIV file written out must be written in a
26//      format that is readable by ReadHeaderAndWork(type,fname). Each facility gets to pick their own format.
27//
28//      no longer hard-wired to 128x128
29//
30//*********************
31
32
33//works on the data in "type" folder
34//sums all of the data, and normalizes by the number of cells (=pixelX*pixelY)
35// calling procedure must make sure that the folder is on linear scale FIRST
36Function NormalizeDIV(type)
37        String type
38       
39        WAVE data=$("root:Packages:NIST:"+type+":data")
40        WAVE data_lin=$("root:Packages:NIST:"+type+":linear_data")
41        WAVE data_err=$("root:Packages:NIST:"+type+":linear_data_error")
42       
43        Variable totCts=sum(data,Inf,-Inf)              //sum all of the data
44        NVAR pixelX = root:myGlobals:gNPixelsX
45        NVAR pixelY = root:myGlobals:gNPixelsY
46
47       
48        data /= totCts
49        data *= pixelX*pixelY
50       
51        data_lin /= totCts
52        data_lin *= pixelX*pixelY
53       
54        data_err /= totCts
55        data_err *= pixelX*pixelY
56               
57        return(0)
58End
59
60// prompts the user for the location of the "COR" -level data
61// data can be copied to any data folder (except DIV) for use here...
62//
63// then there is a "pause for user" to allow the user to select the "box"
64// in the ON-AXIS datset that is to be replaced by the data in the off-axis data
65//
66// corrections are done...
67//
68// finally, the DIV file is written to disk
69Function MakeDIVFile(ctrType,offType)
70        String ctrType,offType
71       
72        Prompt ctrType,"On-Center Plex data (corrected)",popup,"STO;SUB;BGD;COR;CAL;SAM;EMP;"
73        Prompt offType,"Offset Plex data (corrected)",popup,"STO;SUB;BGD;COR;CAL;SAM;EMP;"
74        DoPrompt "Pick the data types",ctrType,offType
75        //"COR" data in both places - reduction must be done ahead of time
76       
77        //temporarily set data display to linear
78        NVAR gLog = root:Packages:NIST:gLogScalingAsDefault
79        Variable oldState = gLog
80        gLog=0  //linear
81       
82        if(V_Flag==1)
83                //user cancelled
84                return(1)
85        endif
86
87#if (exists("QUOKKA")==6)
88        //corrects edge rows and columns by copy data from adjacent column
89        DoAlert 1,"Do edge correction for Quokka detector?"
90        if(V_flag==1)
91                DoEdgeCorrection(ctrType)
92                DoEdgeCorrection(offType)               
93        endif
94#endif
95       
96        //show the ctrType
97        //get the xy range to replace
98        Execute "ChangeDisplay(\""+ctrType+"\")"
99       
100        NewPanel/K=2/W=(139,341,382,432) as "Get XY Range"
101        DoWindow/C tmp_GetXY
102        AutoPositionWindow/E/M=1/R=SANS_Data
103        DrawText 15,20,"Find the (X1,X2) and (Y1,Y2) range to"
104        DrawText 15,40,"replace and press continue"
105        Button button0, pos={80,58},size={92,20},title="Continue"
106        Button button0,proc=XYContinueButtonProc
107       
108        PauseForUser tmp_GetXY,SANS_Data
109       
110        //replace the center section of the "on" data with the center of the "off" data
111        Variable x1,x2,y1,y2
112        GetXYRange(x1,x2,y1,y2)
113        Printf "X=(%d,%d)  Y=(%d,%d)\r", x1,x2,y1,y2
114        ReplaceDataBlock(ctrType,offType,x1,x2,y1,y2)
115       
116        DoAlert 1,"Is this NG1 data with a second beamstop?"
117        if(V_flag==1)
118                GetXYRange(x1,x2,y1,y2)
119                Printf "X=(%d,%d)  Y=(%d,%d)\r", x1,x2,y1,y2
120                ReplaceDataBlock(ctrType,offType,x1,x2,y1,y2)
121        endif
122       
123        //normalize the new data (and show it)
124        NormalizeDiv(ctrtype)
125        UpdateDisplayInformation(ctrtype)
126        //write out the new data file
127        Write_DIV_File(ctrtype)
128        gLog = oldState         //set log/lin pref back to user - set preference
129        Return(0)
130End
131
132//ctrData is changed -- offData is not touched
133//simple replacement of the selected data...
134//
135// working in detector coordinates
136Function ReplaceDataBlock(ctrType,offType,x1,x2,y1,y2)
137        String ctrType,offType
138        Variable x1,x2,y1,y2
139       
140        //do it crudely, with nested for loops
141        WAVE ctrData=$("root:Packages:NIST:"+ctrtype+":data")
142        WAVE offData=$("root:Packages:NIST:"+offtype+":data")
143       
144        WAVE ctrData_lin=$("root:Packages:NIST:"+ctrtype+":linear_data")
145        WAVE offData_lin=$("root:Packages:NIST:"+offtype+":linear_data")
146       
147        WAVE ctrData_err=$("root:Packages:NIST:"+ctrtype+":linear_data_error")
148        WAVE offData_err=$("root:Packages:NIST:"+offtype+":linear_data_error")
149       
150        Variable ii,jj
151       
152        for(ii=x1;ii<=x2;ii+=1)
153                for(jj=y1;jj<=y2;jj+=1)
154                        ctrData[ii][jj] = offData[ii][jj]
155                        ctrData_lin[ii][jj] = offData_lin[ii][jj]
156                        ctrData_err[ii][jj] = offData_err[ii][jj]
157                endfor
158        endfor
159       
160        return(0)
161End
162
163//continue button waiting for the user to pick the range, and continue the execution
164//
165Function XYContinueButtonProc(ctrlName)
166        String ctrlName
167       
168        DoWindow/K tmp_GetXY
169End
170
171// prompts the user to enter the XY range for the box replacement
172// user can get these numbers by printing out marquee coordinates to the command window
173//
174Function GetXYRange(x1,x2,y1,y2)
175        Variable &x1,&x2,&y1,&y2
176       
177        Variable x1p,x2p,y1p,y2p
178        Prompt x1p,"X1"
179        Prompt x2p,"X2"
180        Prompt y1p,"Y1"
181        Prompt y2p,"Y2"
182        DoPrompt "Enter the range to replace",x1p,x2p,y1p,y2p
183        x1=x1p
184        x2=x2p
185        y1=y1p
186        y2=y2p
187       
188//      Print x1,x2,y1,y2
189        Return(0)
190End
191
192
193/////////////////////
194//
195// for the DIV "protocol" panel, I probably need to have parts of the protocol panel initialized...
196// folders are generated at the startup initialization, before protocol panel
197//
198Proc BuildDIVPanel()
199        DoWindow/F DIV_Panel
200        if(V_flag==0)
201                InitDIVPanel()
202                DIV_Panel()
203        Endif
204End
205
206//initialization procedure for the protocol panel
207//note that :gAbsStr is also shared (common global) to that used in
208//the questionnare form of the protcol (see protocol.ipf)
209//
210//0901, uses 8 points in protocol wave
211Proc InitDIVPanel()
212
213        //set up the global variables needed for the protocol panel
214        //global strings to put in a temporary protocol textwave
215        Variable ii=0,nsteps=8
216        String waveStr="DIV_Protocol"
217        SetDataFolder root:myGlobals:Protocols
218        Make/O/T/N=(nsteps) $"root:myGlobals:Protocols:DIV_Protocol" = ""
219       
220        DIV_protocol[2] = "none"
221        DIV_protocol[3] = "none"
222        DIV_protocol[4] = "none"
223        DIV_protocol[5] = "AVTYPE=none;"
224        DIV_protocol[6] = "DRK=none,DRKMODE=0,"
225       
226
227        String/G root:myGlobals:Protocols:gPlex="Plex"
228        String/G root:myGlobals:Protocols:gPlexBgd="Bgd"
229        String/G root:myGlobals:Protocols:gPlexEmp="Emp"
230        String/G root:myGlobals:Protocols:gPlex_off="Plex offset"
231        String/G root:myGlobals:Protocols:gPlexBgd_off="Bgd offset"
232        String/G root:myGlobals:Protocols:gPlexEmp_off="Emp offset"
233        String/G root:myGlobals:Protocols:gPlexName="Plex_date.div"
234       
235        Variable/G root:myGlobals:Protocols:gPlexX1=45
236        Variable/G root:myGlobals:Protocols:gPlexX2=87
237        Variable/G root:myGlobals:Protocols:gPlexY1=43
238        Variable/G root:myGlobals:Protocols:gPlexY2=85
239        Variable/G root:myGlobals:Protocols:gPlexTrans=0.48
240       
241        SetDataFolder root:
242       
243End
244
245// load in one on-center file and show the box
246//
247Function ShowBoxButtonProc(ba) : ButtonControl
248        STRUCT WMButtonAction &ba
249
250        switch( ba.eventCode )
251                case 2: // mouse up
252                        // click code here
253                        if(cmpstr(ba.ctrlName, "ShowBox") == 0)
254                       
255                                //parse for the first run number
256                                SVAR gPlex = root:myGlobals:Protocols:gPlex
257                                String item,fname
258                               
259                                item = StringFromList(0, gPlex ,",")
260                                fname = FindFileFromRunNumber(str2num(item))
261                                if(strlen(fname) == 0)
262                                        Abort "Bad file number in Plex field"
263                                endif
264                                // load the file
265                                ReadHeaderAndData(fname)        //this is the full Path+file
266                                UpdateDisplayInformation("RAW")
267                                //draw a box of the specified size. This is persistent on the display as you scroll to the offset data
268                                NVAR x1 = root:myGlobals:Protocols:gPlexX1
269                                NVAR x2 = root:myGlobals:Protocols:gPlexX2
270                                NVAR y1 = root:myGlobals:Protocols:gPlexY1
271                                NVAR y2 = root:myGlobals:Protocols:gPlexY2
272                               
273                                SetDrawLayer/W=SANS_Data/K UserFront                    //set the layer, and clear it
274                                SetDrawEnv/W=SANS_Data xcoord=bottom,ycoord=left,fillpat=0,linethick=3,linefgc=(65535, 65535, 65535)
275                                DrawRect/W=SANS_Data x1, y2, x2, y1
276                               
277                                Button $ba.ctrlName,title="Clear Box",rename=HideBox,win=DIV_Panel
278                               
279                        else
280                                if(winType("SANS_Data")==1)
281                                        SetDrawLayer/W=SANS_Data/K UserFront                    //set the layer, and clear it
282                                        Button $ba.ctrlName,title="Show Box",rename=ShowBox,win=DIV_Panel
283                                else
284                                        Button $ba.ctrlName,title="Show Box",rename=ShowBox,win=DIV_Panel
285                                endif
286                        endif   
287                       
288                        break
289        endswitch
290
291        return 0
292End
293
294// do everything...
295//
296Function GenerateDIVButtonProc(ba) : ButtonControl
297        STRUCT WMButtonAction &ba
298
299        Variable err=0
300       
301        switch( ba.eventCode )
302                case 2: // mouse up
303                        // click code here
304                       
305                        //temporarily set data display to linear
306                        NVAR gLog = root:Packages:NIST:gLogScalingAsDefault
307                        Variable oldState = gLog
308                        gLog=0  //linear
309                       
310                       
311                        SVAR gPlex = root:myGlobals:Protocols:gPlex
312                        SVAR gPlexBgd = root:myGlobals:Protocols:gPlexBgd
313                        SVAR gPlexEmp = root:myGlobals:Protocols:gPlexEmp
314                        SVAR gPlex_off = root:myGlobals:Protocols:gPlex_off
315                        SVAR gPlexBgd_off = root:myGlobals:Protocols:gPlexBgd_off
316                        SVAR gPlexEmp_off = root:myGlobals:Protocols:gPlexEmp_off
317                        SVAR gPlexName = root:myGlobals:Protocols:gPlexName
318                       
319                        NVAR X1 = root:myGlobals:Protocols:gPlexX1
320                        NVAR X2 = root:myGlobals:Protocols:gPlexX2
321                        NVAR Y1 = root:myGlobals:Protocols:gPlexY1
322                        NVAR Y2 = root:myGlobals:Protocols:gPlexY2
323                        NVAR gPlexTrans = root:myGlobals:Protocols:gPlexTrans
324                       
325                        WAVE/T proto = $"root:myGlobals:Protocols:DIV_Protocol"
326                       
327                        String item,fname,str
328                        Variable ii,num
329                // reduce the on-center
330                        //patch trans
331                        num = ItemsInList(gPlex, ",")
332                        for(ii=0;ii<num;ii+=1)
333                                item = StringFromList(ii, gPlex ,",")
334                                fname = FindFileFromRunNumber(str2num(item))
335                                if(strlen(fname) == 0)
336                                        Abort "Bad file number in no offset Plex field"
337                                endif
338                                WriteTransmissionToHeader(fname,gPlexTrans)
339                        endfor
340                       
341                        //go through the protocol
342                        str = ParseRunNumberList(gPlexBgd)
343                        if(strlen(str) > 0)
344                                proto[0] = str
345                        else
346                                Abort "Bad file number in no offset Bgd"
347                        endif
348                        str = ParseRunNumberList(gPlexEmp)
349                        if(strlen(str) > 0)
350                                proto[1] = str
351                                err = CheckDIVBeamCenter(str,65,65)
352                                if(err)
353                                        Abort "On-center EMP files do not have correct beam center"
354                                endif
355                        else
356                                Abort "Bad file number in no offset Emp"
357                        endif
358                        str = ParseRunNumberList(gPlex)
359                        if(strlen(str) > 0)
360                                err = CheckDIVBeamCenter(str,65,65)
361                                if(err)
362                                        Abort "On-center PLEX files do not have correct beam center"
363                                endif
364                                ExecuteProtocol("root:myGlobals:Protocols:DIV_Protocol",str)
365                        else
366                                Abort "Bad file number in no offset Plex"
367                        endif
368                        // move it into STO
369                        Execute "CopyWorkFolder(\"COR\",\"STO\")"
370                       
371                       
372                       
373                // reduce the off-center, keep in STO
374                        //patch trans
375                        num = ItemsInList(gPlex_off, ",")
376                        for(ii=0;ii<num;ii+=1)
377                                item = StringFromList(ii, gPlex_off ,",")
378                                fname = FindFileFromRunNumber(str2num(item))
379                                if(strlen(fname) == 0)
380                                        Abort "Bad file number in Plex field"
381                                endif
382                                WriteTransmissionToHeader(fname,gPlexTrans)
383                        endfor
384                       
385                        //go through the protocol
386                        str = ParseRunNumberList(gPlexBgd_off)
387                        if(strlen(str) > 0)
388                                proto[0] = str
389                        else
390                                Abort "Bad file number in offset Bgd"
391                        endif
392                        str = ParseRunNumberList(gPlexEmp_off)
393                        if(strlen(str) > 0)
394                                proto[1] = str
395                                err = CheckDIVBeamCenter(str,105,65)
396                                if(err)
397                                        Abort "Off-center EMP files do not have correct beam center"
398                                endif
399                        else
400                                Abort "Bad file number in offset Emp"
401                        endif
402                        str = ParseRunNumberList(gPlex_off)
403                        if(strlen(str) > 0)
404                                err = CheckDIVBeamCenter(str,105,65)
405                                if(err)
406                                        Abort "On-center EMP files do not have correct beam center"
407                                endif
408                                ExecuteProtocol("root:myGlobals:Protocols:DIV_Protocol",str)
409                        else
410                                Abort "Bad file number in offset Emp"
411                        endif
412                        ConvertFolderToLinearScale("COR")
413                       
414#if (exists("QUOKKA")==6)
415                        //corrects edge rows and columns by copy data from adjacent column
416                        String ctrType="STO",offType="COR"
417                        DoAlert 1,"Do edge correction for Quokka detector?"
418                        if(V_flag==1)
419                                DoEdgeCorrection(ctrType)
420                                DoEdgeCorrection(offType)               
421                        endif
422#endif
423                       
424                // replace the patch
425                // on-center data is changed (STO)
426                        ReplaceDataBlock("STO","COR",x1,x2,y1,y2)
427                // normalize
428                        NormalizeDiv("STO")
429                        UpdateDisplayInformation("STO")
430                //write out the new data file
431                        Write_DIV_File("STO")
432                               
433                        gLog=oldState           //revert display preference to old state       
434                        break
435        endswitch
436
437        return 0
438End
439
440// if a dark color is used, then
441//¥SetVariable setvar0 labelBack=(65535,65535,65535)
442// for each variable will give a white background to the label text
443Proc DIV_Panel()
444        PauseUpdate; Silent 1           // building window...
445        NewPanel /W=(594,44,932,570)/K=1 as "DIV_Panel"
446        DoWindow/C DIV_Panel
447//      ModifyPanel cbRGB=(35867,28177,65535)           //purple
448//      ModifyPanel cbRGB=(1,16019,65535)                               //electric blue
449        ModifyPanel cbRGB=(36631,59604,33902)           //spring green
450        SetDrawLayer UserBack
451        DrawRect 71,324,145,391
452        TitleBox title0,pos={14,16},size={50,20},title="No Offset"
453        TitleBox title0_1,pos={17,125},size={35,20},title="Offset"
454        SetVariable setvar0,pos={15,46},size={250,15},title="PLEX",value= root:myGlobals:Protocols:gPlex
455        SetVariable setvar0_1,pos={16,69},size={250,15},title="EMP",value= root:myGlobals:Protocols:gPlexEmp
456        SetVariable setvar0_2,pos={14,92},size={250,15},title="BGD",value= root:myGlobals:Protocols:gPlexBgd
457        SetVariable setvar1,pos={17,158},size={250,15},title="PLEX",value= root:myGlobals:Protocols:gPlex_off
458        SetVariable setvar001,pos={18,181},size={250,15},title="EMP",value= root:myGlobals:Protocols:gPlexEmp_off
459        SetVariable setvar002,pos={16,204},size={250,15},title="BGD",value= root:myGlobals:Protocols:gPlexBgd_off
460        SetVariable setvar002_1,pos={14,251},size={150,15},title="Transmission"
461        SetVariable setvar002_1,limits={0,1,0.01},value= root:myGlobals:Protocols:gPlexTrans
462//      SetVariable setvar003,pos={16,441},size={250,15},title="DIV FILE NAME"
463//      SetVariable setvar003,value= root:myGlobals:Protocols:gPlexName
464        Button ShowBox,pos={226,325},size={90,20},proc=ShowBoxButtonProc,title="Show Box"
465        Button button1,pos={25,430},size={150,20},proc=GenerateDIVButtonProc,title="Generate DIV File"
466        Button button2,pos={25,460},size={150,20},proc=ReloadDIVButtonProc,title="Load DIV File"
467        Button button4,pos={240,481},size={80,20},proc=DoneDIVButtonProc,title="Done"
468        Button button3,pos={240,10},size={50,20},proc=DIVHelpButtonProc,title="Help"
469        Button button5,pos={25,490},size={150,20},proc=CompareDIVButtonProc,title="Compare DIV Files"
470        SetVariable setvar00201,pos={84,297},size={50,15},limits={0,root:myGlobals:gNPixelsY-1,1},title=" ",value= root:myGlobals:Protocols:gPlexY2
471        SetVariable setvar00202,pos={15,350},size={50,15},limits={0,root:myGlobals:gNPixelsX-1,1},title=" ",value= root:myGlobals:Protocols:gPlexX1
472        SetVariable setvar00203,pos={85,399},size={50,15},limits={0,root:myGlobals:gNPixelsY-1,1},title=" ",value= root:myGlobals:Protocols:gPlexY1
473        SetVariable setvar00204,pos={156,348},size={50,15},limits={0,root:myGlobals:gNPixelsX-1,1},title=" ",value= root:myGlobals:Protocols:gPlexX2
474EndMacro
475
476
477// done
478//
479Function DoneDIVButtonProc(ba) : ButtonControl
480        STRUCT WMButtonAction &ba
481
482        switch( ba.eventCode )
483                case 2: // mouse up
484                        // click code here
485                        DoWindow/K DIV_Panel
486                        break
487        endswitch
488
489        return 0
490End
491
492// load in a DIV file, print out the stats, display in SANS_Data
493//
494Function ReloadDIVButtonProc(ba) : ButtonControl
495        STRUCT WMButtonAction &ba
496
497        switch( ba.eventCode )
498                case 2: // mouse up
499                        // click code here
500                        Execute "ReadWork_DIV()"
501                        WaveStats root:Packages:NIST:DIV:data
502                        Print "*"                       
503//                      Execute "ChangeDisplay(\"DIV\")"       
504                        break
505        endswitch
506
507        return 0
508End
509
510//
511Function DIVHelpButtonProc(ba) : ButtonControl
512        STRUCT WMButtonAction &ba
513
514        switch( ba.eventCode )
515                case 2: // mouse up
516                        // click code here
517                        DisplayHelpTopic/Z/K=1 "SANS Data Reduction Tutorial[Detector Sensitivity File]"
518                        if(V_flag !=0)
519                                DoAlert 0,"The SANS Data Reduction Tutorial Help file could not be found"
520                        endif
521                        break
522        endswitch
523
524        return 0
525End
526
527// load in two DIV files, divide them, and display the results
528// first is divided by the second, results are in SUB
529//
530Function CompareDIVButtonProc(ba) : ButtonControl
531        STRUCT WMButtonAction &ba
532
533        switch( ba.eventCode )
534                case 2: // mouse up
535                        // click code here
536                        DoAlert 0,"First DIV / Second DIV = Result in SUB folder"
537                       
538                        Execute "ReadWork_DIV()"
539                        Execute "CopyWorkContents(\"DIV\",\"STO\")"             // converts linear, copies data, kills linear_data
540                        Execute "CopyWorkContents(\"DIV\",\"SUB\")"             ///just to have waves for later
541
542                        Execute "ReadWork_DIV()"
543                        Execute "CopyWorkContents(\"DIV\",\"DRK\")"             //then data in DRK is guaranteed linear
544
545                        WAVE sub_d = root:Packages:NIST:SUB:data
546                        WAVE sto_d = root:Packages:NIST:STO:data
547                        WAVE drk_d = root:Packages:NIST:DRK:data
548                       
549                        sub_d = sto_d/drk_d
550
551//                      WaveStats root:Packages:NIST:DIV:data
552//                      Print "*"                       
553                        Execute "ChangeDisplay(\"SUB\")"       
554                        break
555        endswitch
556
557        return 0
558End
559Function CompareDIV()
560
561        STRUCT WMButtonAction ba
562
563        ba.eventCode=2
564        CompareDIVButtonProc(ba)
565        return(0)
566End
567
568//loop through each file and check the x and y center
569// within some tolerance (5 pixels) should be fine
570Function CheckDIVBeamCenter(str,xc,yc)
571        String str
572        Variable xc,yc
573       
574        Variable err,ii,num,tmpX,tmpY,badCtr,tol=5
575        String fileStr,pathStr
576       
577        PathInfo catPathName
578        pathStr=S_path
579       
580        num = ItemsInList(str,",")
581        ii=0
582        badCtr = 0
583        do
584                fileStr = pathStr + StringFromList(ii, str,",")
585                tmpX = GetBeamXPos(fileStr)
586                tmpY = GetBeamYPos(fileStr)
587                if(abs(tmpX - xc) > tol)
588                        badCtr = 1
589                endif
590                if(abs(tmpY - yc) > tol)
591                        badCtr = 1
592                endif           
593                ii+=1
594        while(ii<num && !badCtr)
595       
596        return(badCtr)
597//      return(0)
598end
Note: See TracBrowser for help on using the repository browser.