Ignore:
Timestamp:
Feb 5, 2019 3:13:21 PM (4 years ago)
Author:
srkline
Message:

adding procedures for calculating sector averages of the data

still need to add overlay of sector angles.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r1104 r1121  
    130130 
    131131#include "V_Utilities_Comparisons" 
     132#include "V_Sector_Average" 
    132133 
    133134 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf

    r1111 r1121  
    496496        Wave qb = tmp_qb 
    497497        Wave fs = tmp_fs 
     498         
     499        // zero point waves can be generated from sector averages, exit now 
     500        if(numpnts(qw) == 0) 
     501                SetDataFolder root: 
     502                return(1) 
     503        endif 
    498504         
    499505        Variable q1,q2,tol,ii 
     
    748754        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
    749755 
    750         Printf "%d points removed from beginning, %d points from the end  of %s \r",nbeg,nend,detStr 
    751756 
    752757// TODO  
     
    768773                Wave/Z qBar = $("qBar_qxqy_"+detStr) 
    769774                Wave/Z fSubS = $("fSubS_qxqy_"+detStr) 
    770                          
     775 
     776// check for the existence of every wave + non-zero length 
     777// zero length/null waves can be generated with sector averages 
     778// exit if something is wrong 
     779                if(waveExists(qw) == 0 || numpnts(qw) == 0) 
     780                        SetDataFolder root: 
     781                        return(1) 
     782                endif 
     783                if(waveExists(iw) == 0 || numpnts(iw) == 0) 
     784                        SetDataFolder root: 
     785                        return(1) 
     786                endif 
     787                if(waveExists(ew) == 0 || numpnts(ew) == 0) 
     788                        SetDataFolder root: 
     789                        return(1) 
     790                endif 
     791                if(waveExists(sigQ) == 0 || numpnts(sigQ) == 0) 
     792                        SetDataFolder root: 
     793                        return(1) 
     794                endif 
     795                if(waveExists(qBar) == 0 || numpnts(qBar) == 0) 
     796                        SetDataFolder root: 
     797                        return(1) 
     798                endif 
     799                if(waveExists(fSubS) == 0 || numpnts(fSubS) == 0) 
     800                        SetDataFolder root: 
     801                        return(1) 
     802                endif 
     803 
     804 
     805        // waves all exist               
    771806                DeletePoints 0,nBeg, qw,iw,ew,sigQ,qBar,fSubS 
    772807 
     
    775810                DeletePoints npt-nEnd,nEnd, qw,iw,ew,sigQ,qBar,fSubS 
    776811         
     812                Printf "%d points removed from beginning, %d points from the end  of %s \r",nbeg,nend,detStr 
     813                SetDataFolder root: 
    777814        return(0) 
    778815End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1117 r1121  
    741741                                AppendImage/W=MaskEditPanel currentTube 
    742742//                              ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,1,BlueRedGreen,0}        ,minRGB=NaN,maxRGB=0 
    743                                 ModifyImage/W=MaskEditPanel overlay ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,40000) 
     743                                ModifyImage/W=MaskEditPanel overlay ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
    744744                                ModifyImage/W=MaskEditPanel currentTube ctab= {0.9,1,CyanMagenta,0}     ,minRGB=NaN,maxRGB=0 
    745745                //              ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0,*,BlueRedGreen,0}   
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1119 r1121  
    13181318        SVAR gAvgInfoStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr 
    13191319         
    1320         String av_typ,autoSave,AutoName,binType 
    1321 //      Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
    1322         Variable Qctr,qDelta 
     1320        String av_typ,autoSave,AutoName,binType,side 
     1321        Variable phi,dphi,width=10,Qctr = 0.01,qDelta=10 
    13231322        String detGroup 
    13241323         
     
    13341333        qDelta = NumberByKey("QDELTA", gAvgInfoStr  ,"=",";") 
    13351334        detGroup = StringByKey("DETGROUP", gAvgInfoStr  ,"=",";") 
     1335        phi = NumberByKey("PHI", gAvgInfoStr  ,"=",";") 
     1336        dphi = NumberByKey("DPHI", gAvgInfoStr  ,"=",";") 
     1337 
    13361338//      Execute "V_GetAvgInfo_Full()" 
    13371339//              Execute "V_GetAvgInfo()" 
     
    13401342 
    13411343//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 
    1342         Prompt av_typ, "Type of Average",popup,"Circular;Narrow_Slit;Annular;QxQy_ASCII;" 
     1344        Prompt av_typ, "Type of Average",popup,"Circular;Narrow_Slit;Annular;Sector;QxQy_ASCII;" 
    13431345 
    13441346// comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 
     
    13471349        Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" 
    13481350//      Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" 
    1349 //      Prompt side,"Include detector halves?",popup,"both;right;left" 
    1350 //      Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" 
    1351 //      Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" 
     1351        Prompt side,"Include detector halves?",popup,"both;right;left" 
     1352        Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" 
     1353        Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" 
    13521354//      Prompt width, "Width of Rectangular average (1,128)" 
    13531355        Prompt binType,"Binning Type?",popup,ksBinTypeStr 
     
    13581360 
    13591361         
    1360         DoPrompt "Enter Averaging Parameters",av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup 
     1362        DoPrompt "Enter Averaging Parameters",av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup,side,phi,dphi 
    13611363        if (V_Flag) 
    13621364                return(0)                                                               // User canceled 
     
    13811383        gAvgInfoStr += "BINTYPE=" + binType + ";" 
    13821384         
    1383 //      if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
    1384 //              gAvgInfoStr += "SIDE=" + side + ";" 
    1385 //              gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
    1386 //              gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
    1387 //      Endif 
     1385        if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
     1386                gAvgInfoStr += "SIDE=" + side + ";" 
     1387                gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1388                gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
     1389        Endif 
    13881390//       
    13891391//      if(cmpstr(av_typ,"Rectangular")==0) 
     
    31623164                         
    31633165                case "Sector": 
    3164 //                      CircularAverageTo1D(activeType) 
     3166                        String side = StringByKey("SIDE",avgStr,"=",";") 
     3167                        Variable phi_rad = (Pi/180)*NumberByKey("PHI",avgStr,"=",";")           //in radians  
     3168                        Variable dphi_rad = (Pi/180)*NumberByKey("DPHI",avgStr,"=",";") 
     3169                        V_QBinAllPanels_Sector(activeType,binType,collimationStr,side,phi_rad,dphi_rad) 
    31653170                        break 
    31663171                case "Sector_PlusMinus": 
     
    32183223 
    32193224                        case "Circular": 
     3225                        case "Sector": 
    32203226                                V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
    32213227                                V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned                              
    3222                                 break 
    3223                         case "Sector": 
    3224         //                      CircularAverageTo1D(activeType) 
    32253228                                break 
    32263229                        case "Sector_PlusMinus": 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_QIS.ipf

    r1120 r1121  
    394394        String a1Str 
    395395        Variable pixX,pixY 
    396         Variable numTextLines=19,ii,jj,kk 
    397  
     396        Variable numTextLines,ii,jj,kk 
     397        Variable pixSizeX,pixSizeY 
     398 
     399        numTextLines = 23 
    398400        Make/O/T/N=(numTextLines) labelWave 
    399401 
     
    443445        // or -- V_getBeamStopC3_size(type) 
    444446                bstop = V_getBeamStopC2_size(type) 
     447 
     448                pixSizeX = V_getDet_x_pixel_size(type,detStr) 
     449                pixSizeY = V_getDet_y_pixel_size(type,detStr) 
    445450                 
    446451        ///////// 
     
    461466                labelWave[12] = "Average Choices: "+proto[5] 
    462467                labelWave[13] = "Collimation type: "+proto[9] 
    463                 labelWave[14] = "" 
    464                 labelWave[15] = "*** Data written from "+type+" folder and may not be a fully corrected data file ***" 
    465 //              labelWave[16] = "Data columns are Qx - Qy - Qz - I(Qx,Qy) - Err I(Qx,Qy)" 
    466         //      labelWave[16] = "Data columns are Qx - Qy - I(Qx,Qy) - Qz - SigmaQ_parall - SigmaQ_perp - fSubS(beam stop shadow)" 
    467                 labelWave[16] = "Data columns are Qx - Qy - I(Qx,Qy) - err(I) - Qz - SigmaQ_parall - SigmaQ_perp - fSubS(beam stop shadow)" 
    468                 labelWave[17] = "The error wave may not be properly propagated (1/2019)" 
    469                 labelWave[18] = "ASCII data created " +date()+" "+time() 
     468                labelWave[14] = "Panel = "+detStr 
     469                labelWave[15] = "NumXPixels="+num2str(pixX) 
     470                labelWave[16] = "XPixelSize_mm="+num2str(pixSizeX) 
     471                labelWave[17] = "NumYPixels="+num2str(pixY) 
     472                labelWave[18] = "YPixelSize_mm="+num2str(pixSizeY) 
     473                labelWave[19] = "*** Data written from "+type+" folder and may not be a fully corrected data file ***" 
     474//              labelWave[20] = "Data columns are Qx - Qy - Qz - I(Qx,Qy) - Err I(Qx,Qy)" 
     475        //      labelWave[20] = "Data columns are Qx - Qy - I(Qx,Qy) - Qz - SigmaQ_parall - SigmaQ_perp - fSubS(beam stop shadow)" 
     476                labelWave[20] = "Data columns are Qx - Qy - I(Qx,Qy) - err(I) - Qz - SigmaQ_parall - SigmaQ_perp - fSubS(beam stop shadow)" 
     477                labelWave[21] = "The error wave may not be properly propagated (1/2019)" 
     478                labelWave[22] = "ASCII data created " +date()+" "+time() 
    470479                //strings can be too long to print-- must trim to 255 chars 
    471480                for(jj=0;jj<numTextLines;jj+=1) 
     
    518527        //      qval = CalcQval(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 
    519528                Duplicate/O qTot,phi,r_dist 
    520                 Variable pixSizeX,pixSizeY,xctr,yctr 
    521                 pixSizeX = V_getDet_x_pixel_size(type,detStr) 
    522                 pixSizeY = V_getDet_y_pixel_size(type,detStr) 
     529                Variable xctr,yctr 
     530 
    523531 
    524532                xctr = V_getDet_beam_center_x_pix(type,detStr) 
     
    603611End 
    604612 
    605 // this assumes that: 
    606 // --QxQy data was written out in the format specified by the Igor macros, that is the x varies most rapidly 
    607 // 
    608 // TODO -- this needs to be made generic for reading in different panels with different XY dimensions 
    609 // -- add the XY dimensions to the QxQyASCII file header somewhere so that it can be read in and used here 
    610 // 
    611 // the SANS analysis 2D loader assumes that the matrix is square, mangling the VSANS data. 
    612 // the column data (for fitting) is still fine, but the matrix representation is incorrect. 
    613 // 
    614 Function V_ConvertQxQy2Mat(Qx,Qy,inten,matStr) 
    615         Wave Qx,Qy,inten 
    616         String matStr 
    617          
    618         String folderStr=GetWavesDataFolder(Qx,1) 
    619          
    620         Variable numX,numY 
    621         numX=48 
    622         numY=128 
    623         Make/O/D/N=(numX,numY) $(folderStr + matStr) 
    624         Wave mat=$(folderStr + matStr) 
    625          
    626         WaveStats/Q Qx 
    627         SetScale/I x, V_min, V_max, "", mat 
    628         WaveStats/Q Qy 
    629         SetScale/I y, V_min, V_max, "", mat 
    630          
    631         Variable xrows=numX 
    632          
    633         mat = inten[q*xrows+p] 
    634          
    635         return(0) 
    636 End 
    637  
    638  
     613 
Note: See TracChangeset for help on using the changeset viewer.