#pragma rtGlobals=1 // Use modern global access method. #pragma version=5.0 #pragma IgorVersion=6.1 //////////// // vers 1.21 3 may 06 total transmission incorporated (BSG) // //************************** // Vers 1.2 091901 // // marquee functions are used to: // // locate the beamcenter // set the (x,y) box coordinates for the sum for transmission calculation // read out coordinates // do a "box sum" of the same box over a range of files // do a 2D Gaussian fit over a selected range // do a save of the current image (with colorBar) - as a graphics image // //*************************** //sums the data counts in the box specified by (x1,y1) to (x2,y2) //assuming that x10","K6<1"} CurveFit/N Gauss2D data[x1,x2][y1,y2] /I=1 /W=data_err /D /R /A=0 /C=temp_constr Killwaves/Z temp_constr endif End // to save the image, simply invoke the IGOR menu item for saving graphics // Function SaveSANSGraphic() : GraphMarquee NVAR isDemoVersion=root:myGlobals:isDemoVersion if(isDemoVersion==1) // comment out in DEMO_MODIFIED version, and show the alert DoAlert 0,"This operation is not available in the Demo version of IGOR" else DoIGORMenu "File","Save Graphics" endif End //does a sum over each of the files in the list over the specified range // x,y are assumed to already be in-bounds of the data array // output is dumped to the command window // Function DoBoxSum(fileStr,x1,x2,y1,y2,type) String fileStr Variable x1,x2,y1,y2 String type //parse the list of file numbers String fileList="",item="",pathStr="",fullPath="" Variable ii,num,err,cts PathInfo catPathName If(V_Flag==0) Abort "no path selected" Endif pathStr = S_Path fileList=ParseRunNumberList(fileStr) num=ItemsInList(fileList,",") //loop over the list //add each file to SAM (to normalize to monitor counts) //sum over the box //print the results Make/O/N=(num) FileID,BoxCounts Print "Results are stored in root:FileID and root:BoxCounts waves" for(ii=0;ii= 0) ? round(x1) : 0 x2 = (round(x2) <= (pixelsX-1)) ? round(x2) : (pixelsX-1) y1 = (round(y1) >= 0) ? round(y1) : 0 y2 = (round(y2) <= (pixelsY-1)) ? round(y2) : (pixelsY-1) return(0) End //testing function, not used Function testKeepInBounds(x1,x2,y1,y2) Variable x1,x2,y1,y2 KeepSelectionInBounds(x1,x2,y1,y2) Print x1,x2,y1,y2 return(0) End // generates a histogram of the data as defined by the marquee. The longer dimension of the marquee // becomes the x-axis of the histogram (this may need to be changed for some odd case). Pixel range specified // by the marquee is inclusive, and is automatically kept in-bounds // // The counts over the (short) dimension are averaged, and plotted vs. the pixel position. // Pixel position is reported as Detector coordinates (1,128). Counts are whatever the current display // happens to be. // Function SANS_Histogram() : GraphMarquee GetMarquee left,bottom if(V_flag == 0) Abort "There is no Marquee" endif // Variable count,x1,x2,y1,y2,xwidth,ywidth,vsX=1,xx,yy x1 = V_left x2 = V_right y1 = V_bottom y2 = V_top KeepSelectionInBounds(x1,x2,y1,y2) Print "x1,x2,y1,y2 (det) =",x1+1,x2+1,y1+1,y2+1 //determine whether to do x vs y or y vs x xwidth=x2-x1 ywidth=y2-y1 if(xwidth < ywidth) vsX=0 //sum and graph vs Y endif SVAR cur_folder=root:myGlobals:gDataDisplayType WAVE data=$("root:Packages:NIST:"+cur_folder+":data") //don't care if it's log or linear scale Make/O/N=(max(xwidth,ywidth)+1) Position,AvgCounts AvgCounts=0 //set position wave if(vsX) position=p+x1 else position=p+y1 endif //convert the position to Detector coordinates position += 1 //Compute the histogram (manually) if(vsX) for(xx=x1;xx<=x2;xx+=1) //outer loop is the "x-axis" for(yy=y1;yy<=y2;yy+=1) AvgCounts[xx-x1] += data[xx][yy] endfor endfor AvgCounts /= (ywidth+1) else for(yy=y1;yy<=y2;yy+=1) for(xx=x1;xx<=x2;xx+=1) AvgCounts[yy-y1] += data[xx][yy] endfor endfor AvgCounts /= (xwidth+1) endif GetMarquee/K //to keep from drawing the marquee on the new histo graph //draw the graph, or just bring to the front with the new data DoWindow/F SANS_Histo if(V_Flag != 1) Draw_Histo() endif return(0) End //draws the histogram of the 2d data as specified by AvgCounts and Position //both wave are assumed to exist in the data folder. The SANS_Histogram() marquee //operation is responsible for creating them. // Function Draw_Histo() Display /W=(197,329,567,461)/K=1 AvgCounts vs Position DoWindow/C SANS_Histo DoWindow/T SANS_Histo,"Histogram" ModifyGraph mode=0,grid=1,mirror=2 ModifyGraph rgb=(21845,21845,21845) ModifyGraph standoff=0 ModifyGraph hbFill=2 ModifyGraph useNegPat=1 ModifyGraph usePlusRGB=1 ModifyGraph useNegRGB=1 ModifyGraph hBarNegFill=2 ModifyGraph negRGB=(0,0,65535) SetAxis/A/N=2 left Label left "Counts" Label bottom "Pixel (detector coordinates)" End //function will print marquee coordinates in axis terms, not detector terms //since IGOR is [0][127] and detector is (1,128) Function PrintMarqueeCoords() : GraphMarquee GetMarquee left,bottom if(V_flag == 0) Print "There is no Marquee" else Variable count,x1,x2,y1,y2 x1 = V_left x2 = V_right y1 = V_bottom y2 = V_top printf "marquee left in bottom axis terms: %g\r",round(V_left) printf "marquee right in bottom axis terms: %g\r",round(V_right) printf "marquee bottom in left axis terms: %g\r",round(V_bottom) printf "marquee top in left axis terms: %g\r",round(V_top) printf "**note that you must add 1 to each axis coordinate to get detector coordinates\r" KeepSelectionInBounds(x1,x2,y1,y2) SVAR cur_folder=root:myGlobals:gDataDisplayType count = SumCountsInBox(x1,x2,y1,y2,cur_folder) Print "counts = "+ num2str(count) endif End