Ignore:
Timestamp:
Feb 11, 2019 2:44:55 PM (4 years ago)
Author:
srkline
Message:

corrected compiling issue with version 7.87

Fixed logic in defining sector mask
Added mask for Annular average

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

Legend:

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

    r1097 r1126  
    844844        return(0) 
    845845End 
     846 
     847 
     848//  
     849// x- I want to mask out everything that is "out" of the annulus 
     850// 
     851// 0 = keep the point 
     852// 1 = yes, mask the point 
     853Function V_MarkAnnularOverlayPixels(qTotal,overlay,qCtr_ann,qWidth) 
     854        Wave qTotal,overlay 
     855        Variable qCtr_ann,qWidth 
     856                 
     857         
     858        Variable xDim=DimSize(qTotal, 0) 
     859        Variable yDim=DimSize(qTotal, 1) 
     860 
     861        Variable ii,jj,exclude,qVal 
     862         
     863        // initialize the mask to == 1 == exclude everything 
     864        overlay = 1 
     865 
     866// now give every opportunity to keep pixel in 
     867        for(ii=0;ii<xDim;ii+=1) 
     868                for(jj=0;jj<yDim;jj+=1) 
     869                        //qTot = sqrt(qx[ii]^2 + qy[ii]^2+ qz[ii]^2) 
     870                        qval = qTotal[ii][jj] 
     871                        exclude = 1 
     872                 
     873                        // annulus as defined 
     874                        if(V_CloseEnough(qval,qCtr_ann,qWidth)) 
     875                                exclude = 0 
     876                        endif 
     877                         
     878                        // set the mask value 
     879                        overlay[ii][jj] = exclude 
     880                endfor 
     881        endfor 
     882 
     883 
     884        return(0) 
     885End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1124 r1126  
    11321132        SetVariable setvar3,limits={0,359,1},value=root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ 
    11331133 
    1134         PopupMenu popup4,pos={200,100},size={90,23.00},proc=V_DummyPopMenuProc,title="Sector Side(s)" 
     1134        PopupMenu popup4,pos={200,100},size={90,23.00},title="Sector Side(s)"//,proc=V_DummyPopMenuProc 
    11351135        PopupMenu popup4,mode=1,value= #"\"both;left;right;\"" 
    11361136         
     
    13281328 
    13291329 
    1330  
    1331 Function V_DummyPopMenuProc(pa) : PopupMenuControl 
    1332         STRUCT WMPopupAction &pa 
    1333  
    1334         switch( pa.eventCode ) 
    1335                 case 2: // mouse up 
    1336                         Variable popNum = pa.popNum 
    1337                         String popStr = pa.popStr 
    1338                          
    1339                         DoAlert 0,"Fill in the dummy procedure" 
    1340                          
    1341                         break 
    1342                 case -1: // control being killed 
    1343                         break 
    1344         endswitch 
    1345  
    1346         return 0 
    1347 End 
     1330// 
     1331//Function V_DummyPopMenuProc(pa) : PopupMenuControl 
     1332//      STRUCT WMPopupAction &pa 
     1333// 
     1334//      switch( pa.eventCode ) 
     1335//              case 2: // mouse up 
     1336//                      Variable popNum = pa.popNum 
     1337//                      String popStr = pa.popStr 
     1338//                       
     1339//                      DoAlert 0,"Fill in the dummy procedure" 
     1340//                       
     1341//                      break 
     1342//              case -1: // control being killed 
     1343//                      break 
     1344//      endswitch 
     1345// 
     1346//      return 0 
     1347//End 
    13481348 
    13491349 
     
    15191519                                        NVAR qWidth = root:Packages:NIST:VSANS:Globals:Mask:gAnnularDQ                           
    15201520 
    1521                                         break 
    1522                  
     1521                                        // loop over all of the panels 
     1522                                        // fill in the mask 
     1523                                        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     1524                                                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     1525                                                Wave qTotal = $(str1+str2+detStr+":qTot_"+detStr) 
     1526                                                Wave w = V_getDetectorDataW(folderStr,detStr)   //this is simply to get the correct wave scaling on the overlay 
     1527                                                Duplicate/O w $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1528                                                Wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1529                                                V_MarkAnnularOverlayPixels(qTotal,overlay,qCtr_ann,qWidth) 
     1530                                        endfor 
     1531 
     1532                                        break 
    15231533                                default:         
    15241534                                        //do nothing 
     
    16231633                                        ControlInfo/W=VSANS_Det_Panels popup4 
    16241634                                        String side = S_Value 
    1625                                         NVAR phi_rad = root:Packages:NIST:VSANS:Globals:Mask:gSectorAngle 
    1626                                         NVAR dphi_rad = root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ 
     1635                                        NVAR phi = root:Packages:NIST:VSANS:Globals:Mask:gSectorAngle 
     1636                                        NVAR delta = root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ 
    16271637                                                                 
    1628                                         //String side = StringByKey("SIDE",avgStr,"=",";") 
    1629                                         //Variable phi_rad = (Pi/180)*NumberByKey("PHI",avgStr,"=",";")         //in radians  
    1630                                         //Variable dphi_rad = (Pi/180)*NumberByKey("DPHI",avgStr,"=",";") 
    1631                                         V_QBinAllPanels_Sector(activeType,binType,collimationStr,side,phi_rad,dphi_rad) 
     1638                                // convert the angles to radians before passing                                  
     1639                                        V_QBinAllPanels_Sector(activeType,binType,collimationStr,side,phi*pi/180,delta*pi/180) 
    16321640                                        V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
    16331641                                        V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned              
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf

    r1119 r1126  
    2424                "Patch Detector Calibration",V_PatchDetectorCalibrationPanel() 
    2525                "-" 
     26                "Show Mask for Averaging",V_Display_Four_Panels() 
    2627                "Annular Binning",Annular_Binning() 
    2728                "Write Annular Data",V_Write1DAnnular() 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Sector_Average.ipf

    r1124 r1126  
    5353        Variable yDim=DimSize(phi, 1) 
    5454 
    55         Variable ii,jj,isIn,forward,mirror 
    56          
    57 // initialize the mask to keep everything 
    58         overlay = 0 
    59  
     55        Variable ii,jj,exclude,mirror_phiCtr,crossZero 
     56         
     57// does the +- delta cross 0? 
     58        crossZero = 0 
     59        if((phiCtr - delta) < 0) 
     60                crossZero = 1 
     61        endif 
     62        if((phiCtr + delta) > 2*pi) 
     63                crossZero = 1 
     64        endif 
     65// if "both", what is the mirror_phiCtr? 
     66        if(cmpstr(side,"both")==0) 
     67                if(phiCtr < pi) 
     68                        mirror_phiCtr = phiCtr + pi 
     69                else 
     70                        mirror_phiCtr = phiCtr - pi 
     71                endif 
     72        endif 
     73 
     74// initialize the mask to == 1 == exclude everything 
     75        overlay = 1 
     76 
     77 
     78// now give every opportunity to keep pixel in 
    6079        for(ii=0;ii<xDim;ii+=1) 
    6180                for(jj=0;jj<yDim;jj+=1) 
    6281                        //qTot = sqrt(qx[ii]^2 + qy[ii]^2+ qz[ii]^2) 
    6382                        phiVal = phi[ii][jj] 
    64                         isIn = 0 
    65                  
    66                         isIn = V_CloseEnough(phiVal,phiCtr,delta) 
    67                         if(!isIn)               // it's NOT in the sector, do something 
    68                                 overlay[ii][jj] = 1 
     83                        exclude = 1 
     84                 
     85                        // sector as defined 
     86                        if(V_CloseEnough(phiVal,phiCtr,delta)) 
     87                                exclude = 0 
    6988                        endif 
    70  
    71 //                      isIn = V_CloseEnough(phiVal,pi+phiCtr,delta) 
    72 //                      if(!isIn)               // it's NOT in the sector, do something 
    73 //                              overlay[ii][jj] = 1 
    74 //                      endif 
    75  
    76 //                       
    77 //                      if(phiVal < delta) 
    78 //                              forward = 1                     //within forward sector 
    79 //                      else 
    80 //                              forward = 0 
    81 //                      Endif 
    82 //                      if((Pi - phiVal) < delta) 
    83 //                              mirror = 1              //within mirror sector 
    84 //                      else 
    85 //                              mirror = 0 
    86 //                      Endif 
    87 //                      //check if pixel lies within allowed sector(s) 
    88 //                      if(cmpstr(side,"both")==0)              //both sectors 
    89 //                              if ( mirror || forward) 
    90 //                                      //increment 
    91 //                                      isIn = 1 
    92 //                              Endif 
    93 //                      else 
    94 //                              if(cmpstr(side,"right")==0)             //forward sector only 
    95 //                                      if(forward) 
    96 //                                              //increment 
    97 //                                              isIn = 1 
    98 //                                      Endif 
    99 //                              else                    //mirror sector only 
    100 //                                      if(mirror) 
    101 //                                              //increment 
    102 //                                              isIn = 1 
    103 //                                      Endif 
    104 //                              Endif 
    105 //                      Endif           //allowable sectors 
    106 //               
    107                          
    108                  
     89                        //if sector crosses zero, pick up the rest of the sector 
     90                        if(crossZero) 
     91                                if(V_CloseEnough(phiVal-2*pi,phiCtr,delta)) 
     92                                        exclude = 0 
     93                                endif 
     94                                if(V_CloseEnough(phiVal+2*pi,phiCtr,delta)) 
     95                                        exclude = 0 
     96                                endif 
     97                        endif 
     98                         
     99                        //      mirror phi if needed 
     100                        if(cmpstr(side,"both")==0) 
     101                                if(V_CloseEnough(phiVal,mirror_phiCtr,delta)) 
     102                                        exclude = 0 
     103                                endif 
     104                        endif 
     105                                 
     106                        // if only right or left, exclude everything as needed 
     107                        if(cmpstr(side,"right")==0) 
     108                                //if phi is actually on the left 
     109                                if(phiCtr > pi/2 && phiCtr < 3*pi/2) 
     110                                        exclude = 1 
     111                                endif 
     112                        endif 
     113                        if(cmpstr(side,"left")==0) 
     114                                //if phi is actually on the right 
     115                                if( (phiCtr > 0 && phiCtr < pi/2) || (phiCtr > 3*pi/2 && phiCtr < 2*pi) ) 
     116                                        exclude = 1 
     117                                endif 
     118                        endif 
     119                         
     120                        // set the mask value 
     121                        overlay[ii][jj] = exclude 
    109122                endfor 
    110123        endfor 
    111          
     124 
     125 
    112126        return(0) 
    113127End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_QIS.ipf

    r1121 r1126  
    548548                ii=0 
    549549 
    550 s_tic()  
    551550// TODO 
    552551// this loop is the slow step. it takes Å 0.7 s for F or M panels, and Å 120 s for the Back panel (6144 pts vs. 1.12e6 pts) 
     
    560559//              dum = V_get2DResolution(qval,phi,r_dist,type,detStr,collimationStr,SigmaQX,SigmaQY,fsubS) 
    561560 
     561v_tic() 
    562562                do 
    563563                        V_get2DResolution(qval[ii],phi[ii],r_dist[ii],type,detStr,collimationStr,ret1,ret2,ret3) 
     
    567567                        ii+=1 
    568568                while(ii<nq)     
    569 s_toc() 
    570          
     569v_toc()  
    571570        ////*********************        
    572571                Duplicate/O qx_val,qx_val_s 
Note: See TracChangeset for help on using the changeset viewer.