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

changes to read in new USANS Raw data structure, based on the file creation date.

Some additional changes to sector averaging and viewing the "avg" masks on the detector panels. still not quite complete.

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

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/BT5_Loader.ipf

    r1122 r1124  
    8787 
    8888// test by date 
    89 //      Variable thisFileSecs,switchSecs 
    90 //      switchSecs = date2secs(2019,2,6) 
    91 //      thisFileSecs = BT5Date2Secs(filedt)             // could use BT5DateTime2Secs() to include HR:MIN 
    92 //      if(thisFileSecs >= switchSecs) 
    93 //              useNewDataFormat = 1 
    94 //      else 
    95 //              useNewDataFormat = 0 
    96 //      endif 
     89        Variable thisFileSecs 
     90        NVAR switchSecs = root:Packages:NIST:USANS:Globals:MainPanel:gFileSwitchSecs 
     91        thisFileSecs = BT5DateTime2Secs(filedt)         // could use BT5Date2Secs() to exclude HR:MIN 
     92        if(thisFileSecs >= switchSecs) 
     93                useNewDataFormat = 1 
     94        else 
     95                useNewDataFormat = 0 
     96        endif 
    9797 
    9898// or use the global 
    99         NVAR gVal = root:Packages:NIST:gUseNICEDataFormat        
    100         useNewDataFormat = gVal 
     99//      NVAR gVal = root:Packages:NIST:gUseNICEDataFormat        
     100//      useNewDataFormat = gVal 
    101101         
    102102         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/NCNR_USANS_Utils.ipf

    r903 r1124  
    3131        String/G        root:Packages:NIST:USANS:Globals:MainPanel:gUExt = ".bt5" 
    3232         
    33          
     33        // on Feb 7 2019 @ 11:00 AM, the order of the columns in the raw BT5 data file was swapped to  
     34        // put the 5 detectors in positions 2-6, moving the transmission detector from postion 4 to positon 7 
     35        // this was the only change made to the data file (done in expectation of NICE being ready soon) 
     36        // --to switch between the two different read routines, key on the time of data collection in the data file 
     37        // 
     38        Variable/G root:Packages:NIST:USANS:Globals:MainPanel:gFileSwitchSecs=date2secs(2019,2,7)+3600*11               // the seconds of the switch 
    3439         
    3540        return(0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DIVUtils.ipf

    r1111 r1124  
    33// 
    44// ******** 
    5 // TODO -- this file is preliminary. It has not yet been tested on enough real data 
    6 //    to generate a DIV file. 
    7 //    Not sure how it will be measured in practice on VSANS. 
    85// 
    96//   JAN 2018 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1121 r1124  
    10521052         
    10531053End 
     1054 
     1055 
     1056 
     1057 
     1058////////////////// 
     1059// procedures for an integrated panel to show the masks for all panels on a carriage 
     1060// 
     1061// also can be used to show the annular or sector ranges selected for averaging 
     1062// (so this block may be better located in one of the averaging procedure files) 
     1063// viewing the standard mask files may be a side benefit 
     1064// 
     1065// 
     1066// generally: 
     1067// - show the 4 panels on a carriage 
     1068// - allow selection of the averaging options 
     1069// - buttons for toggling of the mask, do average 
     1070// 
     1071// copy the general panel structure from DIVUtils, and add a larger control area for input 
     1072// - use the averaging routines from the main data display 
     1073// 
     1074 
     1075 
     1076Proc V_Display_Four_Panels() 
     1077        V_SetupPanelDisplay() 
     1078end 
     1079 
     1080Function V_SetupPanelDisplay() 
     1081        DoWindow/F VSANS_Det_Panels 
     1082        if(V_flag==0) 
     1083         
     1084                NewDataFolder/O root:Packages:NIST:VSANS:Globals:Mask 
     1085 
     1086                Variable/G root:Packages:NIST:VSANS:Globals:Mask:gAnnularQCtr = 0.1 
     1087                Variable/G root:Packages:NIST:VSANS:Globals:Mask:gAnnularDQ = 0.01 
     1088 
     1089                Variable/G root:Packages:NIST:VSANS:Globals:Mask:gSectorAngle = 30 
     1090                Variable/G root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ = 10 
     1091                         
     1092                Execute "V_Display_Det_Panels()" 
     1093        endif 
     1094End 
     1095 
     1096 
     1097// 
     1098// simple panel to display the 4 detector panels 
     1099// 
     1100// TODO: 
     1101// -- label panels, axes 
     1102// -- add in display of "B" 
     1103 
     1104Proc V_Display_Det_Panels() 
     1105        PauseUpdate; Silent 1           // building window... 
     1106        NewPanel /W=(720,45,1500,570)/N=VSANS_Det_Panels/K=1 
     1107        DoWindow/C VSANS_Det_Panels 
     1108//      ModifyPanel fixedSize=1,noEdit =1 
     1109 
     1110 
     1111        PopupMenu popup0,pos={15.00,10.00},size={77.00,23.00},proc=V_PickCarriagePopMenuProc,title="Carriage" 
     1112        PopupMenu popup0,mode=1,value= #"\"F;M;B;\"" 
     1113        PopupMenu popup1,pos={100.00,10.00},size={68.00,23.00},proc=V_PickFolderPopMenuProc,title="Folder" 
     1114        PopupMenu popup1,mode=1,popvalue="RAW",value= #"\"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;MSK;ADJ;\"" 
     1115        PopupMenu popup2,pos={200.00,10.00},size={83.00,23.00},title="Bin Type"//,proc=V_DummyPopMenuProc 
     1116        PopupMenu popup2,mode=1,value= ksBinTypeStr 
     1117        PopupMenu popup3,pos={350,10.00},size={83.00,23.00},title="Average Type"//,proc=V_DummyPopMenuProc 
     1118        PopupMenu popup3,mode=1,value= #"\"Circular;Sector;Annular;\"" 
     1119//      Button button0,pos={520.00,10.00},size={110.00,20.00},proc=V_UpdatePanelsButtonProc,title="Update Display" 
     1120        Button button1,pos={520.00,40.00},size={100.00,20.00},proc=V_ToggleFourMaskButtonProc,title="Toggle Mask" 
     1121        Button button2,pos={350.00,40.00},size={120.00,20.00},proc=V_ShowAvgRangeButtonProc,title="Show Avg Range" 
     1122        Button button3,pos={350.00,70.00},size={100.00,20.00},proc=V_DoPanelAvgButtonProc,title="Do Average" 
     1123        Button button4,pos={720.00,10.00},size={25.00,20.00},proc=V_AvgPanelHelpButtonProc,title="?" 
     1124 
     1125        SetVariable setvar0,pos={50,40},size={140,23},title="Annulus q-center (A)" 
     1126        SetVariable setvar0,limits={0,1,0.001},value=root:Packages:NIST:VSANS:Globals:Mask:gAnnularQCtr 
     1127        SetVariable setvar1,pos={50,70},size={140,23},title="Annulus (+/-) q (A)" 
     1128        SetVariable setvar1,limits={0,1,0.001},value=root:Packages:NIST:VSANS:Globals:Mask:gAnnularDQ 
     1129        SetVariable setvar2,pos={200,40},size={140,23},title="Sector Angle (deg)" 
     1130        SetVariable setvar2,limits={0,359,1},value=root:Packages:NIST:VSANS:Globals:Mask:gSectorAngle 
     1131        SetVariable setvar3,pos={200,70},size={140,23},title="Sector (+/-) (deg)" 
     1132        SetVariable setvar3,limits={0,359,1},value=root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ 
     1133 
     1134        PopupMenu popup4,pos={200,100},size={90,23.00},proc=V_DummyPopMenuProc,title="Sector Side(s)" 
     1135        PopupMenu popup4,mode=1,value= #"\"both;left;right;\"" 
     1136         
     1137//      Display/W=(745,45,945,425)/HOST=#  
     1138        Display/W=(10,45+80,210,425+80)/HOST=#  
     1139        AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1140 
     1141        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1142        ModifyImage data ctabAutoscale=3 
     1143        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1144        ModifyGraph mirror=2 
     1145        ModifyGraph nticks=4 
     1146        ModifyGraph minor=1 
     1147        ModifyGraph fSize=9 
     1148        ModifyGraph standoff=0 
     1149        ModifyGraph tkLblRot(left)=90 
     1150        ModifyGraph btLen=3 
     1151        ModifyGraph tlOffset=-2 
     1152        RenameWindow #,Panel_L 
     1153        SetActiveSubwindow ## 
     1154 
     1155//      Display/W=(1300,45,1500,425)/HOST=#  
     1156        Display/W=(565,45+80,765,425+80)/HOST=#  
     1157        AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FR:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1158        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1159        ModifyImage data ctabAutoscale=3 
     1160        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1161        ModifyGraph mirror=2 
     1162        ModifyGraph nticks=4 
     1163        ModifyGraph minor=1 
     1164        ModifyGraph fSize=9 
     1165        ModifyGraph standoff=0 
     1166        ModifyGraph tkLblRot(left)=90 
     1167        ModifyGraph btLen=3 
     1168        ModifyGraph tlOffset=-2 
     1169        RenameWindow #,Panel_R 
     1170        SetActiveSubwindow ## 
     1171 
     1172//      Display/W=(945,45,1300,235)/HOST=#  
     1173        Display/W=(210,45+80,565,235+80)/HOST=#  
     1174        AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FT:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1175        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1176        ModifyImage data ctabAutoscale=3 
     1177        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1178        ModifyGraph mirror=2 
     1179        ModifyGraph nticks=4 
     1180        ModifyGraph minor=1 
     1181        ModifyGraph fSize=9 
     1182        ModifyGraph standoff=0 
     1183        ModifyGraph tkLblRot(left)=90 
     1184        ModifyGraph btLen=3 
     1185        ModifyGraph tlOffset=-2 
     1186        RenameWindow #,Panel_T 
     1187        SetActiveSubwindow ## 
     1188 
     1189//      Display/W=(945,235,1300,425)/HOST=#  
     1190        Display/W=(210,235+80,565,425+80)/HOST=#  
     1191        AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1192        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1193        ModifyImage data ctabAutoscale=3 
     1194        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1195        ModifyGraph mirror=2 
     1196        ModifyGraph nticks=4 
     1197        ModifyGraph minor=1 
     1198        ModifyGraph fSize=9 
     1199        ModifyGraph standoff=0 
     1200        ModifyGraph tkLblRot(left)=90 
     1201        ModifyGraph btLen=3 
     1202        ModifyGraph tlOffset=-2 
     1203        RenameWindow #,Panel_B 
     1204        SetActiveSubwindow ## 
     1205// 
     1206 
     1207End 
     1208 
     1209 
     1210// called by the "update" button 
     1211// 
     1212// must check for overlay of mask and of avgMask 
     1213// 
     1214Function V_UpdateFourPanelDisp() 
     1215 
     1216        ControlInfo popup0 
     1217        String carrStr = S_value 
     1218         
     1219        ControlInfo popup1 
     1220        String folder = S_Value 
     1221 
     1222 
     1223        String tmpStr="" 
     1224// 
     1225 
     1226         
     1227        // remove everything from each of the 4 panels 
     1228        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_L",";") 
     1229        if(ItemsInList(tmpStr) > 0) 
     1230                do 
     1231                        RemoveImage /W=VSANS_Det_Panels#Panel_L $(StringFromList(0,tmpStr,";"))         //get 1st item 
     1232                        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_L",";")                                                          //refresh list 
     1233                while(ItemsInList(tmpStr) > 0) 
     1234        endif 
     1235         
     1236        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_R",";") 
     1237        if(ItemsInList(tmpStr) > 0) 
     1238                do 
     1239                        RemoveImage /W=VSANS_Det_Panels#Panel_R $(StringFromList(0,tmpStr,";"))         //get 1st item 
     1240                        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_R",";")                                                          //refresh list 
     1241                while(ItemsInList(tmpStr) > 0) 
     1242        endif 
     1243         
     1244        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_T",";") 
     1245        if(ItemsInList(tmpStr) > 0) 
     1246                do 
     1247                        RemoveImage /W=VSANS_Det_Panels#Panel_T $(StringFromList(0,tmpStr,";"))         //get 1st item 
     1248                        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_T",";")                                                          //refresh list 
     1249                while(ItemsInList(tmpStr) > 0) 
     1250        endif 
     1251         
     1252        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_B",";") 
     1253        if(ItemsInList(tmpStr) > 0) 
     1254                do 
     1255                        RemoveImage /W=VSANS_Det_Panels#Panel_B $(StringFromList(0,tmpStr,";"))         //get 1st item 
     1256                        tmpStr = ImageNameList("VSANS_Det_Panels#Panel_B",";")                                                          //refresh list 
     1257                while(ItemsInList(tmpStr) > 0) 
     1258        endif 
     1259         
     1260 
     1261        // append the new image 
     1262//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_L data 
     1263        AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_L $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"L:data")                
     1264        SetActiveSubwindow VSANS_Det_Panels#Panel_L 
     1265        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1266        ModifyImage data ctabAutoscale=3 
     1267        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1268        ModifyGraph mirror=2 
     1269        ModifyGraph nticks=4 
     1270        ModifyGraph minor=1 
     1271        ModifyGraph fSize=9 
     1272        ModifyGraph standoff=0 
     1273        ModifyGraph tkLblRot(left)=90 
     1274        ModifyGraph btLen=3 
     1275        ModifyGraph tlOffset=-2 
     1276        SetActiveSubwindow ## 
     1277 
     1278 
     1279//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_T data 
     1280        AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_T $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"T:data")                
     1281        SetActiveSubwindow VSANS_Det_Panels#Panel_T 
     1282        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1283        ModifyImage data ctabAutoscale=3 
     1284        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1285        ModifyGraph mirror=2 
     1286        ModifyGraph nticks=4 
     1287        ModifyGraph minor=1 
     1288        ModifyGraph fSize=9 
     1289        ModifyGraph standoff=0 
     1290        ModifyGraph tkLblRot(left)=90 
     1291        ModifyGraph btLen=3 
     1292        ModifyGraph tlOffset=-2 
     1293        SetActiveSubwindow ## 
     1294         
     1295//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_B data 
     1296        AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_B $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"B:data")                
     1297        SetActiveSubwindow VSANS_Det_Panels#Panel_B 
     1298        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1299        ModifyImage data ctabAutoscale=3 
     1300        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1301        ModifyGraph mirror=2 
     1302        ModifyGraph nticks=4 
     1303        ModifyGraph minor=1 
     1304        ModifyGraph fSize=9 
     1305        ModifyGraph standoff=0 
     1306        ModifyGraph tkLblRot(left)=90 
     1307        ModifyGraph btLen=3 
     1308        ModifyGraph tlOffset=-2 
     1309        SetActiveSubwindow ## 
     1310 
     1311//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_R data 
     1312        AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_R $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"R:data")                
     1313        SetActiveSubwindow VSANS_Det_Panels#Panel_R 
     1314        ModifyImage data ctab= {*,*,ColdWarm,0} 
     1315        ModifyImage data ctabAutoscale=3 
     1316        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
     1317        ModifyGraph mirror=2 
     1318        ModifyGraph nticks=4 
     1319        ModifyGraph minor=1 
     1320        ModifyGraph fSize=9 
     1321        ModifyGraph standoff=0 
     1322        ModifyGraph tkLblRot(left)=90 
     1323        ModifyGraph btLen=3 
     1324        ModifyGraph tlOffset=-2 
     1325        SetActiveSubwindow ## 
     1326 
     1327End 
     1328 
     1329 
     1330 
     1331Function 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 
     1347End 
     1348 
     1349 
     1350Function V_PickFolderPopMenuProc(pa) : PopupMenuControl 
     1351        STRUCT WMPopupAction &pa 
     1352 
     1353        switch( pa.eventCode ) 
     1354                case 2: // mouse up 
     1355                        Variable popNum = pa.popNum 
     1356                        String popStr = pa.popStr 
     1357                        break 
     1358                case -1: // control being killed 
     1359                        break 
     1360        endswitch 
     1361 
     1362        return 0 
     1363End 
     1364 
     1365Function V_PickCarriagePopMenuProc(pa) : PopupMenuControl 
     1366        STRUCT WMPopupAction &pa 
     1367 
     1368        switch( pa.eventCode ) 
     1369                case 2: // mouse up 
     1370                        Variable popNum = pa.popNum 
     1371                        String popStr = pa.popStr 
     1372                         
     1373                        // update the data that is displayed 
     1374                        V_UpdateFourPanelDisp() 
     1375                         
     1376                        break 
     1377                case -1: // control being killed 
     1378                        break 
     1379        endswitch 
     1380 
     1381        return 0 
     1382End 
     1383 
     1384 
     1385 
     1386Function V_UpdatePanelsButtonProc(ba) : ButtonControl 
     1387        STRUCT WMButtonAction &ba 
     1388 
     1389        switch( ba.eventCode ) 
     1390                case 2: // mouse up 
     1391                        // click code here 
     1392                         
     1393                        // do nothing 
     1394                         
     1395                         
     1396                                 
     1397                        break 
     1398                case -1: // control being killed 
     1399                        break 
     1400        endswitch 
     1401 
     1402        return 0 
     1403End 
     1404 
     1405 
     1406 
     1407Function V_ToggleFourMaskButtonProc(ba) : ButtonControl 
     1408        STRUCT WMButtonAction &ba 
     1409 
     1410        switch( ba.eventCode ) 
     1411                case 2: // mouse up 
     1412                        // click code here 
     1413                         
     1414                        ControlInfo/W=VSANS_Det_Panels popup1 
     1415                        String folderStr = S_Value 
     1416                        Variable state = 1 
     1417 
     1418                        ControlInfo/W=VSANS_Det_Panels popup0 
     1419                        String carrStr = S_Value 
     1420                         
     1421// test the L image to see if I need to remove the mask 
     1422                        String detStr 
     1423                        if(cmpstr(carrStr,"F")==0) 
     1424                                detStr = "FL" 
     1425                        else 
     1426                                detStr = "ML" 
     1427                        endif 
     1428                         
     1429                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1430                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1431                        if(V_Flag == 1)         //overlay is present 
     1432                                state = 0 
     1433                        else 
     1434                                state = 1 
     1435                        endif 
     1436                         
     1437                        if(cmpstr(carrStr,"F") == 0) 
     1438                                V_OverlayFourMask(folderStr,"FL",state) 
     1439                                V_OverlayFourMask(folderStr,"FR",state) 
     1440                                V_OverlayFourMask(folderStr,"FT",state) 
     1441                                V_OverlayFourMask(folderStr,"FB",state) 
     1442                        else 
     1443                                V_OverlayFourMask(folderStr,"ML",state) 
     1444                                V_OverlayFourMask(folderStr,"MR",state) 
     1445                                V_OverlayFourMask(folderStr,"MT",state) 
     1446                                V_OverlayFourMask(folderStr,"MB",state)                                          
     1447                        endif 
     1448                         
     1449                        break 
     1450                case -1: // control being killed 
     1451                        break 
     1452        endswitch 
     1453 
     1454        return 0 
     1455End 
     1456 
     1457Function V_ShowAvgRangeButtonProc(ba) : ButtonControl 
     1458        STRUCT WMButtonAction &ba 
     1459 
     1460        switch( ba.eventCode ) 
     1461                case 2: // mouse up 
     1462                        // click code here 
     1463 
     1464                        ControlInfo/W=VSANS_Det_Panels popup3 
     1465                        String av_type = S_Value 
     1466                         
     1467                        ControlInfo/W=VSANS_Det_Panels popup1 
     1468                        String folderStr = S_Value 
     1469                         
     1470                        ControlInfo/W=VSANS_Det_Panels popup0 
     1471                        String detGroup = S_Value 
     1472                         
     1473                        // calculate the "mask" to add 
     1474                         
     1475                        // if circular, do nothing 
     1476                        // if annular 
     1477                        // if sector             
     1478                        // display the mask on the current data 
     1479                         
     1480                        Variable ii 
     1481                        String detStr 
     1482                        String str1 = "root:Packages:NIST:VSANS:"+folderStr 
     1483                        String str2 = ":entry:instrument:detector_" 
     1484 
     1485                        strswitch(av_type)      //dispatch to the proper routine to calculate mask 
     1486 
     1487                                case "Circular":         
     1488                                        //do nothing 
     1489                                        break                    
     1490                 
     1491                                case "Sector": 
     1492                                        ControlInfo/W=VSANS_Det_Panels popup4 
     1493                                        String side = S_Value 
     1494                                        NVAR phi_rad = root:Packages:NIST:VSANS:Globals:Mask:gSectorAngle 
     1495                                        NVAR dphi_rad = root:Packages:NIST:VSANS:Globals:Mask:gSectorDQ 
     1496                                         
     1497                                        // loop over all of the panels 
     1498                                        // calculate phi matrix 
     1499                                        // fill in the mask 
     1500                                        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     1501                                                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     1502                                                Wave qTotal = $(str1+str2+detStr+":qTot_"+detStr) 
     1503                                                Wave phi =      V_MakePhiMatrix(qTotal,folderStr,detStr,str1+str2+detStr) 
     1504                                                Wave w = V_getDetectorDataW(folderStr,detStr)   //this is simply to get the correct wave scaling on the overlay 
     1505                                                Duplicate/O w $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1506                                                Wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1507                                                V_MarkSectorOverlayPixels(phi,overlay,phi_rad,dphi_rad,side) 
     1508                                        endfor 
     1509                                         
     1510                                        break 
     1511                                case "Sector_PlusMinus": 
     1512                                        break 
     1513                                case "Rectangular": 
     1514                                        break 
     1515                 
     1516                                case "Annular": 
     1517 
     1518                                        NVAR qCtr_Ann = root:Packages:NIST:VSANS:Globals:Mask:gAnnularQCtr 
     1519                                        NVAR qWidth = root:Packages:NIST:VSANS:Globals:Mask:gAnnularDQ                           
     1520 
     1521                                        break 
     1522                 
     1523                                default:         
     1524                                        //do nothing 
     1525                        endswitch 
     1526                                 
     1527                         
     1528                         
     1529                        // switch for the overlay 
     1530                        strswitch(av_type) 
     1531                                case "Sector": 
     1532                                case "Annular":  
     1533                                case "Sector_PlusMinus": 
     1534                                case "Rectangular": 
     1535                                                                                 
     1536                                        Variable state = 1 
     1537                 
     1538                                        ControlInfo/W=VSANS_Det_Panels popup0 
     1539                                        String carrStr = S_Value 
     1540                                         
     1541                // test the L image to see if I need to remove the mask 
     1542                                        if(cmpstr(carrStr,"F")==0) 
     1543                                                detStr = "FL" 
     1544                                        else 
     1545                                                detStr = "ML" 
     1546                                        endif 
     1547                                         
     1548                                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1549                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1550                                        if(V_Flag == 1)         //overlay is present 
     1551                                                state = 0 
     1552                                        else 
     1553                                                state = 1 
     1554                                        endif 
     1555                                         
     1556                                        if(cmpstr(carrStr,"F") == 0) 
     1557                                                V_OverlayFourAvgMask(folderStr,"FL",state) 
     1558                                                V_OverlayFourAvgMask(folderStr,"FR",state) 
     1559                                                V_OverlayFourAvgMask(folderStr,"FT",state) 
     1560                                                V_OverlayFourAvgMask(folderStr,"FB",state) 
     1561                                        else 
     1562                                                V_OverlayFourAvgMask(folderStr,"ML",state) 
     1563                                                V_OverlayFourAvgMask(folderStr,"MR",state) 
     1564                                                V_OverlayFourAvgMask(folderStr,"MT",state) 
     1565                                                V_OverlayFourAvgMask(folderStr,"MB",state)                                               
     1566                                        endif 
     1567                                         
     1568                                        break 
     1569 
     1570                                default:         
     1571                                        //do nothing 
     1572                        endswitch 
     1573                         
     1574                                 
     1575                        break 
     1576                case -1: // control being killed 
     1577                        break 
     1578        endswitch 
     1579 
     1580        return 0 
     1581End 
     1582 
     1583 
     1584// 
     1585// see V_Proto_doAverage() and V_Proto_doPlot() 
     1586// this duplicates the switch and functionality from these operations 
     1587// 
     1588Function V_DoPanelAvgButtonProc(ba) : ButtonControl 
     1589        STRUCT WMButtonAction &ba 
     1590 
     1591        switch( ba.eventCode ) 
     1592                case 2: // mouse up 
     1593                        // click code here 
     1594         
     1595                        ControlInfo/W=VSANS_Det_Panels popup2 
     1596                        Variable binType = V_BinTypeStr2Num(S_Value) 
     1597//                      V_BinningModePopup("",binType,S_Value)          // does binning of current popString and updates the graph 
     1598 
     1599                        ControlInfo/W=VSANS_Det_Panels popup3 
     1600                        String av_type = S_Value 
     1601                         
     1602                        ControlInfo/W=VSANS_Det_Panels popup1 
     1603                        String activeType = S_Value 
     1604 
     1605                        String collimationStr="pinhole" 
     1606 
     1607 
     1608                        strswitch(av_type)      //dispatch to the proper routine to average to 1D data 
     1609                                case "none":             
     1610                                        //still do nothing 
     1611                                        // set binType and binTypeStr to bad flags 
     1612                                        String binTypeStr = "none" 
     1613                                        binType = -999999 
     1614                                        break                    
     1615                 
     1616                                case "Circular": 
     1617                                        V_QBinAllPanels_Circular(activeType,binType,collimationStr)             // this does a default circular average 
     1618                                        V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     1619                                        V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned              
     1620                                        break 
     1621                                         
     1622                                case "Sector": 
     1623                                        ControlInfo/W=VSANS_Det_Panels popup4 
     1624                                        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 
     1627                                                                 
     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) 
     1632                                        V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     1633                                        V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned              
     1634                                        break 
     1635                                case "Sector_PlusMinus": 
     1636                //                      Sector_PlusMinus1D(activeType) 
     1637                                        break 
     1638                                case "Rectangular": 
     1639                //                      RectangularAverageTo1D(activeType) 
     1640                                        break 
     1641                 
     1642                                case "Annular": 
     1643                                        ControlInfo/W=VSANS_Det_Panels popup0 
     1644                                        String detGroup = S_Value 
     1645                                        NVAR qCtr_Ann = root:Packages:NIST:VSANS:Globals:Mask:gAnnularQCtr 
     1646                                        NVAR qWidth = root:Packages:NIST:VSANS:Globals:Mask:gAnnularDQ                           
     1647                                        //String detGroup = StringByKey("DETGROUP",avgStr,"=",";") 
     1648                                        //Variable qCtr_Ann = NumberByKey("QCENTER",avgStr,"=",";") 
     1649                                        //Variable qWidth = NumberByKey("QDELTA",avgStr,"=",";") 
     1650                                        V_QBinAllPanels_Annular(activeType,detGroup,qCtr_Ann,qWidth) 
     1651                                        V_Phi_Graph_Proc(activeType,detGroup) 
     1652                                        break 
     1653                 
     1654                                case "Narrow_Slit": 
     1655                                        V_QBinAllPanels_Slit(activeType,binType)                // this does a tall, narrow slit average 
     1656                                        V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     1657                                        V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned              
     1658                                         
     1659                                        break 
     1660                                         
     1661                                case "2D_ASCII":         
     1662                                        //do nothing 
     1663                                        break 
     1664                                case "QxQy_ASCII": 
     1665                                        //do nothing 
     1666                                        break 
     1667                                case "PNG_Graphic": 
     1668                                        //do nothing 
     1669                                        break 
     1670                                default:         
     1671                                        //do nothing 
     1672                        endswitch 
     1673 
     1674                                 
     1675                        break 
     1676                case -1: // control being killed 
     1677                        break 
     1678        endswitch 
     1679 
     1680 
     1681 
     1682        return 0 
     1683End 
     1684 
     1685Function V_AvgPanelHelpButtonProc(ba) : ButtonControl 
     1686        STRUCT WMButtonAction &ba 
     1687 
     1688        switch( ba.eventCode ) 
     1689                case 2: // mouse up 
     1690                        // click code here 
     1691                         
     1692                        DoAlert 0,"The help file for this panel has not been written yet." 
     1693                                 
     1694                        break 
     1695                case -1: // control being killed 
     1696                        break 
     1697        endswitch 
     1698 
     1699        return 0 
     1700End 
     1701 
     1702 
     1703 
     1704// 
     1705// overlay the mask 
     1706// 
     1707// 
     1708// if state==1, show the mask, if ==0, hide the mask 
     1709// 
     1710// 
     1711Function V_OverlayFourMask(folderStr,detStr,state) 
     1712        String folderStr,detStr 
     1713        Variable state 
     1714 
     1715 
     1716        String maskPath = "root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data" 
     1717        if(WaveExists($maskPath) == 1) 
     1718                 
     1719                 
     1720                if(state == 1) 
     1721                        //duplicate the mask, which is named "data" 
     1722                        wave maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1723                        // for the wave scaling 
     1724                        wave data = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":data")        
     1725                        Duplicate/O data $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1726                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1727                        overlay = maskW         //this copies the data into the properly scaled wave 
     1728                         
     1729                        strswitch(detStr) 
     1730                                case "ML": 
     1731                                case "FL": 
     1732                                        Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
     1733                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1734                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1735                                                AppendImage/T/W=VSANS_Det_Panels#Panel_L overlay 
     1736                //                              ModifyImage/W=VSANS_Det_Panels#Panel_L overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1737                                                ModifyImage/W=VSANS_Det_Panels#Panel_L ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1738                                        endif 
     1739                                        break 
     1740                                case "MR": 
     1741                                case "FR": 
     1742                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_R overlay 
     1743                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1744                                                AppendImage/T/W=VSANS_Det_Panels#Panel_R overlay 
     1745                //                              ModifyImage/W=VSANS_Det_Panels#Panel_R overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1746                                                ModifyImage/W=VSANS_Det_Panels#Panel_R ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1747                                        endif 
     1748                                        break 
     1749                                case "MT": 
     1750                                case "FT": 
     1751                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_T overlay 
     1752                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1753                                                AppendImage/T/W=VSANS_Det_Panels#Panel_T overlay 
     1754                //                              ModifyImage/W=VSANS_Det_Panels#Panel_T overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1755                                                ModifyImage/W=VSANS_Det_Panels#Panel_T ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1756                                        endif 
     1757                                        break                                    
     1758                                case "MB": 
     1759                                case "FB": 
     1760                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_B overlay 
     1761                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1762                                                AppendImage/T/W=VSANS_Det_Panels#Panel_B overlay 
     1763                //                              ModifyImage/W=VSANS_Det_Panels#Panel_B overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1764                                                ModifyImage/W=VSANS_Det_Panels#Panel_B ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1765                                        endif 
     1766                                        break                                    
     1767                                default:                         
     1768                                        // 
     1769                                        Print "off bottom of switch" 
     1770                        endswitch 
     1771                endif           //state == 1 
     1772 
     1773                if(state == 0) 
     1774                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1775 
     1776                        strswitch(detStr) 
     1777                                case "ML": 
     1778                                case "FL": 
     1779                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1780                                        if(V_Flag == 1)         //overlay is present 
     1781                //                              RemoveImage/W=VSANS_Det_Panels#Panel_L overlay 
     1782                                                RemoveImage/W=VSANS_Det_Panels#Panel_L ''#1 
     1783                                        endif 
     1784                                        break 
     1785                                case "MR": 
     1786                                case "FR": 
     1787                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_R overlay 
     1788                                        if(V_Flag == 1)         //overlay is present 
     1789                //                              RemoveImage/W=VSANS_Det_Panels#Panel_R overlay 
     1790                                                RemoveImage/W=VSANS_Det_Panels#Panel_R ''#1 
     1791                                        endif 
     1792                                        break 
     1793                                case "MT": 
     1794                                case "FT": 
     1795                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_T overlay 
     1796                                        if(V_Flag == 1)         //overlay is present 
     1797                //                              RemoveImage/W=VSANS_Det_Panels#Panel_T overlay 
     1798                                                RemoveImage/W=VSANS_Det_Panels#Panel_T ''#1 
     1799                                        endif 
     1800                                        break                                    
     1801                                case "MB": 
     1802                                case "FB": 
     1803                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_B overlay 
     1804                                        if(V_Flag == 1)         //overlay is present 
     1805                //                              RemoveImage/W=VSANS_Det_Panels#Panel_B overlay 
     1806                                                RemoveImage/W=VSANS_Det_Panels#Panel_B ''#1 
     1807                                        endif 
     1808                                        break                                    
     1809                                default:                         
     1810                                        // 
     1811                                        Print "off bottom of switch" 
     1812                        endswitch 
     1813                endif           //state == 0 
     1814                 
     1815        Endif 
     1816         
     1817        return(0) 
     1818End 
     1819 
     1820 
     1821// 
     1822// overlay the mask 
     1823// 
     1824// 
     1825// if state==1, show the mask, if ==0, hide the mask 
     1826// 
     1827// 
     1828Function V_OverlayFourAvgMask(folderStr,detStr,state) 
     1829        String folderStr,detStr 
     1830        Variable state 
     1831 
     1832 
     1833        String maskPath = "root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data" 
     1834        if(WaveExists($maskPath) == 1) 
     1835                 
     1836                 
     1837                if(state == 1) 
     1838                        //duplicate the mask, which is named "AvgOverlay_" 
     1839//                      wave maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1840//                      // for the wave scaling 
     1841//                      wave data = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":data")        
     1842//                      Duplicate/O data $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1843                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1844//                      overlay = maskW         //this copies the data into the properly scaled wave 
     1845                         
     1846                        strswitch(detStr) 
     1847                                case "ML": 
     1848                                case "FL": 
     1849                                        Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
     1850                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1851                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1852                                                AppendImage/T/W=VSANS_Det_Panels#Panel_L overlay 
     1853                //                              ModifyImage/W=VSANS_Det_Panels#Panel_L overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1854                                                ModifyImage/W=VSANS_Det_Panels#Panel_L ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1855                                        endif 
     1856                                        break 
     1857                                case "MR": 
     1858                                case "FR": 
     1859                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_R overlay 
     1860                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1861                                                AppendImage/T/W=VSANS_Det_Panels#Panel_R overlay 
     1862                //                              ModifyImage/W=VSANS_Det_Panels#Panel_R overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1863                                                ModifyImage/W=VSANS_Det_Panels#Panel_R ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1864                                        endif 
     1865                                        break 
     1866                                case "MT": 
     1867                                case "FT": 
     1868                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_T overlay 
     1869                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1870                                                AppendImage/T/W=VSANS_Det_Panels#Panel_T overlay 
     1871                //                              ModifyImage/W=VSANS_Det_Panels#Panel_T overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1872                                                ModifyImage/W=VSANS_Det_Panels#Panel_T ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1873                                        endif 
     1874                                        break                                    
     1875                                case "MB": 
     1876                                case "FB": 
     1877                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_B overlay 
     1878                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     1879                                                AppendImage/T/W=VSANS_Det_Panels#Panel_B overlay 
     1880                //                              ModifyImage/W=VSANS_Det_Panels#Panel_B overlay ctab= {0.9,0.95,BlueRedGreen,0}  ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1881                                                ModifyImage/W=VSANS_Det_Panels#Panel_B ''#1 ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,35000) 
     1882                                        endif 
     1883                                        break                                    
     1884                                default:                         
     1885                                        // 
     1886                                        Print "off bottom of switch" 
     1887                        endswitch 
     1888                endif           //state == 1 
     1889 
     1890                if(state == 0) 
     1891                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":AvgOverlay_"+detStr) 
     1892 
     1893                        strswitch(detStr) 
     1894                                case "ML": 
     1895                                case "FL": 
     1896                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
     1897                                        if(V_Flag == 1)         //overlay is present 
     1898                //                              RemoveImage/W=VSANS_Det_Panels#Panel_L overlay 
     1899                                                RemoveImage/W=VSANS_Det_Panels#Panel_L ''#1 
     1900                                        endif 
     1901                                        break 
     1902                                case "MR": 
     1903                                case "FR": 
     1904                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_R overlay 
     1905                                        if(V_Flag == 1)         //overlay is present 
     1906                //                              RemoveImage/W=VSANS_Det_Panels#Panel_R overlay 
     1907                                                RemoveImage/W=VSANS_Det_Panels#Panel_R ''#1 
     1908                                        endif 
     1909                                        break 
     1910                                case "MT": 
     1911                                case "FT": 
     1912                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_T overlay 
     1913                                        if(V_Flag == 1)         //overlay is present 
     1914                //                              RemoveImage/W=VSANS_Det_Panels#Panel_T overlay 
     1915                                                RemoveImage/W=VSANS_Det_Panels#Panel_T ''#1 
     1916                                        endif 
     1917                                        break                                    
     1918                                case "MB": 
     1919                                case "FB": 
     1920                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_B overlay 
     1921                                        if(V_Flag == 1)         //overlay is present 
     1922                //                              RemoveImage/W=VSANS_Det_Panels#Panel_B overlay 
     1923                                                RemoveImage/W=VSANS_Det_Panels#Panel_B ''#1 
     1924                                        endif 
     1925                                        break                                    
     1926                                default:                         
     1927                                        // 
     1928                                        Print "off bottom of switch" 
     1929                        endswitch 
     1930                endif           //state == 0 
     1931                 
     1932        Endif 
     1933         
     1934        return(0) 
     1935End 
     1936 
     1937 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Sector_Average.ipf

    r1121 r1124  
    2929        pixSizeY = V_getDet_y_pixel_size(folderStr,detStr) 
    3030        phi = V_FindPhi( pixSizeX*((p+1)-xctr) , pixSizeY*((q+1)-yctr))         //(dx,dy) 
    31         //phi = V_FindPhi( pixSizeX*((p+1)-xctr) , pixSizeY*((q+1)-yctr)+(2)*yg_d)              //with gravity, (dx,dy+yg_d) 
    3231         
    3332        return phi       
     
    3534 
    3635 
    37 // TODO 
    38 // actually, for this to work, I need the inverse of this mask 
    39 // -- I want to mask out everything that is "out" of the sector 
    40 // 
    41 Function V_MarkOverlayPixels() 
    42  
    43         Wave phi=root:phi 
    44         String str="FL" 
    45         Wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay")       
    46          
    47         Variable phiCtr,delta,phiVal 
    48          
    49         phiCtr = pi/2 
    50         delta = 90 * (2*pi)/360         // phi is in radians 
    51          
    52         Variable xDim=48 
    53         Variable yDim=128 
    54  
    55         Variable ii,jj,isIn 
    56          
     36//  
     37// x- I want to mask out everything that is "out" of the sector 
     38// 
     39// 0 = keep the point 
     40// 1 = yes, mask the point 
     41Function V_MarkSectorOverlayPixels(phi,overlay,phiCtr,delta,side) 
     42        Wave phi,overlay 
     43        Variable phiCtr,delta 
     44        String side 
     45         
     46        Variable phiVal 
     47 
     48// convert the imput from degrees to radians    , since phi is in radians 
     49        phiCtr *= pi/180 
     50        delta *= pi/180          
     51         
     52        Variable xDim=DimSize(phi, 0) 
     53        Variable yDim=DimSize(phi, 1) 
     54 
     55        Variable ii,jj,isIn,forward,mirror 
     56         
     57// initialize the mask to keep everything 
     58        overlay = 0 
    5759 
    5860        for(ii=0;ii<xDim;ii+=1) 
     
    6062                        //qTot = sqrt(qx[ii]^2 + qy[ii]^2+ qz[ii]^2) 
    6163                        phiVal = phi[ii][jj] 
    62  
    63 //                       
     64                        isIn = 0 
     65                 
    6466                        isIn = V_CloseEnough(phiVal,phiCtr,delta) 
    65                          
    6667                        if(!isIn)               // it's NOT in the sector, do something 
    6768                                overlay[ii][jj] = 1 
    6869                        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                 
    69109                endfor 
    70110        endfor 
Note: See TracChangeset for help on using the changeset viewer.