Ignore:
Timestamp:
Aug 14, 2018 12:19:01 PM (4 years ago)
Author:
srkline
Message:

minor changes

File:
1 edited

Legend:

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

    r1112 r1113  
    13011301End 
    13021302 
     1303 
     1304 
     1305// TODO 
     1306// -- this is a trimmed down version of the "full" set of averaging options 
     1307//    add to this as needed as I figure out what functionality is appropriate 
     1308// 
     1309// 
    13031310//button action procedure to get the type of average requested by the user 
    13041311//presented as a missing parameter dialog, which is really user-UN-friendly 
     
    13091316        String ctrlName 
    13101317         
    1311 //      Execute "V_GetAvgInfo_Full()" 
    1312         Execute "V_GetAvgInfo()" 
    1313          
    1314         //set the global string 
    1315         SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr 
    1316         String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = tempStr 
    1317  
    1318 End 
    1319  
    1320 // TODO 
    1321 // -- this is a trimmed down version of the "full" set of averaging options 
    1322 //    add to this as needed as I figure out what functionality is appropriate 
    1323 // 
    1324 //procedure called by protocol panel to ask user for average type choices 
    1325 // somewhat confusing and complex, but may be as good as it gets. 
    1326 // 
    1327 //Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) 
    1328 Proc V_GetAvgInfo(av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup) 
     1318        SVAR gAvgInfoStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr 
     1319         
    13291320        String av_typ,autoSave,AutoName,binType 
    13301321//      Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
    1331         Variable Qctr=0.1,qDelta=0.01 
    1332         String detGroup="F" 
     1322        Variable Qctr,qDelta 
     1323        String detGroup 
     1324         
     1325        if(strlen(gAvgInfoStr) > 0) 
     1326//              fill the dialog with the current choice, not resetting to default 
     1327// can't do this, or it will simply bypass the missing parameter dialog! 
     1328//      V_GetAvgInfo(av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup) 
     1329        av_typ = StringByKey("AVTYPE", gAvgInfoStr  ,"=",";") 
     1330        autoSave = StringByKey("SAVE", gAvgInfoStr  ,"=",";") 
     1331        autoName = StringByKey("NAME", gAvgInfoStr  ,"=",";") 
     1332        binType = StringByKey("BINTYPE", gAvgInfoStr  ,"=",";") 
     1333        qCtr = NumberByKey("QCENTER", gAvgInfoStr  ,"=",";") 
     1334        qDelta = NumberByKey("QDELTA", gAvgInfoStr  ,"=",";") 
     1335        detGroup = StringByKey("DETGROUP", gAvgInfoStr  ,"=",";") 
     1336//      Execute "V_GetAvgInfo_Full()" 
     1337//              Execute "V_GetAvgInfo()" 
     1338        endif 
     1339 
    13331340 
    13341341//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 
     
    13491356        Prompt Qdelta,"(+/-) q-width of annulus" 
    13501357        Prompt detGroup,"Group for annulus" 
     1358 
     1359         
     1360        DoPrompt "Enter Averaging Parameters",av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup 
     1361        if (V_Flag) 
     1362                return(0)                                                               // User canceled 
     1363        endif    
    13511364         
    13521365        //assign results of dialog to key=value string, semicolon separated 
    13531366        //do only what is necessary, based on av_typ 
    1354         String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" 
     1367        // 
     1368        // reset the string 
     1369        gAvgInfoStr="" 
    13551370 
    13561371        // TODO: 
     
    13601375                 
    13611376        // all averages need these values 
    1362         root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" 
    1363         root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" 
    1364         root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" 
    1365         root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" 
    1366         root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "BINTYPE=" + binType + ";" 
     1377        gAvgInfoStr += "AVTYPE=" + av_typ + ";" 
     1378        gAvgInfoStr += "SAVE=" + autoSave + ";" 
     1379        gAvgInfoStr += "NAME=" + autoName + ";" 
     1380        gAvgInfoStr += "PLOT=" + autoPlot + ";" 
     1381        gAvgInfoStr += "BINTYPE=" + binType + ";" 
    13671382         
    13681383//      if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
    1369 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
    1370 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
    1371 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
     1384//              gAvgInfoStr += "SIDE=" + side + ";" 
     1385//              gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1386//              gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
    13721387//      Endif 
    13731388//       
    13741389//      if(cmpstr(av_typ,"Rectangular")==0) 
    1375 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
    1376 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
    1377 //              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" 
     1390//              gAvgInfoStr += "SIDE=" + side + ";" 
     1391//              gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1392//              gAvgInfoStr += "WIDTH=" + num2str(width) + ";" 
    13781393//      Endif 
    13791394//       
    13801395        if(cmpstr(av_typ,"Annular")==0) 
    1381                 root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" 
    1382                 root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" 
    1383                 root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DETGROUP=" + detGroup + ";" 
     1396                gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" 
     1397                gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" 
     1398                gAvgInfoStr += "DETGROUP=" + detGroup + ";" 
    13841399        Endif 
    1385 End 
     1400                 
     1401        //set the global string after user choices 
     1402        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = gAvgInfoStr 
     1403 
     1404        return(0) 
     1405End 
     1406 
     1407 
     1408// 
     1409// --- To avoid resetting the dialog with default values, the work is done in  
     1410// V_SetAverageParamsButtonProc --  
     1411// 
     1412// 
     1413//procedure called by protocol panel to ask user for average type choices 
     1414// somewhat confusing and complex, but may be as good as it gets. 
     1415// 
     1416//Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) 
     1417//Proc V_GetAvgInfo(av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup) 
     1418//      String av_typ,autoSave,AutoName,binType 
     1419////    Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
     1420//      Variable Qctr=0.1,qDelta=0.01 
     1421//      String detGroup="F" 
     1422// 
     1423////    Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 
     1424//      Prompt av_typ, "Type of Average",popup,"Circular;Narrow_Slit;Annular;" 
     1425// 
     1426//// comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 
     1427////    Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" 
     1428//      Prompt autoSave,"Save files to disk?",popup,"Yes - Concatenate;Yes - Individual;No" 
     1429//      Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" 
     1430////    Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" 
     1431////    Prompt side,"Include detector halves?",popup,"both;right;left" 
     1432////    Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" 
     1433////    Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" 
     1434////    Prompt width, "Width of Rectangular average (1,128)" 
     1435//      Prompt binType,"Binning Type?",popup,ksBinTypeStr 
     1436// 
     1437//      Prompt Qctr, "q-value of center of annulus" 
     1438//      Prompt Qdelta,"(+/-) q-width of annulus" 
     1439//      Prompt detGroup,"Group for annulus" 
     1440//       
     1441//      //assign results of dialog to key=value string, semicolon separated 
     1442//      //do only what is necessary, based on av_typ 
     1443//      String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" 
     1444// 
     1445//      // TODO: 
     1446//      // hard wired value 
     1447//      String autoPlot = "Yes" 
     1448//       
     1449//               
     1450//      // all averages need these values 
     1451//      root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" 
     1452//      root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" 
     1453//      root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" 
     1454//      root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" 
     1455//      root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "BINTYPE=" + binType + ";" 
     1456//       
     1457////    if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
     1458////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
     1459////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1460////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
     1461////    Endif 
     1462////     
     1463////    if(cmpstr(av_typ,"Rectangular")==0) 
     1464////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
     1465////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1466////            root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" 
     1467////    Endif 
     1468////     
     1469//      if(cmpstr(av_typ,"Annular")==0) 
     1470//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" 
     1471//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" 
     1472//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DETGROUP=" + detGroup + ";" 
     1473//      Endif 
     1474//End 
    13861475 
    13871476 
     
    20052094        String samFileLoaded = file_name                //keep a copy of the sample file loaded  
    20062095         
     2096        SVAR samFiles = root:Packages:NIST:VSANS:Globals:Protocols:gSAM 
     2097        samFiles = samStr 
     2098         
    20072099        //always update 
    20082100        V_UpdateDisplayInformation(ActiveType) 
     
    24362528                 
    24372529 
    2438                 // x- need to get the panel string for the sum. 
    2439                 // x- the detector string is currently hard-wired 
    2440 //              detStr = "MR" 
    2441  
     2530                if(cmpstr(detStr,"B") == 0 ) 
     2531                        Print "Median Filtering RAW data" 
     2532                        Wave w = V_getDetectorDataW("RAW",detStr) 
     2533                        MatrixFilter /N=3 median w 
     2534                endif 
    24422535 
    24432536                emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"RAW",detPanel_toSum) 
     
    24482541                // if it's the back panel, find the read noise to subtract 
    24492542                // shift the marquee to the right to (hopefully) a blank spot 
    2450                 Variable noiseCts,noiseCtsErr,delta 
     2543                Variable noiseCts,noiseCtsErr,delta,nPixInBox 
    24512544                if(isBack) 
    2452                         delta = xyBoxW[1] - xyBoxW[0] 
    2453                         noiseCts = V_SumCountsInBox(xyBoxW[1],xyBoxW[1]+delta,xyBoxW[2],xyBoxW[3],noiseCtsErr,"RAW",detPanel_toSum) 
    2454  
    2455                         print "average read noise per pixel = ",noiseCts/(xyBoxW[1]-xyBoxW[0])/(xyBoxW[3]-xyBoxW[2]) 
    2456                         Print "read noise counts = ",noiseCts 
    2457                         Print "read noise err/counts = ",noiseCtsErr/noiseCts 
    2458                          
    2459                         emptyCts -= noiseCts 
    2460                         empty_ct_err = sqrt(empty_ct_err^2 + noiseCtsErr^2) 
    2461                          
     2545 
     2546                 
     2547//                      delta = xyBoxW[1] - xyBoxW[0] 
     2548//                      noiseCts = V_SumCountsInBox(xyBoxW[1],xyBoxW[1]+delta,xyBoxW[2],xyBoxW[3],noiseCtsErr,"RAW",detPanel_toSum) 
     2549// 
     2550//                      print "average read noise per pixel = ",noiseCts/(xyBoxW[1]-xyBoxW[0])/(xyBoxW[3]-xyBoxW[2]) 
     2551//                      Print "read noise counts = ",noiseCts 
     2552//                      Print "read noise err/counts = ",noiseCtsErr/noiseCts 
     2553//                       
     2554//                      emptyCts -= noiseCts 
     2555//                      empty_ct_err = sqrt(empty_ct_err^2 + noiseCtsErr^2) 
     2556 
     2557 
     2558// Instead, use the defined constant values              
     2559//              kReadNoiseLevel 
     2560//              kReadNoiseLevel_Err 
     2561// 
     2562                        nPixInBox = (xyBoxW[1] - xyBoxW[0])*(xyBoxW[3]-xyBoxW[2]) 
     2563                        emptyCts -= kReadNoiseLevel*nPixInBox 
     2564                        empty_ct_err = sqrt(empty_ct_err^2 + (kReadNoiseLevel_Err*nPixInBox)^2) 
     2565                                                 
    24622566                        Print "adjusted empty counts = ",emptyCts 
    24632567                        Print "adjusted err/counts = ",empty_ct_err/emptyCts 
Note: See TracChangeset for help on using the changeset viewer.