Ignore:
Timestamp:
Oct 2, 2012 3:51:06 PM (10 years ago)
Author:
srkline
Message:

Changes to the polarization reduction, tickets#355, #356, #362,

--saving of the panel states is now something that can be done from a menu item. (there is too much clutter on the panels to add more buttons, unless there is a great outcry).
--"?" has ben added to table columns that require input - coloring of individual columns can't be done with the matrices in the table.
-- the background is now polarization-independent
--the flow of the protocol execution now forces are-load and re--polarization correction every time for SAM, EMP, BGD (trivial) so that the correct files are in the correct locations, every time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationCorrection.ipf

    r853 r864  
    132132 
    133133 
     134// saves the runs+cells for the PolCor Panel, separate from what is saved when the panel is closed 
     135// 
     136//      fname = "CellDecayPanelSaveState.itx" 
     137// 
     138// 
     139Function SavePolCorPanelState() 
     140 
     141        SetDataFolder root:Packages:NIST:Polarization 
     142         
     143        String listStr,item,fname,noteStr,wStr 
     144        Variable num,ii,refnum 
     145         
     146        fname = "PolCorPanelSaveState.itx" 
     147         
     148        // get a list of the List waves 
     149        listStr=WaveList("ListWave_*",";","") 
     150        num=ItemsInList(listStr,";") 
     151//      print listStr 
     152 
     153        Open/P=home refnum as fname             // creates a new file, or overwrites the existing file   
     154        fprintf refNum,"IGOR\r" 
     155                         
     156        // Save each of the list waves, 2D text 
     157        for(ii=0;ii<num;ii+=1) 
     158                item = StringFromList(ii, listStr,";") 
     159                Wave/T tw = $item 
     160                 
     161                Write2DTextWaveToITX(tw,refnum) 
     162                 
     163                fprintf refNum,"\r"             //space between waves 
     164        endfor   
     165 
     166        // get a list of the Selection waves 
     167        listStr=WaveList("lbSelWave_*",";","") 
     168        num=ItemsInList(listStr,";")     
     169         
     170        // Save each of the Selection waves, 2D numerical 
     171        for(ii=0;ii<num;ii+=1) 
     172                item = StringFromList(ii, listStr,";") 
     173                Wave w = $item 
     174 
     175                Write2DWaveToITX(w,refnum) 
     176 
     177                fprintf refNum,"\r"      
     178        endfor   
     179 
     180// save the popState wave 
     181        Wave/T tw=root:Packages:NIST:Polarization:PolCor_popState 
     182        Write2DTextWaveToITX(tw,refnum) 
     183         
     184        Close refnum 
     185 
     186        SetDataFolder root: 
     187        return(0) 
     188End 
     189 
     190// restores the waves for the cell decay table 
     191// 
     192//      fname = "PolCorPanelSaveState.itx" 
     193// 
     194// 
     195Function RestorePolCorPanelState() 
     196 
     197        SetDataFolder root:Packages:NIST:Polarization 
     198         
     199        String listStr,item,fname,noteStr,wStr 
     200        Variable num,ii,refnum 
     201         
     202        fname = "PolCorPanelSaveState.itx" 
     203        LoadWave/O/T fname 
     204         
     205        SetDataFolder root: 
     206        return(0) 
     207End 
     208 
    134209// 
    135210// TODO: 
     
    144219        DoAlert 1,"Do you want to initialize, wiping out all of your entries?" 
    145220        if(V_flag != 1)         //1== yes initialize, so everything else, restore the entries 
    146                 return(1) 
     221                return(1)                       //send back 1 to say yes, restore the saved state 
    147222        endif 
    148223         
     
    542617//      PopupMenu popup_1_UD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
    543618 
    544  
    545 // BKG Tab       
     619// TODO 
     620// BKG Tab -- DU, DD, UD are not shown, since the background is not dependent on the flipper states, so only one background 
     621// file is necessary - this is "incorrectly" labeled as UU. I'll get around to changing this in the future... 
     622// 
     623        TitleBox title_2_UU,pos={350,100},size={400,48},title="\\f01BGD files are independent of polarization\rEnter all as UU",fSize=12 
     624 
     625 
    546626        // UU 
    547627        ListBox ListBox_2_UU,pos={34,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     
    570650 
    571651        // DU 
    572         ListBox ListBox_2_DU,pos={368,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
    573         ListBox ListBox_2_DU,listWave=root:Packages:NIST:Polarization:ListWave_2_DU,titleWave=root:Packages:NIST:Polarization:lbTitles 
    574         ListBox ListBox_2_DU,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     652////////        ListBox ListBox_2_DU,pos={368,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     653////////        ListBox ListBox_2_DU,listWave=root:Packages:NIST:Polarization:ListWave_2_DU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     654////////        ListBox ListBox_2_DU,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
    575655//      SetVariable setvar_2_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
    576656//      SetVariable setvar_2_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_0 
     
    595675 
    596676// DD 
    597         ListBox ListBox_2_DD,pos={33,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
    598         ListBox ListBox_2_DD,listWave=root:Packages:NIST:Polarization:ListWave_2_DD,titleWave=root:Packages:NIST:Polarization:lbTitles 
    599         ListBox ListBox_2_DD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     677////////        ListBox ListBox_2_DD,pos={33,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     678////////        ListBox ListBox_2_DD,listWave=root:Packages:NIST:Polarization:ListWave_2_DD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     679////////        ListBox ListBox_2_DD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
    600680//      SetVariable setvar_2_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
    601681//      SetVariable setvar_2_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_0 
     
    620700 
    621701// UD 
    622         ListBox ListBox_2_UD,pos={368,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
    623         ListBox ListBox_2_UD,listWave=root:Packages:NIST:Polarization:ListWave_2_UD,titleWave=root:Packages:NIST:Polarization:lbTitles 
    624         ListBox ListBox_2_UD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_UD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     702////////        ListBox ListBox_2_UD,pos={368,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     703////////        ListBox ListBox_2_UD,listWave=root:Packages:NIST:Polarization:ListWave_2_UD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     704////////        ListBox ListBox_2_UD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_UD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
    625705//      SetVariable setvar_2_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
    626706//      SetVariable setvar_2_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_0 
     
    777857End 
    778858 
    779  
     859// 0 = SAM, 1 = EMP, 2 = BGD 
     860Function ChangeDataTab(tab) 
     861        Variable tab 
     862        Variable val 
     863         
     864        TabControl PolCorTab win=PolCor_Panel,value=tab 
     865         
     866        // as if the tab was clicked 
     867        val = (tab != 0) 
     868//                      Print "tab 0 val = ",val 
     869        ToggleSelControls("_0_",val) 
     870         
     871        val = (tab != 1) 
     872//                      Print "tab 1 val = ",val 
     873        ToggleSelControls("_1_",val) 
     874         
     875        val = (tab != 2) 
     876//                      Print "tab 2 val = ",val 
     877        ToggleSelControls("_2_",val) 
     878 
     879        return(0)                        
     880End 
    780881 
    781882Function PolCorHelpParButtonProc(ba) : ButtonControl 
     
    9091010// -the PolMatrix of coefficients is filled (the specified row) 
    9101011// 
     1012// *** IF THE DATA IS BGD *** 
     1013// take the file list from UU every time, but load and put this in all 4 XS locations 
     1014//  ************************* 
     1015// 
    9111016// TODO: 
    9121017// X- pre-parsing is not done to check for valid file numbers. This should be done gracefully. 
     
    9351040//      listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
    9361041 
    937         Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     1042//////////// 
     1043        if(tabNum == 2)         //BGD data, read from UU every time, but don't change the pType tag 
     1044                Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+"UU") 
     1045        else 
     1046                Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     1047        endif 
    9381048        num = DimSize(lb,0)             //should be 10, as initialized 
    9391049         
     
    10531163//      listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
    10541164 
    1055  
    1056         Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     1165//////////// 
     1166        if(tabNum == 2)         //BGD data, read from UU every time, but don't change the pType tag 
     1167                Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+"UU") 
     1168        else 
     1169                Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     1170        endif 
    10571171        num = DimSize(lb,0)             //should be 10, as initialized 
    10581172         
     
    16801794// largely copied from ReduceAFile() 
    16811795// 
     1796// 
     1797// 
     1798// 
    16821799Function ReducePolCorDataButton(ctrlName) : ButtonControl 
    16831800        String ctrlName 
    16841801 
    1685         // depends on which tab you're on 
    1686         // (maybe) select UD type 
    1687          
     1802 
    16881803        String pType 
    16891804//      Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;All;" 
     
    17381853// very similar to ExecuteProtocol 
    17391854// 
    1740 // -- SAM, EMP, and BGD do not need to be loaded 
    1741 // -- but they do need to be "moved" into the regular data positions 
    1742 //    rather then their tagged locations. 
    17431855//  
     1856// OCT 2012 - changed this to force a re-load of all of the data, and a re-calculation  
     1857//   of the Pol-corrected data, so that all of the "_pc" waves that are present are the  
     1858// correct, and current values. Only re-loads the data that is used for the particular protocol,  
     1859// just like a normal reduction. This is, somewhat redundant, since the data is re-loaded 4x, when 
     1860// it really only needs to be re-loaded 1x, but this is only a minor speed hit. 
     1861// 
    17441862// -- the "extensions" now all are "_UU_pc" and similar, to use the polarization corrected data and errors 
    17451863// 
     
    17661884        //5 - average params 
    17671885        //6 = DRK file (**out of sequence) 
    1768  
    1769 // don't load the SAM data, just re-tag it       
     1886         
     1887         
     1888        // For each of the tabs (SAM, EMP, BGD) 
     1889        // -- reload the data 
     1890        // -- re-do the polarization correction 
     1891         
     1892        // then, and only then, after we're sure that all of the data is correct and current, then proceed with the 
     1893        // correction of the data with the selected protocol 
     1894        String dataType,str 
     1895 
     1896        STRUCT WMButtonAction ba 
     1897        ba.eventCode = 2                // mouse up 
     1898         
     1899 
     1900// Now ensure that the proper SAM data is loaded, then re-tag it         
    17701901// the Polarization corrected data is UU_pc, DU_pc, etc. 
    17711902// this tags it for display, and puts it in the correctly named waves 
    1772         String dataType,str 
     1903         
     1904        ChangeDataTab(0)                //SAM 
     1905        LoadRawPolarizedButton(ba) 
     1906        PolCorButton(ba) 
    17731907         
    17741908        dataType="SAM" 
     
    17761910        Execute str 
    17771911         
    1778  
    1779  
    1780 // don't load the BGD data, just re-tag it       
     1912// force a re-load of BGD data, then re-tag it   
    17811913        if(cmpstr(prot[0],"none") != 0)         //if BGD is used, protStr[0] = "" 
     1914                ChangeDataTab(2)                //BGD 
     1915                LoadRawPolarizedButton(ba) 
     1916                PolCorButton(ba) 
     1917                 
    17821918                dataType="BGD" 
    17831919                sprintf str,"DisplayTaggedData(\"%s\",\"%s\")",dataType,pType+"_pc" 
     
    17851921        endif 
    17861922 
    1787 // don't load the EMP data, just re-tag it 
    1788 // 
     1923// force a re-load the EMP data, then re-tag it 
    17891924        if(cmpstr(prot[1],"none") != 0)         //if EMP is used, protStr[1] = "" 
     1925                ChangeDataTab(1)                //EMP 
     1926                LoadRawPolarizedButton(ba) 
     1927                PolCorButton(ba) 
     1928         
    17901929                dataType="EMP" 
    17911930                sprintf str,"DisplayTaggedData(\"%s\",\"%s\")",dataType,pType+"_pc" 
     
    20692208                //if this doesn't exist, a dialog will be presented by setting dialog = 1 
    20702209                // 
    2071                 // -- add in pType tag to the name 
     2210                // -- add in pType tag to the name for the polarization "type" 
    20722211                // 
    20732212                Variable dialog = 0 
Note: See TracChangeset for help on using the changeset viewer.