Changeset 754 for sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtils2D_v40.ipf
- Timestamp:
- Oct 15, 2010 4:27:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtils2D_v40.ipf
r747 r754 11 11 // 12 12 // 13 // 13 // - OCT 2010 - added fDoBinning_QxQy2D(folderStr) that takes the QxQyQz data and bins it to I(Q) 14 // 1D result must still be plotted manually, can be automated later. 15 // - for Scaled Image data (QxQy), the function fDoBinning_Scaled2D (in FFT_Cubes) could be 16 // modified and added to this file. It was meant for an FFT slice, but applies to 17 // 2D model calculations (model_lin) 2D data files as well. 14 18 15 19 … … 990 994 991 995 End 996 997 // This routine assumes that the 2D data was loaded with the NCNR loader, so that the 998 // data is in a data folder, and the extensions are known. A more generic form could 999 // be made too, if needed. 1000 // 1001 // X- need error on I(q) 1002 // -- need to set "proper" number of data points (delta and qMax?) 1003 // X- need to remove points at high Q end 1004 // 1005 // -- like the routines in CircSectAve, start with 500 points, and trim after binning is done. 1006 // you'l end up with < 200 points. 1007 // 1008 // the results are in iBin_qxqy, qBin_qxqy, and eBin_qxqy, in the folder passed 1009 // 1010 //Function fDoBinning_QxQy2D(inten,qx,qy,qz) 1011 Function fDoBinning_QxQy2D(folderStr) 1012 String folderStr 1013 1014 // Wave inten,qx,qy,qz 1015 1016 SetDataFolder $("root:"+folderStr) 1017 1018 WAVE inten = $(folderStr + "_i") 1019 WAVE qx = $(folderStr + "_qx") 1020 WAVE qy = $(folderStr + "_qy") 1021 WAVE qz = $(folderStr + "_qz") 1022 1023 Variable xDim=numpnts(qx),yDim 1024 Variable ii,jj,delQ 1025 Variable qTot,nq,var,avesq,aveisq 1026 Variable binIndex,val 1027 1028 nq = 500 1029 1030 yDim = XDim 1031 Make/O/D/N=(nq) iBin_qxqy,qBin_qxqy,nBin_qxqy,iBin2_qxqy,eBin_qxqy 1032 delQ = abs(sqrt(qx[2]^2+qy[2]^2+qz[2]^2) - sqrt(qx[1]^2+qy[1]^2+qz[1]^2)) //use bins of 1 pixel width 1033 qBin_qxqy[] = p* delQ 1034 SetScale/P x,0,delQ,"",qBin_qxqy //allows easy binning 1035 1036 iBin_qxqy = 0 1037 iBin2_qxqy = 0 1038 eBin_qxqy = 0 1039 nBin_qxqy = 0 //number of intensities added to each bin 1040 1041 for(ii=0;ii<xDim;ii+=1) 1042 qTot = sqrt(qx[ii]^2 + qy[ii]^2+ qz[ii]^2) 1043 binIndex = trunc(x2pnt(qBin_qxqy, qTot)) 1044 val = inten[ii] 1045 if (numType(val)==0) //count only the good points, ignore Nan or Inf 1046 iBin_qxqy[binIndex] += val 1047 iBin2_qxqy[binIndex] += val*val 1048 nBin_qxqy[binIndex] += 1 1049 endif 1050 endfor 1051 1052 //calculate errors, just like in CircSectAve.ipf 1053 for(ii=0;ii<nq;ii+=1) 1054 if(nBin_qxqy[ii] == 0) 1055 //no pixels in annuli, data unknown 1056 iBin_qxqy[ii] = 0 1057 eBin_qxqy[ii] = 1 1058 else 1059 if(nBin_qxqy[ii] <= 1) 1060 //need more than one pixel to determine error 1061 iBin_qxqy[ii] /= nBin_qxqy[ii] 1062 eBin_qxqy[ii] = 1 1063 else 1064 //assume that the intensity in each pixel in annuli is normally 1065 // distributed about mean... 1066 iBin_qxqy[ii] /= nBin_qxqy[ii] 1067 avesq = iBin_qxqy[ii]^2 1068 aveisq = iBin2_qxqy[ii]/nBin_qxqy[ii] 1069 var = aveisq-avesq 1070 if(var<=0) 1071 eBin_qxqy[ii] = 1e-6 1072 else 1073 eBin_qxqy[ii] = sqrt(var/(nBin_qxqy[ii] - 1)) 1074 endif 1075 endif 1076 endif 1077 endfor 1078 1079 // find the last non-zero point, working backwards 1080 val=nq 1081 do 1082 val -= 1 1083 while(nBin_qxqy[val] == 0) 1084 1085 // print val, nBin_qxqy[val] 1086 DeletePoints val, nq-val, iBin_qxqy,qBin_qxqy,nBin_qxqy,iBin2_qxqy,eBin_qxqy 1087 1088 SetDataFolder root: 1089 1090 return(0) 1091 End
Note: See TracChangeset
for help on using the changeset viewer.