#pragma rtGlobals=1 // Use modern global access method. // http://www.chm.colostate.edu:16080/bap/People_Pages/BengtSite/pdf/CSU.ipf // last modification 10/26/05 // Edited Wlength2Energy --> 10/26/05 //Edited Writenanowires --> 10/20/05 // Selected macros for CSU / Bruce Parkinson // Macros are based on the programming of A. Klein TU-Darmstadt and B. Jaeckel // [no longer] requires Knofi.ipf !! Menu "Macros" "-" submenu "CSU" "XRD" "XPS_Omicron" "XPS_Omicron_Folder" "Bias_Phi_calc" "Display1Region" "CalcAvTifArea" // Calculates the average grayscale Value of Tiff-images "WriteNanoWire" "Wlength2Energy" // Calcuates an Energy-scale out of an X-axis in [nm] a new-axis in [eV] end "-" End Macro Display1Region(regstr,regstr1) string regstr,regstr1 prompt regstr, "Region Label?" prompt regstr1, "ending?" string speclist, graphname variable numOfspec, counter=0 speclist = WaveList("*"+regstr+"*"+regstr1,";","") print speclist numOfspec = ItemsInList(speclist,";" ) if (numOfspec!=0) Display $GetStrFromList(speclist, 0, ";") as regstr Dowindow /C $regstr do counter+=1 AppendtoGraph $GetStrFromList(speclist, counter, ";") while (counter < (numOfSpec-1)) else print "No such waves: "+regstr endif End Display1Region. Proc My10Colors() : GraphStyle PauseUpdate; Silent 1 // modifying window... ModifyGraph/Z rgb[0]=(0,0,0),rgb[1]=(65280,0,26112),rgb[2]=(39168,0,31232),rgb[3]=(0,0,52224) ModifyGraph/Z rgb[4]=(0,34816,52224),rgb[5]=(0,65280,0),rgb[6]=(0,26112,0),rgb[7]=(39168,26112,0) ModifyGraph/Z rgb[8]=(52224,0,0),rgb[9]=(65280,0,0),rgb[10]=(34816,34816,34816) EndMacro Macro Bias_Phi_calc(hn,bias,Phi,show_result) variable hn=27.51,bias, Phi=4.3 string show_result prompt hn,"enter hv-setting of the spectra program (21.22+6.xx=27.xx)" prompt bias,"enter applied bias voltage [V]" prompt Phi, "Enter analyzer workfunction [eV]" prompt show_result, "Show ?",popup,"Ja;Nein" // modified ralf hunger Sept.02: integrated "Show" option from Macro BachRem silent 1; pauseupdate variable specnum, xl, xr, y_offset string graphname, begraphname, specname, bename, notestr graphname=WinName(0,1) if (cmpstr(graphname,"")==0) doalert 0,"no graphwindow" else do specname=Wavename(graphname,specnum,1) if(cmpstr(specname,"")==0) break else bename=specname+"BP" //BP=Bais and Workfunction Phi duplicate/O $specname $bename wavestats/Q $bename xl=leftx($bename)-((hn-21.22)-bias+Phi) //leftx reads out the left value of the wave"s x-value xr=pnt2x($bename,V_npnts-1)-((hn-21.22)-bias+Phi) sprintf notestr "rescaled to Bias (bias=%g) and Workfunktion (Phi=%g)", bias, Phi note $bename, notestr SetScale/I x xl,xr,"", $bename If (cmpstr(show_result,"Ja")==0) y_offset=waveoffset(specname,graphname,"y") //***Funktion aus AP-Procedures If (specnum==0) begraphname=graphname+"_BP" Display $bename as begraphname ModifyGraph zero(bottom)=1, offset($bename)={0,y_offset} SetAxis/A/R bottom Else Dowindow/F $begraphname Dowindow/C $begraphname AppendToGraph $bename ModifyGraph offset($bename)={0,y_offset} Endif Endif specnum=specnum+1 endif while(1) endif Endmacro KE2BE_rh. Macro Wlength2Energy() string popstr string /G wavelength_X, wavelength_Y PauseUpdate; Silent 1 // building window... NewPanel /W=(120,350,465,620) DrawText 40,17,"Wavelength to Energy-scale converter" PopupMenu x_axis,pos={40,27},size={103,20},proc=PopMenuProcWL,mode=1,popvalue="select",value= #"WaveList(\"*\",\";\",\"\") ",title="x_axis (nm)" //wavelength_X=popstr PopupMenu Y_axis,pos={40,62},size={103,20},proc=PopMenuProcWL,mode=1,popvalue="select",value= #"WaveList(\"*\",\";\",\"\") ",title="y_axis (nm)" Button Calc,pos={80,97},size={200,25},fColor=(2,39321,1),proc=recalc,title="Calculate Energy Scale" Button GraphWL, pos={175,40}, title="show graph",size={100,20},proc=showWLgraph DrawText 10,144,"1. Select the X- and Y-axis (wavelength)" DrawText 10,164,"2. Click on \"Show Graph\" to see the plot (Int vs Wlngth)" DrawText 10,184,"3. If the plot is right, click \"calculate Energy Scale\"" DrawText 10,204,"4. A new graph will apear with an energy scale as" DrawText 25,214,"the x-axis, which is calculated (ready to fit)" DrawText 10,234,"ATTENTION: Use the function only once for a selected" DrawText 25,244,"Y-wave, otherwise an error occurs !!" END Function PopMenuProcWL(ctrlName,popnum,popStr) : PopupMenuControl String ctrlName variable popnum String popStr SVAR wavelength_XFKT=wavelength_X, wavelength_YFKT=wavelength_Y if (strsearch(ctrlname,"x_axis",0)>-1) wavelength_xFKT=popstr print "X-Axis",wavelength_xFKT endif if (strsearch(ctrlname,"Y_axis",0)>-1) wavelength_yFKT=popstr print "Y-Axis",wavelength_yFKT endif End proc showWLgraph(ctrlName) : ButtonControl String ctrlName display /N=Showwavelength $wavelength_y vs $wavelength_x TextBox/C/N=text0/A=MC "\\Z14 Wavelength - plot" GoldenStyle("wavelength","[nm]","Zahl_Label","Intensity [arb.u.]") End Proc recalc(crtlname): bottoncontrol // recalculated a Graph with X und Y-Values a Wave with an Energy-scale string crtlname // with a calculated x-axis variable a=0 variable W_start, W_end, deltaE, xpoints, E_start, E_end variable xWL,dX // killwindow showwavelength variable Plankh=4.135667*10^(-15) // eV/S variable lightC=299792458 // m/s wavestats $wavelength_X xpoints=v_npnts W_start=V_min W_end=v_max print xpoints, W_start, W_end E_start=10^9*(Plankh*lightC)/w_start E_end=10^9*(Plankh*lightC)/w_end print E_start, E_end make /O /N=(xpoints) energy_x make /O /N=(xpoints) energy_y energy_x=(Plankh*lightC)/$wavelength_x deltaE=(E_End-E_start)/xpoints print deltaE, xpoints do xWL=10^9*(Plankh*lightC)/(E_start+a*DeltaE) energy_y[a]=interp(xWL,$wavelength_x,$wavelength_Y) a+=1 // execute the loop body while (a-1) off1 = StrSearch(oldline, ".",0) ke_st=round_dec(str2num(oldline[off1-4,strlen(oldline)]),3) off1 = StrSearch(oldline, ".", off1+2) ke_end=round_dec(str2num(oldline[off1-4,strlen(oldline)]),3) off1 = StrSearch(oldline, ".", off1+2) ke_d=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) n_scans=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) dwell=str2num(oldline[off1-4,strlen(oldline)]) //off1 = StrSearch(oldline, ".", off1+2) t_points=str2num(oldline[off1+8,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) E_pass=str2num(oldline[off1-4,strlen(oldline)]) off1=0 off1 = StrSearch(newline, "Ex=", off1+2) E_hn=str2num(newline[off1+3,strlen(newline)]) off1 = StrSearch(newline, "WF=", off1+2) Wf=str2num(newline[off1+3,strlen(newline)]) wname=filename+"_"+num2char(specnum+65) off1=strsearch(wname,".",0) wname[off1,off1]="_" //print wname wnm="OMIwave"+num2str(specnum) duplicate/O $wnm $wname killwaves $wnm //note $wname oldline note $wname newline[0,strlen(newline)-2] sprintf notestr "original data filename is %s", filename note $wname notestr sprintf notestr "original original comment line: %s", firstline // modified R. hunger 2/2/02 note $wname notestr sprintf notestr "Binding energy: %.3f - %.3f eV", ke_st, ke_end note $wname notestr sprintf notestr "excitation energy: %.3f eV ", E_hn note $wname notestr sprintf notestr "number of scans: %d", n_scans note $wname notestr sprintf notestr "time per point: %.3f sec", dwell note $wname notestr sprintf notestr "analyser pass energy: %deV", E_pass note $wname notestr sprintf notestr "analyser workfunction: %.3f eV", Wf note $wname notestr // Skalierung setscale/I x ke_st, ke_end, "", $wname print "loaded wave", wname, "from file", filename, "KE/BE=", ke_st, "-", ke_end, "hn=", E_hn scalierung=n_scans*dwell //print specnum," wie heie ich", scalierung update="$wname/=scalierung" sprintf dummyfile, update execute dummyfile specnum+=1 endif FStatus refnum //print "Filestatus : ",V_logEOF,V_filePOS if (linecount == 1) // modified R. Hunger 2/2/02 firstline = newline[0,strlen(newline)-2] endif oldline=newline while (V_logEOF>V_filePOS) FSetPos refnum,V_logEOF close refnum endmacro Macro XPS_Omicron() // modified B. Jaeckel 14.09.05: wave note silent 1; pauseupdate variable refnum, off1, off2 string pathname, filename, wname, wnm Open /T="????"/D/R/M="Select a data file" refnum off1 = 0 do off2 = StrSearch(S_Filename, ":", off1) if (off2 == -1) // no more colons ? pathname = S_Filename[0, off1-1] filename = S_Filename[off1,strlen(S_Filename)+1] break endif off1 = off2+1 while (1) //print S_Filename,"X", pathname, "X",filename newpath/Q/O loadpath, pathname LoadWave/Q/P=loadpath/G/N=OMIwave/W filename Open/Z/R/P=LoadPath refnum as filename string newline, oldline, firstline, notestr variable stra, specnum variable ke_st, ke_end, ke_d, n_scans, t_points, E_pass, E_hn variable linecount = 0 do FReadLine refnum,newline linecount += 1 if (strsearch(newline,"PE",0)>-1) off1 = StrSearch(oldline, ".",0) ke_st=round_dec(str2num(oldline[off1-4,strlen(oldline)]),3) off1 = StrSearch(oldline, ".", off1+2) ke_end=round_dec(str2num(oldline[off1-4,strlen(oldline)]),3) off1 = StrSearch(oldline, ".", off1+2) ke_d=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) n_scans=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) t_points=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) E_pass=str2num(oldline[off1-4,strlen(oldline)]) off1 = StrSearch(oldline, ".", off1+2) E_hn=str2num(oldline[off1-4,strlen(oldline)]) wname=filename+"_"+num2char(specnum+65) off1=strsearch(wname,".",0) wname[off1,off1]="_" //print wname wnm="OMIwave"+num2str(specnum) duplicate/O $wnm $wname killwaves $wnm //note $wname oldline note $wname newline[0,strlen(newline)-2] sprintf notestr "original data filename is %s", filename note $wname notestr sprintf notestr "original original comment line: %s", firstline // modified R. hunger 2/2/02 note $wname notestr sprintf notestr "kinetic energy: %.3f - %.3f eV", ke_st, ke_end note $wname notestr sprintf notestr "excitation energy: %.3f eV (without warranty)", E_hn note $wname notestr sprintf notestr "number of scans: %d", n_scans note $wname notestr sprintf notestr "time per point: %.3f sec", t_points note $wname notestr sprintf notestr "analyser pass energy: %deV", E_pass note $wname notestr // Skalierung setscale/I x ke_st, ke_end, "", $wname $wname/=n_scans $wname/=t_points // output is counts per second print "loaded wave", wname, "from file", filename, "KE=", ke_st, "-", ke_end, "hn=", E_hn specnum+=1 endif FStatus refnum //print "Filestatus : ",V_logEOF,V_filePOS if (linecount == 1) // modified R. Hunger 2/2/02 firstline = newline[0,strlen(newline)-2] endif oldline=newline while (V_logEOF>V_filePOS) FSetPos refnum,V_logEOF close refnum Endmacro Macro XRD(mode) // modified 10/04/05 string mode prompt mode, "show data ?", popup , "yes; no" variable refnum, off1, off2 string pathname, filename, wname, wnm,wmn1, filenamewoext // Einlesen Daten in Wave Open /D/R/T="TEXT"/M="Open XRD-File" refnum off1 = 0 do off2 = StrSearch(S_Filename, ":", off1) if (off2 == -1) // no more colons ? pathname = S_Filename[0, off1-1] filename = S_Filename[off1,strlen(S_Filename)+1] break endif off1 = off2+1 while (1) print S_Filename,"X", pathname, "X",filename newpath/Q/O loadpath, pathname LoadWave/Q/P=loadpath/G/N=XRD filename Open/Z/R/P=LoadPath refnum as filename string newline="", oldline="", notestr variable stra, specnum=0, specnum1=0, flag, linecount variable angle_st, angle_end, angle_d, t_points, dwell,wlength linecount = 0 specnum = -1 flag = 0 do FReadLine refnum, newline linecount +=1 // if (strsearch(newline,"ID:",0)>-1) // off1 = strsearch(oldline, "ID:",0) // wname=newline[off1+13,off1+25] // print "Filename: ",wname //endif // reads X-axis if (strsearch(newline,"Start Angle:",0)>-1) off1 = strsearch(oldline, "Start Angle:",0) angle_st=str2num(newline[off1+13,off1+15]) print "Start: ",angle_st endif if (strsearch(newline,"Stop Angle:",0)>-1) off1 = strsearch(oldline, "Stop Angle:",0) angle_end=str2num(newline[off1+12,off1+14]) print "End: ",angle_end endif // reads number of Data-points if (strsearch(newline,"Num Points:",0)>-1) off1 = strsearch(oldline, "Num Points:",0) t_points =str2num(newline[off1+12,off1+16]) print "Data-Points ",t_points endif // reads step size if (strsearch(newline,"Step Size:",0)>-1) off1 = strsearch(oldline, "Step Size:",0) angle_d=str2num(newline[off1+12,off1+16]) print "Delta: ",angle_d endif // reads scan rate if (strsearch(newline,"Scan Rate:",0)>-1) off1 = strsearch(oldline, "Scan Rate:",0) dwell=str2num(newline[off1+12,off1+20]) print "Scan Rate: ",dwell,"Deg/min" endif // reads Wavelength: if (strsearch(newline,"Wavelength:",0)>-1) off1 = strsearch(oldline, "Wavelength:",0) wlength=str2num(newline[off1+12,off1+20]) print "Wavelength: ",wlength," nm" endif //print linecount FStatus refnum //print "Filestatus : ",V_logEOF,V_filePOS while(linecount<14) killwaves XRD0 // add Wavenotenote sprintf notestr "original data filename is %s", filename note XRD1 notestr sprintf notestr "Start angle is %.3f deg", angle_st note XRD1 notestr sprintf notestr "End angle is %.3f deg", angle_end note XRD1 notestr sprintf notestr "Number of Datapoints is %d", t_points note XRD1 notestr sprintf notestr "Step size is %.3f deg", angle_d note XRD1 notestr sprintf notestr "Scan rate is %.3f deg/min", dwell note XRD1 notestr sprintf notestr "Wavelength is %.3f nm", wlength note XRD1 notestr //oldline=newline SetScale/P x angle_st,angle_d,"", XRD1 //print wname, filename string update, dummyfile if (cmpstr(mode,"yes")==0) Display XRD1 //sprintf dummyfile, update //execute dummyfile GoldenStyle("2 Theta ","[deg]","Zahl_Label","Intensity [arb.u.]") Legend/C/N=text0/J/F=2/A=MC "\\Z14\\s(xrd1) xrd1" ModifyGraph grid(bottom)=1,nticks(bottom)=10 endif update="Rename XRD1, $filename" sprintf dummyfile, update execute dummyfile changewavenames(".txt") FSetPos refnum,V_logEOF close refnum End Macro WriteNanoWire() Variable a Variable/G yposn=1 Variable/G xposn=1 Variable/G yorigin=1 Variable/G xorigin=1 Variable/G xaxis=1 Variable/G yaxis=1 Variable/G xscaled=0 Variable/G yscaled=0 Variable/G xmark =0 Variable/G ymark =0 Variable/G numpts =0 Variable/G f1 Make/D/O xarray,yarray string /G filename Variable /G wirenumber=0 ImageLoad/T=tiff PauseUpdate; Silent 1 // building window... Display /W=(10,45,820,550) filename=s_filename+"0" print filename AppendImage /G=1 $filename ModifyImage $filename ctab= {*,*,Grays,0} ModifyGraph mirror=2 SetAxis/A/R left ShowTools ControlBar 56 Button GetXY,pos={0,0},size={60,20},proc=ButtonProc,title="GetXY" ValDisplay Xorig,pos={545,0},size={75,20},title="X Origin" ValDisplay Xorig,limits={0,0,0},barmisc={0,1000},value= #"xorigin" ValDisplay yorig,pos={545,20},size={75,20},title="Y Origin" ValDisplay yorig,limits={0,0,0},barmisc={0,1000},value= #"yorigin" Button GetXYorigin,pos={60,0},size={60,20},proc=ButtonProc,title="Set Origin" Button GetXaxis,pos={120,0},size={80,20},proc=ButtonProc,title="Define Scale" ValDisplay Xax,pos={650,0},size={75,20},title="X axis" ValDisplay Xax,limits={0,0,0},barmisc={0,1000},value= #"xaxis" ValDisplay yax,pos={650,20},size={75,20},title="Y axis" ValDisplay yax,limits={0,0,0},barmisc={0,1000},value= #"yaxis" ValDisplay Xsca,pos={330,1},size={100,20},title="Scaled X",format="%2.1f" ValDisplay Xsca,limits={0,0,0},barmisc={0,1000},value= #"xscaled" ValDisplay Ysca,pos={330,20},size={100,20},title="Scaled Y",format="%2.1f" ValDisplay Ysca,limits={0,0,0},barmisc={0,1000},value= #"yscaled" SetVariable setx,pos={430,0},size={100,20},title="X marker" SetVariable setx,limits={1,15,1},value= xmark SetVariable sety,pos={430,20},size={100,20},title="Y marker" SetVariable sety,limits={1,20,1},value= ymark Button OpenFile,pos={60,20},size={60,20},proc=ButtonProc_1,title="OpenFile" Button CloseFile,pos={120,20},size={80,20},proc=ButtonProc_2,title="Close File" Button WireWrite,pos={200,0},size={80,20},proc=ButtonProc_3,title="Write Wire" //Button WriteMissWire,pos={200,20},size={80,20}, proc=ButtonProc_4,title="Write Wire II" ValDisplay wireofnumber,title="WireNumber",pos={220,25},size={100,20},format="%2.f",fsize=12,value=wirenumber Button NewFil,pos={0,20},size={60,20}, proc=ButtonProc_5,title="New File" End // Pocedure: BottonProc = "SetOrigin", "Define Scale" Requests left-click in the Image at a defined Number, e. G. 21 which // is set as X=1; Y=2 Function ButtonProc(ctrlName) : ButtonControl String ctrlName Nvar xorigin Nvar yorigin Nvar xposn Nvar yposn Nvar xaxis Nvar yaxis Nvar xscaled Nvar yscaled Nvar xmark Nvar ymark Nvar numpts Nvar f1 Wave yarray Wave xarray Variable/C mousePos String optionsStr String s if (cmpstr(ctrlName,"getXYorigin") == 0) //reads the Mousestate for "SET Origin" do s = MouseState("") if (cmpstr(s[0], "1") == 0) break endif while(1) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xorigin = real(mousePos) yorigin= imag(mousePos) endif if (cmpstr(ctrlName,"GetXY") == 0) do s = MouseState("") if (cmpstr(s[0], "1") == 0) break endif while(1) if (cmpstr(s[0], "1") == 0) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xposn = real(mousePos) yposn= imag(mousePos) xscaled=80*((xposn-xorigin)/(xaxis-xorigin)+xmark)-480-40+75 yscaled=80*((yposn-yorigin)/(yaxis-yorigin)-ymark)+320+40-5 endif endif if (cmpstr(ctrlName,"getXaxis") == 0) //reads Mousestate for "Define Scale" do s = MouseState("") if (cmpstr(s[0], "1") == 0) break endif while(1) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xaxis = real(mousePos) yaxis= imag(mousePos) endif End // "ButtonProc_1" open the CAD-file in Igor. To this file the Wirecoordinates are copied Function ButtonProc_1(ctrlName) : ButtonControl String ctrlName String /G CAD_File Nvar f1 Open/A/M="Enter file name" /T=".dc2" f1 //s_filename is the name of the CAD-File CAD_File=s_filename print CAD_File,"-File was opened" End // "ButtonProc_2" close the CAD-file Function ButtonProc_2(ctrlName) : ButtonControl String ctrlName Nvar f1 SVAR filename=CAD_File Close f1 print filename,"-File was closed" filename="" End // Function BottomProc_3 reads the information used for "Write Wire" Function ButtonProc_3(ctrlName) : ButtonControl String ctrlName Nvar xorigin Nvar yorigin Nvar xposn Nvar yposn Nvar xaxis Nvar yaxis Nvar xscaled Nvar yscaled Nvar xmark Nvar ymark Nvar numpts Nvar f1 NVAR wirenumberFKT=wirenumber Wave yarray Wave xarray Variable/C mousePos String optionsStr String s numpts=0 do s = MouseState("") if (cmpstr(s[0], "1") == 0) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xposn = real(mousePos) yposn= imag(mousePos) xscaled=80*((xposn-xorigin)/(xaxis-xorigin)+xmark)-480-40+75 yscaled=80*((yposn-yorigin)/(yaxis-yorigin)-ymark)+320+40-5 numpts =numpts +1 xarray[numpts]=xscaled yarray[numpts]=yscaled Variable t0= ticks do while( t0+30>ticks) endif //if (cmpstr(s[1], "1") == 0) if (numpts== 2) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xposn = real(mousePos) yposn= imag(mousePos) xscaled=80*((xposn-xorigin)/(xaxis-xorigin)+xmark)-480-40+75 yscaled=80*((yposn-yorigin)/(yaxis-yorigin)-ymark)+320+40-5 numpts =numpts +1 xarray[numpts]=xscaled yarray[numpts]=yscaled Variable i // writing the lines in the CAD-file //string OP_system //OP_system=Igorinfo(2) //print OP_system fprintf f1, "1 %d 20 0 0 40 0 0 0\r\n", numpts // Info: \r\n if for Windows, only \r is for Mac !! For (i=1;iticks) endif if (cmpstr(s[1], "1") == 0) optionsStr = "coords=local" mousePos = MousePosition(optionsStr) xposn = real(mousePos) yposn= imag(mousePos) xscaled=80*((xposn-xorigin)/(xaxis-xorigin)+xmark)-480-40+75 yscaled=80*((yposn-yorigin)/(yaxis-yorigin)-ymark)+320+40-5 numpts =numpts +1 xarray[numpts]=xscaled yarray[numpts]=yscaled Variable i fprintf f1, "1 %d 20 0 0 41 0 0 0\r\n", numpts For (i=1;i