#pragma rtGlobals=1 // Use modern global access method. Macro load_WKF(month,today,from,to,delta,plottype) String month="z:2009_02" String today="2009_02_02" variable from=4 variable to =43 variable delta = 23 variable plottype=1 Prompt plottype, "plot type:", popup "dose (Langmuir); scan number (table)" String/G imagePathStr=root:imagePathStr String/G imagetypeStr=root:imageTypeStr String/G scanNameStr=root:scanNameStr String/G scanNumberStr=root:scanNumberStr String/G lastImage=root:lastImage String/G separatorStr = root:separatorStr String locImagePathStr=month+":"+today+":" variable i=from String tmpStr, traceStr String roiStr String stvStr String pmchStr String no=num2Str(from)+"-"+num2Str(to) String scannoStr = "SCANN_"+no String roi = "ROI_"+no String pressStr = "pressure_"+no variable nmax variable deltan=12 make/n=(to-from+1)/o $roi, $pressStr, $scannoStr SetScale/P x (from),1,"", $roi, $pressStr do if (i<10) tmpStr="00"+num2Str(i) else if (i<100) tmpStr="0"+num2Str(i) else tmpStr=num2Str(i) endif endif ImagePathStr = locImagePathStr+today+"_"+tmpStr+"_WKF" newPath/O/Q/Z imagePath ImagePathStr scanNameStr=today+"_"+tmpStr+"_WKF" scanNumberStr=tmpStr roiStr = today+"_"+tmpStr+"_ROI" stvStr = today+"_"+tmpStr+"_STV" pmchStr = "PMCH_"+tmpStr print ImagePathStr, " ", scanNameStr loadImageScan1("") nmax = numpnts($stvStr) shoRoiScan1("") differentiate $RoiStr wavestats $RoiStr integrate $RoiStr //CurveFit gauss $roiStr[V_minloc-10,V_minloc+10] /X=$stvStr /D CurveFit/Q Sigmoid $roiStr[0,min(V_minloc+deltan,nmax)] /X=$stvStr /D $roi[i-from]=W_coef[2] duplicate/o $pmchStr pwave wavestats pwave $pressStr[i-from]=V_rms if (V_rms > 10^-4) $pressStr[i-from] = V_min endif $scannoStr[i-from]=i killseries("") killseries("") i+=1 while (i<=to) $pressStr/=1.3 $pressStr*=10^6 $pressStr*=delta integrate $pressStr if (plottype == 1) display $roi vs $pressStr Label bottom "\\F'Arial'\\Z16Dose (L)" else if (plottype == 2) display $roi vs $scannoStr Label bottom "\\F'Arial'\\Z16Scan number" Edit $scannoStr, $roi endif ModifyGraph mode($roi)=3,marker($roi)=19 Label left "\\F'Arial'\\Z16Work function (eV)";DelayUpdate ModifyGraph axOffset(bottom)=1 ModifyGraph axOffset=1 ModifyGraph width=283.465,height=283.465 //String newname //prompt newname, "enter name for WKF wave:" //doPrompt "duplicate W_coef:", coefStr //if (V_flag == 0) // rename $roi newname //endif rename_wave(roi) End function rename_wave(newname) String newname String wavestr = newname Prompt newname, "enter name for coef wave:" doPrompt "rename to:", newname if (V_flag == 0) rename $wavestr $newname return 0 else return 1 endif end Macro load_ROIs(month,today,from,to,delta,plottype) String month="z:2009_01" String today="2009_01_30" variable from=1 variable to =23 variable delta =1 variable plottype=1 Prompt plottype, "plot type:", popup "dose (Langmuir); scan number (table)" String/G imagePathStr=root:imagePathStr String/G imagetypeStr=root:imageTypeStr String/G scanNameStr=root:scanNameStr String/G scanNumberStr=root:scanNumberStr String/G lastImage=root:lastImage String/G separatorStr = root:separatorStr String locImagePathStr=month+":"+today+":" variable i=from String tmpStr, traceStr String roi1Str,roi2Str,roi3Str,roi4Str,pmchStr String stvStr variable nmax variable deltan=12 String no=num2Str(from)+"-"+num2Str(to) String scannoStr = "SCANN_"+no String roi1 = "ROI1_"+no String roi2 = "ROI2_"+no String roi3 = "ROI3_"+no String roi4 = "ROI4_"+no String pressStr = "pressure_"+no make/n=(to-from+1)/o $roi1, $roi2, $roi3, $roi4, $pressStr, $scannoStr SetScale/P x (from),1,"", $roi1, $roi2, $roi3, $roi4, do if (i<10) tmpStr="00"+num2Str(i) else if (i<100) tmpStr="0"+num2Str(i) else tmpStr=num2Str(i) endif endif ImagePathStr = locImagePathStr+today+"_"+tmpStr+"_WKF" newPath/O/Q/Z imagePath ImagePathStr scanNameStr=today+"_"+tmpStr+"_WKF" scanNumberStr=tmpStr traceStr=today+"_"+tmpStr+"_trace.txt" print "load auxiliary waves from file: ", traceStr Loadwave/A/D/G/K=1/O/Q/P=ImagePath/W traceStr roi1Str="ROI1_"+tmpStr roi2Str="ROI2_"+tmpStr roi3Str="ROI3_"+tmpStr roi4Str="ROI4_"+tmpStr stvStr = "STV_"+tmpStr pmchStr = "PMCH_"+tmpStr nmax = numpnts($stvStr) display appendToGraph $roi1Str,$roi2Str,$roi3Str,$roi4Str vs $stvStr differentiate $Roi1Str wavestats $Roi1Str integrate $Roi1Str CurveFit Sigmoid $roi1Str[0,min(V_minloc+deltan,nmax)] /X=$stvStr /D $roi1[i-from]=W_coef[2] differentiate $Roi2Str wavestats $Roi2Str integrate $Roi2Str CurveFit Sigmoid $roi2Str[0,min(V_minloc+deltan,nmax)] /X=$stvStr /D $roi2[i-from]=W_coef[2] differentiate $Roi3Str wavestats $Roi3Str integrate $Roi3Str CurveFit Sigmoid $roi3Str[0,min(V_minloc+deltan,nmax)] /X=$stvStr /D $roi3[i-from]=W_coef[2] differentiate $Roi4Str wavestats $Roi4Str integrate $Roi4Str CurveFit Sigmoid $roi4Str[0,min(V_minloc+deltan,nmax)] /X=$stvStr /D $roi4[i-from]=W_coef[2] //duplicate/o $pmchStr pwave //wavestats pwave $pressStr[i-from]=V_rms if (V_rms > 10^-4) $pressStr[i-from] = V_min endif $scannoStr[i-from]=i killseries("") i+=1 while (i<=to) $pressStr/=1.3 $pressStr*=10^6 $pressStr*=delta integrate $pressStr if (plottype == 1) display $roi1, $roi2, $roi3, $roi4 vs $pressStr Label bottom "\\F'Arial'\\Z16Dose (L)" else if (plottype == 2) display $roi1, $roi2, $roi3, $roi4 vs $scannoStr Label bottom "\\F'Arial'\\Z16Scan number" Edit $scannoStr, $roi1, $roi2, $roi3, $roi4 endif ModifyGraph mode($roi1)=3,marker($roi1)=19,mode($roi2)=3,marker($roi2)=16;DelayUpdate ModifyGraph rgb($roi2)=(0,39168,0),mode($roi3)=3,marker($roi3)=17;DelayUpdate ModifyGraph rgb($roi3)=(0,12800,52224) ModifyGraph rgb($roi4)=(0,0,0) Label left "\\F'Arial'\\Z16Work function difference (eV)";DelayUpdate ModifyGraph axOffset(bottom)=1 ModifyGraph axOffset=1 ModifyGraph width=283.465,height=283.465 End Function loadImageScan1(ctrlname): buttoncontrol //160203 string ctrlname string tmpStr,newName variable j=0 SVAR imagePathStr=root:imagePathStr SVAR imagetypeStr=root:imageTypeStr SVAR scanNameStr=root:scanNameStr SVAR scanNumberStr=root:scanNumberStr SVAR lastImage=root:lastImage SVAR separatorStr = root:separatorStr NVAR scanFrom=root:scanFrom NVAR scanTo=root:scanTo NVAR energy=root:energy NVAR layer=root:layer // load all waves in trace.txt // load info ImageNum STV MOBJ Mesh BeamCurrent Box1 Box2 Box3 (kin energy scan) // ImageNum Energy --------- Mesh BeamCurrent Box1 Box2 Box3 (photon energy scan) variable lastindex = strsearch(scanNameStr,"_",Inf,1) String nameStr=scanNameStr[0,lastindex-1] string scanType = scanNameStr[lastindex+1,strlen(scanNameStr)] print "scan type = ",scanType // find rootname print "file root name = ",nameStr string scaninfoStr=nameStr+"_trace.txt" print "load auxiliary waves from file: ", scaninfoStr Loadwave/A/D/G/O/Q/P=imagePath/W scaninfoStr lastindex = strsearch(nameStr,"_",Inf,1) scanNumberStr=nameStr[lastIndex+1,strlen(nameStr)] tmpStr = "ImageNum"+nameStr[lastIndex,strlen(nameStr)] print tmpStr,nameStr,scanNumberStr variable scanNpnts=numpnts($tmpStr) // rename waves if (exists(tmpStr)==1) newName = nameStr + "_NUM" duplicate/o $tmpStr $newName killwaves $tmpStr endif tmpStr = "STV_"+scanNumberStr if ( exists(tmpStr)==1 && (stringmatch(scanType,"XPS")==1) || (stringmatch(scanType,"IV")==1) || (stringmatch(scanType,"WKF")==1)) //print "XPS scan type" newName =nameStr + "_STV" duplicate/o $tmpStr $newName scanFrom=returnWaveElement($newname,0) scanTo=returnWaveElement($newname,scanNpnts-1) killwaves $tmpStr endif tmpStr = "Energy_"+scanNumberStr if (exists(tmpStr)==1 && stringmatch(scanType,"XAS")==1) newName = NameStr + "_NRG" duplicate/o $tmpStr $newName scanFrom=returnWaveElement($newname,0) scanTo=returnWaveElement($newname,scanNpnts-1) killwaves $tmpStr endif tmpStr = "BeamCurrent_"+scanNumberStr if (exists(tmpStr)==1) newName = nameStr + "_BCR" duplicate/o $tmpStr $newName killwaves $tmpStr endif tmpStr = "Mesh_"+scanNumberStr if (exists(tmpStr)==1) newName = nameStr + "_MSH" duplicate/o $tmpStr $newName killwaves $tmpStr endif tmpStr = "MOBJ_"+scanNumberStr if (exists(tmpStr)==1 && stringmatch(scanType,"FOCUS")==1) newName = nameStr + "_OBJ" duplicate/o $tmpStr $newName killwaves $tmpStr endif // darkfield //variable darkfield=2 // prompt darkfield, "subtact darkfield", popup, "no;yes" // doPrompt "open image", darkfield //if ((V_flag ==0 )&& (darkfield == 2)) // darkfield=1 //else variable darkfield=1 //endif //load first image in order to dimension the array print "number of images: ",scanNpnts,"start energy: ",scanFrom,"end energy: ",scanTo tmpStr = nameStr +"_"+num2ScanNumberStr(j)+"."+imageTypeStr tmpStr = OpenImage(tmpStr,darkfield) if (stringMatch(tmpStr,"")!=1) // initialise the stack variable np=DimSize($tmpStr,0) variable nq=DimSize($tmpStr,1) make/n=(np,nq,scanNpnts)/O/W $nameStr imageToStack($nameStr,$tmpStr,0) j+=1 // load the rest do tmpStr=nameStr +"_"+num2ScanNumberStr(j)+"."+imageTypeStr //scanNameStr +"_"+num2ScanNumberStr(j)+"."+imageTypeStr tmpStr = OpenImage(tmpStr,darkfield) imageToStack($nameStr,$tmpStr,j) killwaves $tmpStr j+=1 while (j