Ignore:
Timestamp:
Jul 20, 2011 9:40:32 AM (12 years ago)
Author:
srkline
Message:

Changed 2-yukawa to have better names for the parameters, a macro to plot g(r), and to return S(q)=1000 if the calculation fails, to be more obvious.

Added a Corrlation matrix function (in Wrapper.ipf), but it's not linked anywhere yet, since I don't know yet how best to display it.

Simplified the function to list .ASC files

Added comments to the polarization panel procedures.

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

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2010/Two_Yukawa_v40.ipf

    r773 r824  
    6161        xwave_1yuk = alog(log(qmin) + x*((log(qmax)-log(qmin))/num))     
    6262        Make/O/D coef_1yuk = {0.1,50,-1,10} 
    63         make/o/t parameters_1yuk = {"volume fraction","Radius (A)","scale, K","charge, Z"} 
     63        make/o/t parameters_1yuk = {"volume fraction","Radius (A)","scale, K","Decay constant, Z"} 
    6464        Edit parameters_1yuk,coef_1yuk 
    6565        Variable/G root:g_1yuk 
     
    113113        xwave_2yuk = alog(log(qmin) + x*((log(qmax)-log(qmin))/num))     
    114114        Make/O/D coef_2yuk = {0.2,50,6,10,-1,2} 
    115         make/o/t parameters_2yuk = {"volume fraction","Radius (A)","scale, K1","charge, Z1","scale, K2","charge, Z2"} 
     115        make/o/t parameters_2yuk = {"volume fraction","Radius (A)","scale, K1","Decay constant, Z1","scale, K2","Decay constant, Z2"} 
    116116        Edit parameters_2yuk,coef_2yuk 
    117117        Variable/G root:g_2yuk 
     
    162162End 
    163163 
     164// with the regular 2-yukawa plotted, this uses the coefficients to plot g(r) 
     165// 
     166// - no dependency is created, it would just slow things down. So you'll 
     167// need to re-run this every time. 
     168// 
     169//              gr is scaled to dimensionless distance, r/diameter 
     170// 
     171Macro Plot_2Yukawa_Gr() 
     172        //if the regular 2-yukawa procedure is already plotted 
     173        // -- then append it to thte graph yourself 
     174        Duplicate/O ywave_2yuk ywave_2yuk_Igor 
     175 
     176        fTwoYukawa(coef_2yuk,xwave_2yuk,ywave_2yuk_Igor) 
     177         
     178        DoWindow/F Gr_plot 
     179        if(V_flag==0) 
     180                Display gr 
     181                DoWindow/C Gr_plot 
     182                Modifygraph log=0 
     183                SetAxis bottom 0,10 
     184                Modifygraph lsize=2 
     185                Label left "g(r)";DelayUpdate 
     186                Label bottom "dimensionless distance (r/diameter)" 
     187                legend 
     188        endif 
     189         
     190         
     191         
     192End 
     193 
     194 
     195 
    164196// 
    165197Function fTwoYukawa(cw,xw,yw) : FitFunc 
     
    190222                        yw = SqTwoYukawa(xw*radius*2, Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2) 
    191223//                      printf("%g      %g\n",q,sq) 
     224                else 
     225                        yw = 1000               //return a really bogus answer, as Yun suggests 
    192226                endif 
    193227        endif 
     
    16021636        gr[0] = 0 
    16031637         
     1638        SetScale/P x,0,dr, gr 
     1639         
    16041640//      Killwaves/Z temp 
    16051641 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf

    r801 r824  
    14581458        return(1) 
    14591459End 
     1460 
     1461// displays the covariance matrix for the current data set in the popup 
     1462// AND whatever was the last fit for that data set. it may not necessarily 
     1463// be the displayed function... 
     1464Function DisplayCovarianceMatrix() 
     1465 
     1466        ControlInfo/W=wrapperpanel popup_0 
     1467        String folderStr=S_Value 
     1468         
     1469        SetDataFolder $("root:"+folderStr) 
     1470         
     1471        Wave M_Covar=M_Covar 
     1472        Duplicate/O M_Covar, CorMat      // You can use any name instead of CorMat 
     1473        CorMat = M_Covar[p][q]/sqrt(M_Covar[p][p]*M_Covar[q][q]) 
     1474        Edit CorMat 
     1475         
     1476        SetDataFolder root: 
     1477         
     1478        return(0) 
     1479End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_FlipperPanel.ipf

    r817 r824  
    105105                        // the cell must already be defined 
    106106                        String condStr, cellStr 
    107                         Prompt condStr,"Condition, <12 characters" 
     107                        Prompt condStr,"Condition, <12 characters, NO UNDERSCORES" 
    108108                        Prompt cellStr,"Cell",popup,D_CellNameList() 
    109109                        DoPrompt "Add new condition",condStr, cellStr 
     
    116116                                Print "Condition String trimmed to ",condStr 
    117117                        endif 
     118                         
     119                        condStr = ReplaceString("_", condStr, "", 0, inf) 
    118120                         
    119121                        String popStr 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationPanels.ipf

    r817 r824  
    11#pragma rtGlobals=1             // Use modern global access method. 
    22 
     3 
     4// Polarized Beam Reduction Procedures 
     5// 
     6// 
    37// input panels to set and calculate polarization parameters necessary for the  
    48// matrix corrections to the cross sections 
    59// 
    6 // -1- Fundamental Cell Parameters -- these are constants, generally not editable. 
    7 // -2- Decay Parameters -- these are fitted values based on transmission mearurements 
    8 // -3- 
    9  
    10  
    11 // 
    12 // -- need a general way to be sure to NOT re-initialize the values if the panel is closed/reopened 
    13 // 
    14 // 
    15 // TODO: 
    16 // Need a way to output the results - like in a report format 
    17 // cell (panel 1) 
    18 // static params 
    19 // fit gamma params 
    20 // graph 
    21 // 
    22 // and also a separate report (panel 2) 
    23 // flipper/sm @ conditions 
    24 // --- the report could be as simple as a screen snapshot of the panel? 
    25  
    26  
    27 // He cell parameters. Most of these are pre-defined, so that they are supplied as a  
     10// -1- Fundamental Cell Parameters -- these are constants, generally not editable. (this file) 
     11// -2- Decay Parameters -- these are fitted values based on transmission mearurements (this file) 
     12// -3- Flipper Panel is in its own procedure (FlipperPanel.ipf) 
     13// -4- PolCor_Panel is in PolarizationCorrection.ipf 
     14 
     15// 
     16// Driven by 4 panels to get the necessary information from the users 
     17// -1- Fundamental cell parameters: root:Packages:NIST:Polarization:Cells 
     18//              - default cell parameters are loaded. More cell definitions can be added as more cells are used 
     19//              - changes are saved per experiment 
     20//              - important parameters are held in global key=value strings gCell_<name>  
     21//              - cell names and parameters are used by the 2nd panel for calculation of the Decay constant 
     22// 
     23// -2- Decay Constant Panel 
     24//              - decay constant determined for each cell. 
     25//              - popping the cell name makes 2 waves, Decay_<cellname> and DecayCalc_<cellname> 
     26//              - Decay_ is the wave presented in the table. Specified transmission run numbers are entered 
     27//                      and "Calc Sel Row" does the calculation of mu and Pcell (for all rows, actually) 
     28//              - DimLabels are used for the arrays to make the column identity more readable than simply an index 
     29//              - time=0 is taken from the first file 
     30//              - Calculations are based on the count rate of the file, corrected for monitor and attenuation 
     31//              - alerts are posted for files in any row that are not at the same attenuation or SDD 
     32//              - if "include" column is == 1, that row will be included in the fit of the decay data 
     33//              - excluded points are plotted in red 
     34//              - results of the fit are printed on the panel, and written to the wave note of the Decay_ wave  
     35//                      (not DecayCalc_) for use in the next panel 
     36//              - manual entry of all of the parameters in the wave note is allowed. 
     37// 
     38// 
     39// -3- Flipper Panel (not in this procedure - in Pol_FlipperPanel.ipf) 
     40//              - calculates the flipper and supermirror efficiencies for a given cell AND "condition" 
     41//              - start by entering a condition name and choosing a cell 
     42//              - Waves Cond_<condition>_<cell> and CondCalc_<condition>_<cell> are created 
     43//              - DimLabels are used for the arrays to make the column identity more readable than simply an index 
     44//              - enter transmission run numbers as specified in the table 
     45//              - Do Average will calculate the Psm and PsmPfl values (and errors) and average if more than 
     46//                      one row of data is present (and included) 
     47//              - results are printed on the panel, and written to the wave note of Cond_<condition>_<cell> 
     48//              - results are used in the calculation of the polarization matrix 
     49// 
     50// 
     51// -4- PolCor_Panel (not in this procedure - in Pol_PolarizationCorrection.ipf) 
     52//              - gets all of the parameters from the user to do the polariztion correction, then the "normal" SANS reduction 
     53//              - 5 files can be added together for each of the different spin states (more than this??) 
     54//              - global strings in root:Packages:NIST:Polarization:gStr_PolCor_<tab>_<flip>_<position> hold the run number 
     55//              - polarization condition is set with the popup 
     56//              - the same fields/pops are duplicated (hidden) for the SAM/EMP/BGD tabs as needed 
     57//              - on loading of the data, the 2-letter spin state is tagged onto the loaded waves (all of them) 
     58//              - displayed data is simply re-pointed to the desired data 
     59//              - on loading, the raw files are added together as ususal, normalized to monitor counts. Then each contribution  
     60//                      of the file to the polarization matrix is added (scaling each by mon/1e8) 
     61//              - loaded data and PolMatrix are stored in the ususal SAM, EMP, BGD folders. 
     62//              - Polarization correction is done with one click (one per tab). "_pc" tags are added to the resulting names, 
     63//                      and copies of all of the associated waves are again copied (wasteful), but makes switching display very easy 
     64//              - Once all of the polariztion correction is done, then the UU_pc (etc.) data can be reduced as usual (4 passes) 
     65//              - protocol is built as ususal, from this panel only (since the SAM, EMP, and BGD need to be switched, rather than loaded 
     66//              - protocols can be saved/recalled. 
     67//              - reduction will always ask for a protocol rather than using what's on the panel. 
     68//              - closing the panel will save the state (except the protocol). NOT initializing when re-opening will restore the  
     69//                      state of the entered runs and the popups of conditions. 
     70// 
     71// 
     72// 
     73// 
     74 
     75 
     76 
     77 
     78// 
     79// Panel -1- 
     80// 
     81// Fundamental He cell parameters. Most of these are pre-defined, so that they are supplied as a  
    2882// static table, only edited as parameters are refined. 
    2983// 
     
    89143 
    90144// parse strings to fill in waves 
    91  
     145// 
    92146// 
    93147Function Make_HeCell_ParamWaves() 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WorkFileUtils.ipf

    r794 r824  
    15001500//can be lots of other junk present, but this is very fast... 
    15011501// 
     1502// -- simplified to do in a single call -- extension must be .ASC 
     1503// - so far, only used in WorkFileMath popups, which require .ASC 
     1504// 
    15021505Function/S ASC_FileList() 
    15031506 
     
    15111514                Return("") 
    15121515        Endif 
    1513          
    1514         list = IndexedFile(catpathName,-1,"????") 
    1515          
    1516         list = RemoveFromList(ListMatch(list,"*.SA1*",";"), list, ";", 0) 
    1517         list = RemoveFromList(ListMatch(list,"*.SA2*",";"), list, ";", 0) 
    1518         list = RemoveFromList(ListMatch(list,"*.SA3*",";"), list, ";", 0) 
    1519         list = RemoveFromList(ListMatch(list,".*",";"), list, ";", 0) 
    1520         list = RemoveFromList(ListMatch(list,"*.pxp",";"), list, ";", 0) 
    1521         list = RemoveFromList(ListMatch(list,"*.DIV",";"), list, ";", 0) 
    1522         list = RemoveFromList(ListMatch(list,"*.GSP",";"), list, ";", 0) 
    1523         list = RemoveFromList(ListMatch(list,"*.MASK",";"), list, ";", 0) 
    1524  
    1525         //remove VAX version numbers 
    1526         list = RemoveVersNumsFromList(List) 
     1516 
     1517        list = IndexedFile(catpathName,-1,".ASC") 
     1518 
     1519 
     1520//      list = IndexedFile(catpathName,-1,"????") 
     1521//       
     1522//      list = RemoveFromList(ListMatch(list,"*.SA1*",";"), list, ";", 0) 
     1523//      list = RemoveFromList(ListMatch(list,"*.SA2*",";"), list, ";", 0) 
     1524//      list = RemoveFromList(ListMatch(list,"*.SA3*",";"), list, ";", 0) 
     1525//      list = RemoveFromList(ListMatch(list,".*",";"), list, ";", 0) 
     1526//      list = RemoveFromList(ListMatch(list,"*.pxp",";"), list, ";", 0) 
     1527//      list = RemoveFromList(ListMatch(list,"*.DIV",";"), list, ";", 0) 
     1528//      list = RemoveFromList(ListMatch(list,"*.GSP",";"), list, ";", 0) 
     1529//      list = RemoveFromList(ListMatch(list,"*.MASK",";"), list, ";", 0) 
     1530// 
     1531//      //remove VAX version numbers 
     1532//      list = RemoveVersNumsFromList(List) 
    15271533        //sort 
    15281534        newList = SortList(List,";",0) 
Note: See TracChangeset for help on using the changeset viewer.