Ignore:
Timestamp:
Feb 6, 2012 12:19:28 PM (11 years ago)
Author:
srkline
Message:

moving the Polarization routines to a temporary "beta" menu location on the macros menu, numbering the panels.

Created a loader for the polarization routines that will load the SANS reduction if needed.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization
Files:
3 edited

Legend:

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

    r832 r835  
    2222// two waves per condition "Cond_Name_Cell" and "CondCalc_Name_Cell" 
    2323// 
    24 Macro ShowFlipperPanel() 
     24Proc ShowFlipperPanel() 
    2525         
    2626        // init folders 
     
    180180                        SetDataFolder root: 
    181181                         
     182                        // update the globals that are displayed from the wave note 
     183                        String nStr=Note(cond) 
     184                        SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf 
     185                        SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm 
     186                        sprintf gPsmPf, "%g +/- %g",NumberByKey("P_sm_f", nStr, "=",","),NumberByKey("err_P_sm_f", nStr, "=",",") 
     187                        sprintf gPsm, "%g +/- %g",NumberByKey("P_sm", nStr, "=",","),NumberByKey("err_P_sm", nStr, "=",",") 
     188                         
     189                         
    182190                        break 
    183191                case -1: // control being killed 
     
    215223        // generate the dummy wave note now, change as needed 
    216224        String cellStr = StringFromList(1, popStr,"_") 
    217         String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf," 
     225        String testStr = "P_sm_f=0,err_P_sm_f=0,P_sm=0,err_P_sm=0,T0=undefined," 
    218226//      testStr = ReplaceStringByKey("Cell", testStr, cellStr ,"=", ",", 0) 
    219227        Note cond, testStr 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationCorrection.ipf

    r829 r835  
    7575 
    7676// main entry to the PolCor Panel 
    77 Macro ShowPolCorSetup() 
     77Proc ShowPolCorSetup() 
    7878 
    7979        Variable restore=0 
     
    269269        Button button4,pos={620,18},size={30,20},proc=PolCorHelpParButtonProc,title="?" 
    270270        Button button12,pos={440,473},size={120,20},proc=Display4XSButton,title="Display 4 XS" 
     271        Button button13,pos={440,446},size={120,20},proc=ClearPolCorEntries,title="Clear Entries" 
    271272 
    272273        PopupMenu popup1,pos={210,24},size={102,20},title="Condition" 
     
    10151016         
    10161017        Variable row,Psm, PsmPf, PCell,err_Psm, err_PsmPf, err_PCell 
    1017         Variable ii,jj,muPo,err_muPo,gam,err_gam,monCts,t1,num 
     1018        Variable ii,jj,muPo,err_muPo,gam,err_gam,monCts,t1,num,fileCount 
    10181019 
    10191020        Variable ea_uu, ea_ud, ea_dd, ea_du 
     
    10571058 
    10581059        // loop over the (10) rows in the listWave 
     1060        fileCount=0 
    10591061        for(ii=0;ii<num;ii+=1) 
    10601062                runStr =        lb[ii][0]               //the run number 
    10611063                if(cmpstr(runStr, "" ) != 0) 
    1062                          
     1064                 
     1065                        fileCount += 1          //one more file is added 
    10631066                        // get run number (str) 
    10641067                        // get file name 
     
    10851088                        // get file info (monitor counts) 
    10861089                        monCts = getMonitorCount(fname) 
    1087                         monCts /= 1e8           //just to get reasonable values 
     1090                        monCts /= 1e8           //to get a normalized value to add proportionally 
    10881091                         
    10891092                        Variable err_monCts 
     
    12091212// can't take the SQRT here, since the matrix won't necessarily be full yet,  
    12101213         
    1211          
     1214// but now need to re-normalize the row based on the number of files that were added 
     1215// pType has only one value as passed in, so the row has already been set. It would be more correct 
     1216// to switch based on pType... 
     1217         
     1218        matA[row][0] /= fileCount 
     1219        matA[row][1] /= fileCount 
     1220        matA[row][2] /= fileCount 
     1221        matA[row][3] /= fileCount        
     1222         
     1223        matA_err[row][0] /= fileCount 
     1224        matA_err[row][1] /= fileCount 
     1225        matA_err[row][2] /= fileCount 
     1226        matA_err[row][3] /= fileCount    
     1227                                 
    12121228        SetDataFolder root: 
    12131229        return(0) 
     
    24492465End 
    24502466 
     2467// clear the entries for all 4 XS for the currently selected Tab only 
     2468// clears both the run numbers and the cell assignments 
     2469// 
     2470Function ClearPolCorEntries(ba) : ButtonControl 
     2471        STRUCT WMButtonAction &ba 
     2472 
     2473        switch( ba.eventCode ) 
     2474                case 2: // mouse up 
     2475                        // click code here 
     2476                        // 
     2477//                      String type 
     2478                        Variable tabNum 
     2479                        ControlInfo/W=PolCor_Panel PolCorTab 
     2480//                      type = S_value 
     2481//                      Print "selected data type = ",type,V_Value 
     2482                        tabNum = V_Value 
     2483                         
     2484                        WAVE/T twDD = $("root:Packages:NIST:Polarization:ListWave_"+num2str(tabNum)+"_DD") 
     2485                        WAVE/T twUU = $("root:Packages:NIST:Polarization:ListWave_"+num2str(tabNum)+"_UU") 
     2486                        WAVE/T twUD = $("root:Packages:NIST:Polarization:ListWave_"+num2str(tabNum)+"_UD") 
     2487                        WAVE/T twDU = $("root:Packages:NIST:Polarization:ListWave_"+num2str(tabNum)+"_DU") 
     2488                         
     2489                        twDD = "" 
     2490                        twUU = "" 
     2491                        twUD = "" 
     2492                        twDU = "" 
     2493                         
     2494                        break 
     2495                case -1: // control being killed 
     2496                        break 
     2497        endswitch 
     2498 
     2499        return 0 
     2500End 
    24512501 
    24522502 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationPanels.ipf

    r832 r835  
    33 
    44// TODO: 
    5 // - on the decay panel. need to be able to manually enter a date that is to or an offset 
     5// x- on the decay panel. need to be able to manually enter a date that is to or an offset 
    66//              number of hours. currently it takes the first file as t=0, which is often not correct 
    77// 
     
    1616// -1- Fundamental Cell Parameters -- these are constants, generally not editable. (this file) 
    1717// -2- Decay Parameters -- these are fitted values based on transmission mearurements (this file) 
    18 // -3- Flipper Panel is in its own procedure (FlipperPanel.ipf) 
    19 // -4- PolCor_Panel is in PolarizationCorrection.ipf 
    20  
     18// -3- Flipper Panel is in its own procedure (Pol_FlipperPanel.ipf) 
     19// -4- PolCor_Panel is in Pol_PolarizationCorrection.ipf 
     20// 
    2121// 
    2222// Driven by 4 panels to get the necessary information from the users 
     
    7171//              - Polarization correction is done with one click (one per tab). "_pc" tags are added to the resulting names, 
    7272//                      and copies of all of the associated waves are again copied (wasteful), but makes switching display very easy 
    73 //              - Once all of the polariztion correction is done, then the UU_pc (etc.) data can be reduced as usual (xx_pc = 4 passes) 
     73//              - Once all of the polarization correction is done, then the UU_pc (etc.) data can be reduced as usual (xx_pc = 4 passes) 
    7474//              - protocol is built as ususal, from this panel only (since the SAM, EMP, and BGD need to be switched, rather than loaded 
    7575//              - protocols can be saved/recalled. 
     
    8484 
    8585 
     86// for the menu 
     87Menu "Macros" 
     88        "1 Fundamental Cell Parameters",ShowCellParamPanel() 
     89        "2 Cell Decay",ShowCellDecayPanel() 
     90        "3 Flipper States",ShowFlipperPanel() 
     91        "4 Polarization Correction",ShowPolCorSetup() 
     92End 
     93 
    8694 
    8795// 
     
    96104// Te=num 
    97105// err_Te=num 
    98 // mu=nnum 
     106// mu=num 
    99107// err_mu=num 
    100108// 
     
    103111// all of the strings start w/ "gCell_" 
    104112// 
    105 Macro ShowCellParamPanel() 
     113Proc ShowCellParamPanel() 
    106114         
    107115        // init folders 
     
    359367// all of the strings start w/ "gDecay_" 
    360368// 
    361 Macro ShowCellDecayPanel() 
     369Proc ShowCellDecayPanel() 
    362370         
    363371        // init folders 
     
    426434        Button button_6,pos={620,620},size={100,20},proc=WindowSnapshotButton,title="Snapshot" 
    427435        Button button_7,pos={620,580},size={130,20},proc=ManualEnterDecayButton,title="Manual Entry" 
    428  
     436        CheckBox check0,mode=0,pos={600,550},title="Overrride T0?",value=0 
    429437 
    430438 
     
    561569                        SetDataFolder root: 
    562570                         
     571                        // 
     572                        // now show the fit results, if any, from the wave note 
     573                        // 
     574                        SVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
     575                        SVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
     576                        SVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
     577                        SVAR gT0  = root:Packages:NIST:Polarization:Cells:gT0 
     578                        String nStr=note(decay) 
     579                         
     580 
     581                        // for the panel display 
     582                        sprintf gMuPo, "%g +/- %g",NumberByKey("muP", nStr, "=",","),NumberByKey("err_muP", nStr, "=",",") 
     583                        sprintf gPo, "%g +/- %g",NumberByKey("P0", nStr, "=",","),NumberByKey("err_P0", nStr, "=",",") 
     584                        sprintf gGamma, "%g +/- %g",NumberByKey("gamma", nStr, "=",","),NumberByKey("err_gamma", nStr, "=",",") 
     585                        gT0 = StringByKey("T0", nStr, "=",",") 
     586                 
     587                         
     588                        // clear the graph - force the user to update it manually 
     589                        // clear old data, and plot the new 
     590                        // 
     591                        SetDataFolder root:Packages:NIST:Polarization:Cells: 
     592 
     593                        CheckDisplayed/W=DecayPanel#G0 tmp_muP,tmp_muP2,fit_tmp_muP 
     594                        // if both present, bit 0 + bit 1 = 3 
     595                        if(V_flag & 2^0)                        //check bit 0 
     596                                RemoveFromGraph/W=DecayPanel#G0 tmp_muP 
     597                        endif 
     598                        if(V_flag & 2^1) 
     599                                RemoveFromGraph/W=DecayPanel#G0 tmp_muP2 
     600                        endif 
     601                        if(V_flag & 2^2) 
     602                                RemoveFromGraph/W=DecayPanel#G0 fit_tmp_muP 
     603                        endif 
     604                         
     605                        // kill the text box (name is hard-wired) 
     606                        TextBox/W=DecayPanel#G0/K/N=CF_tmp_muP 
     607                         
     608                        setDataFolder root: 
     609                         
    563610                        break 
    564611                case -1: // control being killed 
     
    588635         
    589636        // generate the dummy wave note now, change as needed 
    590         Note decay, "muP=2,err_muP=0,P0=0.6,err_P0=0,T0=asdf,gamma=200,err_gamma=0," 
     637        Note decay, "muP=0,err_muP=0,P0=0,err_P0=0,T0=undefined,gamma=0,err_gamma=0," 
    591638         
    592639        // to hold the results of the calculation 
     
    657704//                      selRow = V_startRow 
    658705 
    659                         Variable sum_muP, err_avg_muP, sum_Po, err_avg_Po, avg_muP, avg_Po 
     706                        Variable sum_muP, err_avg_muP, sum_Po, err_avg_Po, avg_muP, avg_Po, overrideT0 
    660707                        sum_muP = 0 
    661708                        sum_Po = 0 
     
    663710                        err_avg_Po = 0 
    664711                         
     712                        ControlInfo/W=DecayPanel check0 
     713                        overrideT0 = V_Value 
     714                         
    665715                        for(selRow=0;selRow<numRows;selRow+=1) 
    666716                                Print "calculate the row ",selRow 
    667717 
    668                                 if(selRow == 0) 
     718                                if(selRow == 0 && !overrideT0) 
    669719                                        //find T0 
    670720                                        fname = FindFileFromRunNumber(w[0][%Trans_He_In]) 
     
    677727                                        Note w, noteStr 
    678728                                        Print t0str 
    679                                         w[selRow][%elapsed_hr] = 0                      //by definition 
     729                                else 
     730                                        // manually entered on the panel to override the  
     731                                        SVAR gT0 = root:Packages:NIST:Polarization:Cells:gT0 
     732                                        t0Str = gT0 
     733                                        noteStr = note(w) 
     734                                        noteStr = ReplaceStringByKey("T0", noteStr, gT0  ,"=", ",", 0) 
     735                                        Note/K w 
     736                                        Note w, noteStr 
     737                                        Print t0str 
    680738                                endif 
    681739                                 
Note: See TracChangeset for help on using the changeset viewer.