
How do I find where/how a wave is computed within an igor procedure?

KP
Hello,
I am a new igor pro user. I am using an igor procedure written by someone else which (*I think*) computes a wave called 'totscanvol'. Could you please help me figure how the wave is being computed? I am copy pasting the procedure here. I did control+F and control+G to find out where this wave is mentioned, but I could not find how it is being computed. Any help is appreciated. Thank you.
#include <igorthief> #pragma rtGlobals=3 // Use modern global access method and strict wave access. Menu "SEMS" "SEMS Panel", DisplaySEMSPanel() End Function BrowseforFolder() DFREF dfsave = GetDataFolderDFR() SVAR pathstring = root:SEMS:gSEMS_pathstr NewPath/O/Q/M="Choose the folder where the SEMS data lives" SEMSfolder //get folder where SEMS data lives, folder is put in a Path if (V_flag == 0) pathinfo SEMSfolder pathstring = S_path endif Setdatafolder dfsave end Window SEMS_Data_Analysis() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(299,244,1108,607) ModifyPanel frameStyle=1 ShowTools/A ShowInfo/W=SEMS_Data_Analysis GroupBox group2_tab1,pos={195,165},size={169,64} GroupBox group1_tab1,pos={195,236},size={167,101} GroupBox group0_tab1,pos={195,73},size={168,84} SetVariable name_range_tab1,pos={205,277},size={145,16},proc=SetRange_name,title="Name:" SetVariable name_range_tab1,limits={-inf,inf,0},value= root:SEMS:g_range_name,live= 1 Button Make_dist_tab1,pos={203,305},size={121,21},proc=Make_dist_Proc,title="Make Avg. Distribution" TitleBox title0,pos={8,7},size={173,28},title="SEMS Data Analysis" TitleBox title0,labelBack=(65535,65535,65535),fSize=16,fStyle=1,anchor= MC Button Button_Browse,pos={692,11},size={50,20},proc=ButtonProc_Browse,title="Browse" Button Button_Load,pos={747,11},size={50,20},proc=ButtonProc_Load,title="Load" SetVariable sv_FilePath,pos={234,14},size={444,16},proc=SetVarProc,title="File Path" SetVariable sv_FilePath,limits={-inf,inf,0},value= root:SEMS:gSEMS_pathstr Button pop_volume_tab0,pos={780,79},size={13,47},disable=1,proc=Button_pop_vol,title="p\ro\rp" Button pop_volume_tab0,labelBack=(61440,61440,61440),fColor=(65280,65280,0) Button GetRange_tab1,pos={205,124},size={75,21},proc=GetRange_Proc,title="Get Selection" SetVariable from_tab1,pos={206,101},size={76,16},bodyWidth=33,title="From Pt." SetVariable from_tab1,limits={-inf,inf,0},value= root:SEMS:g_fRow,live= 1 SetVariable to_tab1,pos={288,101},size={66,16},bodyWidth=33,title="To Pt." SetVariable to_tab1,limits={-inf,inf,0},value= root:SEMS:g_lRow,live= 1 PopupMenu popup0_tab1,pos={203,196},size={64,21},proc=PopMenuProc_disttype PopupMenu popup0_tab1,mode=1,popvalue="Number",value= #"\"Number;Surface Area;Volume\"" TabControl SEMSTabs,pos={8,50},size={793,304},proc=TabProc TabControl SEMSTabs,labelBack=(60928,60928,60928) TabControl SEMSTabs,tabLabel(0)="Total Concentrations" TabControl SEMSTabs,tabLabel(1)="Size Distributions",value= 1 TitleBox Range_title_tab1,pos={205,81},size={105,13},title="Select or Enter Range" TitleBox Range_title_tab1,frame=0 TitleBox disttype_title_tab1,pos={201,173},size={112,13},title="Select Distribution Type" TitleBox disttype_title_tab1,frame=0 TitleBox distname_title_tab1,pos={202,242},size={120,26},title="Give a name to the range\r(optional)" TitleBox distname_title_tab1,frame=0 Button pop_number_tab0,pos={385,77},size={13,47},disable=1,proc=Button_pop_num,title="p\ro\rp" Button pop_number_tab0,labelBack=(61440,61440,61440),fColor=(65280,65280,0) Button pop_number_tab1,pos={777,78},size={13,47},proc=Button_pop_dist,title="p\ro\rp" Button pop_number_tab1,labelBack=(61440,61440,61440),fColor=(65280,65280,0) String fldrSav0= GetDataFolder(1) SetDataFolder root:SEMS: Display/W=(408,77,773,335)/HOST=# /HIDE=1 totScanVol vs startdatetime SetDataFolder fldrSav0 ModifyGraph dateInfo(bottom)={0,0,0} Label left "SEMS Volume" Label bottom "Date and Time" RenameWindow #,G0_tab0 SetActiveSubwindow ## String fldrSav1= GetDataFolder(1) SetDataFolder root:SEMS: Display/W=(17,76,377,336)/HOST=# /HIDE=1 totScanConc vs startdatetime SetDataFolder fldrSav1 ModifyGraph dateInfo(bottom)={0,0,0} Label left "SEMS Number Concentration" Label bottom "Date and Time" RenameWindow #,G1_tab0 SetActiveSubwindow ## String fldrSav2= GetDataFolder(1) SetDataFolder root:SEMS: Edit/W=(14,72,189,343)/HOST=# startdatetime as "SEMS_Data_Analysis" ModifyTable format(Point)=1,width(Point)=40,format(startdatetime)=8,width(startdatetime)=109 ModifyTable showParts=0x6A ModifyTable statsArea=85 SetDataFolder fldrSav2 RenameWindow #,T0_tab1 SetActiveSubwindow ## String fldrSav3= GetDataFolder(1) SetDataFolder root:SEMS: Display/W=(372,74,767,337)/HOST=# display_dist vs sizebins SetDataFolder fldrSav3 ModifyGraph log(bottom)=1 Label left "Average Distribution (dX/dlogDp)" Label bottom "Diameter (nm)" RenameWindow #,G0_tab1 SetActiveSubwindow ## EndMacro Function DisplaySEMSPanel() // If the panel is already created, just bring it to the front. DoWindow/F SEMS_Data_Analysis if (V_Flag != 0) return 0 endif DFREF dfSave = GetDataFolderDFR() NewDataFolder/O/S root:SEMS wave/Z totScanVol = totScanVol //need to initialize totScanVol and startdatetime so that the graph is ok at panel start up wave/Z/D startdatetime = startdatetime wave/Z totScanConc = totScanConc wave/Z avg_vol_dist = avg_vol_dist wave/Z avg_sa_dist = avg_sa_dist wave/Z avg_num_dist = avg_num_dist if (!(waveexists(TotScanVol) && waveexists(startdatetime) && waveexists(totScanConc))) make/N=0 totScanVol, totScanConc make/D/N=0 startdatetime wave totScanVol, totScanConc wave/D startdatetime totScanVol = nan totScanConc = nan startdatetime = nan endif if(!(waveexists($"display_dist"))) make/N=0 display_dist wave display_dist display_dist = nan endif if(!(waveexists($"sizebins"))) make/N=0 sizebins wave sizebins sizebins = nan endif DFREF SEMS_df = GetDataFolderDFR() string SEMS_df_s = GetDataFolder(1,SEMS_df) string range_name = strVarOrDefault("g_range_name", "") string/G g_range_name = range_name string dist_name = strVarOrDefault("g_dist_name", "avg_num_dist") string/G g_dist_name = dist_name string dist_label = strVarOrDefault("g_dist_label", "Average Distribution (dN/dlogDp)") string/G g_dist_label = dist_label string SEMS_pathstr = StrVarOrDefault(SEMS_df_s+"gSEMS_pathstr", SpecialDirPath("Igor Pro User Files", 0, 0, 0)) //default of user chosen path string string/G gSEMS_pathstr = SEMS_pathstr //gSEMS_pathstr is the path string for the folder where SEMS data lives variable frow = numVarOrDefault("g_frow", 0) variable lrow = numVarOrDefault("g_lrow",0) variable popnum = numVarOrDefault("g_popNum",1) Variable/G g_popNum = popnum string popstr = StrVarOrDefault("g_popStr","Number") string/G g_popStr = popStr Variable/G g_frow =frow Variable/G g_lrow =lrow Execute "SEMS_Data_Analysis()" setdatafolder dfsave end Function SetVarProc(sva) : SetVariableControl STRUCT WMSetVariableAction &sva SVAR pathstring = root:SEMS:gSEMS_pathstr switch( sva.eventCode ) case 1: // mouse up case 2: // Enter key case 3: // Live update Variable dval = sva.dval pathstring = sva.sval break case -1: // control being killed break endswitch return 0 End Function ButtonProc_Browse(ba) : ButtonControl STRUCT WMButtonAction &ba switch( ba.eventCode ) case 2: // mouse up BrowseforFolder() break case -1: // control being killed break endswitch return 0 End Function ButtonProc_Load(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave = getdatafolderDFR() switch( ba.eventCode ) case 2: //mouse up SVAR pathstring = root:SEMS:gSEMS_pathstr NewPath/O/Z/Q SEMSfolder pathstring if (V_flag != 0) BrowseforFolder() endif string/G root:SEMS:gSEMS_datfilelist = IndexedFile (SEMSfolder, -1, ".dat") SVAR fileliststring = root:SEMS:gSEMS_datfilelist if (StringMatch(fileliststring, "")) print "No SEMS data files were found." endif string/G root:SEMS:gSEMS_conclist = ListMatch(fileliststring, "SEMS_CONC*") string/G root:SEMS:gSEMS_auxlist = ListMatch(fileliststring, "SEMS_AUX*") SVAR conclist = root:SEMS:gSEMS_conclist SVAR auxlist = root:SEMS:gSEMS_auxlist auxlist = SortList(auxlist) conclist = SortList(conclist) //start loading files //loadmultfiles(filelist, line number for column names, first line, first column, number of columns) loadmultfiles(auxlist,9,10,0, 11,"") loadmultfiles(auxlist,9,10,43, 0,"") NVAR bincols = root:SEMS:bincols loadmultfiles(auxlist,9,10, 11, 42,"binlimits") loadmultfiles(conclist, 26,27,9,bincols,"numdist") setdatafolder root:SEMS: appendwaves() Make/O/N=(bincols) root:SEMS:sizebins wave sizebins = root:SEMS:sizebins wave numdist0 = root:SEMS:numdist0 variable v1, v2 variable j = 0 for (j = 0; j<bincols; j+=1) string dimtemp = GetDimLabel(numdist0,1,j) sscanf dimtemp,"Bin%f_%f", v1, v2 sizebins[j] = v2 endfor setdatafolder root:SEMS: plot_sems_totals("root:SEMS") wave startdatetime, binlimits0 duplicate/O numdist0, numdist duplicate/O binlimits0, binlimits killwaves binlimits0, numdist0 Totals_calc(sizebins, numdist, startdatetime, binlimits) break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function TabProc(tca) : TabControl STRUCT WMTabControlAction &tca switch( tca.eventCode ) case 2: // mouse up Variable tab = tca.tab String curTabMatch= "*_tab"+num2istr(tca.tab) String controls= ControlNameList("") String childwindows = ChildWindowList("#") Variable i, n= ItemsInList(controls) for(i=0; i<n; i+=1) String control= StringFromList(i, controls) Variable isInATab= stringmatch(control,"*_tab*") if( isInATab ) Variable show= stringmatch(control,curTabMatch) ControlInfo $control // gets V_disable if( show ) V_disable= V_disable & ~0x1 // clear the hide bit else V_disable= V_disable | 0x1 // set the hide bit endif ModifyControl $control disable=V_disable endif endfor n = ItemsInList(childwindows) for(i=0; i<n; i+=1) String windowname = StringFromList(i, childwindows) windowname = "#"+windowname isInATab= stringmatch(windowname,"*_tab*") if( isInATab ) show= stringmatch(windowname,curTabMatch) if( show ) Setwindow $windowname hide = 0, needUpdate= 1 else Setwindow $windowname hide = 1 endif endif endfor return 0 break case -1: // control being killed break endswitch return 0 End Function Button_pop_vol(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave =getdatafolderDFR() SetDataFolder root:SEMS: wave TotScanVol, startdatetime switch( ba.eventCode ) case 2: String fldrSav0= GetDataFolder(1) Display/W=(13,72,314,245) TotScanVol vs startdatetime SetDataFolder fldrSav0 ModifyGraph dateInfo(bottom)={0,0,0} Label left "SEMS Volume" Label bottom "Date and Time" break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function Button_pop_num(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave =getdatafolderDFR() SetDataFolder root:SEMS: wave totscanconc, startdatetime switch( ba.eventCode ) case 2: // mouse up String fldrSav0= GetDataFolder(1) Display/W=(13,72,314,245) TotScanConc vs startdatetime SetDataFolder fldrSav0 ModifyGraph dateInfo(bottom)={0,0,0} Label left "SEMS Number Concentration" Label bottom "Date and Time" break break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function Button_pop_dist(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave = getdatafolderDFR() setDataFolder root:SEMS: switch( ba.eventCode ) case 2: // mouse up wave sizebins NVAR g_popNum SVAR g_dist_name, g_dist_label //switch (g_popNum) //case 1: //display $g_dist_name vs sizebins //break //case 2: //break //case 3: //break //endswitch display $g_dist_name vs sizebins label left g_dist_label label bottom "Diameter (nm)" ModifyGraph log(bottom)=1 break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function loadmultfiles (filelist, nameline, firstline, firstcolumn, numcolumns, matrixload) string filelist variable nameline, firstline, firstcolumn, numcolumns string matrixload DFREF dfsave = getdatafolderDFR() setdatafolder root:SEMS: variable filenumber = itemsinlist(filelist) variable i for (i = 0; i<filenumber; i+=1) variable refnum Open/R/P=SEMSfolder refNum as stringfromlist(i,filelist) if (refNum == 0) return -1 endif variable lineNumber = 0 variable len = 0 string buffer = "" do FReadLine refNum, buffer len = strlen(buffer) if (len == 0) break // No more lines to be read endif lineNumber += 1 while (1) Close refnum if (lineNumber>firstline) setdatafolder root:SEMS: NewDataFolder/O/S $("file_"+num2str(i)) if(stringmatch(matrixload,"")) loadwave/Q/O/A/W/J/L={nameline, firstline, 0, firstcolumn,numcolumns}/k=0 /P=SEMSfolder stringfromlist(i,filelist) string/G wavenames = S_wavenames else loadwave/K=0/J/N=$matrixload/M/U={0,0,1,0} /Q/O/P=SEMSfolder/L={nameline, firstline, 0, firstcolumn,numcolumns} stringfromlist(i,filelist) endif if(i==0 && WhichListItem("NumBins",S_wavenames) !=-1) wave numbins = numbins variable/G root:SEMS:bincols = numbins[0] NVAR bincols = root:SEMS:bincols print "First file has ",numbins[0]," SEMS bins. Files with different number bins will be skipped" endif if (i != 0 && WhichListItem("NumBins",S_wavenames) !=-1) wave numbins = numbins variable tempbins = numbins[0] if(tempbins !=bincols) print "File "+stringfromlist(i,filelist)+" has ",tempbins,". Skipping file." filelist = removelistitem(i,filelist) i = i-1 filenumber = filenumber-1 endif endif else print "File "+stringfromlist(i,filelist)+" has no data. Skipping it." filelist = removelistitem(i,filelist) i = i-1 filenumber = filenumber-1 endif endfor setdatafolder dfsave end Function AppendWaves() setdatafolder root:SEMS:file_0 string listofwaves listofwaves = WaveList("*",";","") string thewave variable index, index2 index = 0 do thewave = stringFromList (index, listofwaves) if(strlen(thewave) == 0) break endif duplicate/O $thewave, ::$thewave index += 1 while (1) setdatafolder :: index = 1 do if(!DataFolderExists(GetDataFolder(1)+"file_"+num2str(index))) break endif Setdatafolder root:SEMS:$("file_"+num2str(index)) index2=0 do thewave = stringFromList (index2, listofwaves) if(strlen(thewave) == 0) break endif Concatenate/NP=0 {$thewave}, ::$thewave index2 += 1 while (1) setdatafolder :: index +=1 while(1) end Function GetRange_Proc(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave = getdatafolderDFR() SetDataFolder root:SEMS: switch( ba.eventCode ) case 2: // mouse up Variable/G g_frow, g_lrow GetSelection table, SEMS_Data_Analysis#T0_tab1, 1 g_frow = V_startRow g_lrow = V_endRow break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function SetRange_name(sva) : SetVariableControl STRUCT WMSetVariableAction &sva DFREF dfsave = getdatafolderDFR() setdatafolder root:SEMS: switch( sva.eventCode ) case 1: // mouse up case 2: // Enter key case 3: // Live update String/G g_range_name = sva.sval break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function PopMenuProc_disttype(pa) : PopupMenuControl STRUCT WMPopupAction &pa DFREF dfsave = getdatafolderDFR() setdatafolder root:SEMS: switch( pa.eventCode ) case 2: // mouse up variable/G g_popNum = pa.popNum string/G g_popStr = pa.popStr break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End Function Make_dist_Proc(ba) : ButtonControl STRUCT WMButtonAction &ba DFREF dfsave = getdatafolderDFR() setdatafolder root:SEMS: switch( ba.eventCode ) case 2: // mouse up averagedist() break case -1: // control being killed break endswitch setdatafolder dfsave return 0 End
Indeed, I don't see any place in that code where totscanvol is filled with values. Perhaps it is in a different procedure file? Try Cmd-Shift-F to bring up the Find in Multiple Windows dialog. Turn on the checkbox to search in procedure windows, and then search for it.
By the way, it's best to use the "Insert Code Snippet" feature for code like this. If you select Igor as the language the website even colorizes the code appropriately.
March 31, 2020 at 11:29 am - Permalink
I used my admin access to edit your posting to put it into a code snippet.
March 31, 2020 at 11:31 am - Permalink
Ok, thank you!
April 6, 2020 at 01:24 pm - Permalink