Ignore:
Timestamp:
Sep 8, 2011 3:19:48 PM (12 years ago)
Author:
srkline
Message:

Lots of changes to the polarization routines, mostly to incorporate error propagation to the matrix inversion for the polarization correction to the data. Switched the big PolCor? panel to use listboxes to specify files to add together rather than individual popups. Right now 10 files can be added, but this could be expanded to an unlimited number.

Also some minor bug fixes and error handling.

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

    r824 r829  
    9595End 
    9696 
     97// now, this does not depend on the cell, just the condition 
    9798Function AddFlipperConditionButton(ba) : ButtonControl 
    9899        STRUCT WMButtonAction &ba 
     
    102103                        // click code here 
    103104                         
    104                         // get the new name for the condition and the name of the cell used 
    105                         // the cell must already be defined 
    106                         String condStr, cellStr 
     105 
     106                        String condStr//, cellStr 
    107107                        Prompt condStr,"Condition, <12 characters, NO UNDERSCORES" 
    108                         Prompt cellStr,"Cell",popup,D_CellNameList() 
    109                         DoPrompt "Add new condition",condStr, cellStr 
     108//                      Prompt cellStr,"Cell",popup,D_CellNameList() 
     109                        DoPrompt "Add new condition",condStr//, cellStr 
    110110                        if(V_Flag==1) 
    111111                                return 0                                                                        // user canceled 
     
    120120                         
    121121                        String popStr 
    122                         popStr = condStr+"_"+cellStr 
     122//                      popStr = condStr+"_"+cellStr 
     123                        popStr = condStr 
    123124                         
    124125                        MakeFlipperResultWaves(popStr) 
     
    154155                        if(exists(popStr) == 1) 
    155156                                WAVE cond = $(popStr) 
     157                                WAVE/T cellW = $("CondCell_"+popStr[5,strlen(popStr)-1]) 
    156158                        else 
    157159                                // if not, report an error                               
     
    169171                        Edit/W=(14,55,794,275)/HOST=FlipperPanel 
    170172                        RenameWindow #,T0 
     173                        AppendtoTable/W=FlipperPanel#T0 cellW                   // 
    171174                        AppendtoTable/W=FlipperPanel#T0 cond.ld                 //show the labels 
    172175                        ModifyTable width(Point)=0 
     
    188191// "Cond_"+popStr 
    189192// and "CondCalc_"+popStr 
     193// ... and now "CondCell"+popStr 
    190194 
    191195Function MakeFlipperResultWaves(popStr) 
     
    193197 
    194198        SetDataFolder root:Packages:NIST:Polarization:Cells 
     199 
     200        Make/O/T/N=1  $("CondCell_"+popStr) 
    195201 
    196202        Make/O/D/N=(1,8) $("Cond_"+popStr) 
     
    209215        // generate the dummy wave note now, change as needed 
    210216        String cellStr = StringFromList(1, popStr,"_") 
    211         String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf,Cell=asdf," 
    212         testStr = ReplaceStringByKey("Cell", testStr, cellStr ,"=", ",", 0) 
     217        String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf," 
     218//      testStr = ReplaceStringByKey("Cell", testStr, cellStr ,"=", ",", 0) 
    213219        Note cond, testStr 
    214220 
     
    297303 
    298304 
    299  
    300  
     305// 
    301306// just recalculate everything, every time 
     307// 
     308// -- now that the cell name is entered, I need to try to catch errors where the cell decay parameters are not 
     309// properly calculated -- right now, invalid cell names are caught, but valid cell names with no decay data 
     310// behind them just calculate Inf for the polarization values. This is hopefull enough to catch someone's attention... 
    302311// 
    303312Function FlipperAverageButtonProc(ba) : ButtonControl 
     
    317326                        WAVE w=$("root:Packages:NIST:Polarization:Cells:"+condStr)              //the one that is displayed 
    318327                        WAVE calc=$("root:Packages:NIST:Polarization:Cells:CondCalc_"+condStr[5,strlen(condStr)-1])             //the one that holds results 
     328                        WAVE/T CellW=$("root:Packages:NIST:Polarization:Cells:CondCell_"+condStr[5,strlen(condStr)-1])          //the textW with cell name 
    319329                         
    320330                        Variable numRows,ncalc,diff 
     
    325335                        if(numRows != ncalc) 
    326336                                if(ncalc > numRows) 
    327                                         DoAlert 0,"The DecayCalc_ is larger than displayed. Seek help." 
     337                                        DoAlert 0,"The CondCalc_ is larger than displayed. Seek help." 
    328338                                        err = 1 
    329339                                        return(err) 
     
    334344                        endif 
    335345                         
    336                         noteStr=note(w) 
    337                         cellStr = StringByKey("Cell", noteStr, "=", ",", 0) 
    338                         Wave decay = $("root:Packages:NIST:Polarization:Cells:Decay_"+cellStr)   
    339                         noteStr=note(decay) 
    340                         t0Str = StringByKey("T0", noteStr, "=", ",", 0) 
     346//                      noteStr=note(w) 
     347//                      cellStr = StringByKey("Cell", noteStr, "=", ",", 0) 
     348//                      Wave decay = $("root:Packages:NIST:Polarization:Cells:Decay_"+cellStr)   
     349//                      noteStr=note(decay) 
     350//                      t0Str = StringByKey("T0", noteStr, "=", ",", 0) 
    341351//                      Print "CellStr, T0 = ",cellStr, t0Str 
    342352 
    343                         Variable sum_PsmPf, err_sum_PsmPf, sum_Psm, err_sum_Psm 
     353                        Variable sum_PsmPf, err_sum_PsmPf, sum_Psm, err_sum_Psm,nRowsIncluded=0 
    344354                        sum_PsmPf = 0 
    345355                        err_sum_PsmPf = 0 
     
    350360                                Print "calculate the row ",selRow 
    351361 
    352                                 // parse the rows, report errors (there, not here), exit if any found 
    353                                 err = ParseFlipperRow(w,selRow) 
    354                                 if(err) 
    355                                         return 0 
     362                                //include this row of data? 
     363                                if(w[selRow][%Include] == 1) 
     364                                        nRowsIncluded += 1 
     365                                         
     366                                        // now the cell depends on the row 
     367                                        cellStr = CellW[selRow] 
     368                                        Wave/Z decay = $("root:Packages:NIST:Polarization:Cells:Decay_"+cellStr) 
     369                                        if(WaveExists(decay) == 0)              // catch gross errors 
     370                                                Abort "The cell "+cellStr+" in row "+num2str(selRow)+" does not exist" 
     371                                        endif 
     372                                        noteStr=note(decay) 
     373                                        t0Str = StringByKey("T0", noteStr, "=", ",", 0) 
     374         
     375                                        // parse the rows, report errors (there, not here), exit if any found 
     376                                        err = ParseFlipperRow(w,selRow) 
     377                                        if(err) 
     378                                                return 0 
     379                                        endif 
     380                                         
     381                                        // do the calculations: 
     382                 
     383                                        Print "The Blocked CR is not rescaled to zero attenuators" 
     384                                        cr1 = TotalCR_FromRun(w[selRow][%UU_Trans],err_cr1,0) 
     385                                        cr2 = TotalCR_FromRun(w[selRow][%DU_Trans],err_cr2,0) 
     386                                        cr3 = TotalCR_FromRun(w[selRow][%DD_Trans],err_cr3,0)    
     387                                        cr4 = TotalCR_FromRun(w[selRow][%UD_Trans],err_cr4,0) 
     388                                        cr5 = TotalCR_FromRun(w[selRow][%Blocked],err_cr5,1)            //blocked beam is NOT normalized to zero attenuators 
     389         
     390                                        calc[selRow][%cr_UU] = cr1 
     391                                        calc[selRow][%cr_DU] = cr2 
     392                                        calc[selRow][%cr_DD] = cr3 
     393                                        calc[selRow][%cr_UD] = cr4 
     394                                        calc[selRow][%cr_Blocked] = cr5 
     395                                        calc[selRow][%err_cr_UU] = err_cr1 
     396                                        calc[selRow][%err_cr_DU] = err_cr2 
     397                                        calc[selRow][%err_cr_DD] = err_cr3 
     398                                        calc[selRow][%err_cr_UD] = err_cr4 
     399                                        calc[selRow][%err_cr_Blocked] = err_cr5 
     400                 
     401                                        // Calc PsmPf, and assign the values 
     402                                        PsmPf = Calc_PsmPf(w,calc,noteStr,selRow,err_PsmPf) 
     403                                        calc[selRow][%P_sm_f] = PsmPf 
     404                                        calc[selRow][%err_P_sm_f] = err_PsmPf 
     405                                        w[selRow][%Pol_SM_FL] = PsmPf 
     406                                         
     407                                        // Calc Psm, and assign the values 
     408                                        Psm = Calc_Psm(w,calc,noteStr,selRow,err_Psm) 
     409                                        calc[selRow][%P_sm] = Psm 
     410                                        calc[selRow][%err_P_sm] = err_Psm 
     411                                        w[selRow][%Pol_SM] = Psm 
     412         
     413                                        // running average of PsmPf and Psm 
     414                                        sum_PsmPf += PsmPf 
     415                                        err_sum_PsmPf += err_PsmPf^2  
     416                                        sum_Psm += Psm 
     417                                        err_sum_Psm += err_Psm^2 
     418                                         
    356419                                endif 
    357420                                 
    358                                 // do the calculations: 
    359          
    360                                 Print "The Blocked CR is not rescaled to zero attenuators" 
    361                                 cr1 = TotalCR_FromRun(w[selRow][%UU_Trans],err_cr1,0) 
    362                                 cr2 = TotalCR_FromRun(w[selRow][%DU_Trans],err_cr2,0) 
    363                                 cr3 = TotalCR_FromRun(w[selRow][%DD_Trans],err_cr3,0)    
    364                                 cr4 = TotalCR_FromRun(w[selRow][%UD_Trans],err_cr4,0) 
    365                                 cr5 = TotalCR_FromRun(w[selRow][%Blocked],err_cr5,1)            //blocked beam is NOT normalized to zero attenuators 
    366  
    367                                 calc[selRow][%cr_UU] = cr1 
    368                                 calc[selRow][%cr_DU] = cr2 
    369                                 calc[selRow][%cr_DD] = cr3 
    370                                 calc[selRow][%cr_UD] = cr4 
    371                                 calc[selRow][%cr_Blocked] = cr5 
    372                                 calc[selRow][%err_cr_UU] = err_cr1 
    373                                 calc[selRow][%err_cr_DU] = err_cr2 
    374                                 calc[selRow][%err_cr_DD] = err_cr3 
    375                                 calc[selRow][%err_cr_UD] = err_cr4 
    376                                 calc[selRow][%err_cr_Blocked] = err_cr5 
    377          
    378                                 // Calc PsmPf, and assign the values 
    379                                 PsmPf = Calc_PsmPf(w,calc,noteStr,selRow,err_PsmPf) 
    380                                 calc[selRow][%P_sm_f] = PsmPf 
    381                                 calc[selRow][%err_P_sm_f] = err_PsmPf 
    382                                 w[selRow][%Pol_SM_FL] = PsmPf 
    383                                  
    384                                 // Calc Psm, and assign the values 
    385                                 Psm = Calc_Psm(w,calc,noteStr,selRow,err_Psm) 
    386                                 calc[selRow][%P_sm] = Psm 
    387                                 calc[selRow][%err_P_sm] = err_Psm 
    388                                 w[selRow][%Pol_SM] = Psm 
    389  
    390                                 // running average of PsmPf and Psm 
    391                                 sum_PsmPf += PsmPf 
    392                                 err_sum_PsmPf += err_PsmPf^2  
    393                                 sum_Psm += Psm 
    394                                 err_sum_Psm += err_Psm^2 
    395                                  
    396421                        endfor          //loop over rows 
    397422                         
    398423                        // now get a running average of muP, Po, and the errors 
    399                         PsmPf = sum_PsmPf/numRows 
    400                         Psm = sum_Psm/numRows 
    401                         err_PsmPf = sqrt(err_sum_PsmPf) / numRows 
    402                         err_Psm = sqrt(err_sum_Psm) / numRows 
     424                        // use the actual number of rows included 
     425                        PsmPf = sum_PsmPf/nRowsIncluded 
     426                        Psm = sum_Psm/nRowsIncluded 
     427                        err_PsmPf = sqrt(err_sum_PsmPf) / nRowsIncluded 
     428                        err_Psm = sqrt(err_sum_Psm) / nRowsIncluded 
    403429                         
    404430//      this is the format of the note that is attached to the "Cond_" wave              
    405 //      String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf,Cell=asdf," 
    406 // the "Cell" value was filled in when the Condition was created 
     431//      String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf," 
     432// the "Cell" value is not longer used 
    407433         
    408434         
     
    641667                        ControlInfo/W=FlipperPanel popup_0 
    642668                        popStr = S_Value 
    643                          
    644                         Wave decay = $("Decay_"+popStr) 
    645                         Wave calc = $("DecayCalc_"+popStr) 
    646  
     669                        popStr = StringFromList(1,S_Value,"_")                  //pop is "Cond_<condition>", so get list item 1 
     670                         
     671                        Wave cond = $("Cond_"+popStr) 
     672                        Wave calc = $("CondCalc_"+popStr) 
     673                        Wave/T cellW = $("CondCell_"+popStr) 
     674                         
    647675                        // Delete just those points 
    648676                                                 
    649677                        GetSelection table, FlipperPanel#T0, 1 
    650678                        selRow = V_startRow 
    651                         DeletePoints selRow,1,decay,calc                         
     679                        DeletePoints selRow,1,cond,calc,cellW                    
    652680                         
    653681                        // clear the graph and the results                       
    654                         NVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
    655                         NVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
    656                         NVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
    657                         SVAR gT0  = root:Packages:NIST:Polarization:Cells:gT0 
    658                         gMuPo = 0 
    659                         gPo = 0 
    660                         gGamma = 0 
    661                         gT0 = "recalculate" 
    662                          
     682                        SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm 
     683                        SVAR gPsmPf  = root:Packages:NIST:Polarization:Cells:gPsmPf 
     684                        gPsm = "0" 
     685                        gPsmPf = "0" 
    663686                         
    664687                        SetDataFolder root: 
     
    684707                case 2: // mouse up 
    685708                        // click code here 
    686                         DoAlert 1,"Clear all of the decay waves for the selected cell?" 
     709                        DoAlert 1,"Clear all of the flipper waves for the selected cell?" 
    687710                        if(V_flag !=1) 
    688711                                return(0) 
     
    692715 
    693716                        ControlInfo/W=FlipperPanel popup_0 
    694                         popStr = S_Value 
    695                          
    696                         Wave decay = $("Decay_"+popStr) 
    697                         Wave calc = $("DecayCalc_"+popStr) 
    698                          
    699 //                      re-initialize the decay waves, so it appears as a blank, initialized table 
     717                        popStr = StringFromList(1,S_Value,"_")                  //pop is "Cond_<condition>", so get list item 1 
     718                         
     719                        Wave cond = $("Cond_"+popStr) 
     720                        Wave calc = $("CondCalc_"+popStr) 
     721                        Wave/T cellW = $("CondCell_"+popStr) 
     722                         
     723//                      re-initialize the flipper waves, so it appears as a blank, initialized table 
    700724 
    701725                        MakeFlipperResultWaves(popStr) 
    702                         decay = 0 
     726                        cond = 0 
    703727                        calc = 0 
    704          
     728                        cellW = "" 
     729                        cond[0][7] = 1                  //default to include the point 
     730 
    705731                        // clear the graph and the results?      
    706732                         
    707733                         
    708                                          
    709                         NVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
    710                         NVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
    711                         NVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
    712                         SVAR gT0  = root:Packages:NIST:Polarization:Cells:gT0 
    713                         gMuPo = 0 
    714                         gPo = 0 
    715                         gGamma = 0 
    716                         gT0 = "recalculate" 
    717                          
     734                        SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm 
     735                        SVAR gPsmPf  = root:Packages:NIST:Polarization:Cells:gPsmPf 
     736                        gPsm = "0" 
     737                        gPsmPf = "0" 
    718738                         
    719739                        SetDataFolder root: 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationCorrection.ipf

    r818 r829  
    3232// 
    3333 
    34 // I'll need space for 4 input files in, say SAM_P 
     34// I'll need space for 4 input files in, say SAM 
    3535// - load in all of the UU files, adding together 
    3636// - rename the UU data, error 
    3737// 
    38 // - repeat for the other three cross sections. then in the SAM_P folder, there will be  
     38// - repeat for the other three cross sections, in the SAM folder, there will be  
    3939// scattering data for all four cross sections present. 
    4040// 
     
    4545// 
    4646// Then everything is set to do the inversion. 
    47 // -- the result of the inversion is 4 corrected data sets, with no polarization effects. 
    48 // 
    49 // 
    50 // --- repeat it all for EMP_P (and maybe BKG_P) 
    51 // 
    52 // Now I can one-by-one, copy the correct UU, UD, etc. into "data" and "linear_data" 
     47// -- the result of the inversion is 4 corrected data sets, with no polarization effects. "_pc" 
     48// 
     49// Now I can one-by-one, copy the correct UU, UD, etc. into "data" and "linear_data" (and the Reals, etc) 
    5350// and run through the corrections as if it was normal SANS data 
    5451// 
     
    6158// as needed and that one step won't fail because a previous step wasn't done yet. Combining the 
    6259// first three panels into one w/ tabs would help a lot, but that is rather complex to implement. 
     60// and is still not a fool-proof situation 
    6361// 
    6462// X- mathod to save and restore the panel state - especially the popup selections 
    65  
     63// 
     64// -- should I force the Polarization correction to be re-done just before the protocol is 
     65//                      executed? Then I'm sure that the PC is done. Must do for each tab (only if part of the protocol) 
     66//                      Except that the procedures work on the "active" tab... 
     67// 
     68// -- When multiple files are added together, there are changes made to the RealsRead (monCts, etc.). Are these 
     69//              properly made, and then properly copied to the "_UU", and then properly copied back to the untagged waves 
     70//              for use in the reduction? 
     71// 
     72 
     73 
     74 
     75 
     76// main entry to the PolCor Panel 
    6677Macro ShowPolCorSetup() 
    6778 
     
    129140        SetDataFolder root:Packages:NIST:Polarization 
    130141         
    131         for(ii=0;ii<5;ii+=1) 
    132                 String/G $("gStr_PolCor_0_UU_"+num2str(ii)) = "none" 
    133                 String/G $("gStr_PolCor_0_DU_"+num2str(ii)) = "none" 
    134                 String/G $("gStr_PolCor_0_DD_"+num2str(ii)) = "none" 
    135                 String/G $("gStr_PolCor_0_UD_"+num2str(ii)) = "none" 
    136         endfor 
    137  
    138         for(ii=0;ii<5;ii+=1) 
    139                 String/G $("gStr_PolCor_1_UU_"+num2str(ii)) = "none" 
    140                 String/G $("gStr_PolCor_1_DU_"+num2str(ii)) = "none" 
    141                 String/G $("gStr_PolCor_1_DD_"+num2str(ii)) = "none" 
    142                 String/G $("gStr_PolCor_1_UD_"+num2str(ii)) = "none" 
    143         endfor 
    144          
    145         for(ii=0;ii<5;ii+=1) 
    146                 String/G $("gStr_PolCor_2_UU_"+num2str(ii)) = "none" 
    147                 String/G $("gStr_PolCor_2_DU_"+num2str(ii)) = "none" 
    148                 String/G $("gStr_PolCor_2_DD_"+num2str(ii)) = "none" 
    149                 String/G $("gStr_PolCor_2_UD_"+num2str(ii)) = "none" 
    150         endfor 
    151          
    152         // blank matrix of coefficients is not generated here, but as each set is loaded 
    153 //      Print " *** PolMatrix is not being generated in the correct folder(s)" 
    154 //      Make/O/D/N=(4,4) PolMatrix = 0 
     142        //controls are labeled "name_#_UU_#" where name is the type of control, # is the tab #, and (2nd) # is the control # 
     143 
     144/// new method using a listBox for each state    
     145        Make/O/T/N=2 lbTitles 
     146        lbTitles[0] = "Run #" 
     147        lbTitles[1] = "Cell" 
     148         
     149        Make/O/N=(10,2) lbSelWave 
     150        lbSelWave[][0] = 2                      //Run # column is editable 
     151        lbSelWave[][1] = 1                      //Cell name is a popup, not editable 
     152         
     153        Make/O/T/N=(10,2) ListWave_0_UU="" 
     154        Make/O/T/N=(10,2) ListWave_0_DU="" 
     155        Make/O/T/N=(10,2) ListWave_0_DD="" 
     156        Make/O/T/N=(10,2) ListWave_0_UD="" 
     157        Make/O/N=(10,2) lbSelWave_0_UU 
     158        Make/O/N=(10,2) lbSelWave_0_DU 
     159        Make/O/N=(10,2) lbSelWave_0_DD 
     160        Make/O/N=(10,2) lbSelWave_0_UD 
     161        lbSelWave_0_UU[][0] = 2                 //Run # column is editable 
     162        lbSelWave_0_DU[][0] = 2                 //Run # column is editable 
     163        lbSelWave_0_DD[][0] = 2                 //Run # column is editable 
     164        lbSelWave_0_UD[][0] = 2                 //Run # column is editable 
     165        lbSelWave_0_UU[][1] = 1                 //Cell name is a popup, not editable     
     166        lbSelWave_0_DU[][1] = 1                 //Cell name is a popup, not editable     
     167        lbSelWave_0_DD[][1] = 1                 //Cell name is a popup, not editable     
     168        lbSelWave_0_UD[][1] = 1                 //Cell name is a popup, not editable     
     169         
     170        Make/O/T/N=(10,2) ListWave_1_UU="" 
     171        Make/O/T/N=(10,2) ListWave_1_DU="" 
     172        Make/O/T/N=(10,2) ListWave_1_DD="" 
     173        Make/O/T/N=(10,2) ListWave_1_UD="" 
     174        Make/O/N=(10,2) lbSelWave_1_UU 
     175        Make/O/N=(10,2) lbSelWave_1_DU 
     176        Make/O/N=(10,2) lbSelWave_1_DD 
     177        Make/O/N=(10,2) lbSelWave_1_UD 
     178        lbSelWave_1_UU[][0] = 2                 //Run # column is editable 
     179        lbSelWave_1_DU[][0] = 2                 //Run # column is editable 
     180        lbSelWave_1_DD[][0] = 2                 //Run # column is editable 
     181        lbSelWave_1_UD[][0] = 2                 //Run # column is editable 
     182        lbSelWave_1_UU[][1] = 1                 //Cell name is a popup, not editable     
     183        lbSelWave_1_DU[][1] = 1                 //Cell name is a popup, not editable     
     184        lbSelWave_1_DD[][1] = 1                 //Cell name is a popup, not editable     
     185        lbSelWave_1_UD[][1] = 1                 //Cell name is a popup, not editable             
     186         
     187        Make/O/T/N=(10,2) ListWave_2_UU="" 
     188        Make/O/T/N=(10,2) ListWave_2_DU="" 
     189        Make/O/T/N=(10,2) ListWave_2_DD="" 
     190        Make/O/T/N=(10,2) ListWave_2_UD="" 
     191        Make/O/N=(10,2) lbSelWave_2_UU 
     192        Make/O/N=(10,2) lbSelWave_2_DU 
     193        Make/O/N=(10,2) lbSelWave_2_DD 
     194        Make/O/N=(10,2) lbSelWave_2_UD 
     195        lbSelWave_2_UU[][0] = 2                 //Run # column is editable 
     196        lbSelWave_2_DU[][0] = 2                 //Run # column is editable 
     197        lbSelWave_2_DD[][0] = 2                 //Run # column is editable 
     198        lbSelWave_2_UD[][0] = 2                 //Run # column is editable 
     199        lbSelWave_2_UU[][1] = 1                 //Cell name is a popup, not editable     
     200        lbSelWave_2_DU[][1] = 1                 //Cell name is a popup, not editable     
     201        lbSelWave_2_DD[][1] = 1                 //Cell name is a popup, not editable     
     202        lbSelWave_2_UD[][1] = 1                 //Cell name is a popup, not editable     
     203 
     204 
     205////// old method using individual setVars and popups    
     206//      for(ii=0;ii<5;ii+=1) 
     207//              String/G $("gStr_PolCor_0_UU_"+num2str(ii)) = "none" 
     208//              String/G $("gStr_PolCor_0_DU_"+num2str(ii)) = "none" 
     209//              String/G $("gStr_PolCor_0_DD_"+num2str(ii)) = "none" 
     210//              String/G $("gStr_PolCor_0_UD_"+num2str(ii)) = "none" 
     211//      endfor 
     212// 
     213//      for(ii=0;ii<5;ii+=1) 
     214//              String/G $("gStr_PolCor_1_UU_"+num2str(ii)) = "none" 
     215//              String/G $("gStr_PolCor_1_DU_"+num2str(ii)) = "none" 
     216//              String/G $("gStr_PolCor_1_DD_"+num2str(ii)) = "none" 
     217//              String/G $("gStr_PolCor_1_UD_"+num2str(ii)) = "none" 
     218//      endfor 
     219//       
     220//      for(ii=0;ii<5;ii+=1) 
     221//              String/G $("gStr_PolCor_2_UU_"+num2str(ii)) = "none" 
     222//              String/G $("gStr_PolCor_2_DU_"+num2str(ii)) = "none" 
     223//              String/G $("gStr_PolCor_2_DD_"+num2str(ii)) = "none" 
     224//              String/G $("gStr_PolCor_2_UD_"+num2str(ii)) = "none" 
     225//      endfor 
     226//////////// 
    155227 
    156228        SetDataFolder root: 
    157229 
    158         // initialize new folders for SAM_P, etc, or maybe just use the existing folders 
    159         // 
    160          
     230 
    161231        return(0) 
    162232 
     
    198268        Button button3,pos={222,473},size={160,20},proc=ChangeDisplayedPolData,title="Change Displayed Data" 
    199269        Button button4,pos={620,18},size={30,20},proc=PolCorHelpParButtonProc,title="?" 
    200  
    201         TitleBox title0,pos={116,66},size={24,24},title="\\f01UU",fSize=12 
    202         TitleBox title1,pos={450,66},size={24,24},title="\\f01DU",fSize=12 
    203         TitleBox title2,pos={115,250},size={25,24},title="\\f01DD",fSize=12 
    204         TitleBox title3,pos={450,250},size={24,24},title="\\f01UD",fSize=12 
     270        Button button12,pos={440,473},size={120,20},proc=Display4XSButton,title="Display 4 XS" 
     271 
     272        PopupMenu popup1,pos={210,24},size={102,20},title="Condition" 
     273        PopupMenu popup1, mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     274 
     275        TitleBox title0,pos={100,66},size={24,24},title="\\f01UU or + +",fSize=12 
     276        TitleBox title1,pos={430,66},size={24,24},title="\\f01DU or - +",fSize=12 
     277        TitleBox title2,pos={100,250},size={25,24},title="\\f01DD or - -",fSize=12 
     278        TitleBox title3,pos={430,250},size={24,24},title="\\f01UD or + -",fSize=12 
    205279         
    206280        // bits to set up reduction protocol 
     
    256330// SAM Tab       
    257331        // UU 
    258         SetVariable setvar_0_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
    259         SetVariable setvar_0_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_0 
    260         SetVariable setvar_0_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
    261         SetVariable setvar_0_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_1 
    262         SetVariable setvar_0_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
    263         SetVariable setvar_0_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_2 
    264         SetVariable setvar_0_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
    265         SetVariable setvar_0_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_3 
    266         SetVariable setvar_0_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
    267         SetVariable setvar_0_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_4 
    268         PopupMenu popup_0_UU_0,pos={142,99},size={210,20},title="Condition" 
    269         PopupMenu popup_0_UU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    270         PopupMenu popup_0_UU_1,pos={142,122},size={102,20},title="Condition" 
    271         PopupMenu popup_0_UU_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    272         PopupMenu popup_0_UU_2,pos={142,146},size={102,20},title="Condition" 
    273         PopupMenu popup_0_UU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    274         PopupMenu popup_0_UU_3,pos={142,170},size={102,20},title="Condition" 
    275         PopupMenu popup_0_UU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    276         PopupMenu popup_0_UU_4,pos={142,194},size={102,20},title="Condition" 
    277         PopupMenu popup_0_UU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     332        ListBox ListBox_0_UU,pos={34,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     333        ListBox ListBox_0_UU,listWave=root:Packages:NIST:Polarization:ListWave_0_UU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     334        ListBox ListBox_0_UU,selWave=root:Packages:NIST:Polarization:lbSelWave_0_UU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     335//      SetVariable setvar_0_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
     336//      SetVariable setvar_0_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_0 
     337//      SetVariable setvar_0_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
     338//      SetVariable setvar_0_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_1 
     339//      SetVariable setvar_0_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
     340//      SetVariable setvar_0_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_2 
     341//      SetVariable setvar_0_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
     342//      SetVariable setvar_0_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_3 
     343//      SetVariable setvar_0_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
     344//      SetVariable setvar_0_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UU_4 
     345//      PopupMenu popup_0_UU_0,pos={142,99},size={210,20},title="Cell" 
     346//      PopupMenu popup_0_UU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     347//      PopupMenu popup_0_UU_1,pos={142,122},size={102,20},title="Cell" 
     348//      PopupMenu popup_0_UU_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     349//      PopupMenu popup_0_UU_2,pos={142,146},size={102,20},title="Cell" 
     350//      PopupMenu popup_0_UU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     351//      PopupMenu popup_0_UU_3,pos={142,170},size={102,20},title="Cell" 
     352//      PopupMenu popup_0_UU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     353//      PopupMenu popup_0_UU_4,pos={142,194},size={102,20},title="Cell" 
     354//      PopupMenu popup_0_UU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     355 
    278356        // DU 
    279         SetVariable setvar_0_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
    280         SetVariable setvar_0_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_0 
    281         SetVariable setvar_0_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
    282         SetVariable setvar_0_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_1 
    283         SetVariable setvar_0_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
    284         SetVariable setvar_0_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_2 
    285         SetVariable setvar_0_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
    286         SetVariable setvar_0_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_3 
    287         SetVariable setvar_0_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
    288         SetVariable setvar_0_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_4 
    289         PopupMenu popup_0_DU_0,pos={476,99},size={210,20},title="Condition" 
    290         PopupMenu popup_0_DU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    291         PopupMenu popup_0_DU_1,pos={476,122},size={210,20},title="Condition" 
    292         PopupMenu popup_0_DU_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    293         PopupMenu popup_0_DU_2,pos={476,146},size={102,20},title="Condition" 
    294         PopupMenu popup_0_DU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    295         PopupMenu popup_0_DU_3,pos={476,170},size={102,20},title="Condition" 
    296         PopupMenu popup_0_DU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    297         PopupMenu popup_0_DU_4,pos={476,194},size={102,20},title="Condition" 
    298         PopupMenu popup_0_DU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     357        ListBox ListBox_0_DU,pos={368,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     358        ListBox ListBox_0_DU,listWave=root:Packages:NIST:Polarization:ListWave_0_DU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     359        ListBox ListBox_0_DU,selWave=root:Packages:NIST:Polarization:lbSelWave_0_DU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     360//      SetVariable setvar_0_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
     361//      SetVariable setvar_0_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_0 
     362//      SetVariable setvar_0_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
     363//      SetVariable setvar_0_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_1 
     364//      SetVariable setvar_0_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
     365//      SetVariable setvar_0_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_2 
     366//      SetVariable setvar_0_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
     367//      SetVariable setvar_0_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_3 
     368//      SetVariable setvar_0_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
     369//      SetVariable setvar_0_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DU_4 
     370//      PopupMenu popup_0_DU_0,pos={476,99},size={210,20},title="Cell" 
     371//      PopupMenu popup_0_DU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     372//      PopupMenu popup_0_DU_1,pos={476,122},size={210,20},title="Cell" 
     373//      PopupMenu popup_0_DU_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     374//      PopupMenu popup_0_DU_2,pos={476,146},size={102,20},title="Cell" 
     375//      PopupMenu popup_0_DU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     376//      PopupMenu popup_0_DU_3,pos={476,170},size={102,20},title="Cell" 
     377//      PopupMenu popup_0_DU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     378//      PopupMenu popup_0_DU_4,pos={476,194},size={102,20},title="Cell" 
     379//      PopupMenu popup_0_DU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     380 
    299381// DD 
    300         SetVariable setvar_0_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
    301         SetVariable setvar_0_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_0 
    302         SetVariable setvar_0_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
    303         SetVariable setvar_0_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_1 
    304         SetVariable setvar_0_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
    305         SetVariable setvar_0_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_2 
    306         SetVariable setvar_0_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
    307         SetVariable setvar_0_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_3 
    308         SetVariable setvar_0_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
    309         SetVariable setvar_0_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_4 
    310         PopupMenu popup_0_DD_0,pos={141,283},size={210,20},title="Condition" 
    311         PopupMenu popup_0_DD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    312         PopupMenu popup_0_DD_1,pos={141,306},size={102,20},title="Condition" 
    313         PopupMenu popup_0_DD_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    314         PopupMenu popup_0_DD_2,pos={141,330},size={102,20},title="Condition" 
    315         PopupMenu popup_0_DD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    316         PopupMenu popup_0_DD_3,pos={141,354},size={102,20},title="Condition" 
    317         PopupMenu popup_0_DD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    318         PopupMenu popup_0_DD_4,pos={141,378},size={102,20},title="Condition" 
    319         PopupMenu popup_0_DD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     382        ListBox ListBox_0_DD,pos={33,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     383        ListBox ListBox_0_DD,listWave=root:Packages:NIST:Polarization:ListWave_0_DD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     384        ListBox ListBox_0_DD,selWave=root:Packages:NIST:Polarization:lbSelWave_0_DD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     385//      SetVariable setvar_0_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
     386//      SetVariable setvar_0_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_0 
     387//      SetVariable setvar_0_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
     388//      SetVariable setvar_0_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_1 
     389//      SetVariable setvar_0_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
     390//      SetVariable setvar_0_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_2 
     391//      SetVariable setvar_0_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
     392//      SetVariable setvar_0_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_3 
     393//      SetVariable setvar_0_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
     394//      SetVariable setvar_0_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_DD_4 
     395//      PopupMenu popup_0_DD_0,pos={141,283},size={210,20},title="Cell" 
     396//      PopupMenu popup_0_DD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     397//      PopupMenu popup_0_DD_1,pos={141,306},size={102,20},title="Cell" 
     398//      PopupMenu popup_0_DD_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     399//      PopupMenu popup_0_DD_2,pos={141,330},size={102,20},title="Cell" 
     400//      PopupMenu popup_0_DD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     401//      PopupMenu popup_0_DD_3,pos={141,354},size={102,20},title="Cell" 
     402//      PopupMenu popup_0_DD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     403//      PopupMenu popup_0_DD_4,pos={141,378},size={102,20},title="Cell" 
     404//      PopupMenu popup_0_DD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     405         
    320406// UD 
    321         SetVariable setvar_0_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
    322         SetVariable setvar_0_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_0 
    323         SetVariable setvar_0_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
    324         SetVariable setvar_0_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_1 
    325         SetVariable setvar_0_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
    326         SetVariable setvar_0_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_2 
    327         SetVariable setvar_0_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
    328         SetVariable setvar_0_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_3 
    329         SetVariable setvar_0_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
    330         SetVariable setvar_0_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_4 
    331         PopupMenu popup_0_UD_0,pos={476,283},size={210,20},title="Condition" 
    332         PopupMenu popup_0_UD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    333         PopupMenu popup_0_UD_1,pos={476,306},size={210,20},title="Condition" 
    334         PopupMenu popup_0_UD_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    335         PopupMenu popup_0_UD_2,pos={476,330},size={102,20},title="Condition" 
    336         PopupMenu popup_0_UD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    337         PopupMenu popup_0_UD_3,pos={476,354},size={102,20},title="Condition" 
    338         PopupMenu popup_0_UD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    339         PopupMenu popup_0_UD_4,pos={476,378},size={102,20},title="Condition" 
    340         PopupMenu popup_0_UD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     407        ListBox ListBox_0_UD,pos={368,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     408        ListBox ListBox_0_UD,listWave=root:Packages:NIST:Polarization:ListWave_0_UD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     409        ListBox ListBox_0_UD,selWave=root:Packages:NIST:Polarization:lbSelWave_0_UD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     410//      SetVariable setvar_0_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
     411//      SetVariable setvar_0_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_0 
     412//      SetVariable setvar_0_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
     413//      SetVariable setvar_0_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_1 
     414//      SetVariable setvar_0_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
     415//      SetVariable setvar_0_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_2 
     416//      SetVariable setvar_0_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
     417//      SetVariable setvar_0_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_3 
     418//      SetVariable setvar_0_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
     419//      SetVariable setvar_0_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_0_UD_4 
     420//      PopupMenu popup_0_UD_0,pos={476,283},size={210,20},title="Cell" 
     421//      PopupMenu popup_0_UD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     422//      PopupMenu popup_0_UD_1,pos={476,306},size={210,20},title="Cell" 
     423//      PopupMenu popup_0_UD_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     424//      PopupMenu popup_0_UD_2,pos={476,330},size={102,20},title="Cell" 
     425//      PopupMenu popup_0_UD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     426//      PopupMenu popup_0_UD_3,pos={476,354},size={102,20},title="Cell" 
     427//      PopupMenu popup_0_UD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     428//      PopupMenu popup_0_UD_4,pos={476,378},size={102,20},title="Cell" 
     429//      PopupMenu popup_0_UD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
    341430 
    342431 
    343432// EMP Tab       
    344433        // UU 
    345         SetVariable setvar_1_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
    346         SetVariable setvar_1_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_0 
    347         SetVariable setvar_1_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
    348         SetVariable setvar_1_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_1 
    349         SetVariable setvar_1_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
    350         SetVariable setvar_1_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_2 
    351         SetVariable setvar_1_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
    352         SetVariable setvar_1_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_3 
    353         SetVariable setvar_1_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
    354         SetVariable setvar_1_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_4 
    355         PopupMenu popup_1_UU_0,pos={142,99},size={210,20},title="Condition" 
    356         PopupMenu popup_1_UU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    357         PopupMenu popup_1_UU_1,pos={142,122},size={102,20},title="Condition" 
    358         PopupMenu popup_1_UU_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    359         PopupMenu popup_1_UU_2,pos={142,146},size={102,20},title="Condition" 
    360         PopupMenu popup_1_UU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    361         PopupMenu popup_1_UU_3,pos={142,170},size={102,20},title="Condition" 
    362         PopupMenu popup_1_UU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    363         PopupMenu popup_1_UU_4,pos={142,194},size={102,20},title="Condition" 
    364         PopupMenu popup_1_UU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     434        ListBox ListBox_1_UU,pos={34,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     435        ListBox ListBox_1_UU,listWave=root:Packages:NIST:Polarization:ListWave_1_UU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     436        ListBox ListBox_1_UU,selWave=root:Packages:NIST:Polarization:lbSelWave_1_UU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     437//      SetVariable setvar_1_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
     438//      SetVariable setvar_1_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_0 
     439//      SetVariable setvar_1_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
     440//      SetVariable setvar_1_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_1 
     441//      SetVariable setvar_1_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
     442//      SetVariable setvar_1_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_2 
     443//      SetVariable setvar_1_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
     444//      SetVariable setvar_1_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_3 
     445//      SetVariable setvar_1_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
     446//      SetVariable setvar_1_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UU_4 
     447//      PopupMenu popup_1_UU_0,pos={142,99},size={210,20},title="Cell" 
     448//      PopupMenu popup_1_UU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     449//      PopupMenu popup_1_UU_1,pos={142,122},size={102,20},title="Cell" 
     450//      PopupMenu popup_1_UU_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     451//      PopupMenu popup_1_UU_2,pos={142,146},size={102,20},title="Cell" 
     452//      PopupMenu popup_1_UU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     453//      PopupMenu popup_1_UU_3,pos={142,170},size={102,20},title="Cell" 
     454//      PopupMenu popup_1_UU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     455//      PopupMenu popup_1_UU_4,pos={142,194},size={102,20},title="Cell" 
     456//      PopupMenu popup_1_UU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     457 
    365458        // DU 
    366         SetVariable setvar_1_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
    367         SetVariable setvar_1_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_0 
    368         SetVariable setvar_1_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
    369         SetVariable setvar_1_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_1 
    370         SetVariable setvar_1_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
    371         SetVariable setvar_1_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_2 
    372         SetVariable setvar_1_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
    373         SetVariable setvar_1_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_3 
    374         SetVariable setvar_1_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
    375         SetVariable setvar_1_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_4 
    376         PopupMenu popup_1_DU_0,pos={476,99},size={210,20},title="Condition" 
    377         PopupMenu popup_1_DU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    378         PopupMenu popup_1_DU_1,pos={476,122},size={210,20},title="Condition" 
    379         PopupMenu popup_1_DU_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    380         PopupMenu popup_1_DU_2,pos={476,146},size={102,20},title="Condition" 
    381         PopupMenu popup_1_DU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    382         PopupMenu popup_1_DU_3,pos={476,170},size={102,20},title="Condition" 
    383         PopupMenu popup_1_DU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    384         PopupMenu popup_1_DU_4,pos={476,194},size={102,20},title="Condition" 
    385         PopupMenu popup_1_DU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     459        ListBox ListBox_1_DU,pos={368,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     460        ListBox ListBox_1_DU,listWave=root:Packages:NIST:Polarization:ListWave_1_DU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     461        ListBox ListBox_1_DU,selWave=root:Packages:NIST:Polarization:lbSelWave_1_DU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     462//      SetVariable setvar_1_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
     463//      SetVariable setvar_1_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_0 
     464//      SetVariable setvar_1_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
     465//      SetVariable setvar_1_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_1 
     466//      SetVariable setvar_1_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
     467//      SetVariable setvar_1_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_2 
     468//      SetVariable setvar_1_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
     469//      SetVariable setvar_1_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_3 
     470//      SetVariable setvar_1_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
     471//      SetVariable setvar_1_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DU_4 
     472//      PopupMenu popup_1_DU_0,pos={476,99},size={210,20},title="Cell" 
     473//      PopupMenu popup_1_DU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     474//      PopupMenu popup_1_DU_1,pos={476,122},size={210,20},title="Cell" 
     475//      PopupMenu popup_1_DU_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     476//      PopupMenu popup_1_DU_2,pos={476,146},size={102,20},title="Cell" 
     477//      PopupMenu popup_1_DU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     478//      PopupMenu popup_1_DU_3,pos={476,170},size={102,20},title="Cell" 
     479//      PopupMenu popup_1_DU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     480//      PopupMenu popup_1_DU_4,pos={476,194},size={102,20},title="Cell" 
     481//      PopupMenu popup_1_DU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     482 
    386483// DD 
    387         SetVariable setvar_1_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
    388         SetVariable setvar_1_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_0 
    389         SetVariable setvar_1_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
    390         SetVariable setvar_1_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_1 
    391         SetVariable setvar_1_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
    392         SetVariable setvar_1_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_2 
    393         SetVariable setvar_1_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
    394         SetVariable setvar_1_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_3 
    395         SetVariable setvar_1_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
    396         SetVariable setvar_1_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_4 
    397         PopupMenu popup_1_DD_0,pos={141,283},size={210,20},title="Condition" 
    398         PopupMenu popup_1_DD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    399         PopupMenu popup_1_DD_1,pos={141,306},size={102,20},title="Condition" 
    400         PopupMenu popup_1_DD_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    401         PopupMenu popup_1_DD_2,pos={141,330},size={102,20},title="Condition" 
    402         PopupMenu popup_1_DD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    403         PopupMenu popup_1_DD_3,pos={141,354},size={102,20},title="Condition" 
    404         PopupMenu popup_1_DD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    405         PopupMenu popup_1_DD_4,pos={141,378},size={102,20},title="Condition" 
    406         PopupMenu popup_1_DD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     484        ListBox ListBox_1_DD,pos={33,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     485        ListBox ListBox_1_DD,listWave=root:Packages:NIST:Polarization:ListWave_1_DD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     486        ListBox ListBox_1_DD,selWave=root:Packages:NIST:Polarization:lbSelWave_1_DD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     487//      SetVariable setvar_1_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
     488//      SetVariable setvar_1_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_0 
     489//      SetVariable setvar_1_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
     490//      SetVariable setvar_1_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_1 
     491//      SetVariable setvar_1_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
     492//      SetVariable setvar_1_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_2 
     493//      SetVariable setvar_1_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
     494//      SetVariable setvar_1_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_3 
     495//      SetVariable setvar_1_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
     496//      SetVariable setvar_1_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_DD_4 
     497//      PopupMenu popup_1_DD_0,pos={141,283},size={210,20},title="Cell" 
     498//      PopupMenu popup_1_DD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     499//      PopupMenu popup_1_DD_1,pos={141,306},size={102,20},title="Cell" 
     500//      PopupMenu popup_1_DD_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     501//      PopupMenu popup_1_DD_2,pos={141,330},size={102,20},title="Cell" 
     502//      PopupMenu popup_1_DD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     503//      PopupMenu popup_1_DD_3,pos={141,354},size={102,20},title="Cell" 
     504//      PopupMenu popup_1_DD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     505//      PopupMenu popup_1_DD_4,pos={141,378},size={102,20},title="Cell" 
     506//      PopupMenu popup_1_DD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     507 
    407508// UD 
    408         SetVariable setvar_1_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
    409         SetVariable setvar_1_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_0 
    410         SetVariable setvar_1_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
    411         SetVariable setvar_1_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_1 
    412         SetVariable setvar_1_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
    413         SetVariable setvar_1_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_2 
    414         SetVariable setvar_1_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
    415         SetVariable setvar_1_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_3 
    416         SetVariable setvar_1_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
    417         SetVariable setvar_1_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_4 
    418         PopupMenu popup_1_UD_0,pos={476,283},size={210,20},title="Condition" 
    419         PopupMenu popup_1_UD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    420         PopupMenu popup_1_UD_1,pos={476,306},size={210,20},title="Condition" 
    421         PopupMenu popup_1_UD_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    422         PopupMenu popup_1_UD_2,pos={476,330},size={102,20},title="Condition" 
    423         PopupMenu popup_1_UD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    424         PopupMenu popup_1_UD_3,pos={476,354},size={102,20},title="Condition" 
    425         PopupMenu popup_1_UD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    426         PopupMenu popup_1_UD_4,pos={476,378},size={102,20},title="Condition" 
    427         PopupMenu popup_1_UD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     509        ListBox ListBox_1_UD,pos={368,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     510        ListBox ListBox_1_UD,listWave=root:Packages:NIST:Polarization:ListWave_1_UD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     511        ListBox ListBox_1_UD,selWave=root:Packages:NIST:Polarization:lbSelWave_1_UD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     512//      SetVariable setvar_1_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
     513//      SetVariable setvar_1_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_0 
     514//      SetVariable setvar_1_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
     515//      SetVariable setvar_1_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_1 
     516//      SetVariable setvar_1_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
     517//      SetVariable setvar_1_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_2 
     518//      SetVariable setvar_1_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
     519//      SetVariable setvar_1_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_3 
     520//      SetVariable setvar_1_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
     521//      SetVariable setvar_1_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_1_UD_4 
     522//      PopupMenu popup_1_UD_0,pos={476,283},size={210,20},title="Cell" 
     523//      PopupMenu popup_1_UD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     524//      PopupMenu popup_1_UD_1,pos={476,306},size={210,20},title="Cell" 
     525//      PopupMenu popup_1_UD_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     526//      PopupMenu popup_1_UD_2,pos={476,330},size={102,20},title="Cell" 
     527//      PopupMenu popup_1_UD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     528//      PopupMenu popup_1_UD_3,pos={476,354},size={102,20},title="Cell" 
     529//      PopupMenu popup_1_UD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     530//      PopupMenu popup_1_UD_4,pos={476,378},size={102,20},title="Cell" 
     531//      PopupMenu popup_1_UD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
    428532 
    429533 
    430534// BKG Tab       
    431535        // UU 
    432         SetVariable setvar_2_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
    433         SetVariable setvar_2_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_0 
    434         SetVariable setvar_2_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
    435         SetVariable setvar_2_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_1 
    436         SetVariable setvar_2_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
    437         SetVariable setvar_2_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_2 
    438         SetVariable setvar_2_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
    439         SetVariable setvar_2_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_3 
    440         SetVariable setvar_2_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
    441         SetVariable setvar_2_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_4 
    442         PopupMenu popup_2_UU_0,pos={142,99},size={210,20},title="Condition" 
    443         PopupMenu popup_2_UU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    444         PopupMenu popup_2_UU_1,pos={142,122},size={102,20},title="Condition" 
    445         PopupMenu popup_2_UU_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    446         PopupMenu popup_2_UU_2,pos={142,146},size={102,20},title="Condition" 
    447         PopupMenu popup_2_UU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    448         PopupMenu popup_2_UU_3,pos={142,170},size={102,20},title="Condition" 
    449         PopupMenu popup_2_UU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    450         PopupMenu popup_2_UU_4,pos={142,194},size={102,20},title="Condition" 
    451         PopupMenu popup_2_UU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     536        ListBox ListBox_2_UU,pos={34,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     537        ListBox ListBox_2_UU,listWave=root:Packages:NIST:Polarization:ListWave_2_UU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     538        ListBox ListBox_2_UU,selWave=root:Packages:NIST:Polarization:lbSelWave_2_UU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     539//      SetVariable setvar_2_UU_0,pos={34,102},size={70,16},title="File",fSize=10 
     540//      SetVariable setvar_2_UU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_0 
     541//      SetVariable setvar_2_UU_1,pos={34,125},size={70,16},title="File",fSize=10 
     542//      SetVariable setvar_2_UU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_1 
     543//      SetVariable setvar_2_UU_2,pos={34,149},size={70,16},title="File",fSize=10 
     544//      SetVariable setvar_2_UU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_2 
     545//      SetVariable setvar_2_UU_3,pos={34,173},size={70,16},title="File",fSize=10 
     546//      SetVariable setvar_2_UU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_3 
     547//      SetVariable setvar_2_UU_4,pos={34,197},size={70,16},title="File",fSize=10 
     548//      SetVariable setvar_2_UU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UU_4 
     549//      PopupMenu popup_2_UU_0,pos={142,99},size={210,20},title="Cell" 
     550//      PopupMenu popup_2_UU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     551//      PopupMenu popup_2_UU_1,pos={142,122},size={102,20},title="Cell" 
     552//      PopupMenu popup_2_UU_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     553//      PopupMenu popup_2_UU_2,pos={142,146},size={102,20},title="Cell" 
     554//      PopupMenu popup_2_UU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     555//      PopupMenu popup_2_UU_3,pos={142,170},size={102,20},title="Cell" 
     556//      PopupMenu popup_2_UU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     557//      PopupMenu popup_2_UU_4,pos={142,194},size={102,20},title="Cell" 
     558//      PopupMenu popup_2_UU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     559 
    452560        // DU 
    453         SetVariable setvar_2_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
    454         SetVariable setvar_2_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_0 
    455         SetVariable setvar_2_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
    456         SetVariable setvar_2_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_1 
    457         SetVariable setvar_2_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
    458         SetVariable setvar_2_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_2 
    459         SetVariable setvar_2_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
    460         SetVariable setvar_2_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_3 
    461         SetVariable setvar_2_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
    462         SetVariable setvar_2_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_4 
    463         PopupMenu popup_2_DU_0,pos={476,99},size={210,20},title="Condition" 
    464         PopupMenu popup_2_DU_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    465         PopupMenu popup_2_DU_1,pos={476,122},size={210,20},title="Condition" 
    466         PopupMenu popup_2_DU_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    467         PopupMenu popup_2_DU_2,pos={476,146},size={102,20},title="Condition" 
    468         PopupMenu popup_2_DU_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    469         PopupMenu popup_2_DU_3,pos={476,170},size={102,20},title="Condition" 
    470         PopupMenu popup_2_DU_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    471         PopupMenu popup_2_DU_4,pos={476,194},size={102,20},title="Condition" 
    472         PopupMenu popup_2_DU_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     561        ListBox ListBox_2_DU,pos={368,102},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     562        ListBox ListBox_2_DU,listWave=root:Packages:NIST:Polarization:ListWave_2_DU,titleWave=root:Packages:NIST:Polarization:lbTitles 
     563        ListBox ListBox_2_DU,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DU,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     564//      SetVariable setvar_2_DU_0,pos={368,102},size={70,16},title="File",fSize=10 
     565//      SetVariable setvar_2_DU_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_0 
     566//      SetVariable setvar_2_DU_1,pos={368,125},size={70,16},title="File",fSize=10 
     567//      SetVariable setvar_2_DU_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_1 
     568//      SetVariable setvar_2_DU_2,pos={368,149},size={70,16},title="File",fSize=10 
     569//      SetVariable setvar_2_DU_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_2 
     570//      SetVariable setvar_2_DU_3,pos={368,173},size={70,16},title="File",fSize=10 
     571//      SetVariable setvar_2_DU_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_3 
     572//      SetVariable setvar_2_DU_4,pos={368,197},size={70,16},title="File",fSize=10 
     573//      SetVariable setvar_2_DU_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DU_4 
     574//      PopupMenu popup_2_DU_0,pos={476,99},size={210,20},title="Cell" 
     575//      PopupMenu popup_2_DU_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     576//      PopupMenu popup_2_DU_1,pos={476,122},size={210,20},title="Cell" 
     577//      PopupMenu popup_2_DU_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     578//      PopupMenu popup_2_DU_2,pos={476,146},size={102,20},title="Cell" 
     579//      PopupMenu popup_2_DU_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     580//      PopupMenu popup_2_DU_3,pos={476,170},size={102,20},title="Cell" 
     581//      PopupMenu popup_2_DU_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     582//      PopupMenu popup_2_DU_4,pos={476,194},size={102,20},title="Cell" 
     583//      PopupMenu popup_2_DU_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     584 
    473585// DD 
    474         SetVariable setvar_2_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
    475         SetVariable setvar_2_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_0 
    476         SetVariable setvar_2_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
    477         SetVariable setvar_2_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_1 
    478         SetVariable setvar_2_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
    479         SetVariable setvar_2_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_2 
    480         SetVariable setvar_2_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
    481         SetVariable setvar_2_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_3 
    482         SetVariable setvar_2_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
    483         SetVariable setvar_2_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_4 
    484         PopupMenu popup_2_DD_0,pos={141,283},size={210,20},title="Condition" 
    485         PopupMenu popup_2_DD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    486         PopupMenu popup_2_DD_1,pos={141,306},size={102,20},title="Condition" 
    487         PopupMenu popup_2_DD_1,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    488         PopupMenu popup_2_DD_2,pos={141,330},size={102,20},title="Condition" 
    489         PopupMenu popup_2_DD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    490         PopupMenu popup_2_DD_3,pos={141,354},size={102,20},title="Condition" 
    491         PopupMenu popup_2_DD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    492         PopupMenu popup_2_DD_4,pos={141,378},size={102,20},title="Condition" 
    493         PopupMenu popup_2_DD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     586        ListBox ListBox_2_DD,pos={33,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     587        ListBox ListBox_2_DD,listWave=root:Packages:NIST:Polarization:ListWave_2_DD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     588        ListBox ListBox_2_DD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_DD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     589//      SetVariable setvar_2_DD_0,pos={33,286},size={70,16},title="File",fSize=10 
     590//      SetVariable setvar_2_DD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_0 
     591//      SetVariable setvar_2_DD_1,pos={33,309},size={70,16},title="File",fSize=10 
     592//      SetVariable setvar_2_DD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_1 
     593//      SetVariable setvar_2_DD_2,pos={33,333},size={70,16},title="File",fSize=10 
     594//      SetVariable setvar_2_DD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_2 
     595//      SetVariable setvar_2_DD_3,pos={33,357},size={70,16},title="File",fSize=10 
     596//      SetVariable setvar_2_DD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_3 
     597//      SetVariable setvar_2_DD_4,pos={33,381},size={70,16},title="File",fSize=10 
     598//      SetVariable setvar_2_DD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_DD_4 
     599//      PopupMenu popup_2_DD_0,pos={141,283},size={210,20},title="Cell" 
     600//      PopupMenu popup_2_DD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     601//      PopupMenu popup_2_DD_1,pos={141,306},size={102,20},title="Cell" 
     602//      PopupMenu popup_2_DD_1,mode=1,popvalue="none",value= #"D_CellNameList()" 
     603//      PopupMenu popup_2_DD_2,pos={141,330},size={102,20},title="Cell" 
     604//      PopupMenu popup_2_DD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     605//      PopupMenu popup_2_DD_3,pos={141,354},size={102,20},title="Cell" 
     606//      PopupMenu popup_2_DD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     607//      PopupMenu popup_2_DD_4,pos={141,378},size={102,20},title="Cell" 
     608//      PopupMenu popup_2_DD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
     609 
    494610// UD 
    495         SetVariable setvar_2_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
    496         SetVariable setvar_2_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_0 
    497         SetVariable setvar_2_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
    498         SetVariable setvar_2_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_1 
    499         SetVariable setvar_2_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
    500         SetVariable setvar_2_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_2 
    501         SetVariable setvar_2_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
    502         SetVariable setvar_2_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_3 
    503         SetVariable setvar_2_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
    504         SetVariable setvar_2_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_4 
    505         PopupMenu popup_2_UD_0,pos={476,283},size={210,20},title="Condition" 
    506         PopupMenu popup_2_UD_0,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    507         PopupMenu popup_2_UD_1,pos={476,306},size={210,20},title="Condition" 
    508         PopupMenu popup_2_UD_1,mode=3,popvalue="none",value= #"P_GetConditionNameList()" 
    509         PopupMenu popup_2_UD_2,pos={476,330},size={102,20},title="Condition" 
    510         PopupMenu popup_2_UD_2,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    511         PopupMenu popup_2_UD_3,pos={476,354},size={102,20},title="Condition" 
    512         PopupMenu popup_2_UD_3,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
    513         PopupMenu popup_2_UD_4,pos={476,378},size={102,20},title="Condition" 
    514         PopupMenu popup_2_UD_4,mode=1,popvalue="none",value= #"P_GetConditionNameList()" 
     611        ListBox ListBox_2_UD,pos={368,286},size={200,130},proc=PolCor_FileListBoxProc,frame=2 
     612        ListBox ListBox_2_UD,listWave=root:Packages:NIST:Polarization:ListWave_2_UD,titleWave=root:Packages:NIST:Polarization:lbTitles 
     613        ListBox ListBox_2_UD,selWave=root:Packages:NIST:Polarization:lbSelWave_2_UD,mode= 6,selRow= 0,selCol= 0,editStyle= 2 
     614//      SetVariable setvar_2_UD_0,pos={368,286},size={70,16},title="File",fSize=10 
     615//      SetVariable setvar_2_UD_0,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_0 
     616//      SetVariable setvar_2_UD_1,pos={368,309},size={70,16},title="File",fSize=10 
     617//      SetVariable setvar_2_UD_1,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_1 
     618//      SetVariable setvar_2_UD_2,pos={368,333},size={70,16},title="File",fSize=10 
     619//      SetVariable setvar_2_UD_2,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_2 
     620//      SetVariable setvar_2_UD_3,pos={368,357},size={70,16},title="File",fSize=10 
     621//      SetVariable setvar_2_UD_3,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_3 
     622//      SetVariable setvar_2_UD_4,pos={368,381},size={70,16},title="File",fSize=10 
     623//      SetVariable setvar_2_UD_4,limits={-inf,inf,0},value= root:Packages:NIST:Polarization:gStr_PolCor_2_UD_4 
     624//      PopupMenu popup_2_UD_0,pos={476,283},size={210,20},title="Cell" 
     625//      PopupMenu popup_2_UD_0,mode=3,popvalue="none",value= #"D_CellNameList()" 
     626//      PopupMenu popup_2_UD_1,pos={476,306},size={210,20},title="Cell" 
     627//      PopupMenu popup_2_UD_1,mode=3,popvalue="none",value= #"D_CellNameList()" 
     628//      PopupMenu popup_2_UD_2,pos={476,330},size={102,20},title="Cell" 
     629//      PopupMenu popup_2_UD_2,mode=1,popvalue="none",value= #"D_CellNameList()" 
     630//      PopupMenu popup_2_UD_3,pos={476,354},size={102,20},title="Cell" 
     631//      PopupMenu popup_2_UD_3,mode=1,popvalue="none",value= #"D_CellNameList()" 
     632//      PopupMenu popup_2_UD_4,pos={476,378},size={102,20},title="Cell" 
     633//      PopupMenu popup_2_UD_4,mode=1,popvalue="none",value= #"D_CellNameList()" 
    515634 
    516635EndMacro 
    517636 
    518  
     637// action procedure for the list box that allows the popup menu 
     638// -- much easier to make a contextual popup with a list box than on a table/subwindow hook 
     639// 
     640Function PolCor_FileListBoxProc(lba) : ListBoxControl 
     641        STRUCT WMListboxAction &lba 
     642 
     643        Variable row = lba.row 
     644        Variable col = lba.col 
     645        WAVE/T/Z listWave = lba.listWave 
     646        WAVE/Z selWave = lba.selWave 
     647         
     648        switch( lba.eventCode ) 
     649                case -1: // control being killed 
     650                        break 
     651                case 1: // mouse down 
     652                        if (lba.col == 1)                                                                                       // cell list 
     653//                              SelWave[][][0] = SelWave[p][q] & ~9                                             // de-select everything to make sure we don't leave something selected in another column 
     654//                              SelWave[][s.col][0] = SelWave[p][s.col] | 1                             // select all rows 
     655//                              ControlUpdate/W=$(s.win) $(s.ctrlName) 
     656                                PopupContextualMenu D_CellNameList() 
     657                                if (V_flag > 0) 
     658                                        listWave[lba.row][lba.col] = S_Selection 
     659                                endif 
     660                        endif 
     661                        break 
     662                case 3: // double click 
     663                        break 
     664                case 4: // cell selection 
     665                case 5: // cell selection plus shift key 
     666                        break 
     667                case 6: // begin edit 
     668                        break 
     669                case 7: // finish edit 
     670                        break 
     671                case 13: // checkbox clicked (Igor 6.2 or later) 
     672                        break 
     673        endswitch 
     674 
     675        return 0 
     676End 
     677 
     678 
     679// This hook is activated when the whole window is killed. It saves the state of the popups and list boxes. 
     680// -- the protocol is not saved since it can be recalled 
     681// 
    519682Function PolCorPanelHook(s) 
    520683        STRUCT WMWinHookStruct &s 
     
    537700                        String popList="",item 
    538701                        Variable num,ii 
    539                         popList=ControlNameList("PolCor_Panel",";","popup_*") 
     702 
     703//              -- old way, with popups for the conditions 
     704//                      popList=ControlNameList("PolCor_Panel",";","popup_*") 
     705//              -- new way - list boxes automatically saved, condition popup needs to be saved 
     706                        popList=ControlNameList("PolCor_Panel",";","popup*") 
    540707                        num=ItemsInList(popList,";") 
    541708                        Make/O/T/N=(num,2) root:Packages:NIST:Polarization:PolCor_popState 
     
    617784 
    618785 
    619  
     786// loads the specified type of data (SAM, EMP, BGD) based on the active tab 
     787// loads either specified spin type or all four 
     788// (( now, defaults to trying to load ALL four data spin states )) 
     789//              - I'll have to fix this later if only 2 of the four are needed 
     790//  -- during loading, the proper row of the PolMatrix is filled, based on pType 
     791// 
     792// then after all data is loaded: 
     793//              -the inverse Inv_PolMatrix is calculated 
     794//              -the error in the PolMatrix is calculated 
     795//              -the error in Inv_PolMatrix is calculated 
     796// 
    620797Function LoadRawPolarizedButton(ba) : ButtonControl 
    621798        STRUCT WMButtonAction &ba 
     
    626803                         
    627804                        // depends on which tab you're on 
    628                         // (maybe) select UD type 
     805                        // (maybe) select UD type, maybe force all to load 
     806                         
    629807                        String pType 
    630                         Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;All;" 
    631                         DoPrompt "Type to load",pType 
    632                         if (V_Flag) 
    633                                 return 0                                                                        // user canceled 
    634                         endif 
    635 //                      Print pType 
     808//                      Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;All;" 
     809//                      DoPrompt "Type to load",pType 
     810//                      if (V_Flag) 
     811//                              return 0                                                                        // user canceled 
     812//                      endif 
     813 
     814                        pType = "All" 
    636815                         
    637816                        if(cmpstr(pType,"All") == 0) 
     
    644823                        endif 
    645824                         
     825                        String type 
     826                        Variable row,col,flag=1 
     827                        Variable ii,jj,aa,bb 
     828                         
     829// The PolMatrix is filled on loading the data sets 
     830// once all files are added, take the SQRT of the error matrix 
     831// now calculate its inverse 
     832// -- first checking to be sure that no rows are zero - this will result in a singular matrix otherwise          
     833                        ControlInfo/W=PolCor_Panel PolCorTab 
     834                        type = S_value 
     835                        WAVE matA = $("root:Packages:NIST:"+type+":PolMatrix") 
     836                        WAVE matA_err = $("root:Packages:NIST:"+type+":PolMatrix_err") 
     837                        matA_err = sqrt(matA_err) 
     838                         
     839                        // check for zero rows before inverting -- means not all data loaded 
     840                        for(row=0;row<4;row+=1) 
     841                                if(matA[row][0] == 0 && matA[row][1] == 0 && matA[row][2] == 0 && matA[row][3] == 0) 
     842                                        Print "**** some elements of PolMatrix are zero. Inverse not calculated. Be sure that all four XS are loaded." 
     843                                        row=10 
     844                                        flag=0 
     845                                endif 
     846                        endfor 
     847                        if(flag)                //PolMatrix OK 
     848                                // calculate the inverse of the coefficient matrix 
     849                                SetDataFolder $("root:Packages:NIST:"+type) 
     850                                MatrixInverse/G matA 
     851                                Duplicate/O M_Inverse Inv_PolMatrix 
     852                                 
     853                                // now calculate the error of the inverse matrix 
     854                                Duplicate/O Inv_PolMatrix Inv_PolMatrix_err 
     855                                Inv_PolMatrix_err=0 
     856                                 
     857                                for(aa=0;aa<4;aa+=1) 
     858                                        for(bb=0;bb<4;bb+=1) 
     859                                                for(ii=0;ii<4;ii+=1) 
     860                                                        for(jj=0;jj<4;jj+=1) 
     861                                                                Inv_PolMatrix_err[aa][bb] += (Inv_PolMatrix[aa][ii])^2 * (matA_err[ii][jj])^2 * (Inv_PolMatrix[jj][bb])^2 
     862                                                        endfor 
     863                                                endfor 
     864//                                              Inv_PolMatrix_err[aa][bb] = sqrt(Inv_PolMatrix_err[aa][bb]) 
     865                                        endfor 
     866                                endfor 
     867                                 
     868                                Inv_PolMatrix_err = sqrt(Inv_PolMatrix_err) 
     869         
     870                                 
     871                        endif 
     872         
     873         
     874         
     875                        SetDataFolder root: 
     876                         
    646877                        break 
    647878                case -1: // control being killed 
     
    674905 
    675906        String listStr="",runList="",parsedRuns,condStr 
    676         Variable ii,num,err 
     907        Variable ii,num,err,row 
    677908                         
    678909        // get the current tab 
    679         String type 
     910        String type,runStr,cellStr 
    680911        Variable tabNum 
    681912        ControlInfo/W=PolCor_Panel PolCorTab 
     
    688919        SetDataFolder root:Packages:NIST:Polarization 
    689920//                      Print "Searching  "+"gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*" 
    690         listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
    691  
    692 //                      print listStr 
    693         for(ii=0;ii<itemsinlist(listStr);ii+=1) 
    694                 SVAR str=$StringFromList(ii, listStr ,";") 
    695                 if(cmpstr(str, "none" ) != 0) 
    696                         runList += str + "," 
    697                          
    698                         // and check that the condition is not "none" 
    699                         Print "ControlInfo call is for  "+"popup_"+num2str(tabNum)+"_"+pType+"_"+num2str(ii) 
    700          
    701                         ControlInfo/W=PolCor_Panel $("popup_"+num2str(tabNum)+"_"+pType+"_"+num2str(ii)) 
    702                          
    703                         condStr = S_Value 
    704                         if(cmpstr(condStr, "none" ) == 0) 
    705                                 DoAlert 0,"Condition for file index "+num2str(ii)+" is not set." 
     921//      listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
     922 
     923        Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     924        num = DimSize(lb,0)             //should be 10, as initialized 
     925         
     926        // if the condition (for all of the sets) is "none", get out 
     927        ControlInfo/W=PolCor_Panel popup1 
     928        condStr = S_Value 
     929        if(cmpstr(condStr, "none" ) == 0) 
     930                DoAlert 0,"Condition is not set." 
     931                SetDataFolder root: 
     932                return(0) 
     933        endif 
     934         
     935//                      step through, stop at the first null run number or missing cell specification 
     936        for(row=0;row<num;row+=1) 
     937                runStr = lb[row][0] 
     938                CellStr = lb[row][1] 
     939                 
     940                if(strlen(runStr) > 0 && strlen(cellStr) > 0)                   //non-null entries, go on 
     941                        runList += runStr+","           // this is a comma-delimited list 
     942                else 
     943                        if(strlen(runStr) == 0 && strlen(cellStr) == 0) 
     944                                // not a problem, don't bother reporting 
     945                        else 
     946                                //report the error and stop 
     947                                DoAlert 0,"run number or cell is not set in row "+num2str(row)+" for type "+pType 
    706948                                SetDataFolder root: 
    707949                                return(0) 
     
    735977        if(!WaveExists($("root:Packages:NIST:"+type+":PolMatrix"))) 
    736978                Make/O/D/N=(4,4) $("root:Packages:NIST:"+type+":PolMatrix") 
     979                Make/O/D/N=(4,4) $("root:Packages:NIST:"+type+":PolMatrix_err") 
    737980        endif 
    738981        WAVE matA = $("root:Packages:NIST:"+type+":PolMatrix") 
     982        WAVE matA_err = $("root:Packages:NIST:"+type+":PolMatrix_err") 
    739983 
    740984//                      listStr = ControlNameList("PolCor_Panel",";","*"+pType+"*") 
    741985 
     986        //This loops over all of the files and adds the coefficients to the PolMatrix 
    742987        // the PolMatrix rows are cleared on pass 0 as each pType data is loaded. 
    743         // this way repeated loading will always result in the correct fill                      
    744         AddToPolMatrix(matA,pType,tMid) 
    745  
    746  
     988        // this way repeated loading will always result in the correct fill 
     989        // returns the error matrix as the squared error (take sqrt in calling function)                 
     990        AddToPolMatrix(matA,matA_err,pType,tMid) 
     991 
     992 
     993        SetDataFolder root: 
     994         
     995        return(0) 
    747996End 
     997 
     998 
    748999// by definition-- the rows are: 
    7491000// 
     
    7561007// not yet using the midpoint time 
    7571008// 
    758 // 
    759 Function AddToPolMatrix(matA,pType,tMid) 
    760         Wave matA 
     1009// -- the PolMatrix_err returned from here is the squared error! 
     1010// 
     1011Function AddToPolMatrix(matA,matA_err,pType,tMid) 
     1012        Wave matA,matA_err 
    7611013        String pType 
    7621014        Variable tMid 
    7631015         
    7641016        Variable row,Psm, PsmPf, PCell,err_Psm, err_PsmPf, err_PCell 
    765         Variable ii,muPo,err_muPo,gam,err_gam,monCts,t1 
     1017        Variable ii,jj,muPo,err_muPo,gam,err_gam,monCts,t1,num 
    7661018 
    7671019        Variable ea_uu, ea_ud, ea_dd, ea_du 
    7681020        Variable ec_uu, ec_ud, ec_dd, ec_du 
    7691021         
    770         String listStr,fname="",condStr,condNote,decayNote,cellStr,t0Str,t1Str 
     1022        String listStr,fname="",condStr,condNote,decayNote,cellStr,t0Str,t1Str,runStr 
    7711023 
    7721024        // get the current tab 
     
    7791031         
    7801032        SetDataFolder root:Packages:NIST:Polarization 
    781         listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
    782  
    783  
    784         // loop over the (5) fields 
    785         for(ii=0;ii<itemsinlist(listStr);ii+=1) 
    786                 SVAR str=$StringFromList(ii, listStr ,";")              //the run number 
    787                 if(cmpstr(str, "none" ) != 0) 
     1033//      listStr = StringList("gStr_PolCor_"+num2str(tabNum)+"_*"+pType+"*", ";" ) 
     1034 
     1035 
     1036        Wave/T lb=$("ListWave_"+num2str(tabNum)+"_"+pType) 
     1037        num = DimSize(lb,0)             //should be 10, as initialized 
     1038         
     1039        // if the condition (for all of the sets) is "none", get out 
     1040        ControlInfo/W=PolCor_Panel popup1 
     1041        condStr = S_Value 
     1042        if(cmpstr(condStr, "none" ) == 0) 
     1043                DoAlert 0,"Condition is not set." 
     1044                SetDataFolder root: 
     1045                return(0) 
     1046        endif 
     1047         
     1048        Wave condition = $("root:Packages:NIST:Polarization:Cells:"+condStr) 
     1049        // get wave note from condition 
     1050        condNote = note(condition) 
     1051        // get P's from note 
     1052        Psm = NumberByKey("P_sm", condNote, "=", ",", 0) 
     1053        PsmPf = NumberByKey("P_sm_f", condNote, "=", ",", 0) 
     1054        err_Psm = NumberByKey("err_P_sm", condNote, "=", ",", 0) 
     1055        err_PsmPf = NumberByKey("err_P_sm_f", condNote, "=", ",", 0) 
     1056 
     1057 
     1058        // loop over the (10) rows in the listWave 
     1059        for(ii=0;ii<num;ii+=1) 
     1060                runStr =        lb[ii][0]               //the run number 
     1061                if(cmpstr(runStr, "" ) != 0) 
     1062                         
    7881063                        // get run number (str) 
    7891064                        // get file name 
    790                         fname = FindFileFromRunNumber(str2num(str)) 
    791                         // get condition from popup 
    792                         // 
    793 //                      Print "ControlInfo call is for  " + "popup_"+num2str(tabNum)+"_"+pType+"_"+num2str(ii) 
    794                          
    795                         ControlInfo/W=PolCor_Panel $("popup_"+num2str(tabNum)+"_"+pType+"_"+num2str(ii)) 
    796                         condStr = S_Value 
    797                         Wave condition = $("root:Packages:NIST:Polarization:Cells:"+condStr) 
    798                         // get wave note from condition 
    799                         condNote = note(condition) 
    800                         // get P's from note 
    801                         Psm = NumberByKey("P_sm", condNote, "=", ",", 0) 
    802                         PsmPf = NumberByKey("P_sm_f", condNote, "=", ",", 0) 
    803                         err_Psm = NumberByKey("err_P_sm", condNote, "=", ",", 0) 
    804                         err_PsmPf = NumberByKey("err_P_sm_f", condNote, "=", ",", 0) 
     1065                        fname = FindFileFromRunNumber(str2num(runStr)) 
    8051066                 
    8061067                        // get the cell string to get the Decay wave 
    807                         cellStr = StringFromList(2, condStr ,"_")               // treat the name as a list 
     1068                        cellStr = lb[ii][1] 
    8081069//                      print "Cell = ",cellStr 
    8091070                        // get info to calc Pcell (from the Decay wave) 
     
    8261087                        monCts /= 1e8           //just to get reasonable values 
    8271088                         
     1089                        Variable err_monCts 
     1090                        err_monCts = sqrt(monCts) 
    8281091                        // add appropriate values to matrix elements (switch on UU, DD, etc) 
    829                          
     1092                        // error in monCts is a negligible contribution 
    8301093                        strswitch(pType) 
    8311094                                case "UU":               
     
    8331096                                        if(ii==0) 
    8341097                                                matA[row][] = 0 
     1098                                                matA_err[row][] = 0 
    8351099                                        endif 
    8361100                                        ea_uu = (1+Psm)/2 
     
    8431107                                        matA[row][2] += ea_du*ec_du*monCts 
    8441108                                        matA[row][3] += ea_uu*ec_du*monCts 
    845                                          
    846                                          
     1109 
     1110// this seems to be too large... 
     1111//                                      matA_err[row][0] += (1/2*ec_uu*monCts)^2*err_Psm^2 + (1/2*ea_uu*monCts)^2*err_Pcell^2 
     1112//                                      matA_err[row][1] += (1/2*ec_uu*monCts)^2*err_Psm^2 + (1/2*ea_du*monCts)^2*err_Pcell^2 
     1113//                                      matA_err[row][2] += (1/2*ec_du*monCts)^2*err_Psm^2 + (1/2*ea_du*monCts)^2*err_Pcell^2 
     1114//                                      matA_err[row][3] += (1/2*ec_du*monCts)^2*err_Psm^2 + (1/2*ea_uu*monCts)^2*err_Pcell^2 
     1115 
     1116                                        matA_err[row][0] += (ea_uu*ec_uu*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1117                                        matA_err[row][1] += (ea_du*ec_uu*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1118                                        matA_err[row][2] += (ea_du*ec_du*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1119                                        matA_err[row][3] += (ea_uu*ec_du*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1120                                                                                 
    8471121                                        break 
    8481122                                case "DU":               
     
    8501124                                        if(ii==0) 
    8511125                                                matA[row][] = 0 
     1126                                                matA_err[row][] = 0 
    8521127                                        endif 
    8531128                                        ea_ud = (1-PsmPf)/2 
     
    8611136                                        matA[row][3] += ea_ud*ec_du*monCts 
    8621137                                         
     1138//                                      matA_err[row][0] += (1/2*(1+Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1-PsmPf)/2*monCts)^2*err_Pcell^2 
     1139//                                      matA_err[row][1] += (1/2*(1+Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1+PsmPf)/2*monCts)^2*err_Pcell^2 
     1140//                                      matA_err[row][2] += (1/2*(1-Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1+PsmPf)/2*monCts)^2*err_Pcell^2 
     1141//                                      matA_err[row][3] += (1/2*(1-Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1-PsmPf)/2*monCts)^2*err_Pcell^2                                      
     1142 
     1143                                        matA_err[row][0] += (ea_ud*ec_uu*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1144                                        matA_err[row][1] += (ea_dd*ec_uu*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1145                                        matA_err[row][2] += (ea_dd*ec_du*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1146                                        matA_err[row][3] += (ea_ud*ec_du*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1147                                                         
    8631148                                        break    
    8641149                                case "DD":               
     
    8661151                                        if(ii==0) 
    8671152                                                matA[row][] = 0 
     1153                                                matA_err[row][] = 0 
    8681154                                        endif 
    8691155                                        ea_ud = (1-PsmPf)/2 
     
    8771163                                        matA[row][3] += ea_ud*ec_dd*monCts                                       
    8781164                                         
    879                                          
     1165//                                      matA_err[row][0] += (1/2*(1-Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1-PsmPf)/2*monCts)^2*err_Pcell^2 
     1166//                                      matA_err[row][1] += (1/2*(1-Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1+PsmPf)/2*monCts)^2*err_Pcell^2 
     1167//                                      matA_err[row][2] += (1/2*(1+Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1+PsmPf)/2*monCts)^2*err_Pcell^2 
     1168//                                      matA_err[row][3] += (1/2*(1+Pcell)/2*monCts)^2*err_PsmPf^2 + (1/2*(1-PsmPf)/2*monCts)^2*err_Pcell^2      
     1169 
     1170                                        matA_err[row][0] += (ea_ud*ec_ud*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1171                                        matA_err[row][1] += (ea_dd*ec_ud*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1172                                        matA_err[row][2] += (ea_dd*ec_dd*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1173                                        matA_err[row][3] += (ea_ud*ec_dd*monCts)^2 * (err_PsmPf^2/PsmPf^2 + err_Pcell^2/Pcell^2) 
     1174                                                                                 
    8801175                                        break                                            
    8811176                                case "UD":               
     
    8831178                                        if(ii==0) 
    8841179                                                matA[row][] = 0 
     1180                                                matA_err[row][] = 0 
    8851181                                        endif 
    8861182                                        ea_uu = (1+Psm)/2 
     
    8941190                                        matA[row][3] += ea_uu*ec_dd*monCts                                       
    8951191                                                                                 
    896                                          
    897                                          
     1192//                                      matA_err[row][0] += (1/2*(1-Pcell)/2*monCts)^2*err_Psm^2 + (1/2*(1+Psm)/2*monCts)^2*err_Pcell^2 
     1193//                                      matA_err[row][1] += (1/2*(1-Pcell)/2*monCts)^2*err_Psm^2 + (1/2*(1-Psm)/2*monCts)^2*err_Pcell^2 
     1194//                                      matA_err[row][2] += (1/2*(1+Pcell)/2*monCts)^2*err_Psm^2 + (1/2*(1-Psm)/2*monCts)^2*err_Pcell^2 
     1195//                                      matA_err[row][3] += (1/2*(1+Pcell)/2*monCts)^2*err_Psm^2 + (1/2*(1+Psm)/2*monCts)^2*err_Pcell^2                                  
     1196 
     1197                                        matA_err[row][0] += (ea_uu*ec_ud*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1198                                        matA_err[row][1] += (ea_du*ec_ud*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1199                                        matA_err[row][2] += (ea_du*ec_dd*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1200                                        matA_err[row][3] += (ea_uu*ec_dd*monCts)^2 * (err_Psm^2/Psm^2 + err_Pcell^2/Pcell^2) 
     1201                                                                                 
    8981202                                        break 
    8991203                        endswitch 
     
    9031207        endfor 
    9041208         
    905  
     1209// can't take the SQRT here, since the matrix won't necessarily be full yet,  
     1210         
     1211         
    9061212        SetDataFolder root: 
    9071213        return(0) 
     
    9891295                        // click code here 
    9901296                         
    991                         Variable ii,jj,numRows,numCols 
     1297                        Variable ii,jj,numRows,numCols,row,kk 
    9921298                         
    9931299                        // get the current tab 
     
    10001306                         
    10011307                        // make waves for the result 
    1002 //                      Print "@@ PolCor is hard-wired for SAM --- this must be fixed" 
    10031308                        // these duplicate the data and add "_pc" for later use 
     1309                        // linear_data_error_UU_pc etc. are created 
    10041310                        MakePCResultWaves(type,"UU") 
    10051311                        MakePCResultWaves(type,"DU") 
     
    10091315                         
    10101316                        SetDataFolder $("root:Packages:NIST:"+type) 
    1011                          
     1317 
     1318// the linear data and its errors, declare and initialize                        
    10121319                        WAVE linear_data_UU_pc = linear_data_UU_pc 
    10131320                        WAVE linear_data_DU_pc = linear_data_DU_pc 
    10141321                        WAVE linear_data_DD_pc = linear_data_DD_pc 
    10151322                        WAVE linear_data_UD_pc = linear_data_UD_pc 
    1016                          
     1323                        WAVE linear_data_error_UU_pc = linear_data_error_UU_pc 
     1324                        WAVE linear_data_error_DU_pc = linear_data_error_DU_pc 
     1325                        WAVE linear_data_error_DD_pc = linear_data_error_DD_pc 
     1326                        WAVE linear_data_error_UD_pc = linear_data_error_UD_pc 
     1327                                                 
    10171328                        linear_data_UU_pc = 0 
    10181329                        linear_data_DU_pc = 0 
    10191330                        linear_data_DD_pc = 0 
    10201331                        linear_data_UD_pc = 0 
    1021                          
     1332                        linear_data_error_UU_pc = 0 
     1333                        linear_data_error_DU_pc = 0 
     1334                        linear_data_error_DD_pc = 0 
     1335                        linear_data_error_UD_pc = 0 
     1336                                                 
    10221337                        // make a temp wave for the experimental data vector 
    10231338                        Make/O/D/N=4 vecB 
     
    10301345                        WAVE linear_data_DD = linear_data_DD 
    10311346                        WAVE linear_data_UD = linear_data_UD 
    1032                          
    1033                          
     1347 
     1348// everything needed for the error calculation 
     1349// the PolMatrix error matrices 
     1350// and the data error 
     1351                        WAVE inv = Inv_PolMatrix 
     1352                        WAVE inv_err = Inv_PolMatrix_err                         
     1353                        WAVE linear_data_error_UU = linear_data_error_UU 
     1354                        WAVE linear_data_error_DU = linear_data_error_DU 
     1355                        WAVE linear_data_error_DD = linear_data_error_DD 
     1356                        WAVE linear_data_error_UD = linear_data_error_UD                         
    10341357                         
    10351358                        numRows = DimSize(linear_data_UU_pc, 0 ) 
     
    10521375                                        linear_data_UD_pc[ii][jj] = M_B[3][0] 
    10531376                                 
     1377                         
     1378                                        // and the error at each pixel, once for each of the four 
     1379                                        row = 0         //== UU 
     1380                                        for(kk=0;kk<4;kk+=1) 
     1381                                                linear_data_error_UU_pc[ii][jj] += inv_err[row][kk]^2*linear_data_UU[ii][jj]^2 + inv[row][kk]^2*linear_data_error_UU[ii][jj]^2 
     1382                                        endfor 
     1383                                        row = 1         //== DU 
     1384                                        for(kk=0;kk<4;kk+=1) 
     1385                                                linear_data_error_DU_pc[ii][jj] += inv_err[row][kk]^2*linear_data_DU[ii][jj]^2 + inv[row][kk]^2*linear_data_error_DU[ii][jj]^2 
     1386                                        endfor 
     1387                                        row = 2         //== DD 
     1388                                        for(kk=0;kk<4;kk+=1) 
     1389                                                linear_data_error_DD_pc[ii][jj] += inv_err[row][kk]^2*linear_data_DD[ii][jj]^2 + inv[row][kk]^2*linear_data_error_DD[ii][jj]^2 
     1390                                        endfor 
     1391                                        row = 3         //== UD 
     1392                                        for(kk=0;kk<4;kk+=1) 
     1393                                                linear_data_error_UD_pc[ii][jj] += inv_err[row][kk]^2*linear_data_UD[ii][jj]^2 + inv[row][kk]^2*linear_data_error_UD[ii][jj]^2 
     1394                                        endfor 
     1395                                         
     1396                                 
    10541397                                endfor 
    10551398                        //      Print ii         
    10561399                        endfor 
     1400                         
     1401                        // sqrt of the squared error... 
     1402                        linear_data_error_UU_pc = sqrt(linear_data_error_UU_pc) 
     1403                        linear_data_error_DU_pc = sqrt(linear_data_error_DU_pc) 
     1404                        linear_data_error_DD_pc = sqrt(linear_data_error_DD_pc) 
     1405                        linear_data_error_UD_pc = sqrt(linear_data_error_UD_pc) 
     1406                         
    10571407                         
    10581408                        //update the data as log of the linear. more correct to use the default scaling 
     
    10781428End 
    10791429 
     1430 
     1431// display all 4 XS at once in the same graph 
     1432// - crude right now 
     1433// 
     1434Function Display4XSButton(ba) : ButtonControl 
     1435        STRUCT WMButtonAction &ba 
     1436 
     1437        switch( ba.eventCode ) 
     1438                case 2: // mouse up 
     1439                        // click code here 
     1440                        String dataType,pType,str,scaling 
     1441                        Prompt dataType,"Display WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;SAS;" 
     1442//                      Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;UU_pc;DU_pc;DD_pc;UD_pc;" 
     1443                        Prompt scaling,"scaling",popup,"log;linear;" 
     1444                        DoPrompt "Change Display",dataType,scaling 
     1445                         
     1446                        Display_4(dataType,scaling) 
     1447                         
     1448                        break 
     1449                case -1: // control being killed 
     1450                        break 
     1451        endswitch 
     1452 
     1453        return 0 
     1454End 
     1455 
     1456 
    10801457// Change the displayed SANS data by pointing the data with the  
    10811458// specified tag (suffix) at data, linear_data, etc. 
     
    10881465                case 2: // mouse up 
    10891466                        // click code here 
    1090                         String dataType="SAM",pType,str 
    1091                         Prompt dataType,"Data Folder" 
     1467                        String dataType,pType,str 
     1468                        Prompt dataType,"Display WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;SAS;" 
    10921469                        Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;UU_pc;DU_pc;DD_pc;UD_pc;" 
    10931470                        DoPrompt "Change Display",dataType,pType 
     
    11051482 
    11061483 
    1107 // display the 4x4 polariztion efficiency matrix in a table 
     1484// display the 4x4 polariztion efficiency matrix in a table, and its inverse (if it exists) 
    11081485Function ShowPolMatrixButton(ba) : ButtonControl 
    11091486        STRUCT WMButtonAction &ba 
     
    11211498                        tabNum = V_Value 
    11221499                         
    1123                         Edit $("root:Packages:NIST:"+type+":PolMatrix") 
     1500                        Wave/Z Pol = $("root:Packages:NIST:"+type+":PolMatrix") 
     1501                        if(WaveExists(Pol)) 
     1502                                Edit/W=(5,44,510,251)/K=1 Pol 
     1503                        endif 
     1504                        Wave/Z Inv_Pol = $("root:Packages:NIST:"+type+":Inv_PolMatrix") 
     1505                        if(WaveExists(Inv_Pol)) 
     1506                                Edit/W=(6,506,511,713)/K=1 Inv_Pol 
     1507                        endif 
     1508                        Wave/Z Pol_err = $("root:Packages:NIST:"+type+":PolMatrix_err") 
     1509                        if(WaveExists(Pol_err)) 
     1510                                Edit/W=(5,275,510,482)/K=1 Pol_err 
     1511                        endif 
     1512                        Wave/Z Inv_Pol_err = $("root:Packages:NIST:"+type+":Inv_PolMatrix_err") 
     1513                        if(WaveExists(Inv_Pol_err)) 
     1514                                Edit/W=(6,736,511,943)/K=1 Inv_Pol_err 
     1515                        endif 
    11241516                         
    11251517                        break 
     
    11861578        // depends on which tab you're on 
    11871579        // (maybe) select UD type 
     1580         
    11881581        String pType 
    1189         Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;All;" 
    1190         DoPrompt "Type to load",pType 
    1191         if (V_Flag) 
    1192                 return 0                                                                        // user canceled 
    1193         endif 
     1582//      Prompt pType,"Pol Type",popup,"UU;DU;DD;UD;All;" 
     1583//      DoPrompt "Type to load",pType 
     1584//      if (V_Flag) 
     1585//              return 0                                                                        // user canceled 
     1586//      endif 
    11941587//      Print pType 
    11951588 
     1589 
     1590        pType = "All" 
    11961591 
    11971592// get the protocol to use 
     
    12391634// -- but they do need to be "moved" into the regular data positions 
    12401635//    rather then their tagged locations. 
     1636//  
     1637// -- the "extensions" now all are "_UU_pc" and similar, to use the polarization corrected data and errors 
    12411638// 
    12421639Function ExecutePolarizedProtocol(protStr,pType) 
     
    13491746                        Abort "error in Correct, called from executeprotocol, normal cor" 
    13501747                endif 
     1748                TagLoadedData(activeType,pType+"_pc") 
    13511749                UpdateDisplayInformation(ActiveType)            //update before breaking from loop 
    13521750        While(0) 
     
    13781776                Endif 
    13791777                activeType = "CAL" 
     1778                TagLoadedData(activeType,pType+"_pc") 
    13801779                UpdateDisplayInformation(ActiveType)            //update before breaking from loop 
    13811780        Endif 
     
    14141813                endif 
    14151814                activeType = "ABS" 
     1815                TagLoadedData(activeType,pType+"_pc") 
    14161816                UpdateDisplayInformation(ActiveType)            //update before breaking from loop 
    14171817        Endif 
     
    19212321 
    19222322 
     2323// the data in the SAM, EMP, BKG folders will be either _UU or _UU_pc, depending if the data 
     2324// is as-loaded, or if it's been polarization corrected. This is to display the polarization-corrected "_pc" 
     2325// data sets ONLY. If you want to see the individual data sets, well that's just the SAM, EMP, BGD files. 
     2326// look at thum one-by-one... 
     2327// 
     2328// -- data in subsequent correction step folders do have the _pc extensions, the _pc data is 
     2329//              used for each step, so the _pc is redundant, but consistent 
     2330// 
     2331Function Display_4(type,scaling) 
     2332        String type,scaling 
     2333         
     2334        String dest = "root:Packages:NIST:"+type 
     2335        NVAR isLogscale = $(dest + ":gIsLogScale") 
     2336 
     2337        SetDataFolder $("root:Packages:NIST:"+type) 
     2338         
     2339        wave uu = linear_data_uu_pc 
     2340        wave d_uu = data_uu_pc 
     2341         
     2342        wave du = linear_data_du_pc 
     2343        wave d_du = data_du_pc 
     2344         
     2345        wave dd = linear_data_dd_pc 
     2346        wave d_dd = data_dd_pc 
     2347         
     2348        wave ud = linear_data_ud_pc 
     2349        wave d_ud = data_ud_pc 
     2350                 
     2351        if(cmpstr(scaling,"log") == 0) 
     2352 
     2353                d_uu = log(uu) 
     2354                d_du = log(du) 
     2355                d_dd = log(dd) 
     2356                d_ud = log(ud)                   
     2357                 
     2358                isLogScale = 1 
     2359                         
     2360        else 
     2361 
     2362                d_uu = uu 
     2363                d_du = du 
     2364                d_dd = dd 
     2365                d_ud = ud 
     2366                         
     2367                isLogScale = 0 
     2368 
     2369        endif 
     2370 
     2371        DoWindow/F SANS_X4 
     2372        if(V_flag==0) 
     2373                Display /W=(811,44,1479,758)/K=1 
     2374                ControlBar 100 
     2375                DoWindow/C SANS_X4 
     2376                DoWindow/T SANS_X4,type+"_pc" 
     2377                Button button0 pos={130,65},size={50,20},title="Do It",proc=Change4xsButtonProc 
     2378                PopupMenu popup0 pos={20,35},title="Data Type",value="SAM;EMP;BGD;COR;CAL;ABS;"         //RAW, SAS, DIV, etc, won't have _pc data and are not valid 
     2379                PopupMenu popup1 pos={190,35},title="Scaling",value="log;linear;" 
     2380                TitleBox title0 title="Only Polarization-corrected sets are displayed",pos={5,5} 
     2381 
     2382        else 
     2383                RemoveImage/Z data_uu_pc                //remove the old images (different data folder) 
     2384                RemoveImage/Z data_du_pc 
     2385                RemoveImage/Z data_dd_pc 
     2386                RemoveImage/Z data_ud_pc 
     2387                 
     2388                DoWindow/T SANS_X4,type+"_pc" 
     2389 
     2390        endif 
     2391         
     2392        AppendImage/B=bot_uu/L=left_uu data_UU_pc 
     2393        ModifyImage data_UU_pc ctab= {*,*,YellowHot,0} 
     2394        AppendImage/B=bot_dd/L=left_dd data_DD_pc 
     2395        ModifyImage data_DD_pc ctab= {*,*,YellowHot,0} 
     2396        AppendImage/B=bot_du/L=left_du data_DU_pc 
     2397        ModifyImage data_DU_pc ctab= {*,*,YellowHot,0} 
     2398        AppendImage/B=bot_ud/L=left_ud data_UD_pc 
     2399        ModifyImage data_UD_pc ctab= {*,*,YellowHot,0} 
     2400         
     2401        DoUpdate 
     2402                         
     2403        ModifyGraph freePos(left_uu)={0,kwFraction},freePos(bot_uu)={0.6,kwFraction} 
     2404        ModifyGraph freePos(left_dd)={0,kwFraction},freePos(bot_dd)={0,kwFraction} 
     2405        ModifyGraph freePos(left_du)={0.6,kwFraction},freePos(bot_du)={0.6,kwFraction} 
     2406        ModifyGraph freePos(left_ud)={0.6,kwFraction},freePos(bot_ud)={0,kwFraction} 
     2407         
     2408        ModifyGraph axisEnab(left_uu)={0.6,1},axisEnab(bot_uu)={0,0.4} 
     2409        ModifyGraph axisEnab(left_dd)={0,0.4},axisEnab(bot_dd)={0,0.4} 
     2410        ModifyGraph axisEnab(left_du)={0.6,1},axisEnab(bot_du)={0.6,1} 
     2411        ModifyGraph axisEnab(left_ud)={0,0.4},axisEnab(bot_ud)={0.6,1} 
     2412         
     2413        ModifyGraph standoff=0 
     2414        ModifyGraph lblPosMode(left_uu)=4,lblPosMode(left_dd)=4,lblPosMode(left_du)=4,lblPosMode(left_ud)=4 
     2415        ModifyGraph lblPos(left_uu)=40,lblPos(left_dd)=40,lblPos(left_du)=40,lblPos(left_ud)=40 
     2416        Label left_uu "UU" 
     2417        Label left_dd "DD" 
     2418        Label left_du "DU" 
     2419        Label left_ud "UD"       
     2420         
     2421        ModifyGraph fSize=16 
     2422        // force a redraw to get the axes in the right spot 
     2423        DoUpdate 
     2424         
     2425        SetDataFolder root: 
     2426        return(0) 
     2427End 
     2428 
     2429Function Change4xsButtonProc(ba) : ButtonControl 
     2430        STRUCT WMButtonAction &ba 
     2431 
     2432        String dataType,scaling 
     2433         
     2434        switch( ba.eventCode ) 
     2435                case 2: // mouse up 
     2436                        // click code here 
     2437                        ControlInfo popup0 
     2438                        dataType = S_Value 
     2439                        ControlInfo popup1 
     2440                        scaling = S_Value 
     2441                        Display_4(dataType,scaling) 
     2442                         
     2443                        break 
     2444                case -1: // control being killed 
     2445                        break 
     2446        endswitch 
     2447 
     2448        return 0 
     2449End 
     2450 
     2451 
     2452 
    19232453 
    19242454 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/Polarization/Pol_PolarizationPanels.ipf

    r824 r829  
    3838// 
    3939// -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 
     40//              - calculates the flipper and supermirror efficiencies for a given "condition" 
     41//              - this "condition" may have contributions from multiple cells 
     42//              - start by entering a condition name 
     43//              - Waves Cond_<condition> and CondCalc_<condition>, and CondCell are created 
    4344//              - DimLabels are used for the arrays to make the column identity more readable than simply an index 
     45//              - Enter the name of the cell in the first column (the cell must be defined and decay calculated) 
    4446//              - enter transmission run numbers as specified in the table 
    4547//              - Do Average will calculate the Psm and PsmPfl values (and errors) and average if more than 
    4648//                      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> 
     49//              - results are printed on the panel, and written to the wave note of Cond_<condition> 
    4850//              - results are used in the calculation of the polarization matrix 
    49 // 
     51//              - (the cell name is not entered using a contextual menu, since this is difficult for a subwindow) 
     52//              - (the wave note no longer needs the cell name) 
    5053// 
    5154// -4- PolCor_Panel (not in this procedure - in Pol_PolarizationCorrection.ipf) 
    5255//              - 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 
     56//              - up to 10 files can be added together for each of the different spin states (more than this??) 
     57//              - one polarization condition is set for everything with the popup @ the top 
     58//              - two-column list boxes for each state hold the run number and the cell name 
     59//              - the same list boxes are duplicated (hidden) for the SAM/EMP/BGD tabs as needed 
    5760//              - on loading of the data, the 2-letter spin state is tagged onto the loaded waves (all of them) 
    5861//              - displayed data is simply re-pointed to the desired data 
     
    6265//              - Polarization correction is done with one click (one per tab). "_pc" tags are added to the resulting names, 
    6366//                      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) 
     67//              - Once all of the polariztion correction is done, then the UU_pc (etc.) data can be reduced as usual (xx_pc = 4 passes) 
    6568//              - protocol is built as ususal, from this panel only (since the SAM, EMP, and BGD need to be switched, rather than loaded 
    6669//              - protocols can be saved/recalled. 
     
    107110                endif 
    108111                Make_HeCell_ParamWaves() 
    109                 CellParamPanel() 
     112                DrawCellParamPanel() 
    110113        endif 
    111114 
     
    226229// add a button to add new cells (insert a new row in the table, then update) 
    227230// 
    228 Function CellParamPanel() 
     231Function DrawCellParamPanel() 
    229232 
    230233        SetDataFolder root:Packages:NIST:Polarization:Cells 
    231234         
    232235        PauseUpdate; Silent 1           // building window... 
    233         NewPanel /W=(775,44,1375,377) /N=CellParamPanel/K=1 as "Fundamental Cell Parameters" 
     236        NewPanel /W=(775,44,1375,377)/N=CellParamPanel/K=1 as "Fundamental Cell Parameters" 
    234237        ModifyPanel cbRGB=(65535,49151,55704) 
    235238        ModifyPanel fixedSize=1 
     
    11341137                         
    11351138                        // clear the graph and the results                       
    1136                         NVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
    1137                         NVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
    1138                         NVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
     1139                        SVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
     1140                        SVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
     1141                        SVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
    11391142                        SVAR gT0  = root:Packages:NIST:Polarization:Cells:gT0 
    1140                         gMuPo = 0 
    1141                         gPo = 0 
    1142                         gGamma = 0 
     1143                        gMuPo = "0" 
     1144                        gPo = "0" 
     1145                        gGamma = "0" 
    11431146                        gT0 = "recalculate" 
    1144                          
    11451147                         
    11461148                        SetDataFolder root: 
     
    11891191                         
    11901192                                         
    1191                         NVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
    1192                         NVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
    1193                         NVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
     1193                        SVAR gMuPo = root:Packages:NIST:Polarization:Cells:gMuPo 
     1194                        SVAR gPo  = root:Packages:NIST:Polarization:Cells:gPo 
     1195                        SVAR gGamma  = root:Packages:NIST:Polarization:Cells:gGamma 
    11941196                        SVAR gT0  = root:Packages:NIST:Polarization:Cells:gT0 
    1195                         gMuPo = 0 
    1196                         gPo = 0 
    1197                         gGamma = 0 
     1197                        gMuPo = "0" 
     1198                        gPo = "0" 
     1199                        gGamma = "0" 
    11981200                        gT0 = "recalculate" 
    11991201                         
Note: See TracChangeset for help on using the changeset viewer.