source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf @ 979

Last change on this file since 979 was 979, checked in by srkline, 7 years ago

more additions to start the work file flow of converting RAW folder to a WORK folder. Raw_to_Work will be the function that sequentially applies the corrections. All corrections can be turned on/off with preferences.

File size: 19.7 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2#pragma version=1.0
3#pragma IgorVersion=6.1
4
5
6
7//
8// functions to apply corrections to the detector panels
9//
10// these are meant to be called by the procedures that convert "raw" data to
11// "adjusted" or corrected data sets
12//
13// may be relocated in the future
14//
15
16
17
18//
19// detector dead time
20//
21// input is the data array (N tubes x M pixels)
22// input of N x 1 array of dead time values
23//
24// output is the corrected counts in data, overwriting the input data
25//
26// Note that the equation in Roe (eqn 2.15, p. 63) looks different, but it is really the
27// same old equation, just written in a more complex form.
28//
29// TODO
30// -- verify the direction of the tubes and indexing
31// x- decide on the appropriate functional form for the tubes
32// x- need count time as input
33// -- be sure I'm working in the right data folder
34// -- clean up when done
35// -- calculate + return the error contribution?
36//
37Function DeadTimeCorrectionTubes(dataW,data_errW,dtW,ctTime)
38        Wave dataW,data_errW,dtW
39        Variable ctTime
40       
41        // do I count on the orientation as an input, or do I just figure it out on my own?
42        String orientation
43        Variable dimX,dimY
44        dimX = DimSize(dataW,0)
45        dimY = DimSize(dataw,1)
46        if(dimX > dimY)
47                orientation = "horizontal"
48        else
49                orientation = "vertical"
50        endif
51       
52        // sum the counts in each tube and divide by time for total cr per tube
53        Variable npt
54       
55        if(cmpstr(orientation,"vertical")==0)
56                //      this is data dimensioned as (Ntubes,Npix)
57               
58                MatrixOp/O sumTubes = sumRows(dataW)            // n x 1 result
59                sumTubes /= ctTime              //now count rate per tube
60               
61                dataW[][] = dataW[p][q]/(1-sumTubes[p][0]*dtW[p])               //correct the data
62
63        elseif(cmpstr(orientation,"horizontal")==0)
64        //      this is data (horizontal) dimensioned as (Npix,Ntubes)
65
66                MatrixOp/O sumTubes = sumCols(dataW)            // 1 x m result
67                sumTubes /= ctTime
68               
69                dataW[][] = dataW[p][q]/(1-sumTubes[0][q]*dtW[q])
70       
71        else           
72                DoAlert 0,"Orientation not correctly passed in DeadTimeCorrectionTubes(). No correction done."
73        endif
74       
75        return(0)
76end
77
78
79
80/////
81//
82// non-linear corrections to the tube pixels
83// - returns the distance in mm (although this may change)
84//
85// c0,c1,c2,pix
86// c0-c2 are the fit coefficients
87// pix is the test pixel
88//
89// returns the distance in mm (relative to ctr pixel)
90// ctr is the center pixel, as defined when fitting to quadratic was done
91//
92Function V_TubePixel_to_mm(c0,c1,c2,pix)
93        Variable c0,c1,c2,pix
94       
95        Variable dist
96        dist = c0 + c1*pix + c2*pix*pix
97       
98        return(dist)
99End
100//
101////
102
103
104
105
106
107////////////
108// TODO: all of below is untested code
109//   copied from SANS
110//
111//
112// TODO :
113//   -- DoAlert 0,"This has not yet been updated for VSANS"
114//
115//performs solid angle and non-linear detector corrections to raw data as it is "added" to a work folder
116//function is called by Raw_to_work() and Add_raw_to_work() functions
117//works on the actual data array, assumes that is is already on LINEAR scale
118//
119Function DetCorr(data,data_err,realsread,doEfficiency,doTrans)
120        Wave data,data_err,realsread
121        Variable doEfficiency,doTrans
122
123        DoAlert 0,"This has not yet been updated for VSANS"
124       
125        Variable xcenter,ycenter,x0,y0,sx,sx3,sy,sy3,xx0,yy0
126        Variable ii,jj,dtdist,dtdis2
127        Variable xi,xd,yd,rad,ratio,domega,xy
128        Variable lambda,trans,trans_err,lat_err,tmp_err,lat_corr
129       
130//      Print "...doing jacobian and non-linear corrections"
131
132        NVAR pixelsX = root:myGlobals:gNPixelsX
133        NVAR pixelsY = root:myGlobals:gNPixelsY
134       
135        //set up values to send to auxiliary trig functions
136        xcenter = pixelsX/2 + 0.5               // == 64.5 for 128x128 Ordela
137        ycenter = pixelsY/2 + 0.5               // == 64.5 for 128x128 Ordela
138
139        x0 = realsread[16]
140        y0 = realsread[17]
141        sx = realsread[10]
142        sx3 = realsread[11]
143        sy = realsread[13]
144        sy3 = realsread[14]
145       
146        dtdist = 1000*realsread[18]     //sdd in mm
147        dtdis2 = dtdist^2
148       
149        lambda = realsRead[26]
150        trans = RealsRead[4]
151        trans_err = RealsRead[41]               //new, March 2011
152       
153
154        //waves to contain repeated function calls
155        Make/O/N=(pixelsX) fyy,xx,yy            //Assumes square detector !!!
156        ii=0
157        do
158                xi = ii
159//              fyy[ii] = dc_fy(ii+1,sy,sy3,ycenter)
160//              xx[ii] = dc_fxn(ii+1,sx,sx3,xcenter)
161//              yy[ii] = dc_fym(ii+1,sy,sy3,ycenter)
162                ii+=1
163        while(ii<pixelsX)
164       
165        Make/O/N=(pixelsX,pixelsY) SolidAngle           // testing only
166       
167        ii=0
168        do
169                xi = ii
170//              xd = dc_fx(ii+1,sx,sx3,xcenter)-xx0
171                jj=0
172                do
173                        yd = fyy[jj]-yy0
174                        //rad is the distance of pixel ij from the sample
175                        //domega is the ratio of the solid angle of pixel ij versus center pixel
176                        // product xy = 1 for a detector with a linear spatial response (modern Ordela)
177                        // solid angle calculated, dW^3 >=1, so multiply data to raise measured values to correct values.
178                        rad = sqrt(dtdis2 + xd^2 + yd^2)
179                        domega = rad/dtdist
180                        ratio = domega^3
181                        xy = xx[ii]*yy[jj]
182                       
183                        data[ii][jj] *= xy*ratio
184                       
185                        solidAngle[ii][jj] = xy*ratio           //testing only 
186                        data_err[ii][jj] *= xy*ratio                    //error propagation assumes that SA and Jacobian are exact, so simply scale error
187                       
188                       
189                        // correction factor for detector efficiency JBG memo det_eff_cor2.doc 3/20/07
190                        // correction inserted 11/2007 SRK
191                        // large angle detector efficiency is >= 1 and will "bump up" the measured value at the highest angles
192                        // so divide here to get the correct answer (5/22/08 SRK)
193                        if(doEfficiency)
194                                data[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)
195                                data_err[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)
196//                              solidAngle[ii][jj] /= DetEffCorr(lambda,dtdist,xd,yd)           //testing only
197                        endif
198                       
199                        // large angle transmission calculation is <= 1 and will "bump down" the measured value at the highest angles
200                        // so divide here to get the correct answer
201                        if(doTrans)
202                       
203                                if(trans<0.1 && ii==0 && jj==0)
204                                        Print "***transmission is less than 0.1*** and is a significant correction"
205                                endif
206                               
207                                if(trans==0)
208                                        if(ii==0 && jj==0)
209                                                Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation"
210                                        endif
211                                        trans = 1
212                                endif
213                               
214                                // pass in the transmission error, and the error in the correction is returned as the last parameter
215                                lat_corr = LargeAngleTransmissionCorr(trans,dtdist,xd,yd,trans_err,lat_err)             //moved from 1D avg SRK 11/2007
216                                data[ii][jj] /= lat_corr                        //divide by the correction factor
217                                //
218                                //
219                                //
220                                // relative errors add in quadrature
221                                tmp_err = (data_err[ii][jj]/lat_corr)^2 + (lat_err/lat_corr)^2*data[ii][jj]*data[ii][jj]/lat_corr^2
222                                tmp_err = sqrt(tmp_err)
223                               
224                                data_err[ii][jj] = tmp_err
225                               
226//                              solidAngle[ii][jj] = lat_err
227
228                               
229                                //solidAngle[ii][jj] = LargeAngleTransmissionCorr(trans,dtdist,xd,yd)           //testing only
230                        endif
231                       
232                        jj+=1
233                while(jj<pixelsX)
234                ii+=1
235        while(ii<pixelsX)
236       
237        //clean up waves
238       
239        Return(0)
240End
241
242
243
244//distances passed in are in mm
245// dtdist is SDD
246// xd and yd are distances from the beam center to the current pixel
247//
248// TODO:
249//   --         DoAlert 0,"This has not yet been updated for VSANS"
250//
251Function DetEffCorr(lambda,dtdist,xd,yd)
252        Variable lambda,dtdist,xd,yd
253
254        DoAlert 0,"This has not yet been updated for VSANS"
255       
256        Variable theta,cosT,ff,stAl,stHe
257       
258        theta = atan( (sqrt(xd^2 + yd^2))/dtdist )
259        cosT = cos(theta)
260       
261        stAl = 0.00967*lambda*0.8               //dimensionless, constants from JGB memo
262        stHe = 0.146*lambda*2.5
263       
264        ff = exp(-stAl/cosT)*(1-exp(-stHe/cosT)) / ( exp(-stAl)*(1-exp(-stHe)) )
265               
266        return(ff)
267End
268
269// DIVIDE the intensity by this correction to get the right answer
270// TODO:
271//   --         DoAlert 0,"This has not yet been updated for VSANS"
272//
273//
274Function LargeAngleTransmissionCorr(trans,dtdist,xd,yd,trans_err,err)
275        Variable trans,dtdist,xd,yd,trans_err,&err
276
277        DoAlert 0,"This has not yet been updated for VSANS"
278       
279        //angle dependent transmission correction
280        Variable uval,arg,cos_th,correction,theta
281       
282        ////this section is the trans_correct() VAX routine
283//      if(trans<0.1)
284//              Print "***transmission is less than 0.1*** and is a significant correction"
285//      endif
286//      if(trans==0)
287//              Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation"
288//              trans = 1
289//      endif
290       
291        theta = atan( (sqrt(xd^2 + yd^2))/dtdist )              //theta at the input pixel
292       
293        //optical thickness
294        uval = -ln(trans)               //use natural logarithm
295        cos_th = cos(theta)
296        arg = (1-cos_th)/cos_th
297       
298        // a Taylor series around uval*arg=0 only needs about 4 terms for very good accuracy
299        //                      correction= 1 - 0.5*uval*arg + (uval*arg)^2/6 - (uval*arg)^3/24 + (uval*arg)^4/120
300        // OR
301        if((uval<0.01) || (cos_th>0.99))       
302                //small arg, approx correction
303                correction= 1-0.5*uval*arg
304        else
305                //large arg, exact correction
306                correction = (1-exp(-uval*arg))/(uval*arg)
307        endif
308
309        Variable tmp
310       
311        if(trans == 1)
312                err = 0         //no correction, no error
313        else
314                //sigT, calculated from the Taylor expansion
315                tmp = (1/trans)*(arg/2-arg^2/3*uval+arg^3/8*uval^2-arg^4/30*uval^3)
316                tmp *= tmp
317                tmp *= trans_err^2
318                tmp = sqrt(tmp)         //sigT
319               
320                err = tmp
321        endif
322       
323//      Printf "trans error = %g\r",trans_err
324//      Printf "correction = %g +/- %g\r", correction, err
325       
326        //end of transmission/pathlength correction
327
328        return(correction)
329end
330
331
332//
333// TODO:
334//   --         DoAlert 0,"This has not yet been updated for VSANS"
335//
336//test procedure, not called anymore
337Proc AbsoluteScaling(type,c0,c1,c2,c3,c4,c5)
338        String type
339        Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0
340        Prompt type,"WORK data type",popup,"CAL;COR;SAM"
341        Prompt c0, "Sample Transmission"
342        Prompt c1, "Sample Thickness (cm)"
343        Prompt c2, "Standard Transmission"
344        Prompt c3, "Standard Thickness (cm)"
345        Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)"
346        Prompt c5, "Standard Cross-Section (cm-1)"
347
348        Variable err
349        //call the function to do the math
350        //data from "type" will be scaled and deposited in ABS
351        err = Absolute_Scale(type,c0,c1,c2,c3,c4,c5)
352       
353        if(err)
354                Abort "Error in Absolute_Scale()"
355        endif
356       
357        //contents are always dumped to ABS
358        type = "ABS"
359       
360        String newTitle = "WORK_"+type
361        DoWindow/F SANS_Data
362        DoWindow/T SANS_Data, newTitle
363        KillStrings/Z newTitle
364       
365        //need to update the display with "data" from the correct dataFolder
366        //reset the current displaytype to "type"
367        String/G root:myGlobals:gDataDisplayType=Type
368       
369        fRawWindowHook()
370       
371End
372
373//
374// TODO:
375//   --         DoAlert 0,"This has not yet been updated for VSANS"
376//
377//s_ is the standard
378//w_ is the "work" file
379//both are work files and should already be normalized to 10^8 monitor counts
380Function Absolute_Scale(type,w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err)
381        String type
382        Variable w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err
383
384        DoAlert 0,"This has not yet been updated for VSANS"
385               
386        //convert the "type" data to absolute scale using the given standard information
387        //copying the "type" waves to ABS
388       
389        //check for existence of data, rescale to linear if needed
390        String destPath
391        //check for "type"
392        if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0)
393                Print "There is no work file in "+type+"--Aborting"
394                Return(1)               //error condition
395        Endif
396        //check for log-scaling of the "type" data and adjust if necessary
397        destPath = "root:Packages:NIST:"+Type
398        NVAR gIsLogScale = $(destPath + ":gIsLogScale")
399        if(gIsLogScale)
400                Duplicate/O $(destPath + ":linear_data") $(destPath + ":data")//back to linear scale
401                Variable/G $(destPath + ":gIsLogScale")=0       //the "type" data is not logscale anymore
402        endif
403       
404        //copy "oldtype" information to ABS
405        //overwriting out the old contents of the ABS folder (/O option in Duplicate)
406        //copy over the waves data,vlegend,text,integers,reals(read)
407
408        String oldType= "root:Packages:NIST:"+type              //this is where the data to be absoluted is
409        //copy from current dir (type) to ABS, defined by destPath
410        Duplicate/O $(oldType + ":data"),$"root:Packages:NIST:ABS:data"
411        Duplicate/O $(oldType + ":linear_data"),$"root:Packages:NIST:ABS:linear_data"
412        Duplicate/O $(oldType + ":linear_data_error"),$"root:Packages:NIST:ABS:linear_data_error"
413//      Duplicate/O $(oldType + ":vlegend"),$"root:Packages:NIST:ABS:vlegend"
414        Duplicate/O $(oldType + ":textread"),$"root:Packages:NIST:ABS:textread"
415        Duplicate/O $(oldType + ":integersread"),$"root:Packages:NIST:ABS:integersread"
416        Duplicate/O $(oldType + ":realsread"),$"root:Packages:NIST:ABS:realsread"
417        //need to save a copy of filelist string too (from the current type folder)
418        SVAR oldFileList = $(oldType + ":fileList")
419        //need to copy filelist string too
420        String/G $"root:Packages:NIST:ABS:fileList" = oldFileList
421       
422        //now switch to ABS folder
423        //make appropriate wave references
424        WAVE data=$"root:Packages:NIST:ABS:linear_data"                                 // these wave references point to the "type" data in ABS
425        WAVE data_err=$"root:Packages:NIST:ABS:linear_data_error"                                       // these wave references point to the "type" data in ABS
426        WAVE data_copy=$"root:Packages:NIST:ABS:data"                                   // just for display
427        WAVE/T textread=$"root:Packages:NIST:ABS:textread"                      //that are to be directly operated on
428        WAVE integersread=$"root:Packages:NIST:ABS:integersread"
429        WAVE realsread=$"root:Packages:NIST:ABS:realsread"
430        Variable/G $"root:Packages:NIST:ABS:gIsLogscale"=0                      //make new flag in ABS folder, data is linear scale
431       
432        //do the actual absolute scaling here, modifying the data in ABS
433        Variable defmon = 1e8,w_moncount,s1,s2,s3,s4
434       
435        w_moncount = realsread[0]               //monitor count in "type"
436        if(w_moncount == 0)
437                //zero monitor counts will give divide by zero ---
438                DoAlert 0,"Total monitor count in data file is zero. No rescaling of data"
439                Return(1)               //report error
440        Endif
441       
442        //calculate scale factor
443        Variable scale,trans_err
444        s1 = defmon/realsread[0]                //[0] is monitor count (s1 should be 1)
445        s2 = s_thick/w_thick
446        s3 = s_trans/w_trans
447        s4 = s_cross/s_izero
448       
449        // kappa comes in as s_izero, so be sure to use 1/kappa_err
450       
451        data *= s1*s2*s3*s4
452       
453        scale = s1*s2*s3*s4
454        trans_err = realsRead[41]
455       
456//      print scale
457//      print data[0][0]
458       
459        data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2))
460
461//      print data_err[0][0]
462       
463// keep "data" in sync with linear_data
464        data_copy = data
465       
466        //********* 15APR02
467        // DO NOt correct for atenuators here - the COR step already does this, putting all of the data one equal
468        // footing (zero atten) before doing the subtraction.
469        //
470        //Print "ABS data multiplied by  ",s1*s2*s3*s4/attenFactor
471       
472        //update the ABS header information
473        textread[1] = date() + " " + time()             //date + time stamp
474       
475        Return (0) //no error
476End
477
478
479//
480// TODO:
481//   --         DoAlert 0,"This has not yet been updated for VSANS"
482//
483//
484// match the attenuation of the RAW data to the "type" data
485// so that they can be properly added
486//
487// are the attenuator numbers the same? if so exit
488//
489// if not, find the attenuator number for type
490// - find both attenuation factors
491//
492// rescale the raw data to match the ratio of the two attenuation factors
493// -- adjust the detector count (rw)
494// -- the linear data
495//
496//
497Function Adjust_RAW_Attenuation(type)
498        String type
499
500        DoAlert 0,"This has not yet been updated for VSANS"
501       
502        WAVE rw=$("root:Packages:NIST:RAW:realsread")
503        WAVE linear_data=$("root:Packages:NIST:RAW:linear_data")
504        WAVE data=$("root:Packages:NIST:RAW:data")
505        WAVE data_err=$("root:Packages:NIST:RAW:linear_data_error")
506        WAVE/T tw = $("root:Packages:NIST:RAW:textRead")
507       
508        WAVE dest_reals=$("root:Packages:NIST:"+type+":realsread")
509
510        Variable dest_atten,raw_atten,tol
511        Variable lambda,raw_atten_err,raw_AttenFactor,dest_attenFactor,dest_atten_err
512        String fileStr
513
514        dest_atten = dest_reals[3]
515        raw_atten = rw[3]
516       
517        tol = 0.1               // within 0.1 atten units is OK
518        if(abs(dest_atten - raw_atten) < tol )
519                return(0)
520        endif
521
522        fileStr = tw[3]
523        lambda = rw[26]
524        // TODO access correct values
525        raw_AttenFactor = 1//AttenuationFactor(fileStr,lambda,raw_atten,raw_atten_err)
526        dest_AttenFactor = 1//AttenuationFactor(fileStr,lambda,dest_atten,dest_atten_err)
527               
528        rw[2] *= dest_AttenFactor/raw_AttenFactor
529        linear_data *= dest_AttenFactor/raw_AttenFactor
530       
531        // to keep "data" and linear_data in sync
532        data = linear_data
533       
534        return(0)
535End
536
537//
538// TODO:
539//   --         DoAlert 0,"This has not yet been updated for VSANS"
540//
541//************************
542//unused testing procedure, may not be up-to-date with other procedures
543//check before re-implementing
544//
545Proc DIV_a_Workfile(type)
546        String type
547        Prompt type,"WORK data type",popup,"COR;SAM;EMP;BGD"
548       
549        //macro will take whatever is in SELECTED folder and DIVide it by the current
550        //contents of the DIV folder - the function will check for existence
551        //before proceeding
552       
553        Variable err
554        err = Divide_work(type)         //returns err = 1 if data doesn't exist in specified folders
555       
556        if(err)
557                Abort "error in Divide_work"
558        endif
559       
560        //contents are always dumped to CAL
561        type = "CAL"
562       
563        String newTitle = "WORK_"+type
564        DoWindow/F SANS_Data
565        DoWindow/T SANS_Data, newTitle
566        KillStrings/Z newTitle
567       
568        //need to update the display with "data" from the correct dataFolder
569        //reset the current displaytype to "type"
570        String/G root:myGlobals:gDataDisplayType=Type
571       
572        fRawWindowHook()
573       
574End
575
576//
577// TODO:
578//   --         DoAlert 0,"This has not yet been updated for VSANS"
579//
580//function will divide the contents of "type" folder with the contents of
581//the DIV folder
582// all data is converted to linear scale for the calculation
583//
584Function Divide_work(type)
585        String type
586
587        DoAlert 0,"This has not yet been updated for VSANS"
588       
589        //check for existence of data in type and DIV
590        // if the desired workfile doesn't exist, let the user know, and abort
591        String destPath=""
592
593        if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0)
594                Print "There is no work file in "+type+"--Aborting"
595                Return(1)               //error condition
596        Endif
597        //check for DIV
598        // if the DIV workfile doesn't exist, let the user know,and abort
599
600        if(WaveExists($"root:Packages:NIST:DIV:data") == 0)
601                Print "There is no work file in DIV --Aborting"
602                Return(1)               //error condition
603        Endif
604        //files exist, proceed
605       
606        //check for log-scaling of the "DIV" data and adjust if necessary
607        // should not be needed now - using display flag instead
608//      ConvertFolderToLinearScale("DIV")
609       
610        //copy type information to CAL, wiping out the old contents of the CAL folder first
611       
612        //destPath = "root:Packages:NIST:CAL"
613        //SetDataFolder destPath
614        //KillWaves/A/Z                 //get rid of the old data in CAL folder
615
616        //check for log-scaling of the "type" data and adjust if necessary
617        // should not be needed now - using display flag instead
618//      ConvertFolderToLinearScale(type)
619        //then continue
620
621        //copy from current dir (type)=destPath to CAL, overwriting CAL contents
622        destPath = "root:Packages:NIST:" + type
623        Duplicate/O $(destPath + ":data"),$"root:Packages:NIST:CAL:data"
624        Duplicate/O $(destPath + ":linear_data"),$"root:Packages:NIST:CAL:linear_data"
625        Duplicate/O $(destPath + ":linear_data_error"),$"root:Packages:NIST:CAL:linear_data_error"
626//      Duplicate/O $(destPath + ":vlegend"),$"root:Packages:NIST:CAL:vlegend"
627        Duplicate/O $(destPath + ":textread"),$"root:Packages:NIST:CAL:textread"
628        Duplicate/O $(destPath + ":integersread"),$"root:Packages:NIST:CAL:integersread"
629        Duplicate/O $(destPath + ":realsread"),$"root:Packages:NIST:CAL:realsread"
630        //need to save a copy of filelist string too (from the current type folder)
631        SVAR oldFileList = $(destPath + ":fileList")
632
633        //now switch to reference waves in CAL folder
634        destPath = "root:Packages:NIST:CAL"
635        //make appropriate wave references
636        Wave data=$(destPath + ":linear_data")                                  // these wave references point to the data in CAL
637//      Wave data_err=$(destPath + ":linear_data_err")                                  // these wave references point to the data in CAL
638        Wave data_copy=$(destPath + ":data")                                    // these wave references point to the data in CAL
639        Wave/t textread=$(destPath + ":textread")                       //that are to be directly operated on
640        Wave integersread=$(destPath + ":integersread")
641        Wave realsread=$(destPath + ":realsread")
642        Variable/G $(destPath + ":gIsLogScale")=0                       //make new flag in CAL folder, data is linear scale
643        //need to copy filelist string too
644        String/G $(destPath + ":fileList") = oldFileList
645
646        Wave div_data = $"root:Packages:NIST:DIV:data"          //hard-wired in....
647        //do the division, changing data in CAL
648        data /= div_data
649       
650//      data_err /= div_data
651       
652        // keep "data" in sync with linear_data
653        data_copy = data
654       
655        //update CAL header
656        textread[1] = date() + " " + time()             //date + time stamp
657       
658        Return(0)
659End
660
661
662//////////////////////////
Note: See TracBrowser for help on using the repository browser.