#pragma rtGlobals=1 // Use modern global access method. #include "specMore" #include "spec" Menu "Macros" "Squeeze multiple laserscans",SqueezeHorizOffsets(NaN) End Function SqueezeHorizOffsets(timeSpace) Variable timeSpace=10 if (timeSpace<0 || numtype(timeSpace)) timeSpace = 10 Prompt timeSpace, "time between each laserscan (sec)" DoPrompt "give time",timeSpace if (V_flag) return Nan endif endif String traceList = TraceNameList("",";",1) Variable N = ItemsInList(traceList) Variable i,j String traceNameStr Make/N=(N)/O timeStarts__,timeEnds__ timeStarts__ = NaN timeEnds__ = NaN // first loop through the speculars to fill list of starting times for (i=0,j=0;i=0) // binning is present Variable binning=str2num(specComment[i+9,i+20]) if (binning>1) String binStr="binning="+num2istr(binning)+";" prependNote(Io,binStr) prependNote(Time_,binStr) prependNote(Det_bot,binStr) if (exists("Det_top")==1) // a dual detector scan prependNote(Det_top,binStr) endif endif endif endif if (exists("Det_top")==1) // a dual detector scan duplicate/O Io specular,offspec specular = Det_bot / Io / filterTrans offspec = Det_top / Io / filterTrans AppendToGraph specular vs Time_ AppendToGraph offspec vs Time_ else duplicate/O Io sig sig = Det_bot / Io / filterTrans AppendToGraph sig vs Time_ endif LaserStyle_() SetScale d 0,0,"sec", Time_ SetDataFolder fldrSav EndMacro Proc ChooseScanNum(scanNum) Variable scanNum Prompt scanNum,"laserscan number", popup, :temp__list_ Silent 1 :temp__list_ = StringFromList(scanNum-1, :temp__list_ ) EndMacro Function prependNote(wav,nStr) // prepend a string to a wave note, just return is additional part is empty Wave wav // wave String nStr // string to prepend to wave note if (strlen(nStr)<1) return 1 endif String noteStr=note(wav) // save current wavenote Note/K wav // clear wavenote Note wav nStr+noteStr End Function/T GetListOfLaserscans(fileName,path) // get scan number for laserscans in a spec file String fileName String path Variable fileVar // file ref number Variable i,j Variable V_flag String scanList="",posList Open /R/P=$path/M="spec data file"/Z fileVar as fileName if (V_flag) Open /R/M="spec data file" fileVar as fileName endif FStatus(fileVar) if (exists("root:specDefaultFile")!=2) String /G root:specDefaultFile endif String/G root:specDefaultFile = S_fileName if (exists("root:specDefaultPath")!=2) String /G root:specDefaultPath endif String/G root:specDefaultPath = path posList = ListPosOfLineTypes(fileVar," laserscan ") if (strlen(posList)<1) return "" endif String line=" " line = PadString(line, 80, 0) i = 0 Variable N=ItemsInList(posList) do FSetPos fileVar, str2num(StringFromList(i, posList))-20 FBinRead fileVar, line j = strsearch(line, "#S ", 0)+2 if (j>=0) scanList += num2istr(str2num(line[j,j+10]))+";" endif i += 1 while(i0) Label left "detector / I\\Bo\\M";DelayUpdate Label bottom "time (\\U)" SetAxis/A/E=1 left String str=GetDataFolder(0) Variable scanNum=0 if (!cmpstr("spec",str[0,3])) // can decode scan number from current folder scanNum = str2num(str[4,inf]) endif String textStr = "" // String textStr = "Escete ?, " if (exists("specComment2")==2) textStr += specComment2+"\r" endif if (exists("specComment1")==2) textStr += specComment1+"\r" endif if (exists("specComment")==2) textStr += specComment+"\r" endif textStr += "\\Z12" if (exists("timeWritten")==2) textStr += timeWritten else if (exists("specCommand")==2) i = strsearch(specCommand," #D ",0) if (i>0) if (char2num(specCommand[i+3])==32) // remove any leading space i += 1 endif textStr += specCommand[i+3,inf] else textStr += specCommand endif endif endif if (scanNum>0) textStr += ", #"+num2istr(scanNum) endif textStr += "\\M\r" Variable temp = specInfo(scanNum,"temperature") if (!numtype(temp) && temp>0) textStr += "T\\BTC\\M = "+num2str(temp)+"¡ C" else textStr += "T\\BTC\\M = ???¡ C" endif textStr += ", " temp = GetTxray() if (!numtype(temp) && temp>0) textStr += "T\\Bx-ray\\M = "+num2str(temp)+"¡ C" else textStr += "T\\Bx-ray\\M = ???¡ C" endif str = StringByKey("DATAFILE", note($StringFromList(0, wlist)),"=") if (strlen(str)>0) textStr = textStr +"\r\\Z12file = "+str+"\\M" endif Textbox/C/N=text0/F=0/S=3 textStr EndMacro Function GetTxray() Variable Txray = NumVarOrDefault("root:Packages:spec:Txray",NaN) Prompt Txray, "the X-ray temperature (C)" DoPrompt "choose Temperature", Txray if (!numtype(Txray)) Variable/G root:Packages:spec:Txray=Txray endif return Txray End