Ignore:
Timestamp:
Oct 31, 2017 1:09:55 PM (5 years ago)
Author:
srkline
Message:

a few changes to update the calculation of transmission values from the tables, and updating the correct units in a few places. Also updated how a transmission file is matched with a scattering file.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r1063 r1072  
    468468        String fname 
    469469         
     470        Print "reading atten transmission" 
    470471        String path = "entry:instrument:attenuator:attenuator_transmission"      
    471472        return(V_getRealValueFromHDF5(fname,path)) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r1063 r1072  
    11641164//// number of attenuators actually dropped in 
    11651165//// an integer value 
    1166 //Function V_writeAtten_num_dropped(fname,val) 
    1167 //      String fname 
    1168 //      Variable val 
    1169 //       
    1170 ////    String path = "entry:instrument:attenuator:thickness"    
    1171 //       
    1172 //      Make/O/I/N=1 wTmpWrite 
    1173 ////    Make/O/R/N=1 wTmpWrite 
    1174 //      String groupName = "/entry/instrument/attenuator"        
    1175 //      String varName = "num_atten_dropped" 
    1176 //      wTmpWrite[0] = val 
    1177 // 
    1178 //      variable err 
    1179 //      err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
    1180 //      if(err) 
    1181 //              Print "HDF write err = ",err 
    1182 //      endif 
    1183 //      // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
    1184 ////    err = V_KillNamedDataFolder(fname) 
    1185 ////    if(err) 
    1186 ////            Print "DataFolder kill err = ",err 
    1187 ////    endif 
    1188 //      return(err) 
    1189 //end 
     1166Function V_writeAtten_num_dropped(fname,val) 
     1167        String fname 
     1168        Variable val 
     1169         
     1170//      String path = "entry:instrument:attenuator:thickness"    
     1171         
     1172        Make/O/I/N=1 wTmpWrite 
     1173//      Make/O/R/N=1 wTmpWrite 
     1174        String groupName = "/entry/instrument/attenuator"        
     1175        String varName = "num_atten_dropped" 
     1176        wTmpWrite[0] = val 
     1177 
     1178        variable err 
     1179        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
     1180        if(err) 
     1181                Print "HDF write err = ",err 
     1182        endif 
     1183        // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
     1184//      err = V_KillNamedDataFolder(fname) 
     1185//      if(err) 
     1186//              Print "DataFolder kill err = ",err 
     1187//      endif 
     1188        return(err) 
     1189end 
    11901190 
    11911191// thickness of the attenuator (PMMA) - units?? 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Instrument_Resolution.ipf

    r1064 r1072  
    391391 
    392392 
    393  
    394  
    395  
    396 ////////Transmission 
    397 //****************** 
    398 //lookup tables for attenuator transmissions 
    399 // 
    400 // 
    401 // new calibration done June 2007, John Barker 
    402 // 
    403 Proc MakeNG3AttenTable() 
    404  
    405         NewDataFolder/O root:myGlobals:Attenuators 
    406         //do explicitly to avoid data folder problems, redundant, but it must work without fail 
    407         Variable num=10         //10 needed for tables after June 2007 
    408  
    409         Make/O/N=(num) root:myGlobals:Attenuators:ng3att0 
    410         Make/O/N=(num) root:myGlobals:Attenuators:ng3att1 
    411         Make/O/N=(num) root:myGlobals:Attenuators:ng3att2 
    412         Make/O/N=(num) root:myGlobals:Attenuators:ng3att3 
    413         Make/O/N=(num) root:myGlobals:Attenuators:ng3att4 
    414         Make/O/N=(num) root:myGlobals:Attenuators:ng3att5 
    415         Make/O/N=(num) root:myGlobals:Attenuators:ng3att6 
    416         Make/O/N=(num) root:myGlobals:Attenuators:ng3att7 
    417         Make/O/N=(num) root:myGlobals:Attenuators:ng3att8 
    418         Make/O/N=(num) root:myGlobals:Attenuators:ng3att9 
    419         Make/O/N=(num) root:myGlobals:Attenuators:ng3att10 
    420          
    421         // and a wave for the errors at each attenuation factor 
    422         Make/O/N=(num) root:myGlobals:Attenuators:ng3att0_err 
    423         Make/O/N=(num) root:myGlobals:Attenuators:ng3att1_err 
    424         Make/O/N=(num) root:myGlobals:Attenuators:ng3att2_err 
    425         Make/O/N=(num) root:myGlobals:Attenuators:ng3att3_err 
    426         Make/O/N=(num) root:myGlobals:Attenuators:ng3att4_err 
    427         Make/O/N=(num) root:myGlobals:Attenuators:ng3att5_err 
    428         Make/O/N=(num) root:myGlobals:Attenuators:ng3att6_err 
    429         Make/O/N=(num) root:myGlobals:Attenuators:ng3att7_err 
    430         Make/O/N=(num) root:myGlobals:Attenuators:ng3att8_err 
    431         Make/O/N=(num) root:myGlobals:Attenuators:ng3att9_err 
    432         Make/O/N=(num) root:myGlobals:Attenuators:ng3att10_err 
    433          
    434          
    435         //each wave has 10 elements, the transmission of att# at the wavelengths  
    436         //lambda = 4,5,6,7,8,10,12,14,17,20 (4 A and 20 A are extrapolated values) 
    437         Make/O/N=(num) root:myGlobals:Attenuators:ng3lambda={4,5,6,7,8,10,12,14,17,20} 
    438          
    439         // new calibration done June 2007, John Barker 
    440         root:myGlobals:Attenuators:ng3att0 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } 
    441         root:myGlobals:Attenuators:ng3att1 = {0.444784,0.419,0.3935,0.3682,0.3492,0.3132,0.2936,0.2767,0.2477,0.22404} 
    442         root:myGlobals:Attenuators:ng3att2 = {0.207506,0.1848,0.1629,0.1447,0.1292,0.1056,0.09263,0.08171,0.06656,0.0546552} 
    443         root:myGlobals:Attenuators:ng3att3 = {0.092412,0.07746,0.06422,0.05379,0.04512,0.03321,0.02707,0.02237,0.01643,0.0121969} 
    444         root:myGlobals:Attenuators:ng3att4 = {0.0417722,0.03302,0.02567,0.02036,0.01604,0.01067,0.00812,0.006316,0.00419,0.00282411} 
    445         root:myGlobals:Attenuators:ng3att5 = {0.0187129,0.01397,0.01017,0.007591,0.005668,0.003377,0.002423,0.001771,0.001064,0.000651257} 
    446         root:myGlobals:Attenuators:ng3att6 = {0.00851048,0.005984,0.004104,0.002888,0.002029,0.001098,0.0007419,0.0005141,0.000272833,0.000150624} 
    447         root:myGlobals:Attenuators:ng3att7 = {0.00170757,0.001084,0.0006469,0.0004142,0.0002607,0.0001201,7.664e-05,4.06624e-05,1.77379e-05,7.30624e-06} 
    448         root:myGlobals:Attenuators:ng3att8 = {0.000320057,0.0001918,0.0001025,6.085e-05,3.681e-05,1.835e-05,6.74002e-06,3.25288e-06,1.15321e-06,3.98173e-07} 
    449         root:myGlobals:Attenuators:ng3att9 = {6.27682e-05,3.69e-05,1.908e-05,1.196e-05,8.738e-06,6.996e-06,6.2901e-07,2.60221e-07,7.49748e-08,2.08029e-08} 
    450         root:myGlobals:Attenuators:ng3att10 = {1.40323e-05,8.51e-06,5.161e-06,4.4e-06,4.273e-06,1.88799e-07,5.87021e-08,2.08169e-08,4.8744e-09,1.08687e-09} 
    451    
    452   // percent errors as measured, May 2007 values 
    453   // zero error for zero attenuators, appropriate average values put in for unknown values 
    454         root:myGlobals:Attenuators:ng3att0_err = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 
    455         root:myGlobals:Attenuators:ng3att1_err = {0.15,0.142,0.154,0.183,0.221,0.328,0.136,0.13,0.163,0.15} 
    456         root:myGlobals:Attenuators:ng3att2_err = {0.25,0.257,0.285,0.223,0.271,0.405,0.212,0.223,0.227,0.25} 
    457         root:myGlobals:Attenuators:ng3att3_err = {0.3,0.295,0.329,0.263,0.323,0.495,0.307,0.28,0.277,0.3} 
    458         root:myGlobals:Attenuators:ng3att4_err = {0.35,0.331,0.374,0.303,0.379,0.598,0.367,0.322,0.33,0.35} 
    459         root:myGlobals:Attenuators:ng3att5_err = {0.4,0.365,0.418,0.355,0.454,0.745,0.411,0.367,0.485,0.4} 
    460         root:myGlobals:Attenuators:ng3att6_err = {0.45,0.406,0.473,0.385,0.498,0.838,0.454,0.49,0.5,0.5} 
    461         root:myGlobals:Attenuators:ng3att7_err = {0.6,0.554,0.692,0.425,0.562,0.991,0.715,0.8,0.8,0.8} 
    462         root:myGlobals:Attenuators:ng3att8_err = {0.7,0.705,0.927,0.503,0.691,1.27,1,1,1,1} 
    463         root:myGlobals:Attenuators:ng3att9_err = {1,0.862,1.172,0.799,1.104,1.891,1.5,1.5,1.5,1.5} 
    464         root:myGlobals:Attenuators:ng3att10_err = {1.5,1.054,1.435,1.354,1.742,2,2,2,2,2} 
    465    
    466  
    467 End 
    468  
    469  
    470  
    471  
    472  
    473 //returns the transmission of the attenuator (at NG3) given the attenuator number 
    474 //which must be an integer(to select the wave) and given the wavelength. 
    475 //the wavelength may be any value between 4 and 20 (A), and is interpolated 
    476 //between calibrated wavelengths for a given attenuator 
    477 // 
    478 // Mar 2010 - abs() added to attStr to account for ICE reporting -0.0001 as an attenuator position, which truncates to "-0" 
    479 Function LookupAttenNG3(lambda,attenNo,atten_err) 
    480         Variable lambda, attenNo, &atten_err 
    481          
    482         Variable trans 
    483         String attStr="root:myGlobals:Attenuators:ng3att"+num2str(trunc(abs(attenNo))) 
    484         String attErrWStr="root:myGlobals:Attenuators:ng3att"+num2str(trunc(abs(attenNo)))+"_err" 
    485         String lamStr = "root:myGlobals:Attenuators:ng3lambda" 
    486          
    487         if(attenNo == 0) 
    488                 return (1)              //no attenuation, return trans == 1 
    489         endif 
    490          
    491         if( (lambda < 4) || (lambda > 20 ) ) 
    492                 Abort "Wavelength out of calibration range (4,20). You must manually enter the absolute parameters" 
    493         Endif 
    494          
    495         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) || !(WaveExists($attErrWStr))) 
    496                 Execute "MakeNG3AttenTable()" 
    497         Endif 
    498         //just in case creating the tables fails.... 
    499         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 
    500                 Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" 
    501         Endif 
    502          
    503         //lookup the value by interpolating the wavelength 
    504         //the attenuator must always be an integer 
    505         Wave att = $attStr 
    506         Wave attErrW = $attErrWStr 
    507         Wave lam = $lamstr 
    508         trans = interp(lambda,lam,att) 
    509         atten_err = interp(lambda,lam,attErrW) 
    510  
    511 // the error in the tables is % error. return the standard deviation instead 
    512         atten_err = trans*atten_err/100 
    513                  
    514 //      Print "trans = ",trans 
    515 //      Print "trans err = ",atten_err 
    516          
    517         return trans 
    518 End 
    519  
    520  
    521  
    522  
    523 // a utility function so that I can get the values from the command line 
    524 // since the atten_err is PBR 
    525 // 
    526 Function PrintAttenuation(instr,lam,attenNo) 
    527         String instr 
    528         Variable lam,attenNo 
    529          
    530         Variable atten_err, attenFactor 
    531          
    532         // 22 FEB 2013 - not sure what changed with the writeout of ICE data files... but .... 
    533         // to account for ICE occasionally writing out "3" as 2.9998, make sure I can construct 
    534         // a single digit -> string "3" to identify the proper wave in the lookup table 
    535          
    536         attenNo = round(attenNo) 
    537          
    538         strswitch(instr) 
    539                 case "CGB": 
    540                 case "NG3": 
    541                         attenFactor = LookupAttenNG3(lam,attenNo,atten_err) 
    542                         break 
    543                 default:                                                         
    544                         //return error? 
    545                         DoAlert 0, "No matching instrument -- PrintAttenuation" 
    546                         attenFactor=1 
    547         endswitch 
    548  
    549         Print "atten, err = ", attenFactor, atten_err 
    550          
    551         return(0) 
    552 End 
    553  
    554  
    555 // 
    556 //returns the proper attenuation factor based on the instrument (NG3, NG5, or NG7) 
    557 //NG5 values are taken from the NG7 tables (there is very little difference in the 
    558 //values, and NG5 attenuators have not been calibrated (as of 8/01) 
    559 // 
    560 // filestr is passed from TextRead[3] = the default directory 
    561 // lam is passed from RealsRead[26] 
    562 // AttenNo is passed from ReaslRead[3] 
    563 // 
    564 // Attenuation factor as defined here is <= 1 
    565 // 
    566 // HFIR can pass ("",1,attenuationFactor) and have this function simply 
    567 // spit back the attenuationFactor (that was read into rw[3]) 
    568 // 
    569 // called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf 
    570 // 
    571 // 
    572 // as of March 2011, returns the error (one standard deviation) in the attenuation factor as the last parameter, by reference 
    573 Function AttenuationFactor(fileStr,lam,attenNo,atten_err) 
    574         String fileStr 
    575         Variable lam,attenNo, &atten_err 
    576          
    577         Variable attenFactor=1,loc 
    578         String instr=fileStr[1,3]       //filestr is "[NGnSANSn] " or "[NGnSANSnn]" (11 characters total) 
    579  
    580  
    581         // 22 FEB 2013 - not sure what changed with the writeout of ICE data files... but .... 
    582         // to account for ICE occasionally writing out "3" as 2.9998, make sure I can construct 
    583         // a single digit -> string "3" to identify the proper wave in the lookup table 
    584          
    585         attenNo = round(attenNo) 
    586          
    587                  
    588         strswitch(instr) 
    589                 case "CGB": 
    590                 case "NG3": 
    591                         attenFactor = LookupAttenNG3(lam,attenNo,atten_err) 
    592                         break 
    593                 default:                                                         
    594                         //return error? 
    595                         DoAlert 0, "No matching instrument -- PrintAttenuation" 
    596                         attenFactor=1 
    597         endswitch 
    598 //      print "instr, lambda, attenNo,attenFactor = ",instr,lam,attenNo,attenFactor 
    599         return(attenFactor) 
    600 End 
    601  
    602  
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1071 r1072  
    25722572                 
    25732573        //get the necessary variables for the calculation of kappa 
    2574         Variable countTime,monCnt,sdd,pixel 
     2574        Variable countTime,monCnt,sdd,pixel_x,pixel_y 
    25752575        String detStr,junkStr,errStr 
    25762576 
     
    26932693                monCnt = V_getBeamMonNormData("RAW") 
    26942694                 
    2695                 pixel = V_getDet_x_pixel_size("RAW",detPanel_toSum) 
    2696                 pixel /= 10             //convert mm to cm, since sdd in cm 
     2695                pixel_x = V_getDet_x_pixel_size("RAW",detPanel_toSum) 
     2696                pixel_x /= 10           //convert mm to cm, since sdd in cm 
     2697                pixel_y = V_getDet_y_pixel_size("RAW",detPanel_toSum) 
     2698                pixel_y /= 10           //convert mm to cm, since sdd in cm 
    26972699                sdd = V_getDet_ActualDistance("RAW",detPanel_toSum) 
    26982700                 
    2699 //              kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime)*(pixel/sdd)^2 
     2701//              kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime)*(pixel_x*pixel_y/sdd^2) 
    27002702                kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime) 
    27012703                 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Transmission.ipf

    r1064 r1072  
    8787                        WAVE groupIDW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID 
    8888                        WAVE transmW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission 
     89                        WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent 
    8990                         
    9091                        // TODO 
     
    105106                // TODO x- set the popup string to the matching name on exit 
    106107                        Variable targetID = groupIDW[ii] 
    107                         String list = V_getFilePurposeList("TRANSMISSION",0) 
     108//                      String list = V_getFilePurposeList("TRANSMISSION",0) 
     109                        String list = V_getFileIntentPurposeList("SAMPLE","TRANSMISSION",0) 
     110                         
    108111                        WAVE/T purposeW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose 
    109112                        for(ii=0;ii<np;ii+=1) 
    110                                 if(cmpstr(purposeW[ii],"TRANSMISSION")==0 && groupIDW[ii] == targetID) 
     113                                if(cmpstr(purposeW[ii],"TRANSMISSION")==0 && cmpstr(intentW[ii],"SAMPLE")==0 && groupIDW[ii] == targetID) 
    111114                                        Print "transmission file match at ",filenameW[ii] 
    112115                                        SetVariable setvar_2,value=labelW[ii] 
    113116                                        SetVariable setvar_3,value=groupIDW[ii] 
    114                                         PopupMenu popup_1,mode=WhichListItem(fileNameW[ii], list )+1 
     117                                        PopupMenu popup_1,mode=WhichListItem(fileNameW[ii], list )+1,popValue=fileNameW[ii] 
    115118                                        break 
    116119                                endif            
     
    122125                // x-  Detector Panel field is hard-wired for "B" 
    123126                //       
    124                         WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent 
    125127                        list = V_getFileIntentList("EMPTY BEAM",0) 
    126128                         
     
    129131                                        Print "empty beam match at ",filenameW[ii] 
    130132                                        SetVariable setvar_4,value=labelW[ii] 
    131                                         PopupMenu popup_2,mode=WhichListItem(fileNameW[ii], list )+1 
     133                                        PopupMenu popup_2,mode=WhichListItem(fileNameW[ii], list )+1,popValue=fileNameW[ii] 
    132134                                         
    133135//                                      SetVariable setvar_6,value =_STR:"ML" 
Note: See TracChangeset for help on using the changeset viewer.