-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadSESb.ipf
More file actions
2546 lines (2271 loc) · 89.1 KB
/
LoadSESb.ipf
File metadata and controls
2546 lines (2271 loc) · 89.1 KB
1
// File: LoadSESb Created: 12/99// Jonathan Denlinger, JDDenlinger@lbl.gov#pragma version=21.0514// 5/14/21 -- add SortList() also to _UpdateFolder() - why not there already?// 4/22/21 -- [BCS] accidently got removed from start of Labview-written Header in Jan 2021; // -- changed back to [BCS] in April 2021, but now also check for USER// 7/26/20 -- Assemble/Append LoadSESb_WaveCatF speed report: #/sec -> sec/pt// -- add HeaderListbox section shortcut selection popup menu// 5/2/20 -- have SummarizeFolder append _Motor_Pos.txt map file info to end of .pxt list// -- ideally want to read it in order with .pxt and skip rest of .pxt for the map// 12/20/18 Jimin Kim v3.10 add SortList() to Update/SelectFolder() to correct for out-of-order// files returned from IndexedFolder() for new Apple File System (OS>10.13)// 12/24/17 jdd v3.09 -- make simpler titlestr and fix transpose handling// 2/16/16 jdd -- comment out NewImg() link to ImageTool; tweak listbox widths// 9/4/13 jdd -- fix nselect indexing error for SummarizeVariable// 6/2/13 jdd v3.08 -- fix 1D spectrum loading to avoid 2D ImgDeglitch call// 5/24/13 jdd 3.07 -- make unit a dropdown menu selection in GetAssemblyPref()// 11/17/12 jdd -- added BinXOP to ImgResize() for faster loading with Rebin; no change here// 2/28/12 jd v3.06 add LoadSESStyle() option for processing and plotting single images upon loading// 5/23/12 jd v3.05 more header added from Labview; start header search earlier in file in ReadSEShdr // (-BE) initial default (escale=3); screen out *.dat temporary files// 1/9/12 jd v3.04 add new header read of SlitPlate, Polar, Azimuth, Temp_B, iflux, EnSlit, ExSlit// 1/10/12 add SummarizeVariable function// 11/4/11 jd v3.03 rewrite energy axis re-scaling getting written scale mode from header and values from data (not header)// increase headerw dimesion from (50,2) to (55,2) to get all info into listbox// 10/1/11 jd v3.02 change list default from "Multiple Contiguous" to "Mulitple Disjoint" -> change back to "Contiguous"// -if this is bothersome for multiple contiguous selection then can add a toggle switch option// add LUT image intensity array and Gamma adjustment variable and slider// 8/23/11 jd v3.01 expand & move header box to side of file list;// add fileListFilter string to select sublist of files// 7/6/11 tm v3.0 Add loop to load multiple files// 6/22/11 jd v2.12 Additional look for "[BCS]" start of header; check nslice=1 (incorrectly written in BCS)// 5/29/11 jd v2.11 Add Volume appedn textstring box// 5/26/11 jd v2.1 Add checkboxes for Rebin and DitherSum// 2/10/11 jdd v2.03// 4/8/10 jdd (v2.02) ReadSEShdr accomodate for increased number header lines// 2/20/08 jdd (v2.01) tweak folder summarize format// 12/10/05 jdd (v2.0) Replace FileList PopMenu with ListBox (single row) selector// -- rename many Procs with "LoadSES_" prefix // -- Add Check Version if using old panel & exercise SelectFolder // -- preliminary switch to load .dat files// 2/1/05 (v1.8) -- change ReadSEShdr to handle v1.15--> v1.2.2 "Aquisition Mode" --> "Acquisition Mode"// and fix original error of FReadLine/N=1000 (multiple regions data files) // added IT button for ImageTool instead of global preference// 6/18/04 -- changed ImgResize option to conform to /O/D changes// 9/27/03 (v1.7) added filesize to Summarize folder// -- added image size rebin to import// 2/21/03 jdd moved version # from text box to value display in control bar; add GroupBoxes// add OS specific load panel resize// 9/11/02 jdd convert all data to Single Precision (FP32); new 1.1.5 SES software stores// transmission as UINT32 and Angular as UINT16// 12/29/01 jdd (v1.5) improved filelist updating when switching folders; // changed Cts/Sec to also divided by # energy points; added kCounts & kCts/Sec// integrate SESpreview into Load_SESb_Panel// 5/17/01 er (v1.4) convert "-" to "_" in extractname()for new version Scienta software naming// 2/18/01 jdd (v1.3) added datafolder list memory; added dwell to front panel// 9/22/00 jdd (v1.2) added prompt for Z scale input for 3D data sets// -- added Summarize folder to preview popup// 6/10/00 jdd (v1.1) add Preview data option including pipeline to ImageTool // 6/00 jdd added balloon help to menus; added append image to volume function#pragma TextEncoding = "MacRoman"#pragma rtGlobals=1 // Use modern global access method.#include "List_util"#include "wav_util" // WriteMod(), ExtractName()#include "Image_Util" //ImgResize( ) #include "Volume" // appendimg (to volume), VolResize//#include "LoadSESdat123" // not needed anymore#include "progresswindow"// SES-100 Binary File structure (v1.1.5) // -- saves *.pxt file in Igor packed experiment (template) format// contains a single binary wave (for a single region sequence)// ** Wavenote contains header information:// Wave: VB_Fixed// Type: FP64 Size: 329120 bytes// Dim[0]:411 Units:eV Start: 88.7085 Delta: 0.00876042// Dim[1]:100 Units:deg Start: -7.86684 Delta: 0.150403// Note: // --> [SES] added in v1.2.2// --> Version=1.2.2// Instrument=SES 2002-567// Location=HERS// User=Jonathan// Sample=UGe2// Comments=// --> (new blank line in v1.2.2)// Date=2/11/02// Time=4:02:39 AM// Detector Channels=471// Region Name=VB_Fixed// Excitation Energy=92// Energy Scale=Kinetic// Aquisition Mode=Fixed --> Acquisition Mode (v1.2.2)// --> Center Energy = (new line in v1.2.2)// Low Energy=88.4480753586606// High Energy=92.5519246413394// Energy Step=0.00876041652087167// Step Time=30// Detector First X-Channel=30// Detector Last X-Channel=440// Detector First Y-Channel=160// Detector Last Y-Channel=459// Number of Slices=100// Lens Mode=Angular// Pass Energy=50// Number of Sweeps=4// EndSES --> blank line or "[Run Mode Information" in v1.2.2// --> (increase number of lines and text block reordering in v1.2.5)// e.g. "Instrument=" nows comes after "Region Name="// [SES]// Version=1.2.5// Region Name=Test10eV// Lens Mode=Transmission// Pass Energy=10// Number of Sweeps=1// Excitation Energy=0// Energy Scale=Kinetic// Acquisition Mode=Fixed// Energy Unit=Kinetic// Center Energy=10// Low Energy=9.57739890096339// High Energy=10.4226010990366// Energy Step=0.000795110252185523// Step Time=667y// Detector First X-Channel=1// Detector Last X-Channel=1064// Detector First Y-Channel=1// Detector Last Y-Channel=1000// Number of Slices=250// File=C:\Program Files\SES 1.2.5\Factory\Bldg7\Test0002.pxt// Sequence=C:\Program Files\SES 1.2.5\Sequences\factory.seq// Spectrum Name=Test10eV// Instrument=R8000-8MS203// Location=Bldg7// User=Denlinger// Sample=AngleTestDevice// Comments=// Date=4/5/2010// Time=4:46:58 PM// Time per Spectrum Channel=1.334// [Run Mode Information]//Contents://Proc LoadSES(disp, hv, wf, en, cts)//Fct/T ReadSESb()//Fct/T ReadSESHdr(fpath, fnam)//Fct NextBlockPosSES(file, blocksize) -- not used//Fct/T ExtractNameB( filenam, option, numchar )//Proc LoadSESb_ShowInfo(wvn, opt)//Fct/T SESInfoB( wv, opt )//Macro AddSESTitleB( Sample, filnum, Polar, Elev, Epass, WkFct, hv )//Proc SummarizeSESLibrary()//Proc SES_XPS_Style(xlabel, ylabel) : GraphStyle//Proc GetZscale( st, inc, unit )//Proc LoadSESb_ShowPanel()//Wndw Load_SES() : Panel//Proc SelectLibSES(ctrlName) : ButtonControl//Proc LoadSESb_SelectFile(ctrlName,popNum,popStr) : PopupMenuControl//Proc LoadSESb_SetPop(ctrlName,popNum,popStr) : PopupMenuControl//Proc LoadSESb_SetVar(ctrlName,varNum,varStr,varName) : SetVariableControl//Proc PlotSES(ctrlName) : ButtonControl//Proc SetPreview(ctrlName,popNum,popStr) : PopupMenuControl//Wndw SESpreview() : Graphmenu "Plot" "-" "Load SES Panel!"+num2char(19), LoadSESb_ShowPanel() help={"Show GUI Panel for automated loading SES data (binary Igor .pxt files)"} "Summarize SES Folder", LoadSESb_SummarizeFolder("") help={"Create a notebook with tabular header info from a folder of data"} "Summarize SES Variable", LoadSESb_SummarizeVariable() help={"Extract header variable into array"} "Load Binary SES file", LoadSESb() help={"Load & plot single SES data file"} "Append SES spectrum/`", LoadSESb(root:SES:dscale, root:SES:escale, root:SES:hv_, root:SES:wfct, root:SES:angoffset1, root:SES:angoffset2, root:SES:nametyp, root:SES:namenum, 2) help={"Load SES data file & append spectrum to top graph"} "Show SES info", LoadSESb_ShowInfo() help={"Show table of header info for specified data in memory"} "Add SES Graph title", AddSEStitleB() help={"Create customized title annotation for top graph"}endProc PlotSESb_prefb(ctrlName) : ButtonControl // String ctrlName PlotSESb_prefs() string/G root:SES:wvnam=root:SES:skind[0]+ExtractName( root:SES:filnam, root:SES:nameopt)EndProc PlotSESb_prefs( namopt, dscal, escal, xscal, imgtool)//------------------------ string namopt=StrVarOrDefault("root:SES:nameopt","/B=-3") variable dscal=NumVarOrDefault("root:SES:dscale",6) variable escal=NumVarOrDefault("root:SES:escale",3) variable xscal=NumVarOrDefault("root:SES:xscale",2) variable imgtool=NumVarOrDefault("root:SES:autoload",1) prompt namopt, "Wave Naming [/B=n/E/U/P=prefix/S=suffix]" prompt dscal, "Data intensity scaling", popup "Counts;kCts;Mcts;Cts/Sec;kHz;MHz" prompt escal, "Energy Scale", popup "KE;BE; -BE" prompt xscal, "Axis scaling", popup "Y vs X;Y(x)" prompt imgtool, "Preview", popup "Standard;2D/3D data to ImageTool" String curr= GetDataFolder(1) SetDataFolder root:SES: variable/G dscale=dscal, escale=escal, xscale=xscal, autoload=imgtool string/G nameopt=namopt SetDataFolder $currendFunction LoadSESb_Prefs(ctrlName) : ButtonControl//------------------------ string ctrlName string namopt=StrVarOrDefault("root:SES:nameopt","/B=-3") variable dscal=NumVarOrDefault("root:SES:dscale",6) variable escal=NumVarOrDefault("root:SES:escale",3) variable xscal=NumVarOrDefault("root:SES:xscale",2)// variable imgtool=NumVarOrDefault("root:SES:autoload",1) string eshiftw=StrVarOrDefault("root:SES:EF_ShiftWave","") string acorrfldr=StrVarOrDefault("root:SES:AngCorr_fldr","") string gstyle=StrVarOrDefault("root:SES:GraphStyle","") string color_table=StrVarOrDefault("root:SES:ClrTable","") prompt namopt, "Naming [/B=n/E/U/P=pre/S=suffix]" prompt dscal, "Data intensity scaling", popup "Counts;kCts;Mcts;Cts/Sec;kHz;MHz" prompt escal, "Energy Scale", popup "KE;BE; -BE" prompt xscal, "Axis scaling", popup "Y vs X;Y(x)"// prompt imgtool, "Preview", popup "Standard;2D/3D data to ImageTool" prompt eshiftw, "EF shift wave *_e", popup, WaveList("*_e", ";", "DIMS:1") prompt acorrfldr, "Angle correction folder corr_*", popup, FolderList("corr_*", ";", "root:") prompt gstyle, "Graph style proc *_Style", popup, MacroList("*Style", ";", "KIND:1") prompt color_table, "Output Color Table", popup, CTnamelist(2) DoPrompt "Preferences,", namopt, dscal, escal, xscal, eshiftw, acorrfldr, gstyle, color_table String curr= GetDataFolder(1) SetDataFolder root:SES: variable/G dscale=dscal, escale=escal, xscale=xscal //, autoload=imgtool string/G nameopt=namopt string/G EF_Shiftwave=eshiftw, AngCorr_fldr=acorrfldr string/G GraphStyle=gstyle, ClrTable=color_table SetDataFolder $currendProc LoadSESb_CheckBox(ctrlName,checked):CheckBoxControl//----------------- String ctrlName Variable checked if (stringmatch( ctrlName, "SelectAll") ) root:SES:fileSelectw[][0][0] = 1 CheckBox SelectAll value=0 endif if (stringmatch( ctrlName, "checkCTinvert")) ModifyImage data2D ctab= {*,*,Grays,checked} endif if (stringmatch( ctrlName, "checkTranpose")) // perform imagetranspose MatrixTranspose root:SES:data2D // also transpose immediately endif End//Proc LoadSESb( cts, escal, hv, wf, angoff1, angoff2, namtyp, namnum, plotopt)Proc LoadSESb( cts, escal, hv, plotopt)//------------------------ variable plotopt, cts=NumVarOrDefault("root:SES:dscale",1) //variable angoff1=NumVarOrDefault("root:SES:angoffset1",NaN), angoff2=NumVarOrDefault("root:SES:angoffset2",NaN) variable hv=NumVarOrDefault("root:SES:hv_",NaN) //, wf=NumVarOrDefault("root:SES:wfct",0) variable namtyp=NumVarOrDefault("root:SES:nametyp",1), namnum=NumVarOrDefault("root:SES:namenum",1) variable escal=NumVarOrDefault("root:SES:escale",1) prompt cts, "Intensity option", popup "Counts;kCts; Cts/Sec;kCts/Sec" prompt plotopt, "Spectrum plot option", popup "Display;Append" //prompt angoff1, "Sample Angle(NaN for no offset):" //prompt angoff2, "Detector Angle Offset (NaN for no offset):" prompt hv, "Photon Energy (eV) [NaN=leave as KE scale]" //prompt wf, "Work Function (eV) [4.1, SES, 4/97]:" //prompt namtyp, "Wave Naming (derived from filename):", popup "Prefix only;Remove . ;Convert . to _;Extension only" //prompt namnum, "Number of prefix characters", popup "all;2;3;4;5;6;7;8" prompt escal, "Energy Scale interpretion", popup "KE;BE" variable dum=1 silent 1; pauseupdate String curr= GetDataFolder(1) NewDataFolder/O/S root:SES //Variable/G angoffset1=angoff1, angoffset2=angoff2, hv_=hv, wfct=wf, nametyp=namtyp, namenum=namnum, dscale=cts, escale=escal Variable/G hv_=hv, dscale=cts, escale=escal SetDataFolder curr// string xlbl="Kinetic Energy (eV)", ylbl="Intensity (arb)"//Load from binary files string base// string base=ReadSESb(1-(plotopt<0))// if (strlen(base)==0)// abort // endif //base=ExtractNameB( base, namtyp, namnum ) // need to put in loop for multiple regions //base=root:SES:skind[0]+base //print "base=", base //base=WaveNameSES( base ) //print "base=", base //Duplicate/O root:SES:infowav $(base+"_info") base = root:SES:wvnam// variable doimage=(disp==1)+(disp==2), dospectra=(disp==2) string dwn, xwn, ywn=base+"_y" //duplicate/o root:SES:ANGLE $ywn string titlestr, wlst, winnam, xlbl, ylbl variable nx, ny=root:SES:nslice, nregion=root:SES:nregion string eunit, yunit variable ireg=0, eoff, yoff variable nfiles variable Ndim string loadwv// DO // DO not allow multiple region loading for now - need to eliminate variable declarations inside nx=root:SES:enpts[ireg]// if (nregion==1) dwn=base// else// dwn=base+num2str(ireg)// endif //if (cts<4) IF (root:SES:iDitherSum) print "DitherSum: ", LoadSESb_DitherSum() loadwv="root:SES:DitherSum" ELSE curr=GetDataFolder(1)// SetDataFolder root:SES:Load// nfiles=ItemsInList( wavelist("*",";","")) nfiles = CountObjects("root:SES:Load", 1)// SetDataFolder $curr // get last wave in data folder in case previous one couldn't be purged loadwv="root:SES:Load:"+PossiblyQuoteName(GetIndexedObjName("root:SES:Load",1 ,nfiles-1 )) ENDIF //print loadwv, "///", dwn // variable nx0=DimSize( $dwn, 0), ny0=DimSize( $dwn, 1), nz=DimSize( $dwn, 2) //ny0=SelectNumber( ny0==0, ny0, 1) Ndim=WaveDims($loadwv) if (Ndim==2) //check for two dimensional but only 1 column if (DimSize($loadwv,1)==1) Ndim=1 endif endif //print "Ndims:", ndim IF( Ndim==1 ) duplicate/o $loadwv $("root:"+dwn) titlestr=dwn ELSE IF (Ndim==2) // also incorporate DeGlitch() IF (root:SES:iRebin) titlestr=ImgResize( $loadwv, root:SES:srebin, "/R/D=root:"+dwn ) ELSE titlestr=ImgResize( $loadwv, "1,1", "/R/D=root:"+dwn ) ENDIF ImgDeglitch( $("root:"+dwn),"/O") ELSE //Ndim==3 titlestr=VolResize( $loadwv, root:SES:srebin+",1", "/R/D=root:"+dwn ) // ImgDeglitch( $("root:"+dwn), opt) ENDIF ENDIF //if (wavetype($("root:"+dwn))==96) //96=UINT32, 80=UINT16 //Redimension/D $("root:"+dwn) //convert Unsigned INT32 to FP64 (double precision) // print "dwn:", dwn Redimension/S $("root:" + dwn) //convert Unsigned INT32 to FP32 (single precision) //endif //else // dwn+="flux" // duplicate/o $("root:SES:FLUX"+num2str(ireg)) $dwn //endif // (optional) rescale data to desired format //---------------------------- ylbl=StringFromList( cts-1, "Counts;kCts;Cts/sec/chan;kHz/chan" ) if (cts>=3) //$dwn/=(root:SES:dwell[ireg]*root:SES:nsweep[ireg]*root:SES:enpts[ireg]) $dwn/=(root:SES:dwell[ireg]*root:SES:nsweep[ireg]*(root:SES:Xend[ireg]-root:SES:Xstart[ireg]+1)) endif if (mod(cts,2)==0) // cts=2 or 4 => kilo- $dwn/=1000 endif // *** Do Not trust header info for data size -- nx(enpts) and ny(nslice) // Not reliable when written from BCS program; ok from SES program // Extract size info from actual data object variable nx0=DimSize( $dwn, 0), ny0=DimSize( $dwn, 1), nz=DimSize( $dwn, 2) // ny0=SelectNumber( ny0==0, ny0, 1) //print nx, nx0, ny, ny0 // if (nx!=nx0) // print "nx discrepancy: hdr=", nx, ", data=", nx0 // nx=nx0 // endif if (ny0>0) if (ny!=ny0) // print "ny discrepancy: hdr=", ny, ", data=", ny0 ny=ny0 endif endif // (optional) offset x-scale to BE using specified photon energy & work function //--------------------------------- eoff=0 //if (numtype(wf)==0) // skip if NaN or INF // eoff=-wf //endif variable mode=1 xlbl=StringFromList( escal-1, "Kinetic Energy (eV);E-E\BF\M (eV);E-E\BF\M (eV)" ) //IF(mode==1) // File saved with KE values even if acquired in BE mode?? Not anymore 11/02 // *** Do Not trust header info for Start and end energy -- estart[ireg], estep[ireg] // Not reliable when written from BCS program; ok from SES program // Extract energy scaling info from actual data object variable estart0=DimOffset( $dwn, 0), einc0=DimDelta( $dwn, 0), eend0 eend0=estart0+nx0*einc0 // *** Data in *.pxt can be saved with either KE or +BE scales -- need to determine this first? // Axis Units is "eV" for both KE and BE scaling, so use header "Energy Scale" // -- not previously extracted from header? escal/escale variable is the preferred destination scaling // so add sescale variable to ReadSEShdr() // destination preference: escal= 1 (KE), 2 (BE), 3 (-BE) // Any circumstance to add work function to eoff? Would need to add SES EOFF into written header if (stringmatch(root:SES:sescale, "Kinetic")) // if (escal==1) => no change if (escal==2) SetScale/P x estart0-hv, einc0, "", $dwn endif if (escal==3) SetScale/P x -estart0+hv, -einc0, "", $dwn endif else if (stringmatch(root:SES:sescale, "Binding")) if (escal==1) SetScale/P x hv-estart0, -einc0, "", $dwn endif // if (escal==2) => no change, already +BE if (escal==3) SetScale/P x -estart0, -einc0, "", $dwn endif endif endif // 12/17 Provide more useful titlestr of Name: Photon energy and Polarization if (stringmatch(titlestr, "toot:")==1) titlestr = titlestr[5,strlen(titlestr)-1] endif // get number of photon energy header variable (57) variable indx = whichListitem("BL Energy", root:SES:headerVarLst) variable BLene=str2num(root:SES:headerw[indx][1]) indx = whichListitem("EPU POL", root:SES:headerVarLst) variable iPOL=str2num(root:SES:headerw[indx][1]) string sPOL=StringFromList( iPOL+1, "RC;LH;LC;LV" ) titlestr = dwn+": "+num2str(BLene)+sPOL // add to wavenote the offset //string txtstr=num2str(root:SES:Epass[ireg])+root:SES:skind[0]+(root:SES:smode[0])[0] string txtstr=root:SES:infowav[1] //[0] //print txtstr //Note/K $dwn //Note $dwn, num2str(eoff)+",0,1,0,0.5,0,"+num2str(angoff1)+","+txtstr// WriteMod($dwn, eoff, 0, 1, 0, 0.5, 0, hv, txtstr) IF (ny==1) // single cycle: plot spectra only redimension/N=(nx0) $dwn // remove column dimension if (abs(plotopt)==1) display $dwn //y vs x option? SES_XPS_Style( xlbl, ylbl) else DoWindow/F $StringFromList(0, WinList("!*SES*", ";", "Win:1")) append $dwn DoWindow/F Load_SESb_Panel //helps for double-clicking when appending endif ELSE IF (nz==0) // 2D data set ylbl="Det. Angle (deg)" // (optional) offset y-scale to specified center value //------------------------------------ //if ((numtype(angoff2)==0)*(numtype(angoff2)==0)) // skip if NaN or INF // ylbl="Sample Angle (deg)" // yoff=angoff1-angoff2 //else // ylbl="Analyzer Angle (deg)" // yoff=0 //endif //SetScale/P y root:SES:vstart-yoff, root:SES:vinc, "", $dwn //titlestr=ImgResize( $dwn, root:SES:srebin, "/R/O" ) //print titlestr //titlestr=dwn+": "+num2str(nx)+"x"+num2str(ny)+"="+num2str(nx*ny) ELSE // 3D data set GetZscale() // popup dialog SetScale/P z root:SES:zstart, root:SES:zinc,root:SES:zunit, $dwn //titlestr=dwn+": "+num2str(nx)+"x"+num2str(ny)+"x"+num2str(nz) //titlestr=VolResize( $dwn, root:SES:srebin+",1", "/R/O" ) ENDIF //print dwn if (abs(plotopt)==1) DoWindow/F $(dwn+"_") if (V_flag==0) display; appendimage $dwn Textbox/N=title/F=0/A=MT/E titlestr ModifyImage $dwn ctab= {*,*,YellowHot,root:SES:iCTinvert} ModifyGraph margin(right)=10 DoWindow/C $(dwn+"_") if (nz>0) //3D Vol_ControlBar() else endif else Textbox/C/N=title/F=0/A=MT/E titlestr Label bottom xlbl endif if (root:SES:iTranspose) // Transpose print "transpose" MatrixTranspose $dwn endif Label left SelectString(root:SES:iTranspose, ylbl, xlbl) Label bottom SelectString(root:SES:iTranspose, xlbl, ylbl) if (escal==2) // reverse axis direction for +BE SetAxis/A/R bottom else SetAxis/A bottom endif // Apply Style macro for plotting and processing (transpose, shift, etc.) if (root:SES:iApplyStyle) // reverse axis direction for +BE //LoadSESStyle( dwn ) // execute $Graphstyle+"()" Img_Style() CTmake( $dwn, "/CT=41/gamma=1/P") endif else if (abs(plotopt)==2) // Append Image means redimension image/vol array AppendVol(root:SES:appendwvn , dwn ) Killwaves/Z $dwn else //no displau, e.g. first file load for a VolAppend endif endif ENDIF// ireg+=1// WHILE( ireg<nregion) //print SESInfoB($base,0) //DeleteWaveList( S_Wavenames )endFunction/T ReadSEShdr(fpath, fnam)//=================// read SES binary file header (actually ASCII text at the end)// saves values in root:SES folder variables string fpath, fnam variable debug=0 // programming flag Variable file wave/T headerw = root:SES:headerw NewDataFolder/O/S root:SES //SetDataFolder root:SES: String/G filnam=fnam, filpath=fpath variable/G nregion=1 //variable/G kind variable/G vstart=0, vinc=1, nslice=1, filesize=1 string/G skind string/G sheader="" string/G sescale="Kinetic" // added 11/04/11 string sline //, sheader Open/R file as filpath+filnam FStatus file if (debug) print S_Filename, ", numbytes=", V_logEOF endif // -- get number of regions //FReadLine file, sline FReadLine/N=1000 file, sline //print strlen(sline) if (strsearch(sline, "[Info]",0)>=0) FReadLine file, sline //print StringByKey( "Number of Regions", sline[0,strlen(sline)-1], "=") nregion=str2num( StringByKey( "Number of Regions", sline, "=" ) ) //[0,strlen(sline)-2] // Not sure if this variable exists or is correct // nregion = DountObjects(:root:SES:Load", 1) // after ReadSESb() else nregion=1 endif // ----- Read region info from [REGION #] blocks ------- //, iEp, Epass, mode //variable/G estart, eend, estep, dwell, nsweep variable/G hv_ make/o/T/n=10 smode make/o/T/n=10 AcqMode, LensMode make/o/n=10 iEp, Epass, mode, estart, eend, estep, dwell, nsweep, enpts WAVE/T smode=smode WAVE iEp=iEp, mode=mode, estart=estart, eend=eend, estep=estep, dwell=dwell, nsweep=nsweep, enpts=enpts WAVE Xstart=Xstart, Xend=Xend, Ystart=Ystart, Yend=Yend// added for Merlin Beamline WAVE/T AcqMode=AcqMode, LensMode=LensMode variable/G SlitPlate, Polar, Azimuth, Temp_B, iflux, EnSlit, ExSlit NVAR SlitPlate=SlitPlate, Polar=Polar, Azimuth=Azimuth, Temp_B=Temp_B NVAR iflux=iflux, EnSlit=EnSlit, ExSlit=ExSlit// added for Variable Summary string/G headerVarLst, headerVarStr SVAR headerVarLst=headerVarLst, headerVarStr=headerVarStr variable/G headerVarIndex NVAR headerVarIndex=headerVarIndex // Jump to near the end & then search for text FSetPos file, V_logEOF-1500 //increase from 1300 to 1500, 5/23/12 //increase from 900 to 1300, 7/12/11 // increase from 600 to 900, 4/8/10 variable ii=0, val, kk=0 DO //-- find Region ii+1 start variable jj=0 DO FReadLine file, sline //if (strsearch(sline, "[Region "+num2str(ii+1)+"]",0)>=0) // if (strsearch(sline, "Location=",0)>=0) // 4/8/10 new header starts with [BCS] search text // if ( (strsearch(sline, "[SES]",0)>=0)+(strsearch(sline, "[BCS]",0)>=0) ) // Jan 2021 Header now starts with "USER" line instead of [BCS] if ( (strsearch(sline,"[SES]",0)>=0)+(strsearch(sline,"[BCS]",0)>=0)+(strsearch(sline,"USER",0)>=0) ) // print "r", jj, sline break endif //print "r", jj, sline jj+=1 WHILE(jj<1000) //FStatus file// print V_logEOF, V_FilePos, V_logEOF-V_FilePos, jj //-- load header lines into string, and into text wave headerVarLst="" jj=0 kk=0 DO FReadLine file, sline if(strLen(sline)>=2) sheader+=sline[0,strlen(sline)-2]+";" headerVarLst+=StringFromList( 0, sline[0,strlen(sline)-2], "=")+";" headerw[kk][0] = StringFromList( 0, sline[0,strlen(sline)-2], "=") headerw[kk][1] = StringFromList( 1, sline[0,strlen(sline)-2], "=") kk+=1 endif jj+=1 WHILE(jj<72) //increase from 66, 7/9/12 //increase from 35, 7/12/11 // increase from 25, 4/8/10 //print sheader //-- extract variables from header keyword list smode[ii]=StringByKey("Aquisition Mode", sheader, "=")+StringByKey("Acquisition Mode", sheader, "=") sescale=StringByKey("Energy Scale", sheader, "=") // added 11/04/11 AcqMode[ii]=StringByKey("Acquisition Mode", sheader, "=") LensMode[ii]=StringByKey("Lens Mode", sheader, "=") skind=SelectString( stringmatch( skind[0], "T"), skind, "Trans") // smode[ii]=StringByKey("Aquisition Mode", sheader, "=") estart[ii]=str2num( StringByKey("Low Energy", sheader, "=") ) eend[ii]=str2num( StringByKey("High Energy", sheader, "=") ) estep[ii]=str2num( StringByKey("Energy Step", sheader, "=") )*sign(eend[ii]-estart[ii]) nsweep[ii]=str2num( StringByKey("Number of Sweeps", sheader, "=") ) dwell[ii]=str2num( StringByKey("Step Time", sheader, "=") ) //*nsweep[ii] Xstart[ii]=str2num( StringByKey("Detector First X-Channel", sheader, "=") ) Xend[ii]=str2num( StringByKey("Detector Last X-Channel", sheader, "=") ) Ystart[ii]=str2num( StringByKey("Detector First Y-Channel", sheader, "=") ) Yend[ii]=str2num( StringByKey("Detector Last Y-Channel", sheader, "=") ) Epass[ii]=str2num( StringByKey("Pass Energy", sheader, "=") ) nslice=str2num( StringByKey("Number of Slices", sheader, "=") ) filesize=round(V_logEOF/1000) hv_=str2num( StringByKey("Excitation Energy", sheader, "=") ) // new additions to Merlin ARPES header SlitPlate=str2num( StringByKey("Slit Plate", sheader, "=") ) Polar=str2num( StringByKey("Polar", sheader, "=") ) Azimuth=str2num( StringByKey("Azimuth", sheader, "=") ) Temp_B=str2num( StringByKey("Temperature Sensor B", sheader, "=") ) iflux=str2num( StringByKey("Mesh Current", sheader, "=") ) EnSlit=str2num( StringByKey("Entrance Slit", sheader, "=") ) ExSlit=str2num( StringByKey("Exit Slit", sheader, "=") ) headerVarStr=StringByKey( StringFromList( headerVarIndex-1, headerVarLst), sheader, "=") enpts[ii]=round((eend[ii]-estart[ii])/estep[ii]+1) //smode[ii]=StrFromList("Fixed;Swept;Stepped", mode[ii], ";") if (debug) print ii,": E: start, stop, step, Np, dwell, nsweep, mode, Ep=", estart[ii], eend[ii], estep[ii], enpts[ii], dwell[ii], nsweep[ii], smode[ii], Epass[ii] endif ii+=1 WHILE(ii<nregion) Close file string/G smode0=smode[0] //abort //--- write info wave if (nregion>1) make/T/o/n=(18,nregion) infowav else make/T/o/n=(18) infowav endif //infowav={filnam, skind, smode,"hv","slits","Polar",num2str(Ep),"Slit#",num2tr(Estart) //string/G smode0=smode[0] variable slen ii=0 DO infowav[0][ii]=filnam[0,strlen(filnam)-5] //infowav[1][ii]=skind; infowav[2][ii]=smode[ii]// infowav[1][ii] = num2str(Epass[ii])+(skind[ii])[0]+(smode[ii])[0] slen=strlen( LensMode[ii] ) infowav[1][ii] = num2str(Epass[ii])+(LensMode[ii])[0]+(LensMode[ii])[slen-2, slen-1]+(AcqMode[ii])[0]// infowav[2][ii] ="#" infowav[2][ii] =num2str(round(2*SlitPlate)/2) // round to nearest 0.5 infowav[2][ii]+=SelectString( mod(round(SlitPlate),2)==0, "||", "))") // Odd=||, Even=)) infowav[3][ii]=num2str(round(10*hv_)/10); // infowav[4][ii]="RP"; infowav[4][ii]=num2str(round(EnSlit))+"/"+num2str(round(ExSlit))// infowav[5][ii]="Theta"; infowav[6][ii]="Phi"; infowav[5][ii]=num2str(round(10*Polar)/10) infowav[6][ii]=num2str(round(10*Azimuth)/10) infowav[7][ii]=num2str(round(10*Temp_B)/10) infowav[8][ii]=num2str(Estart[ii]); infowav[9][ii]=num2str(Eend[ii]); infowav[10][ii]=num2str(1E-4*round(1E4*Estep[ii])) infowav[11][ii]=num2str(1E-3*round(1E3*dwell[ii])/1E3) // convert msec to sec infowav[12][ii]=num2str(nsweep[ii]) infowav[13][ii]=num2str(Ystart[ii]); infowav[14][ii]=num2str(Yend[ii]); infowav[15][ii]=num2str(nslice) infowav[16][ii]=num2str(filesize)+"K"// infowav[17][ii]=StrFromList("no;yes",iflux,";") infowav[17][ii]=num2str(iflux) ii+=1 WHILE(ii<nregion) SetDataFolder root: return filnamEndFunction/T ReadSESb(idialog)//=================// read SES binary file// determines the number cycles (angle, space) and number of regions (per cycle)// saves values in root:SES folder variables variable idialog variable debug=0 // programming flag //Variable file SVAR filpath=root:SES:filpath, filnam=root:SES:filnam NewDataFolder/O/S root:SES:Load KillWaves/A/Z // purge before loading new //variable numLoadw=CountObjects("root:SES:Load", 1) //string wvlst=GetIndexedObjName("root:SES:Load",1 ,0 ) string file_path=filpath if (idialog>0) variable file Open/D/R/T="????" file //open file dialog only filnam=S_filename //print S_filename // extract filpath from full file name // and return short filename for wave renaming string delim=":" //"\:"[cmpstr(IgorInfo(2), "Macintosh")==0] variable nch=strlen(filnam), jj jj=nch-1 DO if (cmpstr( filnam[jj], delim)==0) break endif jj-=1 WHILE( jj>0) file_path=filnam[0, jj] filnam=filnam[jj+1, nch-1] //print filpath, "// ", filnam endif LoadData/O/Q file_path+filnam SetDataFolder root: return filnamEndFunction NextBlockPosSES(file, blocksize) //not currently//===================== variable file, blocksize variable blocknum FStatus file return blocksize*ceil(V_filePos/blocksize) EndFunction/T ExtractNameB( filenam, option, numchar )//==================// return substring from DOS 8.3 filename acoording to option// 1=prefix only; 2=remove . ; 3=convert . to _; 4=extension only// 'numchar' specifies the # of prefix characters to use// if numchar <0, interpret as Last N characters of prefix string filenam variable option, numchar string prefix="", suffix="" //variable nc=strlen(filenam) variable ipd=strsearch(filenam,".",0) if (ipd<0) //no period found ipd=strlen(filenam) prefix=filenam option=1 else prefix=filenam[0, ipd-1] suffix=filenam[ipd+1,strlen(filenam)-1] endif if (numchar==1) // all numchar=ipd endif prefix=SelectString( numchar<0, prefix[0, numchar-1], prefix[ipd+numchar, ipd-1]) if (option==1) suffix="" endif if (option==3) prefix=prefix+"_" endif if (option==4) prefix="" endif //return prefix+suffix //string start=prefix+suffix, answer="" //variable ii=0,lim=strlen(start) // do //new scienta software version: convert "-" in filename to "_" // answer+=SelectString( cmpstr(start[ii],"-")==0, start[ii], "_") // ii+=1 //while(ii<lim) //new Scienta software version: convert "-" in filename to "_" string answer=prefix+suffix variable ihyphen=strsearch(answer,"-", 0) //works for only one occurence of "-" if (ihyphen>=0) answer[ihyphen,ihyphen]="_" endif return answerEndProc NamingPrefsSES(ctrlName) : ButtonControl String ctrlName WaveNamePrefsSES( )EndProc WaveNamePrefsSES( prefx, namtyp, namnum)//------------------------ string prefx=StrVarOrDefault("root:LOOM:prefix","") variable namtyp=NumVarOrDefault("root:SES:nametyp",1), namnum=NumVarOrDefault("root:SES:namenum",3) prompt prefx, "Manual Wave Name prefix" prompt namtyp, "Wave Naming (derived from filename):", popup, "Full Prefix only;First N prefix characters;Last N prefix characters;Manual prefix only;Extension only;Remove . ;Convert . to _;" prompt namnum, "Number of prefix characters", popup, "1;2;3;4;5;6;7;8" silent 1; pauseupdate String curr= GetDataFolder(1) NewDataFolder/O/S root:SES string/G prefix=prefx Variable/G nametyp=namtyp, namenum=namnum SetDataFolder curr root:SES:filnam=root:SES:filnam // prompt wvnam global updateEndFunction/T WaveNameSES( filenam )//==================//Options:// prefix, "Wave Name prefix"// namtyp, "Full Prefix only;First N prefix characters;Last N prefix characters;Extension only;Remove . ;Convert . to _;"// namnum, "Number of prefix characters", popup, "1;2;3;4;5;6;7;8" string filenam //SVAR prefix0=root:SES:prefix SVAR skind=root:SES:skind NVAR nametyp=root:SES:nametyp, namenum=root:SES:namenum //print skind, nametyp, namenum string prefix="", ext="" //prefix0=skind[0] //print prefix0 variable ipd=strsearch(filenam,".",0) if (ipd<0) //no period found ipd=strlen(filenam) prefix=filenam ext="" else prefix=filenam[0, ipd-1] ext=filenam[ipd+1,strlen(filenam)-1] endif //string basenam=prefix0, wvnam string basenam=skind[0], wvnam if (nametyp==1) basenam+=prefix endif if (nametyp==2) basenam+=prefix[0,namenum-1] endif if (nametyp==3) basenam+=prefix[ipd-namenum, ipd-1] endif if (nametyp==4) basenam+=ext endif if (nametyp==5) basenam+=prefix+ext endif if (nametyp==6) basenam+=prefix+"_"+ext endif variable ihyphen=strsearch(basenam,"-", 0) //works for only one occurence of "-" if (ihyphen>=0) basenam[ihyphen,ihyphen]="_" endif return basenamEndProc GetZscale( st, inc, unit )//----------------- variable st=NumVarOrDefault("root:SES:zstart",0), inc=NumVarOrDefault("root:SES:zinc",1) string unit=StrVarOrDefault("root:SES:zunit","polar") prompt st, "Z start value" prompt inc, "Z increment" prompt unit, "Z-axis unit" variable/G root:SES:zstart=st, root:SES:zinc=inc string/G root:SES:zunit=unitEndProc LoadSESb_ShowInfo(wvn, opt)//----------------- string wvn=root:SES:filnam+"_info" variable opt prompt wvn, "SES file info wave", popup, WaveList("*_info",";","") prompt opt, "Display option", popup, "New Table;Append to topmost Table" if (opt==1) if (exists("root:SES:infonam")==0) //make/N=18/T/O root:SES:infonam List2Textw("filename,mode,slit,(hv),(R.P.),(Theta),(Phi),T(K),Ei,Ef,Estep,dwell,# sweep,Astart,Ainc,nslice,size,flux", ",", "root:SES:infonam") endif edit root:SES:infonam, $wvn else DoWindow/F $WinName(0, 2) append $wvn endifEndFunction/T SESinfoB( wv, opt )//====================//returns text string with specific file information//options: 0-return string only, 1-also print to history, 2-display table of all info wave wv variable opt string base=NameOfWave(wv) variable ptr=strsearch(base,"_",0) if (ptr>0) base=base[0,ptr-1] endif WAVE/T info=$(base+"_info") string str=base+": " str+="hv="+info[3] str+="; resol="+info[4] str+="; Ep="+info[6] str+="; dwell="+info[12]+"x"+info[11]+" s" //Energy scale //WAVE xw=$(base+"_x"), raw=$(base+"_raw") //WaveStats/Q xw //variable incr=abs(round((xw[1]-xw[0])*1E4)/1E4) str+="; rng=("+info[8]+","+info[9]+","+info[10]+")" WaveStats/Q wv //or just use info[14] str+="; max="+num2str(V_max/1000)+""+info[18] //Io fluctuation // WAVE mesh=$(base+"_mesh") // WaveStats/Q mesh // variable fluc=trunc(1000*(V_max-V_min)/V_avg)/10 // str+="; ÆIo="+num2str(fluc)+"%" if (opt==2) DoWindow/F $(base+"_info") if (V_Flag==0) if (exists("SES_info")==0) make/o/T/N=15 SES_info SES_info={"start","final","incr","range","resolution","hv","gate (ms)","#scans","Epass","pressure","CIS/CFS BE","mesh current","start beam curr.","end beam curr.","max counts (Hz)"} endif edit SES_info, info as base+"_info" endif else if (opt==1) print str endif endif return strendProc AddSESTitleB( Sample, WinNam, filnum, Temp, hv, slits, Polr, Azim, Ep, WFct )//---------------- string Sample=StrVarOrDefault("root:SES:Sample0","A\\B1\\MB\\B2\\M") string WinNam=StrVarOrDefault("root:SES:title0","TITLE"), filnum=StrVarOrDefault("root:SES:filnum0","000-009") string Polr=num2str( NumVarOrDefault("root:SES:angoffset1",0)), Azim=StrVarOrDefault("root:SES:Azimuth","0") variable Ep=root:SES:Epass[0], Wfct=NumVarOrDefault("root:SES:Wfct",4.35) string hv=num2str(NumVarOrDefault("root:SES:hv_",30)), slits=StrVarOrDefault("root:SES:slit","10") variable Temp=NumVarOrDefault("root:SES:TempK",30) prompt WinNam, "Title/Window Name (<>=no change)" prompt slits, "Mono Slits or Res. Power" PauseUpdate; Silent 1 String curr= GetDataFolder(1) NewDataFolder/O/S root:SES String/G Sample0=Sample, title0=WinNam, filnum0=filnum, Azimuth=Azim //, hv_=hv //, Polar=Polr, Variable/G Wfct0=Wfct, TempK=Temp, angoffset1=str2num(Polr), hv_=str2num(hv) Epass[0]=Ep SetDataFolder curr //root:SES:sampleSav=sample //root:SES:titleSav=WinNam //root:SES:filnumSav=filnum //root:SES:polarSav=polr //root:SES:elevSav=elev //root:SES:EpassSav=Epass //root:SES:WFct=Wkfct //root:SES:hvSav=hv string titlestr="\\JC\\[0"+Sample+", "+WinNam+ ", ("+filnum+")" titlestr+="\rhv="+hv+" eV ("+ slits +"), Polar="+Polr+", Azim="+Azim+"," titlestr+="Ep="+num2str(Ep)+", WF="+num2str(WFct)+", T="+num2str(Temp)+"K" Textbox/K/N=title Textbox/N=title/F=0/A=MT/E titlestr if (strlen(WinNam)>0) variable ic=StrSearch(WinNam, " ", 0) if (ic>0) WinNam[ic,ic]="_" endif DoWindow/C $WinNam execute "DoWindow/C "+WinNam endif EndProc LoadSESb_SummarizeFolder( pathnam )//----------------// reads scan info from each file in a specified (dialog) SES data folder // and prints the info to an Igor Notebook which than can then be used as is// or imported (saved/pasted) into a spreadsheet// 5/20 read the _Motor_Posns.txt files to summarize the data "maps"// and skip over reading the rest of those files (except the first) string pathnam //PauseUpdate; Silent 1 if (strlen(pathnam)==0) NewPath/O/Q/M="Select SES Data Folder" DataLibrary //dialog selection Pathinfo DataLibrary pathnam=S_path endif variable nfolder=ItemsInList(pathnam, ":") //FolderSep()) same on both Mac & PC string libnam=StrFromList(pathnam, nfolder-1, ":") if (nfolder>=2) libnam=StrFromList(pathnam, nfolder-2, ":") +"_"+libnam endif if (char2num(libnam[0])<65) //non-alpha first character libnam="N"+libnam endif //print pathnam, libnam NewPath/O/Q DataLibrary pathnam string filelst=IndexedFile( DataLibrary, -1, ".pxt") //"*.pxt" variable numfil=ItemsInList(filelst, ";") print "# files=", numfil //, filelst string Nbknam=libnam Nbknam = cleanupName(Nbknam,0) NewNotebook/W=(10,50,725,250)/F=1/N=$Nbknam variable j=72 //pts per inch// Notebook $Nbknam, fSize=9, margins={0,0,10.0*j }, backRGB=(65535,65534,49151), fStyle=1, showruler=0 Notebook $Nbknam, fSize=9, margins={0,0,11.0*j }, backRGB=(60681,65535,65535), fStyle=1, showruler=1, pageMargins={28,54,28,54} Notebook $Nbknam, tabs={0.1*j,1.1*j,1.75*j, 2.1*j,2.5*j,3.05*j,3.5*j,3.9*j,4.5*j,5*j, 5.5*j, 6.1*j,6.6*j,7.05*j,7.5*j,8*j,8.5*j,9*j,9.5*j} Notebook $Nbknam, fstyle=1, text="\tfilename\tmode\tslit\thv\tR.P.\tTheta\tPhi\tT(K)\tEi\tEf\tEstep\tdwell\tnswp\tAi\tAinc\tnslice\tSize" string fnam, infostr variable ii=0 DO fnam=StrFromList(filelst, ii, ";") ReadSESHdr( pathnam, fnam ) //print Textw2List(root:SES:infowav, "", 0, 18) //root:SES:infowav[2] = root:SES:infowav[6]+(root:SES:infowav[1])[0]+"#"+(root:SES:infowav[2])[0] infostr="\r\t"+Textw2List(root:SES:infowav, "\t", 0, 16) NoteBook $Nbknam, fstyle=0, text=infostr //SESInfoB() ii+=1 WHILE(ii<numfil)//append map information filelst=IndexedFile( DataLibrary, -1, ".txt")// filelst=IndexedFile( DataLibrary, -1, "_Motor_Pos.txt") numfil=ItemsInList(filelst, ";") print "# maps=", numfil ii=0 DO fnam=StrFromList(filelst, ii, ";") infostr="\r\t"+ReadMOTORtxt(pathnam, fnam) NoteBook $Nbknam, fstyle=0, text=infostr ii+=1 WHILE(ii<numfil) EndFunction/T ReadMOTORtxt(fpath, fnam)//=================// read BL403 *_Motor_Pos.txt files to get map information// return string with: MotorName start, stop, inc string fpath, fnam variable debug=0 // programming flag Variable file// wave/T headerw = root:SES:headerw NewDataFolder/O/S root:SES //SetDataFolder root:SES: String/G filnam=fnam, filpath=fpath string sline, sbasen, smotor //, sheader variable mstart, mend, minc, mnpts Open/R file as filpath+filnam FStatus file if (debug) print S_Filename, ", numbytes=", V_logEOF endif//Extract _Motor_Pos.txt from filename sbasen = filnam[0, strsearch(filnam, "_Motor_Pos", 0)-1] // First lines: Motor name FReadLine file, sline smotor=sline[0, strlen(sline)-2] // remove CRLF // second line: start value FReadLine file, sline mstart=str2num( sline )// determine increment from third line FReadLine file, sline if (strlen(sline) == 0) // scan aborted only one entry mend=mstart minc=0 mnpts=1 else minc=str2num( sline ) - mstart variable ii=2 DO FReadLine file, sline if (strlen(sline) == 0) break // No more lines to be read endif mend =str2num( sline ) ii+=1 WHILE(ii<1000) //FStatus file mnpts=ii// print mend, mstart +minc*(mnpts-1) endif Close file return sbasen+"\t"+smotor+"\t"+num2str(mstart)+"\t"+" "+num2str(mend)+"\t"+num2str(minc)+"\t"+num2str(mnpts)EndFunction LoadSESb_SummarizeVariable()//=====================// only summarize selected files in folder SVAR headerVarLst = root:SES:headerVarLst WAVE fileSelectw = root:SES:fileSelectw// SVAR filnam = root:SES:filnam SVAR filpath = root:SES:filpath WAVE/T fileListw = root:SES:fileListw variable varindex=NumVarOrDefault("root:SES:headerVarIndex", 34) string VarArrNam=StrVarOrDefault("root:SES:headerVarArrNam", "Temp_B") variable iplot prompt varindex, "Header Variable Name", popup, headerVarLst prompt vararrnam, "Output Array Name" prompt iplot,"Display output array", popup, "Table;Plot (numeric);Table & plot" DoPrompt "Extract Header Variable", varindex, vararrnam, iplot NVAR headerVarIndex=root:SES:headerVarIndex headerVarIndex= varIndex SVAR headerVarStr=root:SES:headerVarStr string/G headerVarArrNam=VarArrNam variable np=DimSize( root:SES:fileListw, 0)// print np, headerVarIndex, varindex, headerVarArrNam make/o/n=(np)/T root:SES:headerVarArr //text array WAVE/T headerVarArr=root:SES:headerVarArr string filnam variable ii=0, nselect=0 do if (fileSelectw[ii][0] >= 1) //selection = 1 or 8 filnam=fileListw[ii][0] ReadSESHdr( filpath, filnam ) // stores select string into headerVarStr headerVarArr[nselect] = headerVarStr nselect+=1 endif ii+=1 while (ii<np) Redimension/n=(nselect) headerVarArr // copy VarArr to root: and convert to numeric if possible variable numeric=( numtype(str2num(headerVarArr[0]))==0 ) // test first value of headerVarArr // doesn't work for date "##/##/###) or time (##:##:##") returns first ## if ( numeric ) make/o/n=(nselect) $("root:"+vararrnam) //text array WAVE VarArr=$("root:"+VarArrNam) VarArr = str2num( headerVarArr ) else duplicate/o headerVarArr $("root:"+vararrnam) WAVE VarArr=$("root:"+vararrnam) endif if ((iplot==1)+(iplot==3)) edit VarArr endif if ( ((iplot==2)+(iplot==3))*numeric) display VarArr endif DoWindow/F LoadSESb_Panel EndProc SES_XPS_Style(xlabel, ylabel) : GraphStyle//------------------------ string xlabel="Binding Energy (eV)", ylabel="Intensity (kHz)" PauseUpdate; Silent 1 // modifying window... ModifyGraph/Z rgb[1]=(0,0,65535),rgb[2]=(3,52428,1),rgb[3]=(0,0,0) ModifyGraph/Z tick=2 ModifyGraph/Z mirror=2 ModifyGraph/Z minor=1 ModifyGraph/Z sep=8 ModifyGraph/Z fSize=12 ModifyGraph/Z lblMargin(left)=7,lblMargin(bottom)=4 ModifyGraph/Z lblLatPos(bottom)=-1 ModifyGraph/Z axThick=0.5 Label/Z left ylabel Label/Z bottom xlabelEndMacro//******** Load Panel ***************Proc LoadSESb_ShowPanel()//----------------- DoWindow/F Load_SESb_Panel if (V_flag==0) LoadSESb_Init() LoadSESb_Panel() //Resize Panel (OS specific) string os=IgorInfo(2) if (stringmatch(os[0,2],"Win")) MoveWindow/W=LoadSESb_Panel 600,100,880,500 //633,62,805,515 else //Mac MoveWindow/W=LoadSESb_Panel 600,100,980,660 //676,67,911,600 endif endifEndProc LoadSESb_ShowPanel0()//----------------- DoWindow/F Load_SESb_Panel if (V_flag==0) LoadSESb_Init() LoadSESb_Panel() //Resize Panel (OS specific) string os=IgorInfo(2) if (stringmatch(os[0,2],"Win")) MoveWindow/W=Load_SESb_Panel 633,62,805,415 else //Mac MoveWindow/W=Load_SESb_Panel 676,67,911,500 endif endifEndProc LoadSESb_Init()//----------------- NewDataFolder/O/S root:SES make/o/N=(5,2)/T fileListw // for ListBox make/o/N=(5,2,2) fileSelectw Make/O/W/U fileColors= {{0,0,0},{43690,43690,43690},{0,0,0},{65535,0,0},{0,0,65535}} //Make/O/W/U fileColors= {{65535,65535,65535},{65535,0,0},{0,0,65535},{0,65535,65535}} //Make/O/W/U fileColors= {{52428,52428,52428},{65535,0,0},{0,0,65535},{0,65535,65535}} MatrixTranspose fileColors string/G filpath, filnam, fileList if (exists("folderList")!=2) string/G folderList="Select New Folder;Summarize Folder;Summarize Variable;-;" endif variable/G filnum, numfiles, nregion, nslice Make/O/N=(20) Estart, Eend, Estep, Epass, Enpts Make/O/N=(20) Xstart, Xend, Ystart, Yend string/G skind, smode0, sescale variable/G SlitPlate, Polar, Azimuth, Temp_B, iflux, EnSlit, ExSlit // added 1/9/12 string/G LoadArrNam string/G wvnam, prefix="" string/G appendwvn="Map1" string/G fileListFilter="" // 11/23/11 jd //variable/G nametyp=1, namenum=3 string/G nameopt="/B" variable/G hv_, wfct, angoffset1, angoffset2, dscale, escale variable/G autoload=0, NumDim=1 variable/G iRebin=0, iDitherSum=0 string/G srebin="5,3" List2Textw("filename,mode,slit,(hv),(R.P.),(Theta),(Phi),T(K),Ei,Ef,Estep,dwell,# sweep,Astart,Ainc,nslice,size,flux", ",", "root:SES:infonam") make/o/n=(19)/T infowav make/o/n=(20) data1D make/o/n=(20,20) data2D variable/G zStart=0, zInc=1 make/o/n=(66,2)/T headerw //5/29/12 variable/G iDitherSum=0 // useful before Dither mode created; remove from front panel variable/G iEFcorrect=0 // Apply Imagae shift in E-direction (transpose dependent) string/G EF_ShiftWave="" // "*_e" shift wave Preference selection variable/G iAngCorrect=0 // Apply trapezoid Angle correction; Preference selection of ccrr_ folder string/G AngCorr_fldr="" // Preference selection; corr_* folder created by ApplyAngCorr() variable/G iTranspose=0 // Transpose Image X<>Y; do after energy and angle correction variable/G iApplyStyle=0 // can do a lot of the above in the graph style string/G GraphStyle="" // Preference selection; string/G ClrTable="" variable/G data2D_gamma=0.5, iCTinvert=0 make/o/n=(256) data2D_LUT data2D_LUT:=(p/256)^data2D_gamma // nonlinear gamma // base=ExtractNameB( base, namtyp, namnum ) // need to put in loop for multiple regions //base=root:SES:skind[0]+base SetDimLabel 2,1,foreColors,fileSelectw //wvnam:= NameSES( filnam ) escale=3 // initial default preference of -BE SetDataFolder root:EndWindow LoadSESb_Panel() : Graph PauseUpdate; Silent 1 // building window... String fldrSav0= GetDataFolder(1) SetDataFolder root:SES: Display /W=(600,100,980,660) data1D as "LoadSESb_Panel" AppendImage/T/R data2D ModifyImage data2D ctab= {*,*,Grays,0} ModifyImage data2D lookup=data2D_LUT SetDataFolder fldrSav0 ModifyGraph cbRGB=(64512,62423,1327) ModifyGraph mirror=0 ModifyGraph fSize=8 ModifyGraph axOffset(right)=-1.6,axOffset(top)=-0.8 Label top " " TitleBox version,pos={205,2},size={26,12},title="v20.0726",fSize=9,frame=0,fStyle=2 TextBox/C/N=text0/F=0/S=3/H=14/A=MT/E "\\{root:SES:filnam}: \\{root:SES:infowav[1]}, \\{root:SES:filesize}K" ControlBar 270 GroupBox prefs,pos={9,168},size={218,71} PopupMenu popFolder,pos={11,1},size={94,20},proc=LoadSESb_SelectFolder,title="Data Folder" PopupMenu popFolder,mode=0,value= #"root:SES:folderList" SetVariable setlib,pos={7,23},size={324,15},title=" ",value= root:SES:filpath PopupMenu popup_file,pos={54,244},size={163,20},proc=LoadSESb_SelectFile,title="File" PopupMenu popup_file,mode=17,popvalue="CeCo5_017_000.pxt",value= #"root:SES:fileList\t\t" Button FileUpdate,pos={146,3},size={50,16},proc=LoadSESb_UpdateFolder,title="Update" ListBox listSESfiles,pos={8,40},size={175,75},proc=LoadSESb_SelectFileLB,frame=4 ListBox listSESfiles,listWave=root:SES:fileListw,selWave=root:SES:fileSelectw ListBox listSESfiles,colorWave=root:SES:fileColors,row= 14,mode= 3 ListBox listSESfiles,widths={95,35} SetVariable set_hv,pos={19,173},size={75,15},proc=LoadSESb_SetVar,title="hv" SetVariable set_hv,value= root:SES:hv_ Button StepMinus,pos={87,215},size={20,16},proc=LoadSESb_StepFile,title="<<" Button StepPlus,pos={113,216},size={20,16},proc=LoadSESb_StepFile,title=">>" Button PlotButton1,pos={26,214},size={55,20},proc=PlotSES,title="Display" Button PlotButton2,pos={142,217},size={58,20},proc=PlotSES,title="Append" SetVariable wvnam,pos={22,195},size={120,15},title=" ",value= root:SES:wvnam Button PlotPrefs,pos={164,192},size={40,16},proc=LoadSESb_Prefs,title="Prefs" SetVariable img_rebin,pos={117,174},size={90,15},title=" Img Rebin" SetVariable img_rebin,value= root:SES:srebin CheckBox checkRebin,pos={211,175},size={16,14},title="" CheckBox checkRebin,variable= root:SES:iRebin SetVariable setAppendWvn,pos={99,151},size={63,15},title=" " SetVariable setAppendWvn,value= root:SES:appendwvn Button CatButton1,pos={13,122},size={68,20},proc=LoadSESb_WaveCatF,title="Assemble" Button CatButton2,pos={18,145},size={58,20},proc=LoadSESb_WaveCatF,title="Append" CheckBox SelectAll,pos={101,135},size={57,14},proc=SelectAll,title="Select all" CheckBox SelectAll,value= 0 ListBox header_display,pos={184,41},size={181,120},listWave=root:SES:headerw ListBox header_display,row= 26,mode= 1,selRow= 29,widths={31,15} SetVariable setFileListFilter,pos={100,118},size={63,15},proc=LoadSESb_SetVar,title=" *" SetVariable setFileListFilter,value= root:SES:fileListFilter CheckBox checkANGcorr,pos={246,192},size={90,14},title="Angle correction" CheckBox checkANGcorr,variable= root:SES:iAngCorrect CheckBox checkTranpose,pos={246,209},size={77,14},title="Transpose XY" CheckBox checkTranpose,variable= root:SES:iTranspose, proc=LoadSESb_CheckBox CheckBox checkApplyStyle,pos={246,227},size={68,14},title="Apply Style" CheckBox checkApplyStyle,variable= root:SES:iApplyStyle CheckBox checkCTinvert title="Inv",size={77,14},proc=LoadSESb_CheckBox,value=0 CheckBox checkCTinvert variable=:SES:iCTinvert Slider sliderGamma,pos={240,247},size={70,16} Slider sliderGamma,limits={0.1,1.5,0.05},variable= root:SES:data2D_gamma,side= 2,vert= 0,ticks= 0 PopupMenu popupHeaderSection,pos={291.00,161.00},size={73.00,23.00},proc=LoadSESb_HeaderSection,title="Section" PopupMenu popupHeaderSection,fSize=8,mode=0,value= #"\"Top;SPEC;ENDST;BEAM\""EndMacroWindow LoadSESb_panel1() : Graph PauseUpdate; Silent 1 // building window... String fldrSav0= GetDataFolder(1) SetDataFolder root:SES: Display /W=(697,95,982,628) data1D as "LoadSESb_Panel" AppendImage/T/R data2D ModifyImage data2D ctab= {*,*,Grays,0} SetDataFolder fldrSav0 ModifyGraph cbRGB=(64512,62423,1327) ModifyGraph mirror=0 ModifyGraph fSize=8 ModifyGraph axOffset(right)=-1.6,axOffset(top)=-0.8 Label top " " TextBox/C/N=text0/F=0/S=3/H=14/A=MT/E "\\{root:SES:filnam}: \\{root:SES:infowav[1]}, \\{root:SES:filesize}K" ControlBar 311 GroupBox header,pos={8,120},size={221,84} GroupBox prefs,pos={9,209},size={218,71} PopupMenu popFolder,pos={11,1},size={94,20},proc=LoadSESb_SelectFolder,title="Data Folder" PopupMenu popFolder,mode=0,value= #"root:SES:folderList" SetVariable setlib,pos={7,24},size={225,15},title=" ",value= root:SES:filpath PopupMenu popup_file,pos={54,285},size={124,20},proc=LoadSESb_SelectFile,title="File" PopupMenu popup_file,mode=1,popvalue="EuB_0001.pxt",value= #"root:SES:fileList" Button FileUpdate,pos={146,3},size={50,16},proc=LoadSESb_UpdateFolder,title="Update" ListBox listSESfiles,pos={8,40},size={170,75},proc=LoadSESb_SelectFileLB,frame=4 ListBox listSESfiles,listWave=root:SES:fileListw,selWave=root:SES:fileSelectw ListBox listSESfiles,colorWave=root:SES:fileColors,row= 10,mode= 3 ListBox listSESfiles,widths={70,35}// SetVariable val_kind,pos={21,124},size={61,15},title=" ",value= root:SES:skind// SetVariable val_mode,pos={95,124},size={44,15},title=" ",value= root:SES:smode0// ValDisplay val_Ep,pos={156,124},size={50,13},title="Ep"// ValDisplay val_Ep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Epass[0]"// ValDisplay val_Estart,pos={14,144},size={59,13},title="Ei"// ValDisplay val_Estart,limits={0,0,0},barmisc={0,1000}// ValDisplay val_Estart,value= #"root:SES:Estart[0]"// ValDisplay val_Eend,pos={77,144},size={59,13},title="Ef"// ValDisplay val_Eend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Eend[0]"// ValDisplay val_Estep,pos={149,143},size={68,13},title="Einc"// ValDisplay val_Estep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Estep[0]"// ValDisplay val_nslice,pos={146,163},size={66,13},title="# slice"// ValDisplay val_nslice,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nslice"// ValDisplay val_Nreg,pos={15,184},size={60,13},title="# region"// ValDisplay val_Nreg,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nregion" SetVariable set_hv,pos={19,214},size={75,15},proc=LoadSESb_SetVar,title="hv" SetVariable set_hv,value= root:SES:hv_ Button StepMinus,pos={87,256},size={20,16},proc=LoadSESb_StepFile,title="<<" Button StepPlus,pos={113,257},size={20,16},proc=LoadSESb_StepFile,title=">>" Button PlotButton1,pos={26,255},size={55,20},proc=PlotSES,title="Display"// Button PlotButton2,pos={144,256},size={55,20},proc=PlotSES,title="Append"// ValDisplay val_Astart,pos={14,163},size={55,13},title="Ai"// ValDisplay val_Astart,limits={0,0,0},barmisc={0,1000}// ValDisplay val_Astart,value= #"root:SES:Ystart[0]"// ValDisplay val_Aend,pos={79,164},size={55,13},title="Af"// ValDisplay val_Aend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Yend[0]"// ValDisplay val_dwell,pos={152,183},size={59,13},title="dwell"// ValDisplay val_dwell,limits={0,0,0},barmisc={0,1000},value= #"root:SES:dwell[0]"// ValDisplay val_nswp,pos={85,183},size={59,13},title="nswp"// ValDisplay val_nswp,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nsweep[0]" SetVariable wvnam,pos={22,236},size={120,15},title=" ",value= root:SES:wvnam Button PlotPrefs,pos={164,233},size={40,16},proc=PlotSESb_prefb,title="Prefs" SetVariable img_rebin,pos={117,215},size={90,15},title=" Img Rebin" SetVariable img_rebin,value= root:SES:srebin CheckBox checkRebin,pos={211,216},size={16,14},title="" CheckBox checkRebin,variable= root:SES:iRebin CheckBox checkDitherSum,pos={185,100},size={66,14},title="Dither Sum" CheckBox checkDitherSum,variable= root:SES:iDitherSum SetVariable setAppendWvn,pos={211,259},size={63,15},title=" " SetVariable setAppendWvn,value= root:SES:appendwvn TitleBox version,pos={204,2},size={20,12},title="v3.0",fSize=9,frame=0,fStyle=2 Button CatButton1,pos={182,42},size={68,20},proc=LoadSESb_WaveCatF,title="Assemble" Button CatButton2,pos={187,65},size={58,20},proc=LoadSESb_WaveCatF,title="Append" Checkbox SelectAll, title="Select all", proc=SelectAll, mode=0,size={56,14},pos={186,87} ListBox header_display, pos={14,124},size={169,81},listwave=root:SES:headerw, mode=0EndMacroWindow Load_SESb_Panel1() : Graph PauseUpdate; Silent 1 // building window... String fldrSav= GetDataFolder(1) SetDataFolder root:SES: Display /W=(673,85,914,497) data1D as "Load_SESb_Panel" AppendImage/T/R data2D ModifyImage data2D ctab= {*,*,Grays,0} SetDataFolder fldrSav ModifyGraph cbRGB=(64512,62423,1327) ModifyGraph mirror=0 ModifyGraph fSize=8 ModifyGraph axOffset(right)=-1.6,axOffset(top)=-0.8 Label top " " TextBox/N=text0/F=0/S=3/H=14/A=MT/E "\\{root:SES:filnam}: \\{root:SES:infowav[1]}, \\{root:SES:filesize}K" ControlBar 231 GroupBox header,pos={8,67},size={221,84} GroupBox prefs,pos={9,156},size={218,71} PopupMenu popFolder,pos={11,1},size={94,20},proc=LoadSESb_SelectFolder,title="Data Folder" PopupMenu popFolder,mode=0,value= #"root:SES:folderList" SetVariable setlib,pos={7,24},size={225,15},title=" ",value= root:SES:filpath PopupMenu popup_file,pos={10,44},size={120,20},proc=LoadSESb_SelectFile,title="File" PopupMenu popup_file,mode=26,popvalue="uge026.pxt",value= #"root:SES:fileList" Button FileUpdate,pos={178,44},size={50,16},proc=LoadSESb_UpdateFolder,title="Update" SetVariable val_kind,pos={21,71},size={61,15},title=" ",value= root:SES:skind SetVariable val_mode,pos={95,71},size={44,15},title=" ",value= root:SES:smode0 ValDisplay val_Ep,pos={156,71},size={50,14},title="Ep" ValDisplay val_Ep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Epass[0]" ValDisplay val_Estart,pos={14,91},size={59,14},title="Ei" ValDisplay val_Estart,limits={0,0,0},barmisc={0,1000} ValDisplay val_Estart,value= #"root:SES:Estart[0]" ValDisplay val_Eend,pos={77,91},size={59,14},title="Ef" ValDisplay val_Eend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Eend[0]" ValDisplay val_Estep,pos={149,90},size={68,14},title="Einc" ValDisplay val_Estep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Estep[0]" ValDisplay val_nslice,pos={146,110},size={66,14},title="# slice" ValDisplay val_nslice,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nslice" ValDisplay val_Nreg,pos={15,131},size={60,14},title="# region" ValDisplay val_Nreg,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nregion" SetVariable set_hv,pos={19,161},size={75,15},proc=LoadSESb_SetVar,title="hv" SetVariable set_hv,value= root:SES:hv_ Button StepMinus,pos={87,203},size={20,18},proc=LoadSESb_StepFile,title="<<" Button StepPlus,pos={113,204},size={20,18},proc=LoadSESb_StepFile,title=">>" Button PlotButton1,pos={26,202},size={55,20},proc=PlotSES,title="Display" Button PlotButton2,pos={144,203},size={55,20},proc=PlotSES,title="Append" ValDisplay val_Astart,pos={14,110},size={55,14},title="Ai" ValDisplay val_Astart,limits={0,0,0},barmisc={0,1000} ValDisplay val_Astart,value= #"root:SES:Ystart[0]" ValDisplay val_Aend,pos={79,111},size={55,14},title="Af" ValDisplay val_Aend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Yend[0]" ValDisplay val_dwell,pos={152,130},size={59,14},title="dwell" ValDisplay val_dwell,limits={0,0,0},barmisc={0,1000},value= #"root:SES:dwell[0]" ValDisplay val_nswp,pos={85,130},size={59,14},title="nswp" ValDisplay val_nswp,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nsweep[0]" SetVariable wvnam,pos={22,183},size={120,15},title=" ",value= root:SES:wvnam Button PlotPrefs,pos={164,180},size={40,18},proc=PlotSESb_prefb,title="Prefs" SetVariable img_rebin,pos={117,162},size={90,15},title=" Img Rebin" SetVariable img_rebin,value= root:SES:srebin TitleBox version,pos={204,2},size={25,14},title="v1.8",fSize=9,frame=0, fstyle=2 CheckBox checkRebin,pos={211,216},size={16,14},title="" CheckBox checkRebin,variable= root:SES:iRebin,mode=1 CheckBox checkDitherSum,pos={185,80},size={66,14},title="Dither Sum" CheckBox checkDitherSum,variable= root:SES:iDitherSum SetVariable setAppendWvn,pos={211,259},size={63,15},title=" " SetVariable setAppendWvn,value= root:SES:appendwvn SetDrawLayer UserFrontEndMacroWindow Load_SESb_Panel0() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(713,84,931,364) ModifyPanel cbRGB=(64512,62423,1327) SetDrawLayer UserBack SetDrawEnv fillfgc= (65495,2134,34028) DrawRRect 11,39,210,149 SetDrawEnv fillpat= 5,fillfgc= (65495,2134,34028) DrawRRect 12,156,210,248 PopupMenu popFolder,pos={10,0},size={97,19},proc=LoadSESb_SelectFolder,title="Data Folder" PopupMenu popFolder,mode=0,value= #"root:SES:folderList" SetVariable setlib,pos={12,21},size={195,14},title=" ",fSize=10 SetVariable setlib,limits={-Inf,Inf,1},value= root:SES:filpath PopupMenu popup_file,pos={14,44},size={145,19},proc=LoadSESb_SelectFile,title="File" PopupMenu popup_file,mode=1,popvalue="cerhin-033.pxt",value= #"root:SES:fileList" Button FileUpdate,pos={156,45},size={50,16},proc=LoadSESb_UpdateFolder,title="Update" SetVariable val_kind,pos={18,71},size={61,14},title=" ",fSize=10 SetVariable val_kind,limits={-Inf,Inf,1},value= root:SES:skind SetVariable val_mode,pos={88,71},size={44,14},title=" ",fSize=10 SetVariable val_mode,limits={-Inf,Inf,1},value= root:SES:smode0 ValDisplay val_Ep,pos={142,71},size={50,14},title="Ep",fSize=10 ValDisplay val_Ep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Epass[0]" ValDisplay val_Estart,pos={14,91},size={59,14},title="Ei",fSize=10 ValDisplay val_Estart,limits={0,0,0},barmisc={0,1000} ValDisplay val_Estart,value= #"root:SES:Estart[0]" ValDisplay val_Eend,pos={77,91},size={59,14},title="Ef",fSize=10 ValDisplay val_Eend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Eend[0]" ValDisplay val_Estep,pos={138,91},size={65,14},title="Einc",fSize=10 ValDisplay val_Estep,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Estep[0]" ValDisplay val_nslice,pos={141,110},size={66,14},title="# slice",fSize=10 ValDisplay val_nslice,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nslice" ValDisplay val_Nreg,pos={20,130},size={60,14},title="# region",fSize=10 ValDisplay val_Nreg,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nregion" PopupMenu popup_Cts,pos={32,161},size={72,19},proc=LoadSESb_SetPop PopupMenu popup_Cts,mode=2,popvalue="Cts/Sec",value= #"\"Counts;kCounts;Cts/Sec;kCts/Sec\"" PopupMenu popup_Escale,pos={130,161},size={40,19},proc=LoadSESb_SetPop PopupMenu popup_Escale,mode=1,popvalue="KE",value= #"\"KE;BE\"" SetVariable set_hv,pos={23,186},size={75,14},proc=LoadSESb_SetVar,title="hv" SetVariable set_hv,fSize=10,limits={-Inf,Inf,1},value= root:SES:hv_ SetVariable set_wfct,pos={108,186},size={80,14},proc=LoadSESb_SetVar,title="wfct" SetVariable set_wfct,fSize=10,limits={-Inf,Inf,1},value= root:SES:wfct SetVariable set_ang1,pos={16,206},size={85,14},proc=LoadSESb_SetVar,title="Ang1" SetVariable set_ang1,fSize=10,limits={-Inf,Inf,1},value= root:SES:angoffset1 SetVariable set_ang2,pos={107,206},size={85,14},proc=LoadSESb_SetVar,title="Ang2" SetVariable set_ang2,fSize=10,limits={-Inf,Inf,1},value= root:SES:angoffset2 Button StepMinus,pos={74,252},size={20,18},proc=LoadSESb_StepFile,title="<<" Button StepPlus,pos={99,252},size={20,18},proc=LoadSESb_StepFile,title=">>" Button PlotButton1,pos={14,252},size={55,20},proc=PlotSES,title="Display" Button PlotButton2,pos={124,250},size={55,20},proc=PlotSES,title="Append" ValDisplay val_Astart,pos={14,110},size={55,14},title="Ai",fSize=10 ValDisplay val_Astart,limits={0,0,0},barmisc={0,1000} ValDisplay val_Astart,value= #"root:SES:Ystart[0]" ValDisplay val_Aend,pos={79,109},size={55,14},title="Af",fSize=10 ValDisplay val_Aend,limits={0,0,0},barmisc={0,1000},value= #"root:SES:Yend[0]" PopupMenu popupPreview,pos={131,0},size={76,19},proc=LoadSESb_SetPreview,title="Preview" PopupMenu popupPreview,mode=0,value= #"\"No Preview;Show Preview;Data to ImageTool\"" ValDisplay val_dwell,pos={147,130},size={59,14},title="dwell",fSize=10 ValDisplay val_dwell,limits={0,0,0},barmisc={0,1000},value= #"root:SES:dwell[0]" ValDisplay val_nswp,pos={85,131},size={59,14},title="nswp",fSize=10 ValDisplay val_nswp,limits={0,0,0},barmisc={0,1000},value= #"root:SES:nsweep[0]" SetVariable wvnam,pos={88,227},size={110,14},title=" ",fSize=10 SetVariable wvnam,limits={-Inf,Inf,1},value= root:SES:wvnam Button WvNamePrefs,pos={23,225},size={55,18},proc=NamingPrefsSES,title="Naming"EndMacroProc SelectSESfolder(ctrlName,popNum,popStr) : PopupMenuControl//------------ String ctrlName Variable popNum String popStr LoadSES_CheckVersion()EndFunction LoadSES_CheckVersion()//===================== string/G root:SES:version="v2.1" SVAR version=root:SES:version ControlInfo/W=LoadSES_Panel version string curr_ver=stringbykey("title", S_recreation,"=",",") curr_ver=StringFromList(0, curr_ver, "\r") print "Current Panel version = " + curr_ver+"; Newest Panel version = "+version if (stringmatch(curr_ver, "\""+version+"\"")==0) string alertstr="Using old version of LoadSESb_Panel ("+curr_ver+")." alertstr+="\rNeed to close and reopen Panel ("+version+"). " alertstr+="\r(This will preserve data folder list.)" alertstr+="\rDO IT NOW?" DoAlert 1, alertstr if (V_flag==1) //Yes DoWindow/K LoadSESb_Panel DoWindow/K Load_SESb_Panel execute "LoadSES_ShowPanel()" endif endifEndProc LoadSESb_SelectFolder(ctrlName,popNum,popStr) : PopupMenuControl//------------------- String ctrlName Variable popNum String popStr PauseUpdate SetDataFolder root:SES: string fullfileList if (popNum==2) //print "Summarize Folder" LoadSESb_SummarizeFolder(filpath) else if (popNum==3) //print "Summarize Variable" LoadSESb_SummarizeVariable() else if (popNum==1) //print "Select Folder" NewPath/O/Q/M="Select SES Data Library" SESdata //dialog selection string/G filpath Pathinfo SESdata filpath=S_path folderList=folderList+filpath+";" endif if (popNum>3) //print "Select Existing Folder" filpath=StringFromList(popNum-1,folderList) //print popNum, filpath NewPath/O/Q SESdata filpath endif fullfileList=IndexedFile( SESdata, -1, "????") filelist=SortList(fullfileList) // added 12/2018 for new Apple File System filelist=ReduceList( filelist, "!*.txt" ) // screen out extensions not desired filelist=ReduceList( fileList, "*"+root:SES:fileListFilter+"*" ) numfiles=ItemsInList( fileList, ";") numfiles= List2Textw(fileList, ";","fileListw") Redimension/N=(numfiles,2) fileListw Redimension/N=(numfiles,2,2) fileSelectw //string fileTypeList= //SetDimLabel 2,1,foreColors,fileSelectw //fileListw[][1]="-CM"[ SpecTypeSES( filpath, fileListw[p][0]) ] fileListw[][1]=num2str( FileSizeSES( filpath, fileListw[p][0]) )+" K" // file size column// fileSelectw[][][%forecolors]=SpecTypeSES( fileListw[p][0])+1 endif endif SetDataFolder root: // Update filelist menu and reset to first file PopupMenu popup_file value=root:SES:fileList, mode=1 //LoadSESb_SelectFile("",1,"")EndFunction SpecTypeSES( filnam )//==================// 0=other, 1=.pxt (packed Igor experiment), 2=.dat (SES work file format), 3=.txt (dat summary) string filnam variable stype=0 if (stringmatch( filnam[strlen(filnam)-4,inf], ".pxt")==1) stype=1 endif if (stringmatch( filnam[strlen(filnam)-4,inf], ".pxp")==1) stype=1 endif if (stringmatch( filnam[strlen(filnam)-4,inf], ".dat")==1) stype=2 endif if (stringmatch( filnam[strlen(filnam)-4,inf], ".txt")==1) stype=3 endif return stypeEndFunction FileSizeSES( filpath, filnam )//==================// 0=blank (aborted scan), 1=C (channeltron), 2=M (Mott) string filpath, filnam //variable stype=1 //execute "GetFileFolderInfo/Q/Z/P="+filpath+" "+ filnam GetFileFolderInfo/Q/Z filpath+ filnam //NVAR V_logEOF=V_logEOF //print V_logEOF, filpath, filnam //stype=SelectNumber( V_logEOF<4000, stype, 0) //stype=SelectNumber( V_logEOF>10000, stype, 2) //return stype return round( V_logEOF/1000 )EndProc LoadSESb_UpdateFolder(ctrlName) : ButtonControl//----------------------- String ctrlName SetDataFolder root:SES: fileList=IndexedFile( SESdata, -1, ".pxt")+IndexedFile( SESdata, -1, ".pxp")// fullfileList=IndexedFile( SESdata, -1, "????") filelist=SortList(fileList) // added 12/2018 for new Apple File System // screen out temporary *.dat files // filelist=ReduceList( fileList, "!*.dat" )// include only matches to filter string filelist=ReduceList( fileList, "*"+root:SES:fileListFilter+"*" ) numfiles=ItemsInList( fileList, ";") numfiles=List2Textw(fileList, ";","fileListw")// Redimension/N=(numfiles,1,2) fileSelectw Redimension/N=(numfiles,2) fileListw Redimension/N=(numfiles,2,2) fileSelectw PopupMenu popup_file value=root:SES:fileList //#"root:SES:fileList" fileListw[][1]=num2str( FileSizeSES( filpath, fileListw[p][0]) )+" K"// fileSelectw[][][%forecolors]=SpecTypeSES( fileListw[p][0])+1 LoadSESb_StepFile("StepPlus") // increment file selection to next (N+1) SetDataFolder root:EndProc LoadSESb_SelectFile(ctrlName,popNum,popStr) : PopupMenuControl//----------------------------- String ctrlName Variable popNum String popStr root:SES:filnum=popNum //root:SES:filnam=popStr root:SES:filnam=StringFromList(root:SES:filnum-1, root:SES:fileList, ";") string/G root:SES:wvnam=root:SES:skind[0]+ExtractName( root:SES:filnam, root:SES:nameopt ) ListBox listSESfiles selRow=popNum-1, row=max(0,popNum-3) variable datatyp=SpecTypeSES( root:SES:filnam ) IF (datatyp==1) // .pxt ReadSESHdr( root:SES:filpath, root:SES:filnam ) //variable autoload=1 //if (root:SES:autoload>0) // Preview option PauseUpdate; Silent 1 ReadSESb(0) root:SES:nregion = CountObjects("root:SES:Load", 1) string loadwn, curr variable nfiles curr=GetDataFolder(1) SetDataFolder root:SES:Load nfiles=itemsinlist( wavelist("*",";","")) SetDataFolder $curr //print nfiles loadwn="root:SES:Load:"+PossiblyQuoteName( GetIndexedObjName("root:SES:Load",1 ,nfiles-1 )) Redimension/S $loadwn variable Ndim=WaveDims($loadwn) variable/G root:SES:NumDim=Ndim string/G root:SES:LoadArrNam=loadwn //print loadwn, Ndim if (Ndim==1) duplicate/o $loadwn root:SES:data1D root:SES:data2D=nan endif if (Ndim==2) if ( root:SES:autoload==2 ) // Pipeline to data to Image_Tool DoWindow/F ImageTool if (V_flag==1) NewImg( loadwn ) DoWindow/F Load_SESb_Panel endif //root:SES:data1D=nan //execute "NewImg( \""+loadwn+"\" )" // else duplicate/o $loadwn root:SES:data2D variable nx=DimSize(root:SES:data2D, 0) , ny=DimSize(root:SES:data2D, 1) Redimension/N=(nx) root:SES:data1D CopyScales root:SES:data2D, root:SES:data1D root:SES:data1D=root:SES:data2D[p][ny/2] if (root:SES:iTranspose) MatrixTranspose root:SES:data2D endif endif endif if (Ndim==3) if ( root:SES:autoload==2 ) DoWindow/F ImageTool if (V_flag==1) NewImg( loadwn ) DoWindow/F Load_SESb_Panel endif endif root:SES:data1D=Nan root:SES:data2D=Nan print "nz=", DimSize( $loadwn, 2) endif ELSE IF (datatyp==2) // .dat //print "file type = *.dat " ReadSESDhdr( root:SES:filpath, root:SES:filnam ) //variable autoload=1 //if (root:SES:autoload>0) // Preview option PauseUpdate; Silent 1 ReadSESDdat(0) string loadwn="root:SESdat:wdatafull" if (WaveDims($loadwn)==1) duplicate/o $loadwn root:SES:data1D root:SES:data2D=nan endif if (WaveDims($loadwn)==2) if ( root:SES:autoload==2 ) // Pipeline to data to Image_Tool DoWindow/F ImageTool if (V_flag==1) NewImg( loadwn ) DoWindow/F LoadSESD_Panel endif //root:SES:data1D=nan //execute "NewImg( \""+loadwn+"\" )" // else duplicate/o $loadwn root:SES:data2D variable nx=DimSize(root:SES:data2D, 0) , ny=DimSize(root:SES:data2D, 1) Redimension/N=(nx) root:SES:data1D CopyScales root:SES:data2D, root:SES:data1D root:SES:data1D=root:SES:data2D[p][ny/2] endif endif if (WaveDims($loadwn)==3) if ( root:SES:autoload==2 ) DoWindow/F ImageTool if (V_flag==1) NewImg( loadwn ) DoWindow/F LoadSESD_Panel endif endif endif ELSE print "file type = not *.pxt or *.dat " ENDIF ENDIF //endifEndFunction TestLB(ctrlName,row,col,event) : ListBoxControl//==================== String ctrlName Variable row Variable col Variable event //1=mouse down, 2=up, 3=dbl click, 4=cell select with mouse or keys //5=cell select with shift key, 6=begin edit, 7=end print "event=", event, "row=", row EndFunction LoadSESb_SelectFileLB(ctrlName,row,col,event) : ListBoxControl//==================== String ctrlName Variable row Variable col Variable event //1=mouse down, 2=up, 3=dbl click, 4=cell select with mouse or keys //5=cell select with shift key, 6=begin edit, 7=end //print "event=", event, "row=", row PauseUpdate; Silent 1 if ((event==4)) //+(event==10)) // mouse click or arrow up/down or 10=cmd ListBox NVAR filnum=root:SES:filnum, nregion=root:SES:nregion SVAR filnam=root:SES:filnam, filpath=root:SES:filpath WAVE/T fileListw=root:SES:fileListw filnum=row filnam=fileListw[ row ][0] PopupMenu popup_file mode=row+1 SVAR wvnam=root:SES:wvnam, skind=root:SES:skind, nameopt=root:SES:nameopt wvnam=skind[0]+ExtractName( filnam, nameopt ) //print wvnam //root:SES:filnum=row //root:SES:filnam=root:fileListw[ row ]// PopupMenu popup_file mode=row+1 //ReadSESHdr( root:SES:filpath, root:SES:filnam ) variable datatyp=SpecTypeSES( filnam ) IF (datatyp==1) // .pxt ReadSESHdr( filpath, filnam ) PauseUpdate; Silent 1 ReadSESb(0) nregion = CountObjects("root:SES:Load", 1) string loadwn, curr variable nfiles curr=GetDataFolder(1) SetDataFolder root:SES:Load nfiles=itemsinlist( wavelist("*",";","")) SetDataFolder $curr //print nfiles loadwn="root:SES:Load:"+PossiblyQuoteName( GetIndexedObjName("root:SES:Load",1 ,nfiles-1 )) Redimension/S $loadwn variable Ndim=WaveDims($loadwn) variable/G root:SES:NumDim=Ndim string/G root:SES:LoadArrNam=loadwn //print loadwn, Ndim NVAR autoload=root:SES:autoload WAVE data1D=root:SES:data1D, data2D=root:SES:data2D if (Ndim==1) duplicate/o $loadwn data1D data2D=nan endif if (Ndim==2) if ( autoload==2 ) // Pipeline to data to Image_Tool DoWindow/F ImageTool if (V_flag==1)// NewImg( loadwn ) DoWindow/F LoadSESb_Panel endif //root:SES:data1D=nan //execute "NewImg( \""+loadwn+"\" )" // else duplicate/o $loadwn data2D variable nx=DimSize(data2D, 0) , ny=DimSize(data2D, 1) Redimension/N=(nx) data1D CopyScales data2D, data1D data1D=data2D[p][ny/2] endif endif if (Ndim==3) if ( autoload==2 ) DoWindow/F ImageTool if (V_flag==1)// NewImg( loadwn ) DoWindow/F LoadSESb_Panel endif endif data1D=Nan data2D=Nan print "nz=", DimSize( $loadwn, 2) endif ELSEIF (datatyp==2) // .dat print "file type = *.dat " ELSE print "file type = not *.pxt or *.dat " ENDIF endif return rowEndFunction LoadSESb_StepFile(ctrlName) : ButtonControl//==================== String ctrlName NVAR filnum=root:SES:filnum, numfiles=root:SES:numfiles string filnam if (cmpstr(ctrlName,"StepMinus")==0) filnum=max(1, filnum-1) endif if (cmpstr(ctrlName,"StepPlus")==0) filnum=min(numfiles, filnum+1) endif SVAR fileList=root:SES:fileList WAVE fileListw=root:SES:fileListw filnam=StringFromList( filnum-1, fileList, ";") //filnam=fileListw[ filnum-1 ] PopupMenu popup_file mode=filnum ListBox listSESfiles selRow=filnum-1, row=max(0,filnum-3) print filnam, filnum DoUpdate //** 10/13/03 string cmd="LoadSESb_SelectFile( \"\", "+num2str(filnum)+", \""+filnam+"\" )" //print cmd execute cmd //LoadSESb_SelectFileLB( "", filnum-1, 1,1 ) //TestLB( "", filnum-1, 1,1 )EndProc LoadSESb_SetPop(ctrlName,popNum,popStr) : PopupMenuControl//--------------------------------- String ctrlName Variable popNum String popStr if (cmpstr(ctrlName,"popup_cts")==0) root:SES:dscale= popNum endif if (cmpstr(ctrlName,"popup_escale")==0) root:SES:escale= popNum endifEndProc LoadSESb_SetVar(ctrlName,varNum,varStr,varName) : SetVariableControl//---------------------------------- String ctrlName Variable varNum String varStr String varName if (cmpstr(ctrlName,"set_hv")==0) root:SES:hv_= varNum endif if (cmpstr(ctrlName,"set_wfct")==0) root:SES:wfct= varNum endif if (cmpstr(ctrlName,"set_ang1")==0) root:SES:angoffset1= varNum endif if (cmpstr(ctrlName,"set_ang2")==0) root:SES:angoffset2= varNum endif if (cmpstr(ctrlName,"setFileListFilter")==0) root:SES:fileListFilter= varStr LoadSESb_UpdateFolder("") endifEndProc PlotSES(ctrlName) : ButtonControl//--------------------- String ctrlName if (cmpstr(ctrlName,"PlotButton3")==0) // pipeline to ImageTool if (root:SES:NumDim==1) abort endif string arrnam="root:SES:data2D" if (root:SES:NumDim==3) //arrnam="root:SES:Load:"+PossiblyQuoteName( GetIndexedObjName("root:SES:Load",1 ,nfiles-1 )) arrnam=root:SES:LoadArrNam endif DoWindow/F ImageTool if (V_flag==1) NewImg( arrnam ) DoWindow/F Load_SESb_Panel endif else variable plotopt=-1 //negative means ReadSESB skips open dialog and uses current filename if (cmpstr(ctrlName,"PlotButton2")==0) //Append plotopt=-2 endif //LoadSESb(root:SES:dscale, root:SES:escale, root:SES:hv_, root:SES:wfct, root:SES:angoffset1, root:SES:angoffset2, root:SES:nametyp, root:SES:namenum, plotopt) LoadSESb(root:SES:dscale, root:SES:escale, root:SES:hv_, plotopt) endifEndFunction LoadSESb_WaveCatF(ctrlName):ButtonControl//=====================//Alternative to LoadSESb_WaveCat in function form. Currently under testing. Tristan, 7/7/11 String ctrlName Wave fileSelectw = root:SES:fileSelectw SVAR filnam = root:SES:filnam Wave/T fileListw = root:SES:fileListw SVAR wvnam = root:SES:wvnam SVAR skind = root:SES:skind SVAR nameopt = root:SES:nameopt NVAR dscale = root:SES:dscale NVAR escale = root:SES:escale NVAR hv_ = root:SES:hv_ SVAR appendwvn = root:SES:appendwvn NVAR zstart=root:SES:zstart, zinc=root:SES:zinc SVAR zunit=root:SES:zunit variable ii=0, jj=0, np=DimSize( root:SES:fileListw, 0) make/o/n=(np) fileSel fileSel = fileSelectw[p][0][0] if(cmpstr(ctrlName,"CatButton1")==0) //creates a new wave, rather than simply appending to existing wave Execute/Q "GetAssemblyPrefs()" do if (fileSel[ii] == 1) break endif ii+=1 while (ii<np) filnam=fileListw[ii][0]// root:SES:wvnam=skind[0]+ExtractName( filnam, nameopt ) wvnam=skind[0]+ExtractName( filnam, nameopt )// print "wvnam:", wvnam readSESb(0)// Execute/Q "LoadSESb(dscale, escale, hv_,-1)" Execute/Q "LoadSESb("+num2str(dscale)+", "+num2str(escale)+", "+num2str(hv_)+",0)" // No plot of first file // KillWaves/Z $appendwvn// if(exists(appendwvn))// abort("Cannot kill "+appendwvn+". Close graphs, use a different name, or append to existing wave.")// endif// rename $wvnam, $appendwvn Duplicate/o $wvnam, $appendwvn // first time will always be 2D (nz=0), not 3D KillWaves/Z $wvnam // plotopt=-1 above will plot this and not appendwvn ii+=1 jj+=1 endif variable timerRef=StartMStimer, loadtime openProgressWindow("Loading SES",sum(fileSel)+1) updateProgressWindow(jj) do if (fileSel[ii] == 1) filnam=fileListw[ii][0] wvnam=skind[0]+ExtractName( filnam, nameopt ) readSESb(0)// Execute/Q "LoadSESb(dscale, escale, hv_,-2)" Execute/Q "LoadSESb("+num2str(dscale)+", "+num2str(escale)+", "+num2str(hv_)+",-2)" jj+=1 updateProgressWindow(jj) endif ii+=1 while (ii<np) loadtime = StopMStimer( timerRef)/1E6 SVAR srebin=root:SES:srebin print jj, "/", loadtime , "=", 1E-2*round(100*jj/loadtime), "/sec : Rebin=", srebin // For 81 files, 67 sec on first try, 39 on subsequent tries. It is unclear why the length varies CloseProgressWindow() if(cmpstr(ctrlName,"CatButton1")==0) SetScale/P z zstart, zinc,zunit, $appendwvn DoWindow/F $(appendwvn+"_") if (V_flag==0) display; appendimage $appendwvn// Textbox/N=title/F=0/A=MT/E titlestr ModifyImage $appendwvn ctab= {*,*,YellowHot,0}// Label left ylbl// Label bottom xlbl ModifyGraph margin(right)=10 DoWindow/C $(appendwvn+"_")// if (DimSize( $appendwvn, 2)>0) //3D// Vol_ControlBar()// endif endif execute "Vol_ControlBar()" Slider PlaneSlide limits={0,DimSize( $appendwvn, 2)-1,1} endif if(cmpstr(ctrlName,"CatButton2")==0) DoWindow/F $(appendwvn+"_")// DimSize( $dwn, 2) Slider PlaneSlide limits={0,DimSize( $appendwvn, 2)-1,1} endif EndProc LoadSESb_WaveCat(ctrlName):ButtonControl//------------------- String ctrlName variable ii=0, jj=0, np=DimSize( root:SES:fileListw, 0) make/o/n=(np) fileSel fileSel = root:SES:fileSelectw[p][0][0] if(cmpstr(ctrlName,"CatButton1")==0) //creates a new wave, rather than simply appending to existing wave GetAssemblyPrefs() do if (fileSel[ii] == 1) break endif ii+=1 while (ii<np) root:SES:filnam=root:SES:fileListw[ii][0] root:SES:wvnam=root:SES:skind[0]+ExtractName( root:SES:filnam, root:SES:nameopt ) readSESb(0) LoadSESb(root:SES:dscale, root:SES:escale, root:SES:hv_,-1) String temp1 = root:SES:wvnam String temp2 = root:SES:appendwvn KillWaves/Z $temp2 if(exists(temp2)) abort("Cannot kill "+temp2+". Close graphs, use a different name, or append to existing wave.") endif rename $temp1, $temp2 ii+=1 jj+=1 endif variable timerRef=StartMStimer openProgressWindow("Loading SES",sum(fileSel)+1) updateProgressWindow(jj) do if (fileSel[ii] == 1) root:SES:filnam=root:SES:fileListw[ii][0] root:SES:wvnam=root:SES:skind[0]+ExtractName( root:SES:filnam, root:SES:nameopt ) readSESb(0) LoadSESb(root:SES:dscale, root:SES:escale, root:SES:hv_,-2) jj+=1 updateProgressWindow(jj) endif ii+=1 while (ii<np) print StopMStimer( timerRef)/1E6, "sec" // get about 0.5 sec per file load CloseProgressWindow() EndProc getAssemblyPrefs( zSt, zInc, zUnit, wn )//----------------- variable zSt=NumVarOrDefault("root:SES:zstart",0), zInc=NumVarOrDefault("root:SES:zinc",1) string zUnit=StrVarOrDefault("root:SES:zunit","polar"), wn=root:SES:appendwvn prompt zSt, "Z start value" prompt zInc, "Z increment" prompt zUnit, "Z-axis unit", popup, "Polar;hv;time;minute" prompt wn, "Name of assembled wave" variable/G root:SES:zstart=zSt, root:SES:zinc=zInc string/G root:SES:zunit=zUnit root:SES:appendwvn = wnEndProc SelectAll(ctrlName,checked):CheckBoxControl//----------------- String ctrlName Variable checked root:SES:fileSelectw[][0][0] = 1 CheckBox SelectAll value=0EndFunction PlotSESnew(ctrlName) : ButtonControl//======================= String ctrlName SVAR wvnam=root:SES:wvnam string spec, basenam, ext, opt basenam=wvnam NVAR escale=root:SES:escale, dscale=root:SES:dscale NVAR CCchan=root:SES:CCchan, Mottchan=root:SES:Mottchan //SVAR CClist=root:SES:CClist, MottList=root:SES:MottList //string/G MottList="Sum;4-ML1;5-ML3;6-ML2;7-ML4;8-MR1;9-MR3;10-MR2;11-MR4" string MottExt="_MottSum;ML1;ML3;ML2;ML4;MR1;MR3;MR2;MR4" string plotopt=SelectString( stringmatch(ctrlName, "Display*"), "/A", "/D") string escaleopt=SelectString( escale==1, "/X", "") string dscaleopt=SelectString( dscale>0, "", "/DS="+num2str(dscale)) opt=plotopt+escaleopt+dscaleopt strswitch( ctrlName) case "DisplayCC": // Display Channeltron spectrum in new window case "AppendCC": // Append Channeltron spectrum to top graph spec=SelectString( CCchan>0, "SpectrumGroup1", "SpectrumChannel"+num2str(CCchan)) ext=SelectString( CCchan>0, "", "_CC"+num2str(CCchan))// PlotSES_spec(spec, basenam+ext, opt) break case "DisplayMott": // Display Mott spectrum in new window case "AppendMott": // Append Mott spectrum to top graph// if (Mottchan==0)// CalcMottSum()// endif spec=SelectString( Mottchan>0, "MottSum", "SpectrumChannel"+num2str(Mottchan+3)) ext=StringFromList( Mottchan, MottExt)// PlotSES_spec(spec, basenam+ext, opt) break //case "PlotMottAsy": //Plot Mott Asymmetry Preview // LoadSES_MottAsy("") // break case "DisplayMottAsy": // Create root waves & Plot Asymmetry;// CreateMOTTWaves("root:SES:SpectrumChannel", basenam) //NVAR ASYoffset=root:SES:ASYoffset, Sherman=root:SES:Sherman, ASYpercent=root:SES:ASYpercent //opt=SelectString( ASYoffset==1, "", "/Offset") //opt+="/Sherman="+num2str(Sherman) //opt+=SelectString( ASYpercent==1, "", "/P") // CalcASY(basenam, ASYcalcopt() ) //NVAR ASYsdev=root:SES:ASYsdev, ASYuniform=root:SES:ASYuniform //opt="/SDEV="+num2str(ASYsdev) //opt+=SelectString( ASYuniform==1, "", "/U") // DisplayASY(basenam, "Energy (eV)", ASYaxisopt() ) //SetAxisASY(basenam, opt) break endswitchEndFunction PlotSES_Spec( specn, dwn, opt)//============================ String specn, dwn, opt //options //string dwn=KeyStr( "D", opt ) if (strlen(dwn)==0 ) dwn = specn // root directory endif //source wave in SES folder if (stringmatch( specn, "root:SES:*")==0) specn = "root:SES:"+specn endif WAVE specw=$specn // create output data wave Duplicate/O specw $dwn // need root: prefix? WAVE dw=$dwn // Energy Axis: optional reinterpolate to scaled array(s) variable escal=SelectNumber(KeySet("X", opt), 1, 0 ) if (escal==1) // increment varies due to rounding; reinterpolate data after scaling (method=2) ScaleWave( $dwn, "root:SES:Energy", 0, 2) // 2 = reinterp method else Duplicate/O specw $(dwn+"_x") endif // Data scaling string xlbl="Energy (eV)", ylbl="Counts" variable dscale, dgain if (KeySet("DS", opt) ) dscale=KeyVal("DS", opt) ylbl=StringFromList(dscale, "Counts;kHz;MHz" ) dgain=str2num( StringFromList(dscale, "1;1E-3;1E-6" ) ) dw *= dgain endif // Display variable plotopt=KeySet("A", opt) // 0=display, 1=append if (plotopt==0) if (escal==1) Display $dwn else Display $dwn vs $(dwn+"_x") endif // PlotSES_Style( xlbl, ylbl) ShowInfo else DoWindow/F $StringFromList(0, WinList("!*SES*", ";", "Win:1")) if (escal==1) AppendToGraph $dwn else AppendToGraph $dwn vs $(dwn+"_x") endif DoWindow/F LoadSESb_Panel endifEndProc LoadSESb_SetPreview(ctrlName,popNum,popStr) : PopupMenuControl//-------------- String ctrlName Variable popNum String popStr root:SES:autoload=1-root:SES:autoload // toggle on/off if (root:SES:autoload==1) PopupMenu popupPreview value="Ã 2D/3D data to ImageTool" else PopupMenu popupPreview value=" 2D/3D data to ImageTool" endifEndWindow SESpreview() : Graph// ------ not used anymore --- integrated into Load_SESb_Panel PauseUpdate; Silent 1 // building window... String fldrSav= GetDataFolder(1) SetDataFolder root:SES: Display /W=(230,75,582,314) data1D AppendImage/R/T data2D ModifyImage data2D ctab= {*,*,Grays,0} SetDataFolder fldrSav ModifyGraph lSize=0.5 ModifyGraph mirror(left)=0,mirror(bottom)=0 ModifyGraph lblLatPos(right)=-1 Textbox/N=text0/F=0/S=3/H=14/A=MT/X=2.56/Y=2.51/E "\\{root:SES:filnam}: \\{root:SES:skind}, \\{root:SES:smode0}"EndMacro//Proc LoadSESStyle_template( imgnam ) : GraphStyleProc LoadSESStyle_template( ) : GraphStyle//- - - - - - - - - - - - - - // Copy this to the procedure window to edit // string imgnam// print imgnam PauseUpdate; Silent 1 // modifying window... ModifyGraph/Z margin(right)=10 ModifyGraph/Z margin(left)=40 ModifyGraph/Z margin(top)=25 ModifyGraph/Z mirror=2 ModifyGraph/Z sep=8 ModifyGraph/Z standoff=0 ModifyGraph/Z axThick=0.5// Basic Image Graph Style & borders Img_Style()// Axis labeling // PlotAxes( x="E-E\BF\M (eV)", y="Det. Angle (deg)")// Image Transpose// imt() // PlotAxes(x="Det. Angle (deg)", y="E-E\BF\M (eV)") // EF energy correction string imgnam0=StringFromList(0, ImageNameList(WinName(0,1),";")) print imgnam0 ImgShift( $imgnam0, root:fit_fe002_e,"/X/O/E=-1") EndMacrostatic Function/T FolderList( matchstring, sep, startpath ) // original in BZ.ipf//=============// also used as a global variable in LoasSESb.ipf string matchstring, sep, startpath string curr= GetDataFolder(1) SetDataFolder $startpath string lst=DataFolderDir(1) // returns: "FOLDERS:item1,item2,...; SetDataFolder curr // strip "FOLDER:" and convert "," to sep variable ptr=StrSearch(lst, ":", 0) lst=lst[ptr+1, StrLen(lst)-2] ptr=0 Do ptr=StrSearch(lst, ",", ptr+1) //print ptr if (ptr==-1) break endif lst[ptr,ptr]=sep While (ptr<StrLen(lst)) // apply matchstring lst=ReduceList( lst, matchstring) return lstEndFunction LoadSESb_HeaderSection(ctrlName,popNum,popStr) : PopupMenuControl//=========================//jump to listbox section: Top, SPECtrometer; ENDstation;BEAMline String ctrlName Variable popNum String popStr SVAR headerLst=root:SES:headerVarLst variable indx switch(popNum) // numeric switch case 1: indx= 0 break case 2: indx= whichListitem("SPECTROMETER", headerLst) break case 3: indx= whichListitem("ENDSTATION", headerLst) break case 4: indx= whichListitem("BEAMLINE", headerLst) endswitch ListBox header_display selRow=indx, row=indxEnd