#pragma rtGlobals=1 // Use modern global access method. #pragma ModuleName=Triangulation #pragma version = 2.1 #include "microGeometry", version>=2.1 Menu "micro" SubMenu "Refinement" "Triangulate...",Triangulate("") End SubMenu "Tables" "Pixel Rays for Triang",/Q,EditTriangPixelRays($"") End End //Function plot_all_rays() // if (exists("Triangulate_rays")==1) // Wave rays = Triangulate_rays // elseif (exists("TriPixelRays")==1) // Wave rays = TriPixelRays // else // return 1 // endif // Variable i, N=DimSize(rays,1) // display // for (i=0;i0)) Prompt range,"range of file numbers to triangulate" DoPrompt "range",range if (V_flag) return 1 endif printf "Triangulate(\"%s\")\r",range endif Variable N=ItemsInRange(range) if (!(N>0)) DoAlert 0,"No items in range '"+range+"'" endif String prefixList = "FullPeakList_tri_" String strStruct=StrVarOrDefault(":geoStructStr","") // get to values in current directory if (strlen(strStruct)<1) strStruct=StrVarOrDefault("root:Packages:geometry:geoStructStr","") // try the default values endif if (strlen(strStruct)<1) Abort "you must set the geomery parameters first" endif STRUCT microGeometry geo StructGet/S/B=2 geo, strStruct // load previous values Variable xc=geo.xcent, yc=geo.ycent, ddOffset=geo.ddOffset xc -= 1 // change from 1 based to 0 based yc -= 1 Variable m, allHere for(m=str2num(range),allHere=1; !numtype(m)&&allHere; m=NextInRange(range,m)) // loop over every image allHere = (exists(prefixList+num2istr(m))==1) endfor if (allHere) DoAlert 1,"Use the already loaded data?" allHere = (V_flag==1) endif if (!allHere) // load and process each image Variable fid Open/D/R/P=home/T=".SPE"/M="pick one of the spe files" fid if (strlen(S_fileName)<1) DoAlert 0,"No file chosen" return 1 endif String fileRoot = ParseFilePath(1,S_fileName,":",1,0)+ParseFilePath(3,S_fileName,":",1,0) Variable i, ichar, zero=char2num("0"), nine=char2num("9") for (i=strlen(fileRoot)-1;i>=0 && isdigit(fileRoot[i]);i-=1) endfor fileRoot = fileRoot[0,i] printf "Triangulating with '%s', range=\"%s\"\r",fileRoot,range for(m=str2num(range); !numtype(m); m=NextInRange(range,m)) // loop over every image if (ProcessOneTriangImage(fileRoot,m,prefixList)) DoAlert 0,"Unable to process image "+num2istr(m) return 1 endif printf "processed image %s%d.SPE\r",fileRoot,m endfor endif // done loading and processing all images (delted them too), have left the fitted peak lists Wave fitted = $(prefixList+num2istr(LastInRange(range))) Variable Nrays = round(DimSize(fitted,0)*0.7) printf "doing triangulation on %d different rays\r",Nrays Make/N=3/O/D Triangulate_xyz Wave xyz = Triangulate_xyz Make/N=(N,Nrays,5)/O/D Triangulate_rays, TriPixelRays // only used for looking at, nothing really uses this wave Wave rays = Triangulate_rays SetDimLabel 0,-1,'height',TriPixelRays String str for(i=0;i