| [816] | 1 | #pragma rtGlobals=1 // Use modern global access method. |
|---|
| 2 | |
|---|
| 3 | // input panels to set and calculate polarization parameters necessary for the |
|---|
| 4 | // matrix corrections to the cross sections |
|---|
| 5 | // |
|---|
| 6 | // |
|---|
| 7 | // -3-Flipper efficiency |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | // |
|---|
| 11 | // TODO: |
|---|
| [817] | 12 | // X- add a way to manually enter the P values into a "blank" condition, in case that the users |
|---|
| [816] | 13 | // calculate the values in a different way. This should be as simple as a dialog to enter values and |
|---|
| 14 | // change the wave note (and displayed strings). |
|---|
| 15 | // |
|---|
| 16 | // |
|---|
| 17 | // Polarization parameters for each condition. Results are stored in a wave note for each condition |
|---|
| 18 | // |
|---|
| 19 | // |
|---|
| 20 | // str = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf,Cell=asdf," |
|---|
| 21 | // |
|---|
| 22 | // two waves per condition "Cond_Name_Cell" and "CondCalc_Name_Cell" |
|---|
| 23 | // |
|---|
| [835] | 24 | Proc ShowFlipperPanel() |
|---|
| [816] | 25 | |
|---|
| 26 | // init folders |
|---|
| 27 | // ASK before initializing cell constants |
|---|
| 28 | // open the panel |
|---|
| 29 | DoWindow/F FlipperPanel |
|---|
| 30 | if(V_flag == 0) |
|---|
| 31 | InitPolarizationFolders() |
|---|
| 32 | InitFlipperGlobals() |
|---|
| 33 | DrawFlipperPanel() |
|---|
| 34 | endif |
|---|
| 35 | end |
|---|
| 36 | |
|---|
| 37 | Function InitFlipperGlobals() |
|---|
| 38 | |
|---|
| 39 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 40 | |
|---|
| 41 | String/G gPsmPf = "Psm*Pf" |
|---|
| 42 | String/G gPsm = "Psm" |
|---|
| 43 | |
|---|
| 44 | SetDataFolder root: |
|---|
| 45 | return(0) |
|---|
| 46 | End |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | // |
|---|
| 50 | // makes the panel for the calculation of flipper and supermirror efficiencies |
|---|
| 51 | // |
|---|
| 52 | Function DrawFlipperPanel() |
|---|
| 53 | |
|---|
| 54 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 55 | |
|---|
| 56 | PauseUpdate; Silent 1 // building window... |
|---|
| 57 | NewPanel /W=(1023,44,1832,526)/N=FlipperPanel/K=1 as "Flipper and Supermirror" |
|---|
| 58 | ModifyPanel cbRGB=(1,52428,26586) |
|---|
| 59 | |
|---|
| 60 | PopupMenu popup_0,pos={32,18},size={49,20},title="Field Condition",proc=FlipperPanelPopMenuProc |
|---|
| 61 | PopupMenu popup_0,mode=1,value= #"D_ConditionNameList()" |
|---|
| 62 | |
|---|
| 63 | Button button_0,pos={42,310},size={100,20},proc=FlipperAverageButtonProc,title="Do Average" |
|---|
| 64 | |
|---|
| 65 | GroupBox group_0,pos={39,350},size={335,103},title="AVERAGED RESULTS",fSize=10 |
|---|
| 66 | GroupBox group_0,fStyle=1 |
|---|
| 67 | SetVariable setvar_0,pos={49,385},size={250,15},title="Sam_depol*Psm*Pf" |
|---|
| 68 | SetVariable setvar_0,fStyle=1 |
|---|
| 69 | SetVariable setvar_0,limits={0,0,0},value= root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 70 | SetVariable setvar_1,pos={49,417},size={250,15},title="Sam_depol*Psm",fStyle=1 |
|---|
| 71 | SetVariable setvar_1,limits={0,0,0},value= root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 72 | // SetVariable setvar_2,pos={560,518},size={200,13},title="Gamma (h)",fStyle=1 |
|---|
| 73 | // SetVariable setvar_2,limits={0,0,0},barmisc={0,1000} |
|---|
| 74 | // SetVariable setvar_2,value= root:Packages:NIST:Polarization:Cells:gGamma |
|---|
| 75 | // SetVariable setvar_3,pos={560,488},size={200,15},title="T0",fStyle=1 |
|---|
| 76 | // SetVariable setvar_3,limits={0,0,0},value= root:Packages:NIST:Polarization:Cells:gT0 |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | Button button_1,pos={320,17},size={120,20},proc=AddFlipperConditionButton,title="Add Condition" |
|---|
| 80 | Button button_2,pos={403,295},size={110,20},proc=ClearAllFlipperWavesButton,title="Clear Table" |
|---|
| 81 | Button button_3,pos={183,310},size={120,20},proc=ShowFlipperCalcButton,title="Show Calc" |
|---|
| 82 | Button button_4,pos={540,295},size={110,20},proc=ClearFlipperRowButton,title="Clear Row" |
|---|
| 83 | Button button_5,pos={620,18},size={30,20},proc=FlipperHelpParButtonProc,title="?" |
|---|
| 84 | Button button_6,pos={488,418},size={100,20},proc=WindowSnapshotButton,title="Snapshot" |
|---|
| 85 | Button button_7,pos={488,380},size={130,20},proc=ManualEnterPfPsmButton,title="Manual Entry" |
|---|
| 86 | |
|---|
| 87 | // table |
|---|
| 88 | Edit/W=(14,55,794,275)/HOST=# |
|---|
| 89 | ModifyTable format=1,width=0 |
|---|
| 90 | RenameWindow #,T0 |
|---|
| 91 | SetActiveSubwindow ## |
|---|
| 92 | |
|---|
| 93 | SetDataFolder root: |
|---|
| 94 | return(0) |
|---|
| 95 | End |
|---|
| 96 | |
|---|
| [829] | 97 | // now, this does not depend on the cell, just the condition |
|---|
| [816] | 98 | Function AddFlipperConditionButton(ba) : ButtonControl |
|---|
| 99 | STRUCT WMButtonAction &ba |
|---|
| 100 | |
|---|
| 101 | switch( ba.eventCode ) |
|---|
| 102 | case 2: // mouse up |
|---|
| 103 | // click code here |
|---|
| 104 | |
|---|
| [829] | 105 | |
|---|
| 106 | String condStr//, cellStr |
|---|
| [824] | 107 | Prompt condStr,"Condition, <12 characters, NO UNDERSCORES" |
|---|
| [829] | 108 | // Prompt cellStr,"Cell",popup,D_CellNameList() |
|---|
| 109 | DoPrompt "Add new condition",condStr//, cellStr |
|---|
| [816] | 110 | if(V_Flag==1) |
|---|
| 111 | return 0 // user canceled |
|---|
| 112 | endif |
|---|
| 113 | |
|---|
| 114 | if(strlen(condStr) > 12) |
|---|
| 115 | condStr = condStr[0,11] |
|---|
| 116 | Print "Condition String trimmed to ",condStr |
|---|
| 117 | endif |
|---|
| 118 | |
|---|
| [824] | 119 | condStr = ReplaceString("_", condStr, "", 0, inf) |
|---|
| 120 | |
|---|
| [816] | 121 | String popStr |
|---|
| [829] | 122 | // popStr = condStr+"_"+cellStr |
|---|
| 123 | popStr = condStr |
|---|
| [816] | 124 | |
|---|
| 125 | MakeFlipperResultWaves(popStr) |
|---|
| 126 | |
|---|
| 127 | break |
|---|
| 128 | case -1: // control being killed |
|---|
| 129 | break |
|---|
| 130 | endswitch |
|---|
| 131 | |
|---|
| 132 | return 0 |
|---|
| 133 | End |
|---|
| 134 | |
|---|
| 135 | Function FlipperPanelPopMenuProc(pa) : PopupMenuControl |
|---|
| 136 | STRUCT WMPopupAction &pa |
|---|
| 137 | |
|---|
| 138 | switch( pa.eventCode ) |
|---|
| 139 | case 2: // mouse up |
|---|
| 140 | Variable popNum = pa.popNum |
|---|
| 141 | String popStr = pa.popStr |
|---|
| 142 | |
|---|
| 143 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 144 | |
|---|
| 145 | // based on the selected string, display the right set of inputs |
|---|
| 146 | // Print "now I need to display the right set of waves (2D text?) for ",popStr |
|---|
| 147 | |
|---|
| 148 | if(cmpstr(popStr,"no conditions defined") == 0) |
|---|
| 149 | SetDataFolder root: |
|---|
| 150 | return(0) |
|---|
| 151 | endif |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | // for the given cell name, if the wave(s) exist, declare them |
|---|
| 155 | if(exists(popStr) == 1) |
|---|
| 156 | WAVE cond = $(popStr) |
|---|
| [829] | 157 | WAVE/T cellW = $("CondCell_"+popStr[5,strlen(popStr)-1]) |
|---|
| [816] | 158 | else |
|---|
| 159 | // if not, report an error |
|---|
| 160 | DoAlert 0,"The Cond_ waves should exist, this is an error" |
|---|
| 161 | |
|---|
| 162 | SetDataFolder root: |
|---|
| 163 | return(0) |
|---|
| 164 | //MakeFlipperResultWaves(popStr) |
|---|
| 165 | //WAVE cond = $("root:Packages:NIST:Polarization:Cells:Cond_"+popStr) |
|---|
| 166 | endif |
|---|
| 167 | // append matrix, clearing the old one first |
|---|
| 168 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 169 | |
|---|
| 170 | KillWindow FlipperPanel#T0 |
|---|
| 171 | Edit/W=(14,55,794,275)/HOST=FlipperPanel |
|---|
| 172 | RenameWindow #,T0 |
|---|
| [829] | 173 | AppendtoTable/W=FlipperPanel#T0 cellW // |
|---|
| [816] | 174 | AppendtoTable/W=FlipperPanel#T0 cond.ld //show the labels |
|---|
| 175 | ModifyTable width(Point)=0 |
|---|
| 176 | ModifyTable width(cond.l)=20 |
|---|
| 177 | |
|---|
| 178 | SetActiveSubwindow ## |
|---|
| 179 | |
|---|
| 180 | SetDataFolder root: |
|---|
| 181 | |
|---|
| [835] | 182 | // update the globals that are displayed from the wave note |
|---|
| 183 | String nStr=Note(cond) |
|---|
| 184 | SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 185 | SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 186 | sprintf gPsmPf, "%g +/- %g",NumberByKey("P_sm_f", nStr, "=",","),NumberByKey("err_P_sm_f", nStr, "=",",") |
|---|
| 187 | sprintf gPsm, "%g +/- %g",NumberByKey("P_sm", nStr, "=",","),NumberByKey("err_P_sm", nStr, "=",",") |
|---|
| 188 | |
|---|
| 189 | |
|---|
| [816] | 190 | break |
|---|
| 191 | case -1: // control being killed |
|---|
| 192 | break |
|---|
| 193 | endswitch |
|---|
| 194 | |
|---|
| 195 | return 0 |
|---|
| 196 | End |
|---|
| 197 | |
|---|
| 198 | // waves are: |
|---|
| 199 | // "Cond_"+popStr |
|---|
| 200 | // and "CondCalc_"+popStr |
|---|
| [829] | 201 | // ... and now "CondCell"+popStr |
|---|
| [816] | 202 | |
|---|
| 203 | Function MakeFlipperResultWaves(popStr) |
|---|
| 204 | String popStr |
|---|
| 205 | |
|---|
| 206 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 207 | |
|---|
| [829] | 208 | Make/O/T/N=1 $("CondCell_"+popStr) |
|---|
| 209 | |
|---|
| [816] | 210 | Make/O/D/N=(1,8) $("Cond_"+popStr) |
|---|
| 211 | WAVE cond = $("Cond_"+popStr) |
|---|
| 212 | // set the column labels |
|---|
| 213 | SetDimLabel 1,0,UU_Trans,cond |
|---|
| 214 | SetDimLabel 1,1,DU_Trans,cond |
|---|
| 215 | SetDimLabel 1,2,DD_Trans,cond |
|---|
| 216 | SetDimLabel 1,3,UD_Trans,cond |
|---|
| 217 | SetDimLabel 1,4,Blocked,cond |
|---|
| 218 | SetDimLabel 1,5,Pol_SM_FL,cond |
|---|
| 219 | SetDimLabel 1,6,Pol_SM,cond //for a mask wave, non-zero is used in the fit |
|---|
| 220 | SetDimLabel 1,7,Include,cond |
|---|
| 221 | cond[0][7] = 1 //default to include the point |
|---|
| 222 | |
|---|
| 223 | // generate the dummy wave note now, change as needed |
|---|
| 224 | String cellStr = StringFromList(1, popStr,"_") |
|---|
| [835] | 225 | String testStr = "P_sm_f=0,err_P_sm_f=0,P_sm=0,err_P_sm=0,T0=undefined," |
|---|
| [829] | 226 | // testStr = ReplaceStringByKey("Cell", testStr, cellStr ,"=", ",", 0) |
|---|
| [816] | 227 | Note cond, testStr |
|---|
| 228 | |
|---|
| 229 | // to hold the results of the calculation |
|---|
| 230 | Make/O/D/N=(1,14) $("CondCalc_"+popStr) |
|---|
| 231 | WAVE CondCalc = $("CondCalc_"+popStr) |
|---|
| 232 | SetDimLabel 1,0,CR_UU,CondCalc |
|---|
| 233 | SetDimLabel 1,1,err_CR_UU,CondCalc |
|---|
| 234 | SetDimLabel 1,2,CR_DU,CondCalc |
|---|
| 235 | SetDimLabel 1,3,err_CR_DU,CondCalc |
|---|
| 236 | SetDimLabel 1,4,CR_DD,CondCalc |
|---|
| 237 | SetDimLabel 1,5,err_CR_DD,CondCalc |
|---|
| 238 | SetDimLabel 1,6,CR_UD,CondCalc |
|---|
| 239 | SetDimLabel 1,7,err_CR_UD,CondCalc |
|---|
| 240 | SetDimLabel 1,8,CR_Blocked,CondCalc |
|---|
| 241 | SetDimLabel 1,9,err_CR_Blocked,CondCalc |
|---|
| 242 | SetDimLabel 1,10,P_sm_f,CondCalc |
|---|
| 243 | SetDimLabel 1,11,err_P_sm_f,CondCalc |
|---|
| 244 | SetDimLabel 1,12,P_sm,CondCalc |
|---|
| 245 | SetDimLabel 1,13,err_P_sm,CondCalc |
|---|
| 246 | |
|---|
| 247 | SetDataFolder root: |
|---|
| 248 | |
|---|
| 249 | return(0) |
|---|
| 250 | End |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | // allows manual entry of Psm and Pf values |
|---|
| 254 | // |
|---|
| 255 | Function ManualEnterPfPsmButton(ba) : ButtonControl |
|---|
| 256 | STRUCT WMButtonAction &ba |
|---|
| 257 | |
|---|
| 258 | Variable selRow,err=0 |
|---|
| 259 | String fname, t0str, condStr,noteStr,t1Str,cellStr |
|---|
| 260 | |
|---|
| 261 | switch( ba.eventCode ) |
|---|
| 262 | case 2: // mouse up |
|---|
| 263 | // click code here |
|---|
| 264 | Variable cr1,cr2,cr3,cr4,cr5,err_cr1,err_cr2,err_cr3,err_cr4,err_cr5 |
|---|
| 265 | Variable PsmPf, err_PsmPf, Psm, err_Psm |
|---|
| 266 | |
|---|
| 267 | ControlInfo/W=FlipperPanel popup_0 |
|---|
| 268 | condStr = S_Value |
|---|
| 269 | WAVE w=$("root:Packages:NIST:Polarization:Cells:"+condStr) //the one that is displayed |
|---|
| 270 | WAVE calc=$("root:Packages:NIST:Polarization:Cells:CondCalc_"+condStr[5,strlen(condStr)-1]) //the one that holds results |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | Prompt PsmPf, "Enter PsmPf: " |
|---|
| 274 | Prompt err_PsmPf, "Enter err_PsmPf: " |
|---|
| 275 | Prompt Psm, "Enter Psm: " |
|---|
| 276 | Prompt err_Psm, "Enter err_Psm: " |
|---|
| 277 | DoPrompt "Enter Supermirror and Flipper Parameters", PsmPf, err_PsmPf, Psm, err_Psm |
|---|
| 278 | if (V_Flag) |
|---|
| 279 | return -1 // User canceled |
|---|
| 280 | endif |
|---|
| 281 | |
|---|
| 282 | // this is the format of the note that is attached to the "Cond_" wave |
|---|
| 283 | // String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf,Cell=asdf," |
|---|
| 284 | // the "Cell" value was filled in when the Condition was created |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | // Put the average values into the wave note and display on the panel |
|---|
| 288 | noteStr = note(w) |
|---|
| 289 | noteStr = ReplaceNumberByKey("P_sm_f", noteStr, PsmPf ,"=", ",", 0) |
|---|
| 290 | noteStr = ReplaceNumberByKey("P_sm", noteStr, Psm ,"=", ",", 0) |
|---|
| 291 | noteStr = ReplaceNumberByKey("err_P_sm_f", noteStr, err_PsmPf ,"=", ",", 0) |
|---|
| 292 | noteStr = ReplaceNumberByKey("err_P_sm", noteStr, err_Psm ,"=", ",", 0) |
|---|
| 293 | |
|---|
| 294 | // replace the string |
|---|
| 295 | Note/K w |
|---|
| 296 | Note w, noteStr |
|---|
| 297 | |
|---|
| 298 | //update the global values for display |
|---|
| 299 | SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 300 | SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 301 | sprintf gPsmPf, "%g +/- %g",PsmPf,err_PsmPf |
|---|
| 302 | sprintf gPsm, "%g +/- %g",Psm,err_Psm |
|---|
| 303 | |
|---|
| 304 | break |
|---|
| 305 | case -1: // control being killed |
|---|
| 306 | break |
|---|
| 307 | endswitch |
|---|
| 308 | |
|---|
| 309 | return 0 |
|---|
| 310 | End |
|---|
| 311 | |
|---|
| 312 | |
|---|
| [829] | 313 | // |
|---|
| [816] | 314 | // just recalculate everything, every time |
|---|
| 315 | // |
|---|
| [829] | 316 | // -- now that the cell name is entered, I need to try to catch errors where the cell decay parameters are not |
|---|
| 317 | // properly calculated -- right now, invalid cell names are caught, but valid cell names with no decay data |
|---|
| 318 | // behind them just calculate Inf for the polarization values. This is hopefull enough to catch someone's attention... |
|---|
| 319 | // |
|---|
| [816] | 320 | Function FlipperAverageButtonProc(ba) : ButtonControl |
|---|
| 321 | STRUCT WMButtonAction &ba |
|---|
| 322 | |
|---|
| 323 | Variable selRow,err=0 |
|---|
| 324 | String fname, t0str, condStr,noteStr,t1Str,cellStr |
|---|
| 325 | |
|---|
| 326 | switch( ba.eventCode ) |
|---|
| 327 | case 2: // mouse up |
|---|
| 328 | // click code here |
|---|
| 329 | Variable cr1,cr2,cr3,cr4,cr5,err_cr1,err_cr2,err_cr3,err_cr4,err_cr5 |
|---|
| 330 | Variable PsmPf, err_PsmPf, Psm, err_Psm |
|---|
| 331 | |
|---|
| 332 | ControlInfo/W=FlipperPanel popup_0 |
|---|
| 333 | condStr = S_Value |
|---|
| 334 | WAVE w=$("root:Packages:NIST:Polarization:Cells:"+condStr) //the one that is displayed |
|---|
| 335 | WAVE calc=$("root:Packages:NIST:Polarization:Cells:CondCalc_"+condStr[5,strlen(condStr)-1]) //the one that holds results |
|---|
| [829] | 336 | WAVE/T CellW=$("root:Packages:NIST:Polarization:Cells:CondCell_"+condStr[5,strlen(condStr)-1]) //the textW with cell name |
|---|
| [816] | 337 | |
|---|
| 338 | Variable numRows,ncalc,diff |
|---|
| 339 | numRows = DimSize(w,0) //rows in the displayed table |
|---|
| 340 | ncalc = DimSize(calc,0) |
|---|
| 341 | |
|---|
| 342 | // add rows to the ConcCalc_ matrix as needed |
|---|
| 343 | if(numRows != ncalc) |
|---|
| 344 | if(ncalc > numRows) |
|---|
| [829] | 345 | DoAlert 0,"The CondCalc_ is larger than displayed. Seek help." |
|---|
| [816] | 346 | err = 1 |
|---|
| 347 | return(err) |
|---|
| 348 | else |
|---|
| 349 | diff = numRows - ncalc |
|---|
| 350 | InsertPoints/M=0 ncalc, diff, calc |
|---|
| 351 | endif |
|---|
| 352 | endif |
|---|
| 353 | |
|---|
| [829] | 354 | // noteStr=note(w) |
|---|
| 355 | // cellStr = StringByKey("Cell", noteStr, "=", ",", 0) |
|---|
| 356 | // Wave decay = $("root:Packages:NIST:Polarization:Cells:Decay_"+cellStr) |
|---|
| 357 | // noteStr=note(decay) |
|---|
| 358 | // t0Str = StringByKey("T0", noteStr, "=", ",", 0) |
|---|
| [816] | 359 | // Print "CellStr, T0 = ",cellStr, t0Str |
|---|
| 360 | |
|---|
| [829] | 361 | Variable sum_PsmPf, err_sum_PsmPf, sum_Psm, err_sum_Psm,nRowsIncluded=0 |
|---|
| [816] | 362 | sum_PsmPf = 0 |
|---|
| 363 | err_sum_PsmPf = 0 |
|---|
| 364 | sum_Psm = 0 |
|---|
| 365 | err_sum_Psm = 0 |
|---|
| 366 | |
|---|
| 367 | for(selRow=0;selRow<numRows;selRow+=1) |
|---|
| 368 | Print "calculate the row ",selRow |
|---|
| 369 | |
|---|
| [829] | 370 | //include this row of data? |
|---|
| 371 | if(w[selRow][%Include] == 1) |
|---|
| 372 | nRowsIncluded += 1 |
|---|
| 373 | |
|---|
| 374 | // now the cell depends on the row |
|---|
| 375 | cellStr = CellW[selRow] |
|---|
| 376 | Wave/Z decay = $("root:Packages:NIST:Polarization:Cells:Decay_"+cellStr) |
|---|
| 377 | if(WaveExists(decay) == 0) // catch gross errors |
|---|
| 378 | Abort "The cell "+cellStr+" in row "+num2str(selRow)+" does not exist" |
|---|
| 379 | endif |
|---|
| 380 | noteStr=note(decay) |
|---|
| 381 | t0Str = StringByKey("T0", noteStr, "=", ",", 0) |
|---|
| [816] | 382 | |
|---|
| [829] | 383 | // parse the rows, report errors (there, not here), exit if any found |
|---|
| 384 | err = ParseFlipperRow(w,selRow) |
|---|
| 385 | if(err) |
|---|
| 386 | return 0 |
|---|
| 387 | endif |
|---|
| 388 | |
|---|
| 389 | // do the calculations: |
|---|
| 390 | |
|---|
| 391 | Print "The Blocked CR is not rescaled to zero attenuators" |
|---|
| 392 | cr1 = TotalCR_FromRun(w[selRow][%UU_Trans],err_cr1,0) |
|---|
| 393 | cr2 = TotalCR_FromRun(w[selRow][%DU_Trans],err_cr2,0) |
|---|
| 394 | cr3 = TotalCR_FromRun(w[selRow][%DD_Trans],err_cr3,0) |
|---|
| 395 | cr4 = TotalCR_FromRun(w[selRow][%UD_Trans],err_cr4,0) |
|---|
| [832] | 396 | // cr5 = TotalCR_FromRun(w[selRow][%Blocked],err_cr5,1) //blocked beam is NOT normalized to zero attenuators |
|---|
| 397 | cr5 = TotalCR_FromRun(w[selRow][%Blocked],err_cr5,0) //blocked beam is NOT normalized to zero attenuators |
|---|
| [816] | 398 | |
|---|
| [829] | 399 | calc[selRow][%cr_UU] = cr1 |
|---|
| 400 | calc[selRow][%cr_DU] = cr2 |
|---|
| 401 | calc[selRow][%cr_DD] = cr3 |
|---|
| 402 | calc[selRow][%cr_UD] = cr4 |
|---|
| 403 | calc[selRow][%cr_Blocked] = cr5 |
|---|
| 404 | calc[selRow][%err_cr_UU] = err_cr1 |
|---|
| 405 | calc[selRow][%err_cr_DU] = err_cr2 |
|---|
| 406 | calc[selRow][%err_cr_DD] = err_cr3 |
|---|
| 407 | calc[selRow][%err_cr_UD] = err_cr4 |
|---|
| 408 | calc[selRow][%err_cr_Blocked] = err_cr5 |
|---|
| 409 | |
|---|
| 410 | // Calc PsmPf, and assign the values |
|---|
| 411 | PsmPf = Calc_PsmPf(w,calc,noteStr,selRow,err_PsmPf) |
|---|
| 412 | calc[selRow][%P_sm_f] = PsmPf |
|---|
| 413 | calc[selRow][%err_P_sm_f] = err_PsmPf |
|---|
| 414 | w[selRow][%Pol_SM_FL] = PsmPf |
|---|
| 415 | |
|---|
| 416 | // Calc Psm, and assign the values |
|---|
| 417 | Psm = Calc_Psm(w,calc,noteStr,selRow,err_Psm) |
|---|
| 418 | calc[selRow][%P_sm] = Psm |
|---|
| 419 | calc[selRow][%err_P_sm] = err_Psm |
|---|
| 420 | w[selRow][%Pol_SM] = Psm |
|---|
| 421 | |
|---|
| 422 | // running average of PsmPf and Psm |
|---|
| 423 | sum_PsmPf += PsmPf |
|---|
| 424 | err_sum_PsmPf += err_PsmPf^2 |
|---|
| 425 | sum_Psm += Psm |
|---|
| 426 | err_sum_Psm += err_Psm^2 |
|---|
| 427 | |
|---|
| 428 | endif |
|---|
| [816] | 429 | |
|---|
| 430 | endfor //loop over rows |
|---|
| 431 | |
|---|
| 432 | // now get a running average of muP, Po, and the errors |
|---|
| [829] | 433 | // use the actual number of rows included |
|---|
| 434 | PsmPf = sum_PsmPf/nRowsIncluded |
|---|
| 435 | Psm = sum_Psm/nRowsIncluded |
|---|
| 436 | err_PsmPf = sqrt(err_sum_PsmPf) / nRowsIncluded |
|---|
| 437 | err_Psm = sqrt(err_sum_Psm) / nRowsIncluded |
|---|
| [816] | 438 | |
|---|
| 439 | // this is the format of the note that is attached to the "Cond_" wave |
|---|
| [829] | 440 | // String testStr = "P_sm_f=2,err_P_sm_f=0,P_sm=0.6,err_P_sm=0,T0=asdf," |
|---|
| 441 | // the "Cell" value is not longer used |
|---|
| [816] | 442 | |
|---|
| 443 | |
|---|
| 444 | // Put the average values into the wave note and display on the panel |
|---|
| 445 | noteStr = note(w) |
|---|
| 446 | noteStr = ReplaceNumberByKey("P_sm_f", noteStr, PsmPf ,"=", ",", 0) |
|---|
| 447 | noteStr = ReplaceNumberByKey("P_sm", noteStr, Psm ,"=", ",", 0) |
|---|
| 448 | noteStr = ReplaceNumberByKey("err_P_sm_f", noteStr, err_PsmPf ,"=", ",", 0) |
|---|
| 449 | noteStr = ReplaceNumberByKey("err_P_sm", noteStr, err_Psm ,"=", ",", 0) |
|---|
| 450 | |
|---|
| 451 | // replace the string |
|---|
| 452 | Note/K w |
|---|
| 453 | Note w, noteStr |
|---|
| 454 | |
|---|
| 455 | //update the global values for display |
|---|
| 456 | SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 457 | SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 458 | sprintf gPsmPf, "%g +/- %g",PsmPf,err_PsmPf |
|---|
| 459 | sprintf gPsm, "%g +/- %g",Psm,err_Psm |
|---|
| 460 | |
|---|
| 461 | break |
|---|
| 462 | case -1: // control being killed |
|---|
| 463 | break |
|---|
| 464 | endswitch |
|---|
| 465 | |
|---|
| 466 | return 0 |
|---|
| 467 | End |
|---|
| 468 | |
|---|
| 469 | // gCellKW passed in has gamma, muPo, etc. needed for PCell(t) calculation |
|---|
| 470 | // |
|---|
| 471 | // these are not the equations that Kaythrn gave to me, but rather |
|---|
| 472 | // equations 14 and 15 from the SS handout. These replacement equations |
|---|
| 473 | // are in terms of relative transmissions, so I can use count rates |
|---|
| 474 | // otherwise, I don't know how to calculate a transmission -- I don't know what |
|---|
| 475 | // the "empty beam" condition is... |
|---|
| 476 | // |
|---|
| 477 | // this is only using the measurement at t1 for the calculation! |
|---|
| 478 | // |
|---|
| 479 | Function Calc_PsmPf(w,calc,gCellKW,selRow,err_PsmPf) |
|---|
| 480 | WAVE w,calc |
|---|
| 481 | String gCellKW |
|---|
| 482 | Variable selRow,&err_PsmPf |
|---|
| 483 | |
|---|
| 484 | // DD is cr3, DU is cr2, Blocked is cr5 |
|---|
| 485 | String t0Str,t1Str,t2Str,fname |
|---|
| 486 | Variable PsmPf,t1,t2,PCell_t1,PCell_t2,err_PCell_t1,err_PCell_t2 |
|---|
| 487 | Variable muPo,err_muPo,gam,err_gam |
|---|
| 488 | Variable crDD, crDU,err_crDD,err_crDU,crBB, err_crBB |
|---|
| 489 | |
|---|
| 490 | t0Str = StringByKey("T0", gCellKW, "=", ",", 0) |
|---|
| 491 | muPo = NumberByKey("muP", gCellKW, "=", ",", 0) |
|---|
| 492 | err_muPo = NumberByKey("err_muP", gCellKW, "=", ",", 0) |
|---|
| 493 | gam = NumberByKey("gamma", gCellKW, "=", ",", 0) |
|---|
| 494 | err_gam = NumberByKey("err_gamma", gCellKW, "=", ",", 0) |
|---|
| 495 | |
|---|
| 496 | fname = FindFileFromRunNumber(w[selRow][%UU_Trans]) |
|---|
| 497 | t1str = getFileCreationDate(fname) |
|---|
| 498 | t1 = ElapsedHours(t0Str,t1Str) |
|---|
| 499 | |
|---|
| 500 | fname = FindFileFromRunNumber(w[selRow][%DU_Trans]) |
|---|
| 501 | t2str = getFileCreationDate(fname) |
|---|
| 502 | t2 = ElapsedHours(t0Str,t2Str) |
|---|
| 503 | |
|---|
| 504 | PCell_t1 = Calc_PCell_atT(muPo,err_muPo,gam,err_gam,t1,err_PCell_t1) |
|---|
| 505 | PCell_t2 = Calc_PCell_atT(muPo,err_muPo,gam,err_gam,t2,err_PCell_t2) |
|---|
| 506 | |
|---|
| 507 | // DD is cr3, DU is cr2, Blocked is cr5 |
|---|
| 508 | crDD = calc[selRow][%cr_DD] |
|---|
| 509 | crDU = calc[selRow][%cr_DU] |
|---|
| 510 | crBB = calc[selRow][%cr_Blocked] |
|---|
| 511 | err_crDD = calc[selRow][%err_cr_DD] |
|---|
| 512 | err_crDU = calc[selRow][%err_cr_DU] |
|---|
| 513 | err_crBB = calc[selRow][%err_cr_Blocked] |
|---|
| 514 | |
|---|
| 515 | // this really needs transmissions |
|---|
| 516 | // PsmPf = (crDD - crDU)/(PCell_t1 + PCell_t2) |
|---|
| 517 | |
|---|
| 518 | // eqn (15) from the SS handout |
|---|
| 519 | Variable tmp,dfdx |
|---|
| 520 | tmp = (crDD - crBB)/(crDU - crBB) |
|---|
| 521 | |
|---|
| 522 | PsmPf = (tmp - 1)/(Pcell_t1*(1+tmp)) |
|---|
| 523 | |
|---|
| 524 | dfdx = 1/(Pcell_t1*(1+tmp)) - (tmp-1)*Pcell_t1/(Pcell_t1^2*(1+tmp)^2) |
|---|
| 525 | |
|---|
| 526 | err_PsmPf = ( (tmp-1)/((1+tmp)*Pcell_t1^2) *err_Pcell_t1 )^2 |
|---|
| 527 | err_PsmPf += ( dfdx / (crDU-crBB) * err_crDD)^2 |
|---|
| 528 | err_PsmPf += ( dfdx*(crDD-crBB)/(crDU-crBB)^2 * err_crDU)^2 |
|---|
| 529 | err_PsmPf += ( dfdx*(-tmp/(crDD-crBB) + tmp/(crDU-crBB)) * err_crBB)^2 |
|---|
| 530 | |
|---|
| 531 | err_PsmPf = sqrt(err_PsmPf) |
|---|
| 532 | Printf "At t1=%g PsmPf = %g +/- %g (%g%)\r",t1,PsmPf,err_PsmPf,err_PsmPf/PsmPf*100 |
|---|
| 533 | |
|---|
| 534 | |
|---|
| 535 | return(PsmPf) |
|---|
| 536 | end |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | // gCellKW passed in has gamma, muPo, etc. needed for PCell(t) calculation |
|---|
| 540 | // |
|---|
| 541 | // these are not the equations that Kaythrn gave to me, but rather |
|---|
| 542 | // equations 14 and 15 from the SS handout. These replacement equations |
|---|
| 543 | // are in terms of relative transmissions, so I can use count rates |
|---|
| 544 | // otherwise, I don't know how to calculate a transmission -- I don't know what |
|---|
| 545 | // the "empty beam" condition is... |
|---|
| 546 | // |
|---|
| 547 | // this is only using the measurement at t1 for the calculation! |
|---|
| 548 | // |
|---|
| 549 | Function Calc_Psm(w,calc,gCellKW,selRow,err_Psm) |
|---|
| 550 | WAVE w,calc |
|---|
| 551 | String gCellKW |
|---|
| 552 | Variable selRow,&err_Psm |
|---|
| 553 | |
|---|
| 554 | // UU is cr1, UD is cr4, Blocked is cr5 |
|---|
| 555 | String t0Str,t1Str,t2Str,fname |
|---|
| 556 | Variable Psm,t1,t2,PCell_t1,PCell_t2,err_PCell_t1,err_PCell_t2 |
|---|
| 557 | Variable muPo,err_muPo,gam,err_gam |
|---|
| 558 | Variable crUU, crUD,err_crUU,err_crUD,crBB, err_crBB |
|---|
| 559 | |
|---|
| 560 | t0Str = StringByKey("T0", gCellKW, "=", ",", 0) |
|---|
| 561 | muPo = NumberByKey("muP", gCellKW, "=", ",", 0) |
|---|
| 562 | err_muPo = NumberByKey("err_muP", gCellKW, "=", ",", 0) |
|---|
| 563 | gam = NumberByKey("gamma", gCellKW, "=", ",", 0) |
|---|
| 564 | err_gam = NumberByKey("err_gamma", gCellKW, "=", ",", 0) |
|---|
| 565 | |
|---|
| 566 | fname = FindFileFromRunNumber(w[selRow][%UU_Trans]) |
|---|
| 567 | t1str = getFileCreationDate(fname) |
|---|
| 568 | t1 = ElapsedHours(t0Str,t1Str) |
|---|
| 569 | |
|---|
| 570 | fname = FindFileFromRunNumber(w[selRow][%DU_Trans]) |
|---|
| 571 | t2str = getFileCreationDate(fname) |
|---|
| 572 | t2 = ElapsedHours(t0Str,t2Str) |
|---|
| 573 | |
|---|
| 574 | PCell_t1 = Calc_PCell_atT(muPo,err_muPo,gam,err_gam,t1,err_PCell_t1) |
|---|
| 575 | PCell_t2 = Calc_PCell_atT(muPo,err_muPo,gam,err_gam,t2,err_PCell_t2) |
|---|
| 576 | |
|---|
| 577 | // UU is cr1, UD is cr4, Blocked is cr5 |
|---|
| 578 | crUU = calc[selRow][%cr_UU] |
|---|
| 579 | crUD = calc[selRow][%cr_UD] |
|---|
| 580 | crBB = calc[selRow][%cr_Blocked] |
|---|
| 581 | err_crUU = calc[selRow][%err_cr_UU] |
|---|
| 582 | err_crUD = calc[selRow][%err_cr_UD] |
|---|
| 583 | err_crBB = calc[selRow][%err_cr_Blocked] |
|---|
| 584 | |
|---|
| 585 | // this really needs transmissions |
|---|
| 586 | |
|---|
| 587 | // eqn (14) from the SS handout |
|---|
| 588 | Variable tmp,dfdx |
|---|
| 589 | tmp = (crUU - crBB)/(crUD - crBB) |
|---|
| 590 | |
|---|
| 591 | Psm = (tmp - 1)/(Pcell_t1*(1+tmp)) |
|---|
| 592 | |
|---|
| 593 | dfdx = 1/(Pcell_t1*(1+tmp)) - (tmp-1)*Pcell_t1/(Pcell_t1^2*(1+tmp)^2) |
|---|
| 594 | |
|---|
| 595 | err_Psm = ( (tmp-1)/((1+tmp)*Pcell_t1^2) *err_Pcell_t1 )^2 |
|---|
| 596 | err_Psm += ( dfdx / (crUD-crBB) * err_crUU)^2 |
|---|
| 597 | err_Psm += ( dfdx*(crUU-crBB)/(crUD-crBB)^2 * err_crUD)^2 |
|---|
| 598 | err_Psm += ( dfdx*(-tmp/(crUU-crBB) + tmp/(crUD-crBB)) * err_crBB)^2 |
|---|
| 599 | |
|---|
| 600 | err_Psm = sqrt(err_Psm) |
|---|
| 601 | Printf "At t1=%g Psm = %g +/- %g (%g%)\r",t1,Psm,err_Psm,err_Psm/Psm*100 |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | return(Psm) |
|---|
| 605 | end |
|---|
| 606 | |
|---|
| [836] | 607 | // |
|---|
| 608 | // calculate the (atomic) He polarization at some delta time |
|---|
| 609 | // |
|---|
| 610 | // t2 is in hours, gamma in hours |
|---|
| 611 | // |
|---|
| 612 | Function Calc_PHe_atT(Po,err_Po,gam,err_gam,t2,err_Pt) |
|---|
| 613 | Variable Po,err_Po,gam,err_gam,t2,&err_Pt |
|---|
| [816] | 614 | |
|---|
| 615 | |
|---|
| [836] | 616 | Variable Pt |
|---|
| 617 | |
|---|
| 618 | Pt = Po*exp(-t2/gam) |
|---|
| 619 | |
|---|
| 620 | Variable arg,tmp2 |
|---|
| 621 | // 2 terms, no error in t2 |
|---|
| 622 | err_Pt = Pt^2/Po^2*err_Po^2 + t2^2/gam^4*Pt^2*err_gam^2 |
|---|
| 623 | |
|---|
| 624 | err_Pt = sqrt(err_Pt) |
|---|
| 625 | |
|---|
| 626 | Printf "At (delta)t=%g P_He(t) = %g +/- %g (%g%)\r",t2,Pt,err_Pt,err_Pt/Pt*100 |
|---|
| 627 | |
|---|
| 628 | return(Pt) |
|---|
| 629 | End |
|---|
| 630 | |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | // |
|---|
| [816] | 634 | // t2 is in hours, muP0 is at t0 |
|---|
| 635 | // |
|---|
| 636 | Function Calc_PCell_atT(muPo,err_muPo,gam,err_gam,t2,err_PCell) |
|---|
| 637 | Variable muPo,err_muPo,gam,err_gam,t2,&err_PCell |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | Variable Pcell |
|---|
| 641 | |
|---|
| 642 | PCell = tanh(muPo * exp(-t2/gam)) |
|---|
| [836] | 643 | // PCell = (muPo * exp(-t2/gam)) |
|---|
| [816] | 644 | |
|---|
| 645 | Variable arg,tmp2 |
|---|
| 646 | arg = PCell |
|---|
| 647 | tmp2 = (1-tanh(arg)^2)^2 |
|---|
| 648 | err_PCell = tmp2 * (exp(-t2/gam) * err_muPo)^2 //dominant term (10x larger) |
|---|
| 649 | err_PCell += tmp2 * (arg*t2/gam/gam * err_gam)^2 |
|---|
| 650 | |
|---|
| 651 | err_PCell = sqrt(err_Pcell) |
|---|
| 652 | |
|---|
| 653 | Printf "At t=%g Pcell = %g +/- %g (%g%)\r",t2,Pcell,err_Pcell,err_Pcell/PCell*100 |
|---|
| 654 | |
|---|
| 655 | return(PCell) |
|---|
| 656 | End |
|---|
| 657 | |
|---|
| 658 | // bring up a table with the calculation results |
|---|
| 659 | Function ShowFlipperCalcButton(ba) : ButtonControl |
|---|
| 660 | STRUCT WMButtonAction &ba |
|---|
| 661 | |
|---|
| 662 | switch( ba.eventCode ) |
|---|
| 663 | case 2: // mouse up |
|---|
| 664 | // click code here |
|---|
| 665 | ControlInfo/W=FlipperPanel popup_0 |
|---|
| 666 | String condStr = S_Value |
|---|
| 667 | condStr = condStr[5,strlen(condStr)-1] // trim off "Calc_" from the beginning of the string |
|---|
| 668 | WAVE calc=$("root:Packages:NIST:Polarization:Cells:CondCalc_"+condStr) |
|---|
| 669 | edit calc.ld |
|---|
| 670 | |
|---|
| 671 | break |
|---|
| 672 | case -1: // control being killed |
|---|
| 673 | break |
|---|
| 674 | endswitch |
|---|
| 675 | |
|---|
| 676 | return 0 |
|---|
| 677 | End |
|---|
| 678 | |
|---|
| 679 | |
|---|
| 680 | |
|---|
| 681 | // clear just the row |
|---|
| 682 | // |
|---|
| 683 | Function ClearFlipperRowButton(ba) : ButtonControl |
|---|
| 684 | STRUCT WMButtonAction &ba |
|---|
| 685 | |
|---|
| 686 | String popStr="" |
|---|
| 687 | Variable selRow |
|---|
| 688 | |
|---|
| 689 | switch( ba.eventCode ) |
|---|
| 690 | case 2: // mouse up |
|---|
| 691 | // click code here |
|---|
| 692 | DoAlert 1,"Clear the selected row?" |
|---|
| 693 | if(V_flag !=1) |
|---|
| 694 | return(0) |
|---|
| 695 | endif |
|---|
| 696 | |
|---|
| 697 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 698 | |
|---|
| 699 | ControlInfo/W=FlipperPanel popup_0 |
|---|
| 700 | popStr = S_Value |
|---|
| [829] | 701 | popStr = StringFromList(1,S_Value,"_") //pop is "Cond_<condition>", so get list item 1 |
|---|
| [816] | 702 | |
|---|
| [829] | 703 | Wave cond = $("Cond_"+popStr) |
|---|
| 704 | Wave calc = $("CondCalc_"+popStr) |
|---|
| 705 | Wave/T cellW = $("CondCell_"+popStr) |
|---|
| 706 | |
|---|
| [816] | 707 | // Delete just those points |
|---|
| 708 | |
|---|
| 709 | GetSelection table, FlipperPanel#T0, 1 |
|---|
| 710 | selRow = V_startRow |
|---|
| [829] | 711 | DeletePoints selRow,1,cond,calc,cellW |
|---|
| [816] | 712 | |
|---|
| 713 | // clear the graph and the results |
|---|
| [829] | 714 | SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 715 | SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 716 | gPsm = "0" |
|---|
| 717 | gPsmPf = "0" |
|---|
| [816] | 718 | |
|---|
| 719 | SetDataFolder root: |
|---|
| 720 | break |
|---|
| 721 | case -1: // control being killed |
|---|
| 722 | break |
|---|
| 723 | endswitch |
|---|
| 724 | |
|---|
| 725 | return 0 |
|---|
| 726 | End |
|---|
| 727 | |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | // for this, do I want to clear everything, or just a selected row?? |
|---|
| 731 | // |
|---|
| 732 | // |
|---|
| 733 | Function ClearAllFlipperWavesButton(ba) : ButtonControl |
|---|
| 734 | STRUCT WMButtonAction &ba |
|---|
| 735 | |
|---|
| 736 | String popStr="" |
|---|
| 737 | |
|---|
| 738 | switch( ba.eventCode ) |
|---|
| 739 | case 2: // mouse up |
|---|
| 740 | // click code here |
|---|
| [829] | 741 | DoAlert 1,"Clear all of the flipper waves for the selected cell?" |
|---|
| [816] | 742 | if(V_flag !=1) |
|---|
| 743 | return(0) |
|---|
| 744 | endif |
|---|
| 745 | |
|---|
| 746 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 747 | |
|---|
| 748 | ControlInfo/W=FlipperPanel popup_0 |
|---|
| [829] | 749 | popStr = StringFromList(1,S_Value,"_") //pop is "Cond_<condition>", so get list item 1 |
|---|
| [816] | 750 | |
|---|
| [829] | 751 | Wave cond = $("Cond_"+popStr) |
|---|
| 752 | Wave calc = $("CondCalc_"+popStr) |
|---|
| 753 | Wave/T cellW = $("CondCell_"+popStr) |
|---|
| [816] | 754 | |
|---|
| [829] | 755 | // re-initialize the flipper waves, so it appears as a blank, initialized table |
|---|
| [816] | 756 | |
|---|
| 757 | MakeFlipperResultWaves(popStr) |
|---|
| [829] | 758 | cond = 0 |
|---|
| [816] | 759 | calc = 0 |
|---|
| [829] | 760 | cellW = "" |
|---|
| 761 | cond[0][7] = 1 //default to include the point |
|---|
| 762 | |
|---|
| [816] | 763 | // clear the graph and the results? |
|---|
| 764 | |
|---|
| 765 | |
|---|
| [829] | 766 | SVAR gPsm = root:Packages:NIST:Polarization:Cells:gPsm |
|---|
| 767 | SVAR gPsmPf = root:Packages:NIST:Polarization:Cells:gPsmPf |
|---|
| 768 | gPsm = "0" |
|---|
| 769 | gPsmPf = "0" |
|---|
| [816] | 770 | |
|---|
| 771 | SetDataFolder root: |
|---|
| 772 | break |
|---|
| 773 | case -1: // control being killed |
|---|
| 774 | break |
|---|
| 775 | endswitch |
|---|
| 776 | |
|---|
| 777 | return 0 |
|---|
| 778 | End |
|---|
| 779 | |
|---|
| 780 | |
|---|
| 781 | Function FlipperHelpParButtonProc(ba) : ButtonControl |
|---|
| 782 | STRUCT WMButtonAction &ba |
|---|
| 783 | |
|---|
| 784 | switch( ba.eventCode ) |
|---|
| 785 | case 2: // mouse up |
|---|
| 786 | // click code here |
|---|
| [836] | 787 | DisplayHelpTopic/Z/K=1 "Flipper States Panel" |
|---|
| 788 | if(V_flag !=0) |
|---|
| 789 | DoAlert 0,"The Flipper States Panel Help file could not be found" |
|---|
| 790 | endif |
|---|
| [816] | 791 | break |
|---|
| 792 | case -1: // control being killed |
|---|
| 793 | break |
|---|
| 794 | endswitch |
|---|
| 795 | |
|---|
| 796 | return 0 |
|---|
| 797 | End |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | |
|---|
| 801 | // null condition is not right. if the loop fails, then the |
|---|
| 802 | // retStr will be ";;;;", not zero length. What's the proper test? |
|---|
| 803 | // Does it matter? the list of default gCell_sss should already be there. |
|---|
| 804 | // |
|---|
| 805 | Function/S D_ConditionNameList() |
|---|
| 806 | |
|---|
| 807 | String listStr="" |
|---|
| 808 | |
|---|
| 809 | SetDataFolder root:Packages:NIST:Polarization:Cells |
|---|
| 810 | |
|---|
| 811 | // get a list of the Condition waves |
|---|
| 812 | listStr=WaveList("Cond_*",";","") |
|---|
| 813 | // print listStr |
|---|
| 814 | |
|---|
| 815 | if(strlen(listStr) == 0) |
|---|
| 816 | listStr = "no conditions defined;" |
|---|
| 817 | endif |
|---|
| 818 | |
|---|
| 819 | SetDataFolder root: |
|---|
| 820 | return(listStr) |
|---|
| 821 | End |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | // parse the row to be sure that: |
|---|
| 825 | // |
|---|
| 826 | // - files are valid numbers |
|---|
| 827 | // - files are all at same SDD |
|---|
| 828 | // - files are all with same attenuation (just print a warning to cmd) |
|---|
| 829 | // - files all use the same cell |
|---|
| 830 | // - files are all within 20 minutes of each other |
|---|
| 831 | // |
|---|
| 832 | // |
|---|
| 833 | // SetDimLabel 1,0,UU_Trans,cond |
|---|
| 834 | // SetDimLabel 1,1,DU_Trans,cond |
|---|
| 835 | // SetDimLabel 1,2,DD_Trans,cond |
|---|
| 836 | // SetDimLabel 1,3,UD_Trans,cond |
|---|
| 837 | // SetDimLabel 1,4,Blocked,cond |
|---|
| 838 | // SetDimLabel 1,5,Pol_SM_FL,cond |
|---|
| 839 | // SetDimLabel 1,6,Pol_SM,cond //for a mask wave, non-zero is used in the fit |
|---|
| 840 | // SetDimLabel 1,7,Include,cond |
|---|
| 841 | // |
|---|
| 842 | // There are 5 separate files now |
|---|
| 843 | // |
|---|
| 844 | Function ParseFlipperRow(w,selRow) |
|---|
| 845 | Wave w |
|---|
| 846 | Variable selRow |
|---|
| 847 | |
|---|
| 848 | Variable err=0 |
|---|
| 849 | Variable atten1,atten2,atten3,atten4,atten5 |
|---|
| 850 | Variable sdd1,sdd2,sdd3,sdd4,sdd5 |
|---|
| 851 | Variable t1,t2,t3,t4,t5 |
|---|
| 852 | String cell1,cell2,cell3,cell4,cell5 |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | String fname="" |
|---|
| 856 | |
|---|
| 857 | |
|---|
| 858 | // are all file numbers valid? |
|---|
| 859 | fname = FindFileFromRunNumber(w[selRow][%UU_Trans]) |
|---|
| 860 | if(cmpstr(fname,"")==0) |
|---|
| 861 | DoAlert 0,"UU_Trans run "+num2str(w[selRow][%UU_Trans])+" is not a valid run number" |
|---|
| 862 | err = 1 |
|---|
| 863 | else |
|---|
| 864 | atten1 = getAttenNumber(fname) |
|---|
| 865 | sdd1 = getSDD(fname) |
|---|
| 866 | endif |
|---|
| 867 | |
|---|
| 868 | fname = FindFileFromRunNumber(w[selRow][%DU_Trans]) |
|---|
| 869 | if(cmpstr(fname,"")==0) |
|---|
| 870 | DoAlert 0,"DU_Trans run "+num2str(w[selRow][%DU_Trans])+" is not a valid run number" |
|---|
| 871 | err = 1 |
|---|
| 872 | else |
|---|
| 873 | atten2 = getAttenNumber(fname) |
|---|
| 874 | sdd2 = getSDD(fname) |
|---|
| 875 | endif |
|---|
| 876 | |
|---|
| 877 | fname = FindFileFromRunNumber(w[selRow][%DD_Trans]) |
|---|
| 878 | if(cmpstr(fname,"")==0) |
|---|
| 879 | DoAlert 0,"DD_Trans run "+num2str(w[selRow][%DD_Trans])+" is not a valid run number" |
|---|
| 880 | err = 1 |
|---|
| 881 | else |
|---|
| 882 | atten3 = getAttenNumber(fname) |
|---|
| 883 | sdd3 = getSDD(fname) |
|---|
| 884 | endif |
|---|
| 885 | |
|---|
| 886 | fname = FindFileFromRunNumber(w[selRow][%UD_Trans]) |
|---|
| 887 | if(cmpstr(fname,"")==0) |
|---|
| 888 | DoAlert 0,"UD_Trans run "+num2str(w[selRow][%UD_Trans])+" is not a valid run number" |
|---|
| 889 | err = 1 |
|---|
| 890 | else |
|---|
| 891 | atten4 = getAttenNumber(fname) |
|---|
| 892 | sdd4 = getSDD(fname) |
|---|
| 893 | endif |
|---|
| 894 | |
|---|
| 895 | fname = FindFileFromRunNumber(w[selRow][%Blocked]) |
|---|
| 896 | if(cmpstr(fname,"")==0) |
|---|
| 897 | DoAlert 0,"Blocked run "+num2str(w[selRow][%Blocked])+" is not a valid run number" |
|---|
| 898 | err = 1 |
|---|
| 899 | else |
|---|
| 900 | atten5 = getAttenNumber(fname) |
|---|
| 901 | sdd5 = getSDD(fname) |
|---|
| 902 | endif |
|---|
| 903 | |
|---|
| 904 | |
|---|
| 905 | |
|---|
| 906 | // do a check of the elapsed time from start to finish |
|---|
| 907 | |
|---|
| 908 | |
|---|
| 909 | |
|---|
| 910 | |
|---|
| 911 | if( (sdd1 != sdd2) || (sdd2 != sdd3) || (sdd1 != sdd3) ) |
|---|
| 912 | DoAlert 0,"Files in row "+num2str(selRow)+" are not all at the same detector distance" |
|---|
| 913 | err = 1 |
|---|
| 914 | endif |
|---|
| 915 | |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | |
|---|
| 920 | if( (atten1 != atten2) || (atten2 != atten3) || (atten1 != atten3) ) |
|---|
| 921 | DoAlert 0,"Files in row "+num2str(selRow)+" are not all collected with the same attenuation. Just so you know." |
|---|
| 922 | err = 0 |
|---|
| 923 | endif |
|---|
| 924 | |
|---|
| 925 | return(err) |
|---|
| 926 | end |
|---|
| 927 | |
|---|
| 928 | |
|---|
| 929 | //////////////////////////////////////////// |
|---|