#pragma rtGlobals=1 // Use modern global access method. #pragma Version=2.21 #pragma IgorVersion=6.0 //******************** // 101101 Vers. 1 // // Main initialization procedures for USANS reduction // initializes globals and oflders // draws the main panel for user interaction // action procedures for the USANS_Panel // // // // 09 NOV 04 vers 1.1 // - updated dOmega and dQv // - write out dQv to 6-column data sets for analysis compatibility // // //******************** Menu "USANS" "USANS Reduction Panel",ShowUSANSPanel() "Build USANS Notebook" "Desmear USANS Data",Desmear() "-" "Load USANS Data",A_LoadOneDData() "Convert to 6 Columns",Convert3ColTo6Col() "-" "Feedback or Bug Report",U_OpenTracTicketPage("") "Check for Updates",CheckForLatestVersion() End // Bring the USANS_Panel to the front // ALWAYS initializes the folders and variables // then draws the panel if necessary // Proc ShowUSANSPanel() //version number Variable/G root:USANS_RED_VERSION=2.21 //distribution as of Jan 2007 Init_MainUSANS() DoWindow/F USANS_Panel if(V_Flag==0) USANS_Panel() Endif End // initializes the folders and globals for use with the USANS_Panel // waves for the listboxes must exist before the panel is drawn // "dummy" values for the COR_Graph are set here // instrumental constants are set here as well // Proc Init_MainUSANS() NewDataFolder/O root:Packages NewDataFolder/O root:Packages:NIST NewDataFolder/O root:Packages:NIST:USANS NewDataFolder/O root:Packages:NIST:USANS:Globals NewDataFolder/O/S root:Packages:NIST:USANS:Globals:MainPanel String/G root:Packages:NIST:USANS:Globals:gUSANSFolder = "root:Packages:NIST:USANS" String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder //NB This is also hardcoded a bit further down - search for "WHY WHY WHY" AJJ Sept 08 Make/O/T/N=1 fileWave,samWave,empWave,curWave //Added curWave Sept 06 A. Jackson fileWave="" samWave="" empWave="" curWave="" //Added Sept 06 A. Jackson //Wave for handling Current Data AJJ Sept 06 Make/O/N=1 SAMisCurrent,EMPisCurrent SAMisCurrent = 0 EMPisCurrent = 0 Make/O/T/N=5 statusWave="" Make/O/B/U/N=1 selFileW Make/O/B/U/N=1 cselFileW //for the graph control bar Variable/G gTransWide = 1 Variable/G gTransRock = 1 Variable/G gEmpCts = 0.76 //default values as of 15 DEC 05 J. Barker Variable/G gBkgCts = 0.62 //default values as of 15 DEC 05 J. Barker Variable/G gThick = 0.1 Variable/G gTypeCheck=1 //Text filter for data files AJJ Sept 06 String/G FilterStr Variable/G gUseCurrentData = 0 SetDataFolder root: NewDataFolder/O $(USANSFolder+":RAW") NewDataFolder/O $(USANSFolder+":SAM") NewDataFolder/O $(USANSFolder+":COR") NewDataFolder/O $(USANSFolder+":EMP") NewDataFolder/O $(USANSFolder+":BKG") NewDataFolder/O $(USANSFolder+":SWAP") NewDataFolder/O $(USANSFolder+":Graph") //dummy waves for bkg and emp levels Make/O $(USANSFolder+":EMP:empLevel"),$(USANSFolder+":BKG:bkgLevel") //WHY WHY WHY????? //Explicit dependency root:Packages:NIST:USANS:EMP:empLevel := root:Packages:NIST:USANS:Globals:MainPanel:gEmpCts //dependency to connect to SetVariable in panel root:Packages:NIST:USANS:BKG:bkgLevel := root:Packages:NIST:USANS:Globals:MainPanel:gBkgCts //INSTRUMENTAL CONSTANTS Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gTheta_H = 3.9e-6 //Darwin FWHM (pre- NOV 2004) Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gTheta_V = 0.014 //Vertical divergence (pre- NOV 2004) //Variable/G root:Globals:MainPanel:gDomega = 2.7e-7 //Solid angle of detector (pre- NOV 2004) Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gDomega = 7.1e-7 //Solid angle of detector (NOV 2004) Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gDefaultMCR= 1e6 //factor for normalization //Variable/G root:Globals:MainPanel:gDQv = 0.037 //divergence, in terms of Q (1/A) (pre- NOV 2004) Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gDQv = 0.117 //divergence, in terms of Q (1/A) (NOV 2004) End //draws the USANS_Panel, the main control panel for the macros // Window USANS_Panel() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(600,44,1015,493)/K=1 as "USANS_Panel" SetDrawLayer UserBack SetDrawEnv fstyle= 1 DrawText 12,53,"Data Files" SetDrawEnv fstyle= 1 DrawText 157,192,"Empty Scans" SetDrawEnv fstyle= 1 DrawText 154,54,"Sample Scans" DrawLine 6,337,398,337 DrawLine 5,33,393,33 SetDrawEnv fstyle= 1 DrawText 140,357,"Raw Data Header" SetDrawEnv fstyle= 1 DrawText 293,55,"Current Data" ListBox fileLB,pos={5,55},size={110,230},proc=FileListBoxProc ListBox fileLB,listWave=root:Packages:NIST:USANS:Globals:MainPanel:fileWave ListBox fileLB,selWave=root:Packages:NIST:USANS:Globals:MainPanel:selFileW,mode= 4 ListBox samLB,pos={149,55},size={110,90},listWave=root:Packages:NIST:USANS:Globals:MainPanel:samWave ListBox samLB,mode= 1,selRow= -1 Button ClearSamButton,pos={224,148},size={35,21},proc=ClearButtonProc,title="Clr" Button ClearSamButton,help={"Clears the list of sample scans"} Button ClearEmpButton,pos={227,286},size={35,20},proc=ClearButtonProc,title="Clr" Button ClearEmpButton,help={"Clears the list of empty scans"} Button RefreshButton,pos={9,310},size={104,20},proc=RefreshListButtonProc,title="Refresh" Button RefreshButton,help={"Refreshes the list of raw ICP data files"} Button DelSamButton,pos={186,148},size={35,20},proc=DelSamButtonProc,title="Del" Button DelSamButton,help={"Deletes the selected file(s) from the list of sample scans"} Button DelEmpButton,pos={190,286},size={35,20},proc=DelEmpButtonProc,title="Del" Button DelEmpButton,help={"Deletes the selected file(s) from the list of empty scans"} ListBox empLB,pos={151,194},size={110,90} ListBox empLB,listWave=root:Packages:NIST:USANS:Globals:MainPanel:empWave,mode= 1,selRow= 0 Button toSamList,pos={118,55},size={25,90},proc=toSamListButtonProc,title="S->" Button toSamList,help={"Adds the selected file(s) to the list of sample scans"} Button toEmpList,pos={120,195},size={25,90},proc=toEmptyListButtonProc,title="E->" Button toEmpList,help={"Adds the selected file(s) to the list of empty (cell) scans"} ListBox StatusLB,pos={11,358},size={386,77} ListBox StatusLB,listWave=root:Packages:NIST:USANS:Globals:MainPanel:statusWave Button pickPathButton,pos={6,8},size={80,20},proc=PickBT5PathButton,title="DataPath..." Button pickPathButton,help={"Select the data folder where the raw ICP data files are located"} Button PlotSelectedSAMButton,pos={148,148},size={35,20},proc=PlotSelectedSAMButtonProc,title="Plot" Button PlotSelectedSAMButton,help={"Plot the selected sample scattering files in the COR_Graph"} Button PlotSelectedEMPButton,pos={152,286},size={35,20},proc=PlotSelectedEMPButtonProc,title="Plot" Button PlotSelectedEMPButton,help={"Plot the selected empty cell scattering files in the COR_Graph"} Button pickSavePathButton,pos={97,8},size={80,20},proc=PickSaveButtonProc,title="SavePath..." Button pickSavePathButton,help={"Select the data folder where data is to be saved to disk"} Button USANSHelpButton,pos={341,6},size={50,20},proc=USANSHelpButtonProc,title="Help" Button USANSHelpButton,help={"Show the USANS reduction help file"} Button RefreshCurrent,pos={298,310},size={95,20},proc=RefreshCurrentButtonProc,title="Refresh",disable=2 Button RefreshCurrent,help={"Updates data files on Charlotte and gets current data file name"} Button AddCurToSAM,pos={264,55},size={25,90},proc=CurtoSamListButtonProc,title="<-S",disable=2 Button AddCurToSAM,help={"Adds the current data file to the list of sample scans"} Button AddCurToEMP,pos={265,194},size={25,90},proc=CurtoEmptyListButtonProc,title="<-E",disable=2 Button AddCurToEMP,help={"Adds the current data file to the list of empty scans"} ListBox CurFileBox,pos={295,55},size={100,230},proc=FileListBoxProc,disable=1 ListBox CurFileBox,listWave=root:Packages:NIST:USANS:Globals:MainPanel:curWave,mode=1 SetVariable FilterSetVar,pos={8,289},size={106,18},title="Filter",fSize=12 SetVariable FilterSetVar,value= root:Packages:NIST:USANS:Globals:MainPanel:FilterStr CheckBox UseCurrentData,pos={298,290},size={10,10},proc=UseCurrentDataProc,title="Enable Current Data" CheckBox UseCurrentData,value=0 Button USANSFeedback,pos={220,6},size={100,20},proc=U_OpenTracTicketPage,title="Feedback" EndMacro //draws a simple graph of the monitor counts, transmission counts, and detector counts // plots the selected raw data file when "plot raw" is selected from the USANS_Panel // Proc GraphRawData() PauseUpdate; Silent 1 // building window... String fldrSav= GetDataFolder(1) String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder SetDataFolder $(USANSFolder+":RAW:") //String textStr = StringForRawGraph() //textStr=StringByKey("FILE",textStr,":",";")+" MONRATE:"+num2str(mean(MonCts)/NumberByKey("TIMEPT",textStr,":",";")) Display /W=(600,525,1015,850)/L=left1/B=bottom1 /K=1 DetCts vs Angle as "Raw Data" ModifyGraph margin(top)=50 //Display /W=(600,525,1015,850) /K=1 DetCts vs Angle as "Raw Data" DoWindow/C RawDataWin //AppendToGraph/L=left1 /B=bottom1 DetCts vs Angle AppendToGraph/L=left2/B=bottom1 TransCts vs Angle AppendToGraph/L=left3/B=bottom1 MonCts vs Angle SetAxis/A/N=2 left1 SetAxis/A/N=2 left2 SetAxis/A/N=2 left3 ModifyGraph mode=4, marker=19 ModifyGraph rgb(TransCts)=(1,4,52428),rgb(MonCts)=(1,39321,19939) ModifyGraph msize=1,grid=1,mirror=2,standoff=1,lblPos=50,tickUnit=1,notation=1,freePos={0.1,kwFraction} ModifyGraph nticks(left2)=2 ModifyGraph nticks(left3)=2 ModifyGraph mirror(bottom1)=0 ModifyGraph axisEnab(left1)={0.1,0.5},gridEnab(left1)={0.1,1} ModifyGraph axisEnab(left2)={0.57,0.77},gridEnab(left2)={0.1,1} ModifyGraph axisEnab(left3)={0.8,1},gridEnab={0.1,1} ModifyGraph axisEnab(bottom1)={0.1,1},gridEnab(bottom1)={0.1,1} ErrorBars DetCts Y,wave=(ErrDetCts,ErrDetCts) TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Angle" TextBox/F=0/O=90/E=2/A=LC/X=2/N=text2 "Counts" //TextBox/N=text1/A=RC/X=0.50/Y=-2 textStr //Label bottom1 "Angle (degrees)" Label left1 " " Label left2 " " Label left3 " " TitleForRawGraph() SetDataFolder fldrSav End // plots the selected EMP files onto the COR_Graph // Does the following: // - loads raw data // - normalizes counts to time and 1E6 monitor counts // sorts by angle // finds zero angle (and peak height) // converts to q-values // finds T wide // updates the graph // Function PlotSelectedEMPButtonProc(ctrlName) : ButtonControl String ctrlName SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder //get selected files from listbox (everything) //use the listBox wave directly Wave/T listW=$(USANSFolder+":Globals:MainPanel:empWave") //Wave for indication of current data set AJJ Sept 2006 Wave isCurrent = $(USANSFolder+":Globals:MainPanel:EMPisCurrent") Variable ii,num=numpnts(listW) String fname="",fpath="",curPathStr="" PathInfo bt5PathName fpath = S_Path PathInfo bt5CurPathName curPathStr = S_Path if(cmpstr("",listW[0])==0) return(0) //null item in 1st position, exit Endif //load, normalize, and append //loop over the number of items in the list for(ii=0;ii