Changeset 795 for sans


Ignore:
Timestamp:
Apr 4, 2011 12:18:33 PM (12 years ago)
Author:
srkline
Message:

Changes to SANS reduction that apply to other Facilities:

These changes are related to the propagation of errors in 2D, on a
per-pixel basis. These changes only affect the errors that are reported in
the QxQy? ASCII file output. The 1D code is unaffected.

If these changes are not implemented, then errors of zero will be substitued as defaults
for these experimental errors.

Upon data loading, an error matrix, linear_data_error is generated and filled with
error values appropriate for Poisson statistics (not simply sqrt(n)).

4 functions in FACILITY_DataReadWrite.ipf have been added, and they are rather
self-explanatory:

In FACILITY_Utils.ipf, the AttenuatorTransmission?() function now returns
an additional parameter, atten_err, which is one standard deviation of the
attenuator transmission value. It returns a default error=0 (which is
correct if no attenuation is used). Facilities can fill this function in
with their own estimates for the uncertainty in the attenutator transmission.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_DataReadWrite.ipf

    r776 r795  
    202202        String/G root:Packages:NIST:RAW:fileList = textw[0] 
    203203         
    204         Duplicate/O data $"root:Packages:NIST:RAW:linear_data"                  //data read in is on linear scale, copy it now 
    205  
     204        Duplicate/O data linear_data                    //data read in is on linear scale, copy it now 
     205 
     206        // proper error for counting statistics, good for low count values too 
     207        // rather than just sqrt(n) 
     208        // see N. Gehrels, Astrophys. J., 303 (1986) 336-346, equation (7) 
     209        // for S = 1 in eq (7), this corresponds to one sigma error bars 
     210        Duplicate/O linear_data linear_data_error 
     211        linear_data_error = 1 + sqrt(linear_data + 0.75)                                 
     212        // 
     213         
    206214        Return 0 
    207215 
     
    409417        data=temp0 
    410418        Redimension/N=(pixelsX,pixelsY) data            //,linear_data 
     419 
     420        Duplicate/O data linear_data_error 
     421        linear_data_error = 1 + sqrt(data + 0.75) 
     422         
     423        //just in case there are odd inputs to this, like negative intensities 
     424        WaveStats/Q linear_data_error 
     425        linear_data_error = numtype(linear_data_error[p]) == 0 ? linear_data_error[p] : V_avg 
     426        linear_data_error = linear_data_error[p] != 0 ? linear_data_error[p] : V_avg 
    411427         
    412428        //linear_data = data 
     
    517533// (3) close the file 
    518534 
    519  
     535// new, April 2011 for error propagation. fill these in with the facility- 
     536// specific versions, if desired. 
     537Function WriteTransmissionErrorToHeader(fname,transErr) 
     538        String fname 
     539        Variable transErr 
     540         
     541 
     542        return(0) 
     543End 
     544 
     545Function WriteBoxCountsErrorToHeader(fname,rel_err) 
     546        String fname 
     547        Variable rel_err 
     548         
     549        return(0) 
     550End 
     551 
     552Function getSampleTransError(fname) 
     553        String fname 
     554         
     555        return(0) 
     556end 
     557 
     558Function getBoxCountsError(fname) 
     559        String fname 
     560         
     561        return(0) 
     562end 
     563 
     564 
     565// end April 2011 additions 
    520566 
    521567//whole transmission is NCNR-specific right now 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_Utils.ipf

    r715 r795  
    166166// detStr is passed as TextRead[9] and is an identifier for the detector 
    167167// 
    168 Function DetectorDeadtime(fileStr,detStr) 
    169         String fileStr,detStr 
     168// [dateAndTimeStr] is optional, and could be used as a switch for  
     169// different historical detector configurations 
     170Function DetectorDeadtime(fileStr,detStr,[dateAndTimeStr]) 
     171        String fileStr,detStr,dateAndTimeStr 
    170172         
    171173        Variable deadtime 
     
    886888// called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf 
    887889// 
    888 Function AttenuationFactor(fileStr,lam,attenNo) 
    889          
    890         // 
     890// atten_err is one std. deviation, passed back by reference 
     891Function AttenuationFactor(fileStr,lam,attenNo,atten_err) 
    891892        String fileStr // 
    892         Variable lam,attenNo 
     893        Variable lam,attenNo, &atten_err 
    893894         
    894895        Variable attenFactor=1 
     
    896897        // your code here        
    897898        attenFactor = LookupAtten(lam,attenNo) 
     899 
     900        // Change April 2011 - now returns error in atten trans 
     901        atten_err = 0 
    898902 
    899903        return(attenFactor) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/FACILITY_DataReadWrite.ipf

    r573 r795  
    187187        // fill the data array with the detector values 
    188188        getDetectorData(fname,data) 
     189         
     190        Duplicate/O data linear_data                    // at this point, the data is still the raw data, and is linear_data 
     191         
     192        // proper error for counting statistics, good for low count values too 
     193        // rather than just sqrt(n) 
     194        // see N. Gehrels, Astrophys. J., 303 (1986) 336-346, equation (7) 
     195        // for S = 1 in eq (7), this corresponds to one sigma error bars 
     196        Duplicate/O linear_data linear_data_error 
     197        linear_data_error = 1 + sqrt(linear_data + 0.75)                                 
     198        // 
    189199         
    190200        //keep a string with the filename in the RAW folder 
     
    350360        data=temp0 
    351361        Redimension/N=(pixelsX,pixelsY) data            //,linear_data 
     362 
     363        Duplicate/O data linear_data_error 
     364        linear_data_error = 1 + sqrt(data + 0.75) 
     365         
     366        //just in case there are odd inputs to this, like negative intensities 
     367        WaveStats/Q linear_data_error 
     368        linear_data_error = numtype(linear_data_error[p]) == 0 ? linear_data_error[p] : V_avg 
     369        linear_data_error = linear_data_error[p] != 0 ? linear_data_error[p] : V_avg 
    352370         
    353371        //linear_data = data 
     
    458476// (3) close the file 
    459477 
     478// new, April 2011 for error propagation. fill these in with the facility- 
     479// specific versions, if desired. 
     480Function WriteTransmissionErrorToHeader(fname,transErr) 
     481        String fname 
     482        Variable transErr 
     483         
     484 
     485        return(0) 
     486End 
     487 
     488Function WriteBoxCountsErrorToHeader(fname,rel_err) 
     489        String fname 
     490        Variable rel_err 
     491         
     492        return(0) 
     493End 
     494 
     495Function getSampleTransError(fname) 
     496        String fname 
     497         
     498        return(0) 
     499end 
     500 
     501Function getBoxCountsError(fname) 
     502        String fname 
     503         
     504        return(0) 
     505end 
     506 
     507 
     508// end April 2011 additions 
     509 
    460510//sample transmission (0<T<=1) 
    461511Function WriteTransmissionToHeader(fname,trans) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/FACILITY_Utils.ipf

    r683 r795  
    611611// 
    612612// called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf 
    613 // 
    614 Function AttenuationFactor(fileStr,lam,attenNo) 
     613// atten_err is one std. deviation, passed back by reference 
     614Function AttenuationFactor(fileStr,lam,attenNo,atten_err) 
    615615        String fileStr 
    616         Variable lam,attenNo 
     616        Variable lam,attenNo, &atten_err 
    617617         
    618618        Variable attenFactor=1 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/HFIR_DataReadWrite.ipf

    r776 r795  
    207207         
    208208        WAVE data=$"root:Packages:NIST:RAW:data" 
    209         Duplicate/O data $"root:Packages:NIST:RAW:linear_data"                  // data is "fresh" and linear scale, so copy it now 
    210          
     209        Duplicate/O data linear_data                    // data is "fresh" and linear scale, so copy it now 
     210                 
     211        // proper error for counting statistics, good for low count values too 
     212        // rather than just sqrt(n) 
     213        // see N. Gehrels, Astrophys. J., 303 (1986) 336-346, equation (7) 
     214        // for S = 1 in eq (7), this corresponds to one sigma error bars 
     215        Duplicate/O linear_data linear_data_error 
     216        linear_data_error = 1 + sqrt(linear_data + 0.75)                                 
     217        // 
    211218         
    212219        SetDataFolder root: 
     
    369376        data=temp0 
    370377        Redimension/N=(pixelsX,pixelsY) data            //,linear_data 
    371          
     378 
     379        Duplicate/O data linear_data_error 
     380        linear_data_error = 1 + sqrt(data + 0.75) 
     381         
     382        //just in case there are odd inputs to this, like negative intensities 
     383        WaveStats/Q linear_data_error 
     384        linear_data_error = numtype(linear_data_error[p]) == 0 ? linear_data_error[p] : V_avg 
     385        linear_data_error = linear_data_error[p] != 0 ? linear_data_error[p] : V_avg 
     386                 
    372387        //linear_data = data 
    373388         
     
    465480// read specific bits of information from the header 
    466481// each of these operations MUST take care of open/close on their own 
     482 
     483// new, April 2011 for error propagation. fill these in with the facility- 
     484// specific versions, if desired. 
     485Function WriteTransmissionErrorToHeader(fname,transErr) 
     486        String fname 
     487        Variable transErr 
     488         
     489 
     490        return(0) 
     491End 
     492 
     493Function WriteBoxCountsErrorToHeader(fname,rel_err) 
     494        String fname 
     495        Variable rel_err 
     496         
     497        return(0) 
     498End 
     499 
     500Function getSampleTransError(fname) 
     501        String fname 
     502         
     503        return(0) 
     504end 
     505 
     506Function getBoxCountsError(fname) 
     507        String fname 
     508         
     509        return(0) 
     510end 
     511 
     512 
     513// end April 2011 additions 
     514 
    467515 
    468516Function/S getStringFromHeader(fname,wantedterm) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/HFIR_Utils.ipf

    r750 r795  
    164164// detStr is passed as TextRead[9] and is an identifier for the detector 
    165165// 
    166 Function DetectorDeadtime(fileStr,detStr) 
    167         String fileStr,detStr 
     166// [dateAndTimeStr] is optional, and could be used as a switch for  
     167// different historical detector configurations 
     168Function DetectorDeadtime(fileStr,detStr,[dateAndTimeStr]) 
     169        String fileStr,detStr,dateAndTimeStr 
    168170         
    169171        Variable deadtime 
     
    977979// called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf 
    978980// 
    979 Function AttenuationFactor(fileStr,lam,attenuation) 
     981// atten_err is one std. deviation, passed back by reference 
     982Function AttenuationFactor(fileStr,lam,attenuation, atten_err) 
    980983        String fileStr 
    981         Variable lam,attenuation  //    0 =< attenuation <= 100 (%) : where no attenuator stands for 0. 
     984        Variable lam,attenuation, &atten_err  //    0 =< attenuation <= 100 (%) : where no attenuator stands for 0. 
    982985         
    983986        Variable attenFactor=1 
     
    986989        attenFactor = 1- attenuation*0.01  //???Attenuate transmission 
    987990 
     991        // Change April 2011 - now returns error in atten trans 
     992        atten_err = 0 
     993         
    988994        return(attenFactor) 
    989995End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_DataReadWrite.ipf

    r779 r795  
    214214        Setdatafolder curpath 
    215215         
    216         Duplicate/O data $"root:Packages:NIST:RAW:linear_data"                  // data is "fresh" and linear scale, so copy it now 
     216        Duplicate/O data linear_data            // data is "fresh" and linear scale, so copy it now 
     217         
     218        // proper error for counting statistics, good for low count values too 
     219        // rather than just sqrt(n) 
     220        // see N. Gehrels, Astrophys. J., 303 (1986) 336-346, equation (7) 
     221        // for S = 1 in eq (7), this corresponds to one sigma error bars 
     222        Duplicate/O linear_data linear_data_error 
     223        linear_data_error = 1 + sqrt(linear_data + 0.75)                                 
     224        // 
    217225         
    218226        //keep a string with the filename in the RAW folder 
     
    394402        data=temp0 
    395403        Redimension/N=(pixelsX,pixelsY) data            //,linear_data 
     404         
     405        Duplicate/O data linear_data_error 
     406        linear_data_error = 1 + sqrt(data + 0.75) 
     407         
     408        //just in case there are odd inputs to this, like negative intensities 
     409        WaveStats/Q linear_data_error 
     410        linear_data_error = numtype(linear_data_error[p]) == 0 ? linear_data_error[p] : V_avg 
     411        linear_data_error = linear_data_error[p] != 0 ? linear_data_error[p] : V_avg 
    396412         
    397413        //linear_data = data 
     
    501517// (2) write the specified value to the header at the correct location in the file 
    502518// (3) close the file 
     519 
     520 
     521// new, April 2011 for error propagation. fill these in with the facility- 
     522// specific versions, if desired. 
     523Function WriteTransmissionErrorToHeader(fname,transErr) 
     524        String fname 
     525        Variable transErr 
     526         
     527 
     528        return(0) 
     529End 
     530 
     531Function WriteBoxCountsErrorToHeader(fname,rel_err) 
     532        String fname 
     533        Variable rel_err 
     534         
     535        return(0) 
     536End 
     537 
     538Function getSampleTransError(fname) 
     539        String fname 
     540         
     541        return(0) 
     542end 
     543 
     544Function getBoxCountsError(fname) 
     545        String fname 
     546         
     547        return(0) 
     548end 
     549 
     550 
     551// end April 2011 additions 
     552 
    503553 
    504554//sample transmission (0<T<=1) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_Utils.ipf

    r764 r795  
    175175// detStr is passed as TextRead[9] and is an identifier for the detector 
    176176// 
    177 Function DetectorDeadtime(fileStr,detStr) 
    178         String fileStr,detStr 
     177// [dateAndTimeStr] is optional, and could be used as a switch for  
     178// different historical detector configurations 
     179Function DetectorDeadtime(fileStr,detStr,[dateAndTimeStr]) 
     180        String fileStr,detStr,dateAndTimeStr 
    179181         
    180182        Variable deadtime 
    181183         
    182 // your code here 
    183 deadtime = (2e-6) 
     184        // your code here 
     185        deadtime = (2e-6) 
    184186 
    185187        return(deadtime) 
     
    922924// called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf 
    923925// 
    924 Function AttenuationFactor(fileStr,lam,attenNo) 
     926// atten_err is one std. deviation, passed back by reference 
     927Function AttenuationFactor(fileStr,lam,attenNo,atten_err) 
    925928        String fileStr 
    926         Variable lam,attenNo 
     929        Variable lam,attenNo,&atten_err 
    927930         
    928931        Variable attenFactor 
     
    930933         
    931934        attenFactor = Attenuators_ILL[attenNo] 
    932          
     935 
     936        // Change April 2011 - now returns error in atten trans 
     937        atten_err = 0 
     938                 
    933939//      print attenfactor 
    934940         
Note: See TracChangeset for help on using the changeset viewer.