Ignore:
Timestamp:
Apr 21, 2009 5:33:27 PM (13 years ago)
Author:
srkline
Message:

Changes to how Patch interprets the match string. 3 cases now:
(1) - interpret as a run number list, just like all other run number lists and ranges.
(2) grep for text in the raw VAX binary. can be slow. did not allow generic regular expressions to be entered since of the three people on earth that know how to use them, none are neutron scatterers.
(3) filter on SDD, just like in the MRED beta ops. Radio buttons control how it's interpreted. Removed the redundant "Show Header" button, as the header is displayed for the currently popped item without user intervention.

This closes Cedric's ticket #212

Plus a few tweaks of MC and Wrapper.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/PatchFiles.ipf

    r412 r494  
    8181        Variable/G root:myGlobals:Patch:gPV19 = 0 
    8282        Variable/G root:myGlobals:Patch:gTransCts = 0 
     83        Variable/G root:myGlobals:Patch:gRadioVal = 0 
    8384End 
    8485 
     
    113114//that is semicolon delimited, and is suitable for display in a popup menu 
    114115// 
    115 Function/S GetValidPatchPopupList() 
     116Function/S xGetValidPatchPopupList() 
    116117 
    117118        //make sure that path exists 
     
    128129        //trim list to include only selected files 
    129130        SVAR match = root:myGlobals:Patch:gPatchMatchStr 
     131        if(strlen(match) == 0)          //if nothing is entered for a match string, return everything, rather than nothing 
     132                match = "*" 
     133        endif 
     134         
    130135        newlist = MyMatchList(match,newlist,";") 
    131136         
     
    134139End 
    135140 
    136  
     141//returns a list of valid files (raw data, no version numbers, no averaged files) 
     142//that is semicolon delimited, and is suitable for display in a popup menu 
     143// 
     144// Uses Grep to look through the any text in the file, which includes the sample label 
     145// can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit 
     146// enter when inputing a filter string) 
     147// 
     148// - or - 
     149// a list or range of run numbers 
     150// - or -  
     151// a SDD (to within 0.001m) 
     152// - or - 
     153// * to get everything 
     154// 
     155//      NVAR gRadioVal= root:myGlobals:Patch:gRadioVal 
     156 // 1== Run # (comma range OK) 
     157 // 2== Grep the text (SLOW) 
     158 // 3== filter by SDD (within 0.001 m) 
     159Function/S GetValidPatchPopupList() 
     160 
     161        //make sure that path exists 
     162        PathInfo catPathName 
     163        String path = S_path 
     164        if (V_flag == 0) 
     165                Abort "folder path does not exist - use Pick Path button" 
     166        Endif 
     167         
     168        String newList = "" 
     169 
     170        newList = GetRawDataFileList() 
     171 
     172        //trim list to include only selected files 
     173        SVAR match = root:myGlobals:Patch:gPatchMatchStr 
     174        if(strlen(match) == 0 || cmpstr(match,"*")==0)          //if nothing or "*" entered for a match string, return everything, rather than nothing 
     175                match = "*" 
     176        // old way, with simply a wildcard 
     177                newlist = MyMatchList(match,newlist,";") 
     178                newList = SortList(newList,";",0) 
     179                return(newList) 
     180        endif 
     181         
     182        //loop through all of the files as needed 
     183        // Grep Note: the \\b sequences limit matches to a word boundary before and after 
     184        // "boondoggle", so "boondoggles" and "aboondoggle" won't match. 
     185         
     186        String list="",item="",fname,runList="",numStr="" 
     187        Variable ii,num=ItemsInList(newList),val,sdd 
     188        NVAR gRadioVal= root:myGlobals:Patch:gRadioVal 
     189         
     190 
     191 
     192        // run number list 
     193        if(gRadioVal == 1) 
     194//              list = ParseRunNumberList(match)                //slow, file access every time 
     195//              list = ReplaceString(",", list, ";") 
     196//              newList = list 
     197                 
     198                list = ExpandNumRanges(match)           //now simply comma delimited 
     199                num=ItemsInList(list,",") 
     200                for(ii=0;ii<num;ii+=1) 
     201                        item = StringFromList(ii,list,",") 
     202                        val=str2num(item) 
     203                        //make a three character string of the run number 
     204                        if(val<10) 
     205                                numStr = "00"+num2str(val) 
     206                        else 
     207                                if(val<100) 
     208                                        numStr = "0"+num2str(val) 
     209                                else 
     210                                        numStr = num2str(val) 
     211                                Endif 
     212                        Endif 
     213                        runList += ListMatch(newList,"*"+numStr+"*",";") 
     214                         
     215                endfor 
     216                newlist = runList 
     217                 
     218        endif 
     219         
     220        //grep through what text I can find in the VAX binary 
     221        if(gRadioVal == 2) 
     222                for(ii=0;ii<num;ii+=1) 
     223                        item=StringFromList(ii, newList , ";") 
     224//                      Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item 
     225                        Grep/P=catPathName/Q/E=("(?i)"+match) item 
     226                        if( V_value )   // at least one instance was found 
     227//                              Print "found ", item,ii 
     228                                list += item + ";" 
     229                        endif 
     230                endfor 
     231 
     232                newList = list 
     233        endif 
     234         
     235        // SDD 
     236        if(gRadioVal == 3) 
     237                val = str2num(match) 
     238//              print val 
     239                for(ii=0;ii<num;ii+=1) 
     240                        item=StringFromList(ii, newList , ";") 
     241                        fname = path + item 
     242                        sdd = getSDD(fname) 
     243                        if(abs(val - sdd) < 0.001       )               //if numerically within 0.001 meter, they're the same 
     244                                list += item + ";" 
     245                        endif 
     246                endfor 
     247                 
     248                newList = list 
     249        endif 
     250 
     251        newList = SortList(newList,";",0) 
     252        Return(newList) 
     253End 
     254 
     255 
     256 
     257 
     258// -- no longer refreshes the list - this seems redundant, and can be slow if grepping 
     259// 
    137260//updates the popup list when the menu is "popped" so the list is  
    138261//always fresh, then automatically displays the header of the popped file 
     
    150273        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched) 
    151274 
    152         String list = GetValidPatchPopupList() 
    153          
    154         String/G root:myGlobals:Patch:gPatchList = list 
    155         ControlUpdate PatchPopup 
     275//      String list = GetValidPatchPopupList() 
     276         
     277//      String/G root:myGlobals:Patch:gPatchList = list 
     278//      ControlUpdate PatchPopup 
    156279        ShowHeaderButtonProc("SHButton") 
    157280End 
     
    177300        String/G root:myGlobals:Patch:gPatchList = list 
    178301        ControlUpdate PatchPopup 
    179          
     302        PopupMenu PatchPopup,mode=1 
    180303End 
    181304 
     
    479602Proc Patch_Panel() 
    480603        PauseUpdate; Silent 1      // building window... 
    481         NewPanel /W=(519,85,950,608)/K=1 as "Patch Raw SANS Data Files" 
     604//      NewPanel /W=(519,85,950,608)/K=1 as "Patch Raw SANS Data Files" 
     605        NewPanel /W=(519,85,950,608) as "Patch Raw SANS Data Files" 
    482606        DoWindow/C Patch_Panel 
    483607        ModifyPanel cbRGB=(1,39321,19939) 
     
    499623        Button helpButton,pos={400,3},size={25,20},proc=ShowPatchHelp,title="?" 
    500624        Button helpButton,help={"Show the help file for patching raw data headers"} 
    501         PopupMenu PatchPopup,pos={4,40},size={156,19},proc=PatchPopMenuProc,title="File(s) to Patch" 
     625        PopupMenu PatchPopup,pos={4,37},size={156,19},proc=PatchPopMenuProc,title="File(s) to Patch" 
    502626        PopupMenu PatchPopup,help={"The displayed file is the one that will be edited. The entire list will be edited if \"Change All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh. \r List items are selected from the file based on MatchString"} 
    503627        PopupMenu PatchPopup,mode=1,popvalue="none",value= #"root:myGlobals:Patch:gPatchList" 
    504         Button SHButton,pos={324,37},size={100,20},proc=ShowHeaderButtonProc,title="Show Header" 
    505         Button SHButton,help={"This will display the header of the file indicated in the popup menu."} 
    506         Button CHButton,pos={314,60},size={110,20},proc=ChangeHeaderButtonProc,title="Change Header" 
     628//      Button SHButton,pos={324,37},size={100,20},proc=ShowHeaderButtonProc,title="Show Header" 
     629//      Button SHButton,help={"This will display the header of the file indicated in the popup menu."} 
     630        Button CHButton,pos={314,37},size={110,20},proc=ChangeHeaderButtonProc,title="Change Header" 
    507631        Button CHButton,help={"This will change the checked values (ONLY) in the single file selected in the popup."} 
    508         SetVariable PMStr,pos={6,65},size={174,13},proc=SetMatchStrProc,title="Match String" 
     632        SetVariable PMStr,pos={6,63},size={174,13},proc=SetMatchStrProc,title="Match String" 
    509633        SetVariable PMStr,help={"Enter the search string to narrow the list of files. \"*\" is the wildcard character. After entering, \"pop\" the menu to refresh the file list."} 
    510634        SetVariable PMStr,font="Courier",fSize=10 
    511635        SetVariable PMStr,limits={-Inf,Inf,0},value= root:myGlobals:Patch:gPatchMatchStr 
    512         Button ChAllButton,pos={245,84},size={180,20},proc=ChAllHeadersButtonProc,title="Change All Headers in List" 
     636        Button ChAllButton,pos={245,60},size={180,20},proc=ChAllHeadersButtonProc,title="Change All Headers in List" 
    513637        Button ChAllButton,help={"This will change the checked values (ONLY) in ALL of the files in the popup list, not just the top file. If the \"change\" checkbox for the item is not checked, nothing will be changed for that item."} 
    514638        Button DoneButton,pos={310,489},size={110,20},proc=DoneButtonProc,title="Done Patching" 
     
    621745        CheckBox checkPV19,pos={18,450},size={20,20},title="",value=0 
    622746        CheckBox checkPV19,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0 
     747 
     748        CheckBox check0,pos={18,80},size={40,15},title="Run #",value= 1,mode=1,proc=MatchCheckProc 
     749        CheckBox check1,pos={78,80},size={40,15},title="Text",value= 0,mode=1,proc=MatchCheckProc 
     750        CheckBox check2,pos={138,80},size={40,15},title="SDD",value= 0,mode=1,proc=MatchCheckProc 
     751 
     752End 
     753 
     754 
     755Function MatchCheckProc(name,value) 
     756        String name 
     757        Variable value 
     758         
     759        NVAR gRadioVal= root:myGlobals:Patch:gRadioVal 
     760         
     761        strswitch (name) 
     762                case "check0": 
     763                        gRadioVal= 1 
     764                        break 
     765                case "check1": 
     766                        gRadioVal= 2 
     767                        break 
     768                case "check2": 
     769                        gRadioVal= 3 
     770                        break 
     771        endswitch 
     772        CheckBox check0,value= gRadioVal==1 
     773        CheckBox check1,value= gRadioVal==2 
     774        CheckBox check2,value= gRadioVal==3 
    623775End 
    624776 
Note: See TracChangeset for help on using the changeset viewer.