Ignore:
Timestamp:
Feb 1, 2019 2:25:12 PM (4 years ago)
Author:
srkline
Message:

added procedures to output QxQy_ASCII data. Each panel is output into its own file. Output format is the same as for 2D SANS data, including the 2D resolution function. However, reading the data back in with the SANS analysis macros currently does not redimension the data back to the matrix correctly as it assumes a square detector.

I will need to add the X and Y dimensions of each panel into the header, and then make use of these values when they are read in. Also, writing the QxQy? data is quick for the M and F panels ( 0.8 s) but is extremely slow for the back, High-res panel (120 s) since there are 1.1.E6 points there vs. 6144 pts. I'll need to find a way to speed this operation up.

File:
1 edited

Legend:

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

    r1117 r1119  
    14271427        Wave qbar = $(folderPath+":"+"qBar_qxqy_"+type) 
    14281428        Wave fsubs = $(folderPath+":"+"fSubS_qxqy_"+type) 
    1429                                  
    1430  
    1431         Variable ret1,ret2,ret3 
    1432         Variable lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses 
    1433  
    1434 // TODO: check the units of all of the inputs 
    1435  
    1436 // lambda = wavelength [A] 
    1437         lambda = V_getWavelength(folderStr) 
    1438          
    1439 // lambdaWidth = [dimensionless] 
    1440         lambdaWidth = V_getWavelength_spread(folderStr) 
    1441          
    1442 // DDet = detector pixel resolution [cm]        **assumes square pixel 
    1443         // V_getDet_pixel_fwhm_x(folderStr,detStr) 
    1444         // V_getDet_pixel_fwhm_y(folderStr,detStr) 
    1445 //      DDet = 0.8              // TODO -- this is hard-wired 
    1446  
    1447         if(strlen(type) == 1) 
    1448                 // it's "B" 
    1449                 DDet = V_getDet_pixel_fwhm_x(folderStr,type)            // value is already in cm 
    1450         else 
    1451                 DDet = V_getDet_pixel_fwhm_x(folderStr,type[0,1])               // value is already in cm 
    1452         endif 
    1453                  
    1454 // apOff = sample aperture to sample distance [cm] 
    1455         apOff = 10              // TODO -- this is hard-wired 
    1456          
    1457 // S1 = source aperture diameter [mm] 
    1458 // may be either circle or rectangle 
    1459         String s1_shape="",bs_shape="" 
    1460         Variable width,height,equiv_S1,equiv_bs 
    1461          
    1462          
    1463         s1_shape = V_getSourceAp_shape(folderStr) 
    1464         if(cmpstr(s1_shape,"CIRCLE") == 0) 
    1465                 S1 = str2num(V_getSourceAp_size(folderStr)) 
    1466         else 
    1467                 S1 = V_getSourceAp_height(folderStr)            // TODO: need the width or at least an equivalent diameter 
    1468         endif 
    1469          
    1470          
    1471 // S2 = sample aperture diameter [cm] 
    1472 // as of 3/2018, the "internal" sample aperture is not in use, only the external 
    1473 // TODO : verify the units on the Ap2 (external) 
    1474 // sample aperture 1(internal) is set to report "12.7 mm" as a STRING 
    1475 // sample aperture 2(external) reports the number typed in... 
    1476 // 
    1477 // so I'm trusting [cm] is in the file 
    1478         S2 = V_getSampleAp2_size(folderStr)*10          // sample ap 1 or 2? 2 = the "external", convert to [mm] 
    1479          
    1480 // L1 = source to sample distance [m]  
    1481         L1 = V_getSourceAp_distance(folderStr)/100 
    1482  
    1483 // L2 = sample to detector distance [m] 
    1484 // take the first two characters of the "type" to get the correct distance. 
    1485 // if the type is say, MLRTB, then the implicit assumption in combining all four panels is that the resolution 
    1486 // is not an issue for the slightly different distances. 
    1487         if(strlen(type) == 1) 
    1488                 // it's "B" 
    1489                 L2 = V_getDet_ActualDistance(folderStr,type)/100                //convert cm to m 
    1490         else 
    1491                 L2 = V_getDet_ActualDistance(folderStr,type[0,1])/100           //convert cm to m 
    1492         endif 
    1493          
    1494 // BS = beam stop diameter [mm] 
    1495 //TODO:? which BS is in? carr2, carr3, none? 
    1496 // -- need to check the detector, num_beamstops field, then description, then shape/size or shape/height and shape/width 
    1497 // 
    1498 // TODO: the values in the file are incorrect!!! BS = 1000 mm diameter!!! 
    1499         BS = V_DeduceBeamstopDiameter(folderStr,type)           //returns diameter in [mm] 
    1500 //      BS = V_getBeamStopC2_size(folderStr)            // Units are [mm]  
    1501 //      BS = 25.4                       //TODO hard-wired value 
    1502          
    1503 //      bs_shape = V_getBeamStopC2_shape(folderStr) 
    1504 //      if(cmpstr(s1_shape,"CIRCLE") == 0) 
    1505 //              bs = V_getBeamStopC2_size(folderStr) 
    1506 //      else 
    1507 //              bs = V_getBeamStopC2_height(folderStr)   
    1508 //      endif 
    1509  
    1510  
    1511          
    1512 // del_r = step size [mm] = binWidth*(mm/pixel)  
    1513         del_r = 1*DDet*10               // TODO: this is probably not the correct value 
    1514  
    1515 // usingLenses = flag for lenses = 0 if no lenses, non-zero if lenses are in-beam 
    1516         usingLenses = 0 
    1517  
    1518 if(cmpstr(detStr,"FL")==0) 
    1519         Print "(FL) Resolution lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses" 
    1520         Print lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses 
    1521 endif 
    1522  
    1523  
    1524 // TODO: 
    1525 // this is the point where I need to switch on the different collimation types (white beam, slit, Xtal, etc) 
     1429        Variable ret1,ret2,ret3                  
     1430 
     1431// all of the different collimation conditions are handled within the V_getResolution function 
     1432// which is responsible for switching based on the different collimation types (white beam, slit, Xtal, etc) 
    15261433// to calculate the correct resolution, or fill the waves with the correct "flags" 
    15271434// 
     
    15421449// narrowSlit 
    15431450// narrowSlit_whiteBeam 
    1544  
    1545         if(cmpstr(collimationStr,"pinhole") == 0) 
    1546  
    1547                 ii=0 
    1548                 do 
    1549                         V_getResolution(qBin_qxqy[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,ret1,ret2,ret3) 
    1550                         sigmaq[ii] = ret1        
    1551                         qbar[ii] = ret2  
    1552                         fsubs[ii] = ret3         
    1553                         ii+=1 
    1554                 while(ii<nq) 
    1555          
    1556         endif 
    1557          
    1558  
    1559         if(cmpstr(collimationStr,"pinhole_whiteBeam") == 0) 
    1560  
    1561 //              set lambdaWidth == 0 so that the gaussian resolution calculates only the geometry contribution. 
    1562 // the white beam distribution will need to be flagged some other way 
    1563 // 
    1564                 lambdaWidth = 0 
    1565                  
    1566                 ii=0 
    1567                 do 
    1568                         V_getResolution(qBin_qxqy[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,ret1,ret2,ret3) 
    1569                         sigmaq[ii] = ret1        
    1570                         qbar[ii] = ret2  
    1571                         fsubs[ii] = ret3         
    1572                         ii+=1 
    1573                 while(ii<nq) 
    1574          
    1575         endif 
    1576  
    1577         if(cmpstr(collimationStr,"convergingPinholes") == 0) 
    1578  
    1579 //              set usingLenses == 1 so that the Gaussian resolution calculation will be for a focus condition 
    1580 // 
    1581                 usingLenses = 1 
    1582                  
    1583                 ii=0 
    1584                 do 
    1585                         V_getResolution(qBin_qxqy[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,ret1,ret2,ret3) 
    1586                         sigmaq[ii] = ret1        
    1587                         qbar[ii] = ret2  
    1588                         fsubs[ii] = ret3         
    1589                         ii+=1 
    1590                 while(ii<nq) 
    1591          
    1592         endif 
    1593  
    1594  
    1595 // should not end up here, except for odd testing cases 
    1596         if(cmpstr(collimationStr,"narrowSlit") == 0) 
    1597  
    1598                 Print "??? Slit data is being averaged as pinhole - reset the AVERAGE parameters in the protocol ???" 
    1599                 ii=0 
    1600                 do 
    1601                         V_getResolution(qBin_qxqy[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,ret1,ret2,ret3) 
    1602                         sigmaq[ii] = ret1        
    1603                         qbar[ii] = ret2  
    1604                         fsubs[ii] = ret3         
    1605                         ii+=1 
    1606                 while(ii<nq) 
    1607          
    1608         endif 
    1609          
    1610 // should not end up here, except for odd testing cases 
    1611         if(cmpstr(collimationStr,"narrowSlit_whiteBeam") == 0) 
    1612  
    1613 //              set lambdaWidth == 0 so that the gaussian resolution calculates only the geometry contribution. 
    1614 // the white beam distribution will need to be flagged some other way 
    1615 // 
    1616                 Print "??? Slit data is being averaged as pinhole - reset the AVERAGE parameters in the protocol ???" 
    1617  
    1618                 lambdaWidth = 0 
    1619                  
    1620                 ii=0 
    1621                 do 
    1622                         V_getResolution(qBin_qxqy[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,ret1,ret2,ret3) 
    1623                         sigmaq[ii] = ret1        
    1624                         qbar[ii] = ret2  
    1625                         fsubs[ii] = ret3         
    1626                         ii+=1 
    1627                 while(ii<nq) 
    1628          
    1629         endif 
    1630  
    1631  
    1632  
    1633                  
     1451// 
     1452        ii=0 
     1453        do 
     1454                V_getResolution(qBin_qxqy[ii],folderStr,type,collimationStr,ret1,ret2,ret3) 
     1455                sigmaq[ii] = ret1        
     1456                qbar[ii] = ret2  
     1457                fsubs[ii] = ret3         
     1458                ii+=1 
     1459        while(ii<nq) 
     1460 
     1461 
    16341462        SetDataFolder root: 
    16351463         
Note: See TracChangeset for help on using the changeset viewer.