Ignore:
Timestamp:
Apr 9, 2007 3:42:39 PM (15 years ago)
Author:
srkline
Message:

2nd pass of pulling out NCNR calls. Also cleared a lot of deadwood from the code, removing depricated functions that were mostly already commented out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/MultipleReduce.ipf

    r41 r76  
    1515//************************** 
    1616 
     17//panel to allow reduction of a series of files using a selected  protocol 
     18// 
     19//main entry procedure to open the panel, initializing if necessary 
     20Proc ReduceMultipleFiles() 
     21         
     22        DoWindow/F Multiple_Reduce_Panel 
     23        If(V_flag == 0) 
     24                InitializeMultReducePanel() 
     25                //draw panel 
     26                Multiple_Reduce_Panel() 
     27                //pop the protocol list 
     28                MRProtoPopMenuProc("",1,"") 
     29        Endif 
     30End 
     31 
     32//create the global variables needed to run the MReduce Panel 
     33//all are kept in root:myGlobals:MRED 
     34// 
     35Proc InitializeMultReducePanel() 
     36 
     37        If(DataFolderExists("root:myGlobals:MRED")) 
     38                //ok, do nothing 
     39        else 
     40                //no, create the folder and the globals 
     41                NewDataFolder/O root:myGlobals:MRED 
     42//              String/G root:myGlobals:MRED:gMRedMatchStr = "*" 
     43                PathInfo catPathName 
     44                If(V_flag==1) 
     45                        String dum = S_path 
     46                        String/G root:myGlobals:MRED:gCatPathStr = dum 
     47                else 
     48                        String/G root:myGlobals:MRED:gCatPathStr = "no path selected" 
     49                endif 
     50                String/G root:myGlobals:MRED:gMRedList = "none" 
     51                String/G root:myGlobals:MRED:gMRProtoList = "none" 
     52                String/G root:myGlobals:MRED:gFileNumList="" 
     53//              String/G root:myGlobals:MRED:gMRS1 = "no file selected" 
     54//              String/G root:myGlobals:MRED:gMRS2 = "no file selected" 
     55//              String/G root:myGlobals:MRED:gMRS3 = "no box selected" 
     56//              Variable/G root:myGlobals:MRED:gMRV1 =0 
     57//              Variable/G root:myGlobals:MRED:gMRV2 = 999 
     58        Endif  
     59End 
     60 
     61//panel recreation macro for the MRED panel 
     62// 
     63Window Multiple_Reduce_Panel() 
     64        PauseUpdate; Silent 1           // building window... 
     65        NewPanel /W=(535,72,951,228) /K=1 as "Multiple File Reduction" 
     66        ModifyPanel cbRGB=(65535,49151,29490) 
     67        ModifyPanel fixedSize=1 
     68        SetDrawLayer UserBack 
     69        DrawLine 7,30,422,30 
     70        SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" 
     71        SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while reducing. If no files appear in the popup, make sure that this folder is set correctly"} 
     72        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gCatPathStr 
     73        Button PathButton,pos={3,3},size={70,20},proc=PickMRPathButton,title="Pick Path" 
     74        Button PathButton,help={"Select the folder containing the raw SANS data files"} 
     75        Button helpButton,pos={385,3},size={25,20},proc=ShowMRHelp,title="?" 
     76        Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} 
     77        PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=MRedPopMenuProc,title="File(s) to Reduce" 
     78        PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} 
     79        PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRedList" 
     80        SetVariable MRList,pos={3,48},size={350,13},proc=FileNumberListProc,title="File number list: " 
     81        SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
     82        SetVariable MRList,limits={-Inf,Inf,1},value= root:myGlobals:MRED:gFileNumList 
     83        Button ReduceAllButton,pos={3,128},size={180,20},proc=ReduceAllPopupFiles,title="Reduce All Files in Popup" 
     84        Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} 
     85        Button DoneButton,pos={292,128},size={110,20},proc=MRDoneButtonProc,title="Done Reducing" 
     86        Button DoneButton,help={"When done reducing files, this will close this control panel."} 
     87        Button cat_short,pos={310,72},size={90,20},proc=DoCatShort,title="File Catalog" 
     88        Button cat_short,help={"Use this button to generate a table with file header information. Very useful for identifying files."} 
     89        Button show_cat_short,pos={280,98},size={120,20},proc=ShowCatShort_MRED,title="Show File Catalog" 
     90        Button show_cat_short,help={"Use this button to bring the File Catalog window to the front."} 
     91        PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=MRProtoPopMenuProc,title="Protocol " 
     92        PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
     93        PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRProtoList" 
     94EndMacro 
    1795 
    1896//simple procedure to bring the CAT TABLE to the front if it is present 
     
    107185End 
    108186 
    109  
    110 //panel to allow reduction of a series of files using a selected  protocol 
    111 // 
    112 //main entry procedure to open the panel, initializing if necessary 
    113 Proc ReduceMultipleFiles() 
    114          
    115         DoWindow/F Multiple_Reduce_Panel 
    116         If(V_flag == 0) 
    117                 InitializeMultReducePanel() 
    118                 //draw panel 
    119                 Multiple_Reduce_Panel() 
    120                 //pop the protocol list 
    121                 MRProtoPopMenuProc("",1,"") 
    122         Endif 
    123 End 
    124  
    125 //create the global variables needed to run the MReduce Panel 
    126 //all are kept in root:myGlobals:MRED 
    127 // 
    128 Proc InitializeMultReducePanel() 
    129  
    130         If(DataFolderExists("root:myGlobals:MRED")) 
    131                 //ok, do nothing 
    132         else 
    133                 //no, create the folder and the globals 
    134                 NewDataFolder/O root:myGlobals:MRED 
    135 //              String/G root:myGlobals:MRED:gMRedMatchStr = "*" 
    136                 PathInfo catPathName 
    137                 If(V_flag==1) 
    138                         String dum = S_path 
    139                         String/G root:myGlobals:MRED:gCatPathStr = dum 
    140                 else 
    141                         String/G root:myGlobals:MRED:gCatPathStr = "no path selected" 
    142                 endif 
    143                 String/G root:myGlobals:MRED:gMRedList = "none" 
    144                 String/G root:myGlobals:MRED:gMRProtoList = "none" 
    145                 String/G root:myGlobals:MRED:gFileNumList="" 
    146 //              String/G root:myGlobals:MRED:gMRS1 = "no file selected" 
    147 //              String/G root:myGlobals:MRED:gMRS2 = "no file selected" 
    148 //              String/G root:myGlobals:MRED:gMRS3 = "no box selected" 
    149 //              Variable/G root:myGlobals:MRED:gMRV1 =0 
    150 //              Variable/G root:myGlobals:MRED:gMRV2 = 999 
    151         Endif  
    152 End 
    153  
    154 //panel recreation macro for the MRED panel 
    155 // 
    156 Window Multiple_Reduce_Panel() 
    157         PauseUpdate; Silent 1           // building window... 
    158         NewPanel /W=(535,72,951,228) /K=1 as "Multiple File Reduction" 
    159         ModifyPanel cbRGB=(65535,49151,29490) 
    160         ModifyPanel fixedSize=1 
    161         SetDrawLayer UserBack 
    162         DrawLine 7,30,422,30 
    163         SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" 
    164         SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while reducing. If no files appear in the popup, make sure that this folder is set correctly"} 
    165         SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gCatPathStr 
    166         Button PathButton,pos={3,3},size={70,20},proc=PickMRPathButton,title="Pick Path" 
    167         Button PathButton,help={"Select the folder containing the raw SANS data files"} 
    168         Button helpButton,pos={385,3},size={25,20},proc=ShowMRHelp,title="?" 
    169         Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} 
    170         PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=MRedPopMenuProc,title="File(s) to Reduce" 
    171         PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} 
    172         PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRedList" 
    173         SetVariable MRList,pos={3,48},size={350,13},proc=FileNumberListProc,title="File number list: " 
    174         SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
    175         SetVariable MRList,limits={-Inf,Inf,1},value= root:myGlobals:MRED:gFileNumList 
    176 //      SetVariable MRLow,pos={3,72},size={150,13},proc=SetLowFileNumProc,title="File range: " 
    177 //      SetVariable MRLow,help={"Enter the first file number to reduce. Files must be consecutively numbered."} 
    178 //      SetVariable MRLow,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gMRV1 
    179         Button ReduceAllButton,pos={3,128},size={180,20},proc=ReduceAllPopupFiles,title="Reduce All Files in Popup" 
    180         Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} 
    181         Button DoneButton,pos={292,128},size={110,20},proc=MRDoneButtonProc,title="Done Reducing" 
    182         Button DoneButton,help={"When done reducing files, this will close this control panel."} 
    183         Button cat_short,pos={310,72},size={90,20},proc=DoCatShort,title="File Catalog" 
    184         Button cat_short,help={"Use this button to generate a table with file header information. Very useful for identifying files."} 
    185         Button show_cat_short,pos={280,98},size={120,20},proc=ShowCatShort_MRED,title="Show File Catalog" 
    186         Button show_cat_short,help={"Use this button to bring the File Catalog window to the front."} 
    187 //      SetVariable MRHigh,pos={160,73},size={90,13},proc=SetHighFileNumProc,title=" to: " 
    188 //      SetVariable MRHigh,help={"Enter the last file number to reduce. Files must be consecutively numbered."} 
    189 //      SetVariable MRHigh,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gMRV2 
    190         PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=MRProtoPopMenuProc,title="Protocol " 
    191         PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
    192         PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRProtoList" 
    193 EndMacro 
    194  
    195187//executed when a list of filenumbers is entered in the box 
    196188//responds as if the file popup was hit, to update the popup list contents 
     
    219211        ShowCATWindow() 
    220212End 
    221  
    222 //obsolete procedure - unused 
    223 // 
    224 //procedure for setVar box to set the low file number (forced to be >=0) 
    225 //sets the global variable, then forces an update of the popup 
    226 // 
    227 //Function SetLowFileNumProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    228 //      String ctrlName 
    229 //      Variable varNum 
    230 //      String varStr 
    231 //      String varName 
    232 //       
    233 //      ControlInfo MRLow 
    234 //      //low value must be >=0 
    235 //      Variable test = v_value 
    236 //      if (test < 0 ) 
    237 //              test = 0 
    238 //      Endif 
    239 //      Variable/G root:myGlobals:MRED:gMRV1 = test 
    240 //      //then update the popup list 
    241 //      MRedPopMenuProc("MRFilesPopup",1,"") 
    242 // 
    243 //End 
    244  
    245 //obsolete procedure - unused 
    246 // 
    247 //procedure for setVar box to set the high file number (forced to be <=999) 
    248 //sets the global variable, then forces an update of the popup 
    249 // 
    250 //Function SetHighFileNumProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    251 //      String ctrlName 
    252 //      Variable varNum 
    253 //      String varStr 
    254 //      String varName 
    255 // 
    256 //      ControlInfo MRHigh 
    257 //      //high value must be <=999 
    258 //      Variable test = V_value 
    259 //      if(test > 999) 
    260 //              test = 999 
    261 //      Endif 
    262 //      Variable/G root:myGlobals:MRED:gMRV2 = test 
    263 //      //then update the popup list 
    264 //      MRedPopMenuProc("MRFilesPopup",1,"") 
    265 //End 
    266213 
    267214//allows the user to set the path to the local folder that contains the SANS data 
     
    294241// range of file numbers entered in the text box 
    295242// 
    296 Function MRedPopMenuProc(MRFilesPopup,popNum,popStr) : PopupMenuControl 
     243Function MREDPopMenuProc(MRFilesPopup,popNum,popStr) : PopupMenuControl 
    297244        String MRFilesPopup 
    298245        Variable popNum 
     
    300247 
    301248        String list = GetValidMRedPopupList() 
    302 //      Wave/T redList = redList 
    303 //      String list = Wave2SemiList(redWave) 
    304249//       
    305250        String/G root:myGlobals:MRED:gMredList = list 
     
    330275        semiList = SortList(semiList,";",0) 
    331276        return(semiList) 
    332          
    333 //      //make sure that path exists 
    334 //      PathInfo catPathName 
    335 //      String path = S_path 
    336 //      if (V_flag == 0) 
    337 //              Abort "folder path does not exist - use Pick Path button" 
    338 //      Endif 
    339 //      String list="" 
    340 //       
    341 //      list = IndexedFile(catPathName,-1,"????")       //get all files in folder 
    342 //       
    343 //      NVAR  lownum = root:myGlobals:MRED:gMRV1 
    344 //      NVAR  highnum = root:myGlobals:MRED:gMRV2 
    345 //       
    346 //      //trim list to include only selected files that are RAW SANS files 
    347 //      //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be reduced) 
    348 //      Variable ii,isRAW,num,runNum=-1 
    349 //      String item="",newList = "",fullName = "",partialName="" 
    350 //       
    351 //      //get rid of version numbers first (up to 11) 
    352 //      list =  RemoveVersNumsFromList(list) 
    353 //       
    354 //      //then filter out only the raw data files within the range lownum to highnum 
    355 //      num = ItemsInList(list,";")             //get the new number of items in the list 
    356 //      ii=0 
    357 //      do 
    358 //              //parse through the list in this order: 
    359 //              // 1 - get the run number from the file (AAAAANNN.SAn_asdfasdfasdf) by finding the "dot" 
    360 //              // 2 - exclude by lownum/highnum 
    361 //              // 3 - exclude by isRaw? (to minimize disk access) 
    362 //              item = StringFromList(ii, list  ,";" ) 
    363 //              if(strlen(item) != 0) 
    364 //                      //find the run number, if it exists 
    365 //                      runNum = GetRunNumFromFile(item) 
    366 //                      //is the runNum in the selected range? 
    367 //                      if( (runNum >= lowNum) && (runNum <= highnum) ) 
    368 //                              //valid number, continue 
    369 //                              //build valid filename 
    370 //                              partialName = FindValidFileName(item) 
    371 //                              if(strlen(partialName) != 0)            //non-null return from FindValidFileName() 
    372 //                                      fullName = path + partialName 
    373 //                                      //check if RAW, if so, add original item to newList 
    374 //                                      isRAW = CheckIfRawData(fullName) 
    375 //                                      if(isRaw) 
    376 //                                              newList += item + ";" 
    377 //                                      Endif 
    378 //                              Endif 
    379 //                      Endif 
    380 //              Endif 
    381 //              ii+=1 
    382 //      while(ii<num)           //process all items in list 
    383 // 
    384 //      Return(newList) 
    385277End 
    386278 
     
    463355        Return 0 
    464356End 
    465  
    466  
    467 //************************************* 
    468 //under construction MRED function 
    469  
    470 //testing - unused 
    471 //Macro Init_NEW_MRED() 
    472 //      Make/O/T/N=1 fileWave,redWave 
    473 //      Make/O/N=1 selWave 
    474 //End 
    475  
    476 //testing - unused 
    477 // 
    478 //returns a list of raw data files from catPathName 
    479 //Function/S RawDataList() 
    480 //      //make sure that path exists 
    481 //      PathInfo catPathName 
    482 //      String path = S_path 
    483 //      if (V_flag == 0) 
    484 //              Abort "folder path does not exist - use Pick Path button" 
    485 //      Endif 
    486 //      String list=IndexedFile(catPathName,-1,"????")  //get all files in folder 
    487 //       
    488 //      //trim list to include only selected files that are RAW SANS files 
    489 //      //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be reduced) 
    490 //      Variable ii,isRAW,num,runNum=-1 
    491 //      String item="",newList = "",fullName = "",partialName="" 
    492 //       
    493 //      //get rid of version numbers first (up to 11) 
    494 //      list =  RemoveVersNumsFromList(list) 
    495 //       
    496 //      //then filter out only the raw data files within the range lownum to highnum 
    497 //      num = ItemsInList(list,";")             //get the new number of items in the list 
    498 //      ii=0 
    499 //      do 
    500 //              //  exclude by isRaw? (to minimize disk access) 
    501 //              item = StringFromList(ii, list  ,";" ) 
    502 //              if(strlen(item) != 0) 
    503 //                              partialName = FindValidFileName(item) 
    504 //                              if(strlen(partialName) != 0)            //non-null return from FindValidFileName() 
    505 //                                      fullName = path + partialName 
    506 //                                      //check if RAW, if so, add original item to newList 
    507 //                                      isRAW = CheckIfRawData(fullName) 
    508 //                                      if(isRaw) 
    509 //                                              newList += item + ";" 
    510 //                                      Endif 
    511 //                              Endif 
    512 //              Endif 
    513 //              ii+=1 
    514 //      while(ii<num)           //process all items in list 
    515 // 
    516 //      Return(newList) 
    517 //End 
    518  
    519 //testing - unused 
    520 // 
    521 //Function/S RunNumList2FileNameList(NumList) 
    522 //      String numList          //text list of run numbers 
    523 // 
    524 //      //find a valid file name if possible, return null otherwise 
    525 //      String retList = "",str="" 
    526 //      Variable numRuns,ii,r_index 
    527 //      numRuns = ItemsInList(numList,";") 
    528 //      for(ii=0;ii<numRuns;ii+=1) 
    529 //              r_index = str2num(StringFromList(ii,numList,";")) 
    530 //              str= FindFileFromRunNumber(r_index) 
    531 //              if(cmpstr(str,"")!=0) 
    532 //                      retList += str + ";" 
    533 //              Endif 
    534 //      EndFor 
    535 //      return(retList) 
    536 //End 
    537  
    538 //testing - unused 
    539 // 
    540 //Window panel0() : Panel 
    541 //      PauseUpdate; Silent 1           // building window... 
    542 //      NewPanel /W=(501,97,929,307) /K=1 
    543 //      ListBox fileList,pos={0,0},size={179,146},listWave=root:fileWave 
    544 //      ListBox fileList,selWave=root:selWave,mode= 4 
    545 //      ListBox redList,pos={219,0},size={179,146},listWave=root:redWave,mode= 1 
    546 //      ListBox redList,selRow= -1 
    547 //      Button button0,pos={114,148},size={50,20},proc=AddButtonProc,title="Add" 
    548 //      Button button1,pos={219,148},size={50,20},proc=ClearButtonProc,title="Clear" 
    549 //      Button button2,pos={337,148},size={50,20},proc=PopButtonProc,title="Pop" 
    550 //      Button button3,pos={4,148},size={50,20},proc=NewListButtonProc 
    551 //      Button button4,pos={279,148},size={50,20},proc=DelButtonProc,title="Del" 
    552 //EndMacro 
    553  
    554 //testing - unused 
    555 // 
    556 //Function DelButtonProc(ctrlName) : ButtonControl 
    557 //      String ctrlName 
    558 //       
    559 //      ControlInfo redList 
    560 //      Variable selRow=V_Value 
    561 //      Wave lw=$S_Value 
    562 //      DeletePoints selRow,1,lw 
    563 //       
    564 //End 
    565  
    566 //testing - unused 
    567 // 
    568 //Function NewListButtonProc(ctrlName) : ButtonControl 
    569 //      String ctrlName 
    570 //       
    571 //      String list=IndexedFile(catPathName,-1,"????") 
    572 //      String newList="",item="" 
    573 //      Variable num=ItemsInList(list,";"),ii 
    574 //      for(ii=0;ii<num;ii+=1) 
    575 //              item = StringFromList(ii, list  ,";") 
    576 //              if( stringmatch(item,"*.sa1*") ) 
    577 //                      newlist += item + ";" 
    578 //              endif 
    579 //              if( stringmatch(item,"*.sa2*") ) 
    580 //                      newlist += item + ";" 
    581 //              endif 
    582 //              if( stringmatch(item,"*.sa3*") ) 
    583 //                      newlist += item + ";" 
    584 //              endif 
    585 //              //print "ii=",ii 
    586 //      endfor 
    587 //      newList = SortList(newList,";",0) 
    588 //      num=ItemsInList(newlist,";") 
    589 //      Make/O/T/N=(num) fileWave 
    590 //      Make/O/N=(num) selWave 
    591 //      fileWave = StringFromList(p,newlist,";") 
    592 //      Sort filewave,filewave 
    593 //End 
    594  
    595 //testing - unused 
    596 // 
    597 //Function AddButtonProc(ctrlName) : ButtonControl 
    598 //      String ctrlName 
    599 // 
    600 //      Wave/T fileWave=fileWave 
    601 //      Wave/T redWave=redWave 
    602 //      Wave sel=selWave 
    603 //       
    604 //      Variable num=numpnts(sel),ii=0 
    605 //      variable lastPt=numpnts(redwave) 
    606 //      do 
    607 //              if(sel[ii] == 1) 
    608 //                      InsertPoints lastPt,1, redWave 
    609 //                      redWave[lastPt]=filewave[ii] 
    610 //                      lastPt +=1 
    611 //              endif 
    612 //              ii+=1 
    613 //      while(ii<num) 
    614 //      return(0) 
    615 //End 
    616  
    617 //testing - unused 
    618 // 
    619 //Function ClearButtonProc(ctrlName) : ButtonControl 
    620 //      String ctrlName 
    621 //      Make/O/T/N=1 redWave 
    622 //End 
    623  
    624 //testing - unused 
    625 // 
    626 //Function PopButtonProc(ctrlName) : ButtonControl 
    627 //      String ctrlName          
    628 //      MRedPopMenuProc("MRFilesPopup",0,"") 
    629 //End 
    630357 
    631358 
Note: See TracChangeset for help on using the changeset viewer.