[1025] | 1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
| 2 | #pragma version=5.0 |
---|
| 3 | #pragma IgorVersion=6.1 |
---|
| 4 | |
---|
| 5 | //************************ |
---|
[1036] | 6 | |
---|
[1025] | 7 | // |
---|
| 8 | //************************* |
---|
| 9 | ////////////////////////////////// |
---|
| 10 | // |
---|
| 11 | // KEYWORD=<value> lists used in protocol definitions |
---|
| 12 | // |
---|
| 13 | // KEYWORDS are ALWAYS capitalized, and yes, it does matter |
---|
| 14 | // |
---|
| 15 | // for ABSOLUTE parameters |
---|
| 16 | // (4) possible keywords, all with numerical values |
---|
| 17 | // TSTAND=value transmission of the standard |
---|
| 18 | // DSTAND=value thickness of the standard, in centimeters |
---|
| 19 | // IZERO=value I(q=0) value for the standard, in normalized neutron counts |
---|
| 20 | // XSECT=value calibrated cross-section of the standard sample |
---|
| 21 | // |
---|
| 22 | // For calibration with a transmission file, set TSTAND, DSTAND, and XSECT to 1.0 |
---|
| 23 | // and set IZERO to KAPPA (defined in Tania's handout, or in documentation of MRED_KAP on VAX) |
---|
| 24 | // |
---|
| 25 | // |
---|
| 26 | // For AVERAGE and for DRAWING |
---|
| 27 | // DRAWING routines only use a subset of the total list, since saving, naming, etc. don't apply |
---|
| 28 | // (10) possible keywords, some numerical, some string values |
---|
| 29 | // AVTYPE=string string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic;Sector_PlusMinus;} |
---|
| 30 | // PHI=value azimuthal angle (-90,90) |
---|
| 31 | // DPHI=value +/- angular range around phi for average |
---|
| 32 | // WIDTH=value total width of rectangular section, in pixels |
---|
| 33 | // SIDE=string string from set {left,right,both} **note NOT capitalized |
---|
[1057] | 34 | |
---|
[1025] | 35 | // QCENTER=value q-value (1/A) of center of annulus for annular average |
---|
[1057] | 36 | // QDELTA=value (+/-) width of annulus centered at QCENTER, in units of q |
---|
| 37 | // DETGROUP=value string with "F" or "M" to name the detector group where the annulus lies. |
---|
| 38 | |
---|
[1025] | 39 | // PLOT=string string from set {Yes,No} = truth of generating plot of averaged data |
---|
[1036] | 40 | // SAVE=string string from set {Yes,No} = truth of saving averaged data to disk, now with "Concatenate" or "Individual" |
---|
[1025] | 41 | // NAME=string string from set {Auto,Manual} = Automatic name generation or Manual(dialog) |
---|
| 42 | // |
---|
| 43 | // |
---|
[1036] | 44 | // BINTYPE=string (VSANS binning type) "One;Two;Four;Slit Mode;", as defined by ksBinTypeStr |
---|
| 45 | // |
---|
| 46 | // |
---|
[1025] | 47 | // For work.DRK usage: |
---|
[1036] | 48 | // **the list is COMMA delimited, separator is = |
---|
[1025] | 49 | // DRK=none,DRKMODE=0, |
---|
| 50 | // DRK=name is the name of the file, must be a full name, expected to be raw data |
---|
| 51 | // DRKMODE=value is a numeric value (0 or 10 to add to the Correct(mode) switch (unused?) |
---|
| 52 | // |
---|
| 53 | ////////////////////////////////// |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | //main entry procedure for initialzing and displaying the protocol panel |
---|
| 57 | // initilaizes folders and globals as needed |
---|
| 58 | // |
---|
| 59 | Proc V_ReductionProtocolPanel() |
---|
| 60 | DoWindow/F V_ProtocolPanel |
---|
| 61 | if(V_flag==0) |
---|
| 62 | V_InitProtocolPanel() |
---|
| 63 | V_ProtocolPanel() |
---|
| 64 | Endif |
---|
| 65 | End |
---|
| 66 | |
---|
| 67 | //initialization procedure for the protocol panel |
---|
| 68 | //note that :gAbsStr is also shared (common global) to that used in |
---|
| 69 | //the questionnare form of the protcol (see protocol.ipf) |
---|
| 70 | // |
---|
| 71 | Proc V_InitProtocolPanel() |
---|
| 72 | |
---|
[1051] | 73 | if(exists(" root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames") == 0) |
---|
| 74 | Abort "You must generate a file catalog before building protocols" |
---|
| 75 | endif |
---|
| 76 | |
---|
[1025] | 77 | //set up the global variables needed for the protocol panel |
---|
| 78 | //global strings to put in a temporary protocol textwave |
---|
[1040] | 79 | Variable ii=0 |
---|
[1025] | 80 | String waveStr="tempProtocol" |
---|
| 81 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
[1040] | 82 | Make/O/T/N=(kNumProtocolSteps) $"root:Packages:NIST:VSANS:Globals:Protocols:tempProtocol" = "" |
---|
[1025] | 83 | |
---|
| 84 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gSAM="ask" |
---|
| 85 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD="ask" |
---|
| 86 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP="ask" |
---|
| 87 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV="ask" |
---|
| 88 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK="ask" |
---|
| 89 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="ask" |
---|
[1040] | 90 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE="AVTYPE=Circular;SAVE=Yes - Concatenate;NAME=Auto;PLOT=No;BINTYPE=One;" |
---|
[1025] | 91 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK="DRK=none,DRKMODE=0," |
---|
| 92 | |
---|
[1040] | 93 | // global strings for trimming data are initialized in the main VSANS initilization |
---|
| 94 | // in case the trimming is done before the protocol panel is opened |
---|
| 95 | |
---|
[1025] | 96 | SetDataFolder root: |
---|
| 97 | |
---|
| 98 | End |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | //button procedure to reset the panel seletctions/checks...etc... |
---|
| 102 | //to reflect the choices in a previously saved protocol |
---|
| 103 | // - parses through the protocol and resets the appropriate global strings and |
---|
| 104 | //updates the panel display |
---|
| 105 | // |
---|
| 106 | Function V_RecallProtocolButton(ctrlName) : ButtonControl |
---|
| 107 | String ctrlName |
---|
| 108 | |
---|
| 109 | //will reset panel values based on a previously saved protocol |
---|
| 110 | //pick a protocol wave from the Protocols folder |
---|
| 111 | //MUST move to Protocols folder to get wavelist |
---|
| 112 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 113 | Execute "V_PickAProtocol()" |
---|
| 114 | |
---|
| 115 | //get the selected protocol wave choice through a global string variable |
---|
| 116 | SVAR protocolName = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr |
---|
| 117 | |
---|
| 118 | //If "CreateNew" was selected, ask user to try again |
---|
| 119 | if(cmpstr("CreateNew",protocolName) == 0) |
---|
| 120 | Abort "CreateNew is for making a new Protocol. Select a previously saved Protocol" |
---|
| 121 | Endif |
---|
| 122 | |
---|
| 123 | //reset the panel based on the protocol textwave (currently a string) |
---|
| 124 | V_ResetToSavedProtocol(protocolName) |
---|
| 125 | |
---|
| 126 | SetDataFolder root: |
---|
| 127 | return(0) |
---|
| 128 | End |
---|
| 129 | |
---|
| 130 | //deletes the selected protocol from the list and from memory |
---|
| 131 | // |
---|
| 132 | Function V_DeleteProtocolButton(ctrlName) : ButtonControl |
---|
| 133 | String ctrlName |
---|
| 134 | |
---|
| 135 | //put up a list of protocols and pick one |
---|
| 136 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 137 | // Execute "DeleteAProtocol()" |
---|
| 138 | String Protocol="" |
---|
| 139 | Prompt Protocol "Delete A Protocol",popup, V_DeletableProtocols() |
---|
| 140 | DoPrompt "Select protocol to delete",protocol |
---|
| 141 | If(V_flag==1) |
---|
| 142 | return(0) |
---|
| 143 | endif |
---|
| 144 | |
---|
| 145 | //If "CreateNew, Base, DoAll, or tempProtocol" was selected, do nothing |
---|
| 146 | strswitch(protocol) |
---|
| 147 | case "CreateNew": |
---|
| 148 | break |
---|
| 149 | case "DoAll": |
---|
| 150 | break |
---|
| 151 | case "Base": |
---|
| 152 | break |
---|
| 153 | case "tempProtocol": |
---|
| 154 | break |
---|
| 155 | default: |
---|
| 156 | //delete the protocol |
---|
| 157 | KillWaves/Z $protocol |
---|
| 158 | endswitch |
---|
| 159 | |
---|
| 160 | SetDataFolder root: |
---|
| 161 | return(0) |
---|
| 162 | End |
---|
| 163 | |
---|
[1040] | 164 | // |
---|
[1025] | 165 | //function that actually parses the protocol specified by nameStr |
---|
| 166 | //which is just the name of the wave, without a datafolder path |
---|
| 167 | // |
---|
[1040] | 168 | // TODO |
---|
| 169 | // -- update this for 12 steps |
---|
| 170 | // |
---|
[1025] | 171 | Function V_ResetToSavedProtocol(nameStr) |
---|
| 172 | String nameStr |
---|
| 173 | |
---|
| 174 | //allow special cases of Base and DoAll Protocols to be recalled to panel - since they "ask" |
---|
| 175 | //and don't need paths |
---|
| 176 | |
---|
| 177 | String catPathStr |
---|
| 178 | PathInfo catPathName |
---|
| 179 | catPathStr=S_path |
---|
| 180 | |
---|
| 181 | //SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols //on windows, data folder seems to get reset (erratically) to root: |
---|
| 182 | Wave/T w=$("root:Packages:NIST:VSANS:Globals:Protocols:" + nameStr) |
---|
| 183 | |
---|
| 184 | String fullPath="",comma=",",list="",nameList="",PathStr="",item="" |
---|
| 185 | Variable ii=0,numItems,checked,specialProtocol |
---|
| 186 | |
---|
| 187 | if((cmpstr(nameStr,"Base")==0) || (cmpstr(nameStr,"DoAll")==0)) |
---|
| 188 | specialProtocol = 1 |
---|
| 189 | else |
---|
| 190 | specialProtocol = 0 |
---|
| 191 | Endif |
---|
| 192 | |
---|
| 193 | //background |
---|
| 194 | checked = 1 |
---|
| 195 | nameList = w[0] |
---|
| 196 | If(cmpstr(nameList,"none") ==0) |
---|
| 197 | checked = 0 |
---|
| 198 | Endif |
---|
| 199 | |
---|
| 200 | //set the global string to display and checkbox |
---|
| 201 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD = nameList |
---|
| 202 | CheckBox prot_check win=V_ProtocolPanel,value=checked |
---|
| 203 | |
---|
| 204 | //empty |
---|
| 205 | checked = 1 |
---|
| 206 | nameList = w[1] |
---|
| 207 | If(cmpstr(nameList,"none") ==0) |
---|
| 208 | checked = 0 |
---|
| 209 | Endif |
---|
| 210 | |
---|
| 211 | //set the global string to display and checkbox |
---|
| 212 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP = nameList |
---|
| 213 | CheckBox prot_check_1 win=V_ProtocolPanel,value=checked |
---|
| 214 | |
---|
| 215 | //DIV file |
---|
| 216 | checked = 1 |
---|
| 217 | nameList = w[2] |
---|
| 218 | If(cmpstr(nameList,"none") ==0) |
---|
| 219 | checked = 0 |
---|
| 220 | Endif |
---|
| 221 | |
---|
| 222 | //set the global string to display and checkbox |
---|
| 223 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV = nameList |
---|
| 224 | CheckBox prot_check_2 win=V_ProtocolPanel,value=checked |
---|
| 225 | |
---|
| 226 | //Mask file |
---|
| 227 | checked = 1 |
---|
| 228 | nameList = w[3] |
---|
| 229 | If(cmpstr(nameList,"none") ==0) |
---|
| 230 | checked = 0 |
---|
| 231 | Endif |
---|
| 232 | |
---|
| 233 | //set the global string to display and checkbox |
---|
| 234 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK = nameList |
---|
| 235 | CheckBox prot_check_3 win=V_ProtocolPanel,value=checked |
---|
| 236 | |
---|
| 237 | //4 = abs parameters |
---|
| 238 | list = w[4] |
---|
| 239 | numItems = ItemsInList(list,";") |
---|
| 240 | checked = 1 |
---|
| 241 | if(numitems == 4 || numitems == 5) //allow for protocols with no SDEV list item |
---|
| 242 | //correct number of parameters, assume ok |
---|
| 243 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = list |
---|
| 244 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
| 245 | else |
---|
| 246 | item = StringFromList(0,list,";") |
---|
| 247 | if(cmpstr(item,"none")==0) |
---|
| 248 | checked = 0 |
---|
| 249 | list = "none" |
---|
| 250 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = list |
---|
| 251 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
| 252 | else |
---|
| 253 | //force to "ask" |
---|
| 254 | checked = 1 |
---|
| 255 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "ask" |
---|
| 256 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
| 257 | Endif |
---|
| 258 | Endif |
---|
| 259 | |
---|
| 260 | //5 = averaging choices |
---|
| 261 | list = w[5] |
---|
| 262 | item = StringByKey("AVTYPE",list,"=",";") |
---|
| 263 | if(cmpstr(item,"none") == 0) |
---|
| 264 | checked = 0 |
---|
| 265 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = "none" |
---|
| 266 | CheckBox prot_check_5 win=V_ProtocolPanel,value=checked |
---|
| 267 | else |
---|
| 268 | checked = 1 |
---|
| 269 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = list |
---|
| 270 | CheckBox prot_check_5 win=V_ProtocolPanel,value=checked |
---|
| 271 | Endif |
---|
| 272 | |
---|
| 273 | // //6 = DRK choice |
---|
| 274 | // list = w[6] |
---|
| 275 | // item = StringByKey("DRK",list,"=",",") |
---|
| 276 | // //print list,item |
---|
| 277 | // if(cmpstr(item,"none") == 0) |
---|
| 278 | // checked = 0 |
---|
| 279 | // String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK = list |
---|
| 280 | // CheckBox prot_check_6 win=V_ProtocolPanel,value=checked |
---|
| 281 | // else |
---|
| 282 | // checked = 1 |
---|
| 283 | // String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK = list |
---|
| 284 | // CheckBox prot_check_6 win=V_ProtocolPanel,value=checked |
---|
| 285 | // Endif |
---|
| 286 | |
---|
[1040] | 287 | //7 = beginning trim points |
---|
| 288 | SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
| 289 | gBegPtsStr = w[7] |
---|
| 290 | //8 = end trim points |
---|
| 291 | SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
| 292 | gEndPtsStr = w[8] |
---|
[1025] | 293 | |
---|
[1040] | 294 | //9 = unused |
---|
| 295 | //10 = unused |
---|
| 296 | //11 = unused |
---|
| 297 | |
---|
| 298 | |
---|
[1025] | 299 | //all has been reset, get out |
---|
| 300 | Return (0) |
---|
| 301 | End |
---|
| 302 | |
---|
| 303 | //button action procedure that simply closes the panel |
---|
| 304 | // |
---|
| 305 | Function V_DoneProtocolButton(ctrlName) : ButtonControl |
---|
| 306 | String ctrlName |
---|
| 307 | |
---|
| 308 | //will gracefully close and exit the protocol panel |
---|
| 309 | |
---|
| 310 | DoWindow/K V_ProtocolPanel |
---|
| 311 | End |
---|
| 312 | |
---|
| 313 | //button action procedure that saves the current choices on the panel |
---|
| 314 | //as a named protocol, for later recall |
---|
| 315 | //asks for a valid name, then creates a protocol from the panel choices |
---|
| 316 | //creates a wave, and sets the current protocol name to this new protocol |
---|
| 317 | // |
---|
| 318 | //now allows the user the choice to overwrite a protocol |
---|
| 319 | // |
---|
| 320 | Function V_SaveProtocolButton(ctrlName) : ButtonControl |
---|
| 321 | String ctrlName |
---|
| 322 | |
---|
| 323 | Variable notDone=1, newProto=1 |
---|
| 324 | //will prompt for protocol name, and save the protocol as a text wave |
---|
| 325 | //prompt for name of new protocol wave to save |
---|
| 326 | do |
---|
| 327 | Execute "V_AskForName()" |
---|
| 328 | SVAR newProtocol = root:Packages:NIST:VSANS:Globals:Protocols:gNewStr |
---|
| 329 | |
---|
| 330 | //make sure it's a valid IGOR name |
---|
| 331 | newProtocol = CleanupName(newProtocol,0) //strict naming convention |
---|
| 332 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr=newProtocol //reassign, if changed |
---|
| 333 | Print "newProtocol = ",newProtocol |
---|
| 334 | |
---|
| 335 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 336 | if(WaveExists( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) == 1) |
---|
| 337 | //wave already exists |
---|
| 338 | DoAlert 1,"That name is already in use. Do you wish to overwrite the existing protocol?" |
---|
| 339 | if(V_Flag==1) |
---|
| 340 | notDone = 0 |
---|
| 341 | newProto = 0 |
---|
| 342 | else |
---|
| 343 | notDone = 1 |
---|
| 344 | endif |
---|
| 345 | else |
---|
| 346 | //name is good |
---|
| 347 | notDone = 0 |
---|
| 348 | Endif |
---|
| 349 | while(notDone) |
---|
| 350 | |
---|
| 351 | //current data folder is root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 352 | if(newProto) |
---|
[1040] | 353 | Make/O/T/N=(kNumProtocolSteps) $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) |
---|
[1025] | 354 | Endif |
---|
| 355 | |
---|
| 356 | V_MakeProtocolFromPanel( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) |
---|
| 357 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtocol |
---|
| 358 | |
---|
| 359 | //the data folder WAS changed above, this must be reset to root: |
---|
| 360 | SetDatafolder root: |
---|
| 361 | End |
---|
| 362 | |
---|
| 363 | //function that does the guts of reading the panel controls and globals |
---|
| 364 | //to create the necessary text fields for a protocol |
---|
| 365 | //Wave/T w (input) is an empty text wave of 8 elements for the protocol |
---|
| 366 | //on output, w[] is filled with the protocol strings as needed from the panel |
---|
| 367 | // |
---|
[1040] | 368 | // TODO |
---|
| 369 | // -- update for 12 points |
---|
| 370 | // |
---|
[1025] | 371 | Function V_MakeProtocolFromPanel(w) |
---|
| 372 | Wave/T w |
---|
| 373 | |
---|
| 374 | //construct the protocol text wave form the panel |
---|
| 375 | //it is to be parsed by ExecuteProtocol() for the actual data reduction |
---|
| 376 | PathInfo catPathName //this is where the files came from |
---|
| 377 | String pathstr=S_path,tempStr,curList |
---|
| 378 | Variable checked,ii,numItems |
---|
| 379 | |
---|
| 380 | //look for checkbox, then take each item in list and prepend the path |
---|
| 381 | //w[0] = background |
---|
| 382 | ControlInfo/W=V_ProtocolPanel prot_check |
---|
| 383 | checked = V_value |
---|
| 384 | if(checked) |
---|
| 385 | //build the list |
---|
| 386 | //just read the global |
---|
| 387 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
| 388 | if(cmpstr(str,"ask")==0) |
---|
| 389 | w[0] = str //just ask |
---|
| 390 | else |
---|
| 391 | tempstr = V_ParseRunNumberList(str) |
---|
| 392 | if(strlen(tempStr)==0) |
---|
| 393 | return(1) //error parsing list |
---|
| 394 | else |
---|
| 395 | w[0] = tempstr |
---|
| 396 | str = tempstr //set the protocol and the global |
---|
| 397 | endif |
---|
| 398 | endif |
---|
| 399 | else |
---|
| 400 | //none used - set textwave (and global?) |
---|
| 401 | w[0] = "none" |
---|
| 402 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD = "none" |
---|
| 403 | endif |
---|
| 404 | |
---|
| 405 | //w[1] = empty |
---|
| 406 | ControlInfo/W=V_ProtocolPanel prot_check_1 |
---|
| 407 | checked = V_value |
---|
| 408 | if(checked) |
---|
| 409 | //build the list |
---|
| 410 | //just read the global |
---|
| 411 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
| 412 | if(cmpstr(str,"ask")==0) |
---|
| 413 | w[1] = str |
---|
| 414 | else |
---|
| 415 | tempstr = V_ParseRunNumberList(str) |
---|
| 416 | if(strlen(tempStr)==0) |
---|
| 417 | return(1) |
---|
| 418 | else |
---|
| 419 | w[1] = tempstr |
---|
| 420 | str=tempStr |
---|
| 421 | endif |
---|
| 422 | endif |
---|
| 423 | else |
---|
| 424 | //none used - set textwave (and global?) |
---|
| 425 | w[1] = "none" |
---|
| 426 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP = "none" |
---|
| 427 | endif |
---|
| 428 | |
---|
| 429 | //w[2] = div file |
---|
| 430 | ControlInfo/W=V_ProtocolPanel prot_check_2 |
---|
| 431 | checked = V_value |
---|
| 432 | if(checked) |
---|
| 433 | //build the list |
---|
| 434 | //just read the global |
---|
| 435 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
| 436 | if(cmpstr(str,"ask")==0) |
---|
| 437 | w[2] = str |
---|
| 438 | else |
---|
| 439 | tempStr = V_ParseRunNumberList(str) |
---|
| 440 | if(strlen(tempStr)==0) |
---|
| 441 | return(1) |
---|
| 442 | else |
---|
| 443 | w[2] = tempstr |
---|
| 444 | str=tempstr |
---|
| 445 | endif |
---|
| 446 | endif |
---|
| 447 | else |
---|
| 448 | //none used - set textwave (and global?) |
---|
| 449 | w[2] = "none" |
---|
| 450 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV = "none" |
---|
| 451 | endif |
---|
| 452 | |
---|
| 453 | //w[3] = mask file |
---|
| 454 | ControlInfo/W=V_ProtocolPanel prot_check_3 |
---|
| 455 | checked = V_value |
---|
| 456 | if(checked) |
---|
| 457 | //build the list |
---|
| 458 | //just read the global |
---|
| 459 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
| 460 | if(cmpstr(str,"ask")==0) |
---|
| 461 | w[3] = str |
---|
| 462 | else |
---|
| 463 | tempstr = V_ParseRunNumberList(str) |
---|
| 464 | if(strlen(tempstr)==0) |
---|
| 465 | return(1) |
---|
| 466 | else |
---|
| 467 | w[3] = tempstr |
---|
| 468 | str = tempstr |
---|
| 469 | endif |
---|
| 470 | endif |
---|
| 471 | else |
---|
| 472 | //none used - set textwave (and global?) |
---|
| 473 | w[3] = "none" |
---|
| 474 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK = "none" |
---|
| 475 | endif |
---|
| 476 | |
---|
| 477 | //w[4] = abs parameters |
---|
| 478 | ControlInfo/W=V_ProtocolPanel prot_check_9 |
---|
| 479 | checked = V_value |
---|
| 480 | if(checked) |
---|
| 481 | //build the list |
---|
| 482 | //just read the global |
---|
| 483 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
| 484 | w[4] = str |
---|
| 485 | else |
---|
| 486 | //none used - set textwave (and global?) |
---|
| 487 | w[4] = "none" |
---|
| 488 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "none" |
---|
| 489 | endif |
---|
| 490 | |
---|
| 491 | //w[5] = averaging choices |
---|
| 492 | ControlInfo/W=V_ProtocolPanel prot_check_5 //do the average? |
---|
| 493 | checked = V_value |
---|
| 494 | if(checked) |
---|
| 495 | //just read the global |
---|
| 496 | SVAR avestr=root:Packages:NIST:VSANS:Globals:Protocols:gAVE |
---|
| 497 | w[5] = avestr |
---|
| 498 | else |
---|
| 499 | //none used - set textwave |
---|
| 500 | w[5] = "AVTYPE=none;" |
---|
| 501 | endif |
---|
| 502 | |
---|
| 503 | //w[6] |
---|
| 504 | //work.DRK information |
---|
| 505 | SVAR drkStr=root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
| 506 | w[6] = drkStr |
---|
| 507 | |
---|
| 508 | //w[7] |
---|
[1040] | 509 | // beginning trim points |
---|
| 510 | SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
| 511 | w[7] = gBegPtsStr |
---|
| 512 | |
---|
| 513 | //w[8] |
---|
| 514 | // End trim points |
---|
| 515 | SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
| 516 | w[8] = gEndPtsStr |
---|
| 517 | |
---|
| 518 | //w[9] |
---|
[1025] | 519 | //currently unused |
---|
[1040] | 520 | w[9] = "" |
---|
| 521 | //w[10] |
---|
| 522 | //currently unused |
---|
| 523 | w[10] = "" |
---|
| 524 | //w[11] |
---|
| 525 | //currently unused |
---|
| 526 | w[11] = "" |
---|
| 527 | |
---|
[1025] | 528 | return(0) |
---|
| 529 | End |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | // |
---|
| 533 | Function V_PickSAMButton(ctrlName) : ButtonControl |
---|
| 534 | String ctrlName |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | End |
---|
| 538 | |
---|
| 539 | |
---|
| 540 | |
---|
| 541 | |
---|
| 542 | // |
---|
| 543 | // TODO |
---|
| 544 | // -- identifying "intent" using V_get can be very slow, since it reads in each and every data file. |
---|
| 545 | // grep is a lot faster, but there can be a lot of false "hits" unless I do it correctly. |
---|
| 546 | // |
---|
| 547 | // |
---|
| 548 | // //grep through what text I can find in the VAX binary |
---|
| 549 | // // Grep Note: the \\b sequences limit matches to a word boundary before and after |
---|
| 550 | // // "boondoggle", so "boondoggles" and "aboondoggle" won't match. |
---|
| 551 | // if(gRadioVal == 2) |
---|
| 552 | // for(ii=0;ii<num;ii+=1) |
---|
| 553 | // item=StringFromList(ii, newList , ";") |
---|
| 554 | //// Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
| 555 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
| 556 | // if( V_value ) // at least one instance was found |
---|
| 557 | //// Print "found ", item,ii |
---|
| 558 | // list += item + ";" |
---|
| 559 | // endif |
---|
| 560 | // endfor |
---|
| 561 | // |
---|
| 562 | // newList = list |
---|
| 563 | // endif |
---|
| 564 | |
---|
[1040] | 565 | // match is the string to look for in the search |
---|
| 566 | // 0 is a flag to tell it to look in the file catalog (the fastest method) |
---|
| 567 | // Other options are to grep, or to read the intent field in every file |
---|
[1036] | 568 | Function/S V_GetSAMList() |
---|
| 569 | |
---|
[1064] | 570 | // String match="SAMPLE" |
---|
| 571 | // String list = V_getFileIntentList(match,0) |
---|
[1036] | 572 | |
---|
[1064] | 573 | String intent = "SAMPLE" |
---|
| 574 | String purpose = "SCATTERING" |
---|
| 575 | String list = V_getFileIntentPurposeList(intent,purpose,0) |
---|
| 576 | |
---|
[1036] | 577 | // Printf "SAM files = %s\r",list |
---|
| 578 | return(list) |
---|
| 579 | end |
---|
| 580 | |
---|
| 581 | |
---|
[1032] | 582 | Function/S V_GetBGDList() |
---|
| 583 | |
---|
| 584 | String match="BLOCKED BEAM" |
---|
| 585 | String list = V_getFileIntentList(match,0) |
---|
| 586 | |
---|
| 587 | // Printf "BGD files = %s\r",list |
---|
| 588 | return(list) |
---|
| 589 | end |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | Function/S V_GetEMPList() |
---|
| 593 | |
---|
| 594 | String match="EMPTY CELL" |
---|
| 595 | String list = V_getFileIntentList(match,0) |
---|
| 596 | |
---|
| 597 | // Printf "EMP files = %s\r",list |
---|
| 598 | return(list) |
---|
| 599 | end |
---|
| 600 | |
---|
| 601 | |
---|
[1025] | 602 | // |
---|
| 603 | // TODO |
---|
| 604 | // -- decide on the way to locate the blocked beam files. Is the enumerated text of the intent |
---|
| 605 | // sufficiently unique to locate the file? |
---|
[1027] | 606 | // -- can I use the Data Catalog waves to locate the files - faster? |
---|
| 607 | // (fails if the catalog has not been read in recently enough) |
---|
[1025] | 608 | // |
---|
[1027] | 609 | // |
---|
[1025] | 610 | Function/S V_PickBGDButton(ctrlName) : ButtonControl |
---|
| 611 | String ctrlName |
---|
| 612 | |
---|
| 613 | String list="",item="",fname,newList,intent |
---|
| 614 | Variable ii,num |
---|
| 615 | |
---|
| 616 | PathInfo catPathName |
---|
| 617 | String path = S_path |
---|
[1032] | 618 | |
---|
| 619 | String match="BLOCKED BEAM" |
---|
| 620 | |
---|
[1056] | 621 | //v_tic() |
---|
[1032] | 622 | // get the list from the file catalog (=0.0007s) |
---|
| 623 | // |
---|
| 624 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
| 625 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
[1025] | 626 | |
---|
[1032] | 627 | Variable np = numpnts(intentW) |
---|
| 628 | for(ii=0;ii<np;ii+=1) |
---|
| 629 | if(cmpstr(intentW[ii],match)==0) |
---|
| 630 | list += fileNameW[ii] + ";" |
---|
| 631 | endif |
---|
| 632 | endfor |
---|
| 633 | |
---|
| 634 | List = SortList(List,";",0) |
---|
| 635 | Printf "BGD files = %s\r",list |
---|
[1056] | 636 | //v_toc() |
---|
[1032] | 637 | |
---|
| 638 | |
---|
[1056] | 639 | ////v_tic() // from grep = 3.3s |
---|
[1032] | 640 | // newList = V_GetRawDataFileList() |
---|
| 641 | // num=ItemsInList(newList) |
---|
| 642 | // |
---|
| 643 | //// for(ii=0;ii<num;ii+=1) |
---|
| 644 | //// item=StringFromList(ii, newList , ";") |
---|
| 645 | //// fname = path + item |
---|
| 646 | //// intent = V_getReduction_intent(fname) |
---|
| 647 | //// if(cmpstr(intent,"BLOCKED BEAM") == 0) |
---|
| 648 | //// list += item + ";" |
---|
| 649 | //// endif |
---|
| 650 | //// |
---|
| 651 | //// endfor |
---|
| 652 | // list = "" |
---|
| 653 | // for(ii=0;ii<num;ii+=1) |
---|
| 654 | // item=StringFromList(ii, newList , ";") |
---|
| 655 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
| 656 | // if( V_value ) // at least one instance was found |
---|
| 657 | //// Print "found ", item,ii |
---|
| 658 | // list += item + ";" |
---|
| 659 | // endif |
---|
| 660 | // endfor |
---|
| 661 | // |
---|
| 662 | // |
---|
| 663 | // List = SortList(List,";",0) |
---|
| 664 | // Printf "BGD files = %s\r",list |
---|
[1056] | 665 | ////v_toc() |
---|
[1032] | 666 | |
---|
| 667 | return(list) |
---|
| 668 | End |
---|
| 669 | |
---|
| 670 | |
---|
| 671 | // |
---|
| 672 | Function/S V_PickEMPButton(ctrlName) : ButtonControl |
---|
| 673 | String ctrlName |
---|
| 674 | String list="",item="",fname,newList,intent |
---|
| 675 | Variable ii,num |
---|
| 676 | |
---|
| 677 | PathInfo catPathName |
---|
| 678 | String path = S_path |
---|
| 679 | |
---|
| 680 | String match="EMPTY CELL" |
---|
| 681 | |
---|
| 682 | // get the list from the file catalog (=0.0007s) |
---|
| 683 | // |
---|
| 684 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
| 685 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
| 686 | |
---|
| 687 | Variable np = numpnts(intentW) |
---|
| 688 | for(ii=0;ii<np;ii+=1) |
---|
| 689 | if(cmpstr(intentW[ii],match)==0) |
---|
| 690 | list += fileNameW[ii] + ";" |
---|
| 691 | endif |
---|
| 692 | endfor |
---|
| 693 | |
---|
| 694 | List = SortList(List,";",0) |
---|
| 695 | Printf "EMP files = %s\r",list |
---|
| 696 | |
---|
| 697 | |
---|
| 698 | // |
---|
| 699 | // newList = V_GetRawDataFileList() |
---|
| 700 | // num=ItemsInList(newList) |
---|
| 701 | // |
---|
| 702 | //// for(ii=0;ii<num;ii+=1) |
---|
| 703 | //// item=StringFromList(ii, newList , ";") |
---|
| 704 | //// fname = path + item |
---|
| 705 | //// intent = V_getReduction_intent(fname) |
---|
| 706 | //// if(cmpstr(intent,"EMPTY CELL") == 0) |
---|
| 707 | //// list += item + ";" |
---|
| 708 | //// endif |
---|
| 709 | //// |
---|
| 710 | //// endfor |
---|
| 711 | // |
---|
| 712 | // for(ii=0;ii<num;ii+=1) |
---|
| 713 | // item=StringFromList(ii, newList , ";") |
---|
| 714 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
| 715 | // if( V_value ) // at least one instance was found |
---|
| 716 | //// Print "found ", item,ii |
---|
| 717 | // list += item + ";" |
---|
| 718 | // endif |
---|
| 719 | // |
---|
| 720 | // endfor |
---|
| 721 | // |
---|
| 722 | // List = SortList(List,";",0) |
---|
| 723 | // Printf "EMP files = %s\r",list |
---|
| 724 | |
---|
| 725 | return(list) |
---|
| 726 | End |
---|
| 727 | |
---|
| 728 | |
---|
[1036] | 729 | // |
---|
| 730 | Function/S V_PickEMPBeamButton(ctrlName) : ButtonControl |
---|
| 731 | String ctrlName |
---|
| 732 | String list="",item="",fname,newList,intent |
---|
| 733 | Variable ii,num |
---|
| 734 | |
---|
| 735 | PathInfo catPathName |
---|
| 736 | String path = S_path |
---|
| 737 | |
---|
| 738 | String match="EMPTY BEAM" |
---|
| 739 | |
---|
| 740 | // get the list from the file catalog (=0.0007s) |
---|
| 741 | // |
---|
| 742 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
| 743 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
| 744 | |
---|
| 745 | Variable np = numpnts(intentW) |
---|
| 746 | for(ii=0;ii<np;ii+=1) |
---|
| 747 | if(cmpstr(intentW[ii],match)==0) |
---|
| 748 | list += fileNameW[ii] + ";" |
---|
| 749 | endif |
---|
| 750 | endfor |
---|
| 751 | |
---|
| 752 | List = SortList(List,";",0) |
---|
| 753 | Printf "EMP Beam files = %s\r",list |
---|
| 754 | |
---|
| 755 | |
---|
| 756 | |
---|
| 757 | |
---|
| 758 | return(list) |
---|
| 759 | End |
---|
| 760 | |
---|
[1032] | 761 | Function/S V_GetDIVList() |
---|
| 762 | |
---|
| 763 | String list="",item="",fname,newList,intent |
---|
| 764 | Variable ii,num |
---|
| 765 | |
---|
| 766 | PathInfo catPathName |
---|
| 767 | String path = S_path |
---|
| 768 | |
---|
| 769 | newList = V_Get_NotRawDataFileList() |
---|
[1025] | 770 | num=ItemsInList(newList) |
---|
| 771 | |
---|
| 772 | // for(ii=0;ii<num;ii+=1) |
---|
| 773 | // item=StringFromList(ii, newList , ";") |
---|
| 774 | // fname = path + item |
---|
| 775 | // intent = V_getReduction_intent(fname) |
---|
[1032] | 776 | // if(cmpstr(intent,"SENSITIVITY") == 0) |
---|
[1025] | 777 | // list += item + ";" |
---|
| 778 | // endif |
---|
| 779 | // |
---|
| 780 | // endfor |
---|
[1032] | 781 | |
---|
| 782 | String match="DIV" |
---|
[1025] | 783 | for(ii=0;ii<num;ii+=1) |
---|
| 784 | item=StringFromList(ii, newList , ";") |
---|
[1032] | 785 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
| 786 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
[1025] | 787 | if( V_value ) // at least one instance was found |
---|
| 788 | // Print "found ", item,ii |
---|
[1032] | 789 | if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) |
---|
| 790 | list += item + ";" |
---|
| 791 | endif |
---|
[1025] | 792 | endif |
---|
| 793 | endfor |
---|
| 794 | |
---|
| 795 | List = SortList(List,";",0) |
---|
[1032] | 796 | |
---|
[1025] | 797 | return(list) |
---|
[1032] | 798 | end |
---|
[1025] | 799 | |
---|
[1032] | 800 | // TODO |
---|
| 801 | // -- find proper way to search for these files |
---|
| 802 | // -- they *may* be written to the file header(reduction block) |
---|
| 803 | // -- or grep for VSANS_DIV (in the title) |
---|
| 804 | Function/S V_PickDIVButton(ctrlName) : ButtonControl |
---|
[1025] | 805 | String ctrlName |
---|
| 806 | String list="",item="",fname,newList,intent |
---|
| 807 | Variable ii,num |
---|
| 808 | |
---|
| 809 | PathInfo catPathName |
---|
| 810 | String path = S_path |
---|
| 811 | |
---|
[1032] | 812 | newList = V_Get_NotRawDataFileList() |
---|
[1025] | 813 | num=ItemsInList(newList) |
---|
| 814 | |
---|
| 815 | // for(ii=0;ii<num;ii+=1) |
---|
| 816 | // item=StringFromList(ii, newList , ";") |
---|
| 817 | // fname = path + item |
---|
| 818 | // intent = V_getReduction_intent(fname) |
---|
[1032] | 819 | // if(cmpstr(intent,"SENSITIVITY") == 0) |
---|
[1025] | 820 | // list += item + ";" |
---|
| 821 | // endif |
---|
| 822 | // |
---|
| 823 | // endfor |
---|
| 824 | |
---|
[1032] | 825 | String match="VSANS_DIV" //this is part of the title of a VSANS DIV file |
---|
[1025] | 826 | for(ii=0;ii<num;ii+=1) |
---|
| 827 | item=StringFromList(ii, newList , ";") |
---|
[1032] | 828 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
| 829 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
[1025] | 830 | if( V_value ) // at least one instance was found |
---|
| 831 | // Print "found ", item,ii |
---|
[1032] | 832 | list += item + ";" |
---|
[1025] | 833 | endif |
---|
| 834 | |
---|
| 835 | endfor |
---|
| 836 | |
---|
| 837 | List = SortList(List,";",0) |
---|
[1032] | 838 | Printf "DIV files = %s\r",list |
---|
[1025] | 839 | |
---|
| 840 | return(list) |
---|
| 841 | |
---|
| 842 | End |
---|
| 843 | |
---|
[1032] | 844 | Function/S V_GetMSKList() |
---|
[1025] | 845 | |
---|
| 846 | String list="",item="",fname,newList,intent |
---|
| 847 | Variable ii,num |
---|
| 848 | |
---|
| 849 | PathInfo catPathName |
---|
| 850 | String path = S_path |
---|
| 851 | |
---|
| 852 | newList = V_Get_NotRawDataFileList() |
---|
| 853 | num=ItemsInList(newList) |
---|
| 854 | |
---|
| 855 | // for(ii=0;ii<num;ii+=1) |
---|
| 856 | // item=StringFromList(ii, newList , ";") |
---|
| 857 | // fname = path + item |
---|
| 858 | // intent = V_getReduction_intent(fname) |
---|
| 859 | // if(cmpstr(intent,"SENSITIVITY") == 0) |
---|
| 860 | // list += item + ";" |
---|
| 861 | // endif |
---|
| 862 | // |
---|
| 863 | // endfor |
---|
| 864 | |
---|
[1043] | 865 | // String match="MASK" // this is part of the title of a VSANS MASK file |
---|
| 866 | String match="VSANS_MASK" // this is part of the title of a VSANS MASK file |
---|
[1025] | 867 | for(ii=0;ii<num;ii+=1) |
---|
| 868 | item=StringFromList(ii, newList , ";") |
---|
| 869 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
| 870 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
| 871 | if( V_value ) // at least one instance was found |
---|
| 872 | // Print "found ", item,ii |
---|
[1032] | 873 | if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) |
---|
| 874 | list += item + ";" |
---|
| 875 | endif |
---|
[1025] | 876 | endif |
---|
| 877 | |
---|
| 878 | endfor |
---|
| 879 | |
---|
| 880 | List = SortList(List,";",0) |
---|
[1032] | 881 | |
---|
[1025] | 882 | return(list) |
---|
[1032] | 883 | end |
---|
[1025] | 884 | |
---|
| 885 | |
---|
| 886 | // |
---|
| 887 | // TODO |
---|
| 888 | // -- find proper way to search for these files |
---|
| 889 | // -- they *may* be written to the file header(reduction block) |
---|
| 890 | // -- or grep for VSANS_MASK (in the title) |
---|
| 891 | Function/S V_PickMASKButton(ctrlName) : ButtonControl |
---|
| 892 | String ctrlName |
---|
| 893 | String list="",item="",fname,newList,intent |
---|
| 894 | Variable ii,num |
---|
| 895 | |
---|
| 896 | PathInfo catPathName |
---|
| 897 | String path = S_path |
---|
| 898 | |
---|
| 899 | newList = V_Get_NotRawDataFileList() |
---|
| 900 | num=ItemsInList(newList) |
---|
| 901 | |
---|
| 902 | // for(ii=0;ii<num;ii+=1) |
---|
| 903 | // item=StringFromList(ii, newList , ";") |
---|
| 904 | // fname = path + item |
---|
| 905 | // intent = V_getReduction_intent(fname) |
---|
| 906 | // if(cmpstr(intent,"MASK") == 0) |
---|
| 907 | // list += item + ";" |
---|
| 908 | // endif |
---|
| 909 | // |
---|
| 910 | // endfor |
---|
| 911 | |
---|
| 912 | String match="MASK" |
---|
| 913 | for(ii=0;ii<num;ii+=1) |
---|
| 914 | item=StringFromList(ii, newList , ";") |
---|
| 915 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
| 916 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
| 917 | if( V_value ) // at least one instance was found |
---|
| 918 | // Print "found ", item,ii |
---|
| 919 | list += item + ";" |
---|
| 920 | endif |
---|
| 921 | |
---|
| 922 | endfor |
---|
| 923 | |
---|
| 924 | List = SortList(List,";",0) |
---|
| 925 | Printf "MASK files = %s\r",list |
---|
| 926 | |
---|
| 927 | return(list) |
---|
| 928 | |
---|
| 929 | |
---|
| 930 | End |
---|
| 931 | |
---|
| 932 | //button action function to reduce one file with the information specified on |
---|
| 933 | //the panel |
---|
| 934 | //a temporary protocol is created, even if the fields correspond to a named protocol |
---|
| 935 | //(only the protocol wave values are written to the data header, but the name is written to the |
---|
| 936 | //schematic - this could cause some unwanted confusion) |
---|
| 937 | // |
---|
| 938 | //if a sample file(s) is selected, only that file(s) will be reduced |
---|
| 939 | //if no file is selected, the user will be prompted with a standard open |
---|
| 940 | //dialog to select sample data file(s) |
---|
| 941 | // |
---|
| 942 | Function V_ReduceOneButton(ctrlName) : ButtonControl |
---|
| 943 | String ctrlName |
---|
| 944 | |
---|
| 945 | //parse the information on the panel and assign to tempProtocol wave (in protocol folder) |
---|
| 946 | //and execute |
---|
| 947 | String temp="root:Packages:NIST:VSANS:Globals:Protocols:tempProtocol" |
---|
| 948 | Wave/T w=$temp |
---|
[1040] | 949 | Variable ii=0,num=12 |
---|
[1025] | 950 | do |
---|
| 951 | w[ii] = "" |
---|
| 952 | ii+=1 |
---|
| 953 | while(ii<num) |
---|
| 954 | |
---|
| 955 | V_MakeProtocolFromPanel(w) |
---|
| 956 | |
---|
| 957 | //the "current" protocol is the "tempProtocol" that was parsed from the panel input |
---|
| 958 | //set the global, so that the data writing routine can find the protocol wave (fatal otherwise) |
---|
| 959 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr="tempProtocol" |
---|
| 960 | |
---|
| 961 | PathInfo catPathName //this is where the files came from |
---|
| 962 | String pathstr=S_path,samStr |
---|
| 963 | |
---|
| 964 | //take the string from the panel |
---|
| 965 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
| 966 | |
---|
| 967 | if( (strlen(tempStr) == 0) || (cmpstr(tempStr,"ask")==0) ) |
---|
| 968 | //let user select the files |
---|
| 969 | tempStr="ask" |
---|
| 970 | V_ExecuteProtocol(temp,tempStr) |
---|
| 971 | return(0) |
---|
| 972 | Else |
---|
| 973 | //parse the list of numbers |
---|
| 974 | //send only the filenames, without paths |
---|
| 975 | samStr = V_ParseRunNumberList(tempStr) |
---|
| 976 | If(strlen(samStr)==0) |
---|
| 977 | DoAlert 0,"The SAM file number cound not be interpreted. Please enter a valid run number or filename" |
---|
| 978 | return(1) |
---|
| 979 | endif |
---|
| 980 | tempStr=samStr //reset the global |
---|
| 981 | V_ExecuteProtocol(temp,samStr) |
---|
| 982 | return(0) |
---|
| 983 | endif |
---|
| 984 | End |
---|
| 985 | |
---|
| 986 | |
---|
| 987 | //button action function will prompt user for absolute scaling parameters |
---|
| 988 | //either from an empty beam file or by manually entering the 4 required values |
---|
| 989 | //uses the same function and shared global string as the questionnare form of reduction |
---|
| 990 | //in "protocol.ipf" - the string is root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
| 991 | // |
---|
| 992 | Function V_SetABSParamsButton(ctrlName) : ButtonControl |
---|
| 993 | String ctrlName |
---|
| 994 | |
---|
| 995 | //will prompt for a list of ABS parameters (4) through a global string variable |
---|
| 996 | |
---|
| 997 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
| 998 | |
---|
| 999 | End |
---|
| 1000 | |
---|
| 1001 | |
---|
| 1002 | |
---|
| 1003 | //the panel recreation macro |
---|
| 1004 | // |
---|
| 1005 | Window V_ProtocolPanel() |
---|
| 1006 | PauseUpdate; Silent 1 // building window... |
---|
[1040] | 1007 | NewPanel /W=(1280,332,1630,932) /K=1 as "VSANS Reduction Protocol" |
---|
[1025] | 1008 | ModifyPanel cbRGB=(56589,50441,50159), fixedSize=1 |
---|
| 1009 | SetDrawLayer UserBack |
---|
[1040] | 1010 | DrawLine 3,65,301,65 |
---|
| 1011 | DrawLine 3,157,301,157 |
---|
| 1012 | DrawLine 3,208,301,208 |
---|
| 1013 | DrawLine 3,257,301,257 |
---|
| 1014 | DrawLine 3,305,301,305 |
---|
| 1015 | DrawLine 3,350,301,350 |
---|
| 1016 | DrawLine 3,445,301,445 |
---|
[1043] | 1017 | DrawLine 3,513,301,513 |
---|
[1040] | 1018 | DrawLine 3,396,301,396 |
---|
[1025] | 1019 | |
---|
| 1020 | // |
---|
[1043] | 1021 | Button button_help,pos={300,2},size={25,20},proc=V_ShowProtoHelp,title="?" |
---|
[1025] | 1022 | Button button_help,help={"Show the help file for setting up a reduction protocol"} |
---|
| 1023 | Button button_quest,pos={20,2},size={150,20},proc=V_ProtocolQuestionnaire,title="Questions" |
---|
| 1024 | Button button_quest,help={"Run through the questionnaire for setting up a reduction protocol"} |
---|
[1040] | 1025 | Button button_quest,disable=2 |
---|
[1036] | 1026 | |
---|
[1040] | 1027 | |
---|
| 1028 | PopupMenu popup_sam,pos={85,68},size={51,23},proc=SAMFilePopMenuProc |
---|
[1036] | 1029 | PopupMenu popup_sam,mode=1,value= #"V_getSAMList()" |
---|
[1040] | 1030 | PopupMenu popup_bkg,pos={85,164},size={51,23},proc=BKGFilePopMenuProc |
---|
[1032] | 1031 | PopupMenu popup_bkg,mode=1,value= #"V_getBGDList()" |
---|
[1040] | 1032 | PopupMenu popup_emp,pos={85,213},size={51,23},proc=EMPFilePopMenuProc |
---|
[1032] | 1033 | PopupMenu popup_emp,mode=1,value= #"V_getEMPList()" |
---|
[1040] | 1034 | PopupMenu popup_div,pos={85,263},size={51,23},proc=DIVFilePopMenuProc |
---|
[1032] | 1035 | PopupMenu popup_div,mode=1,value= #"V_getDIVList()" |
---|
[1040] | 1036 | PopupMenu popup_msk,pos={85,356},size={51,23},proc=MSKFilePopMenuProc |
---|
[1032] | 1037 | PopupMenu popup_msk,mode=1,value= #"V_getMSKList()" |
---|
| 1038 | |
---|
[1040] | 1039 | |
---|
| 1040 | CheckBox prot_check,pos={6,163},size={74,14},title="Background" |
---|
[1025] | 1041 | CheckBox prot_check,help={"If checked, the specified background file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
| 1042 | CheckBox prot_check,value= 1 |
---|
[1040] | 1043 | CheckBox prot_check_1,pos={6,215},size={71,14},title="Empty Cell" |
---|
[1025] | 1044 | CheckBox prot_check_1,help={"If checked, the specified empty cell file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
| 1045 | CheckBox prot_check_1,value= 1 |
---|
[1040] | 1046 | CheckBox prot_check_2,pos={6,263},size={72,14},title="Sensitivity" |
---|
[1025] | 1047 | CheckBox prot_check_2,help={"If checked, the specified detector sensitivity file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
| 1048 | CheckBox prot_check_2,value= 1 |
---|
[1040] | 1049 | CheckBox prot_check_3,pos={6,356},size={43,14},title="Mask" |
---|
[1025] | 1050 | CheckBox prot_check_3,help={"If checked, the specified mask file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
| 1051 | CheckBox prot_check_3,value= 1 |
---|
[1040] | 1052 | CheckBox prot_check_4,pos={6,70},size={53,14},title="Sample" |
---|
[1032] | 1053 | CheckBox prot_check_4,help={"If checked, the specified sample file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
| 1054 | CheckBox prot_check_4,value= 1 |
---|
[1040] | 1055 | CheckBox prot_check_5,pos={6,399},size={56,14},title="Average" |
---|
[1032] | 1056 | CheckBox prot_check_5,help={"If checked, the specified averaging will be performed at the end of the data reduction."} |
---|
| 1057 | CheckBox prot_check_5,value= 1 |
---|
[1040] | 1058 | CheckBox prot_check_9,pos={6,310},size={59,14},title="Absolute" |
---|
[1032] | 1059 | CheckBox prot_check_9,help={"If checked, absolute calibration will be included in the data reduction. If the parameter list is \"ask\", then the user will be prompted for absolue parameters"} |
---|
| 1060 | CheckBox prot_check_9,value= 1 |
---|
| 1061 | |
---|
| 1062 | |
---|
| 1063 | // Button pick_sam,pos={214,28},size={70,20},proc=V_PickSAMButton,title="set SAM" |
---|
| 1064 | // Button pick_sam,help={"This button will set the file selected in the File Catalog table to be the sample file"} |
---|
| 1065 | // Button pick_bgd,pos={214,75},size={70,20},proc=V_PickBGDButton,title="set BGD" |
---|
| 1066 | // Button pick_bgd,help={"This button will set the file selected in the File Catalog table to be the background file."} |
---|
| 1067 | // Button pick_emp,pos={214,125},size={70,20},proc=V_PickEMPButton,title="set EMP" |
---|
| 1068 | // Button pick_emp,help={"This button will set the file selected in the File Catalog table to be the empty cell file."} |
---|
| 1069 | // Button pick_DIV,pos={214,173},size={70,20},proc=V_PickDIVButton,title="set DIV" |
---|
| 1070 | // Button pick_DIV,help={"This button will set the file selected in the File Catalog table to be the sensitivity file."} |
---|
[1040] | 1071 | Button pick_ABS,pos={264,308},size={70,20},proc=V_SetABSParamsButton,title="set ABS" |
---|
[1032] | 1072 | Button pick_ABS,help={"This button will prompt the user for absolute scaling parameters"} |
---|
| 1073 | // Button pick_MASK,pos={214,266},size={70,20},proc=V_PickMASKButton,title="set MASK" |
---|
| 1074 | // Button pick_MASK,help={"This button will set the file selected in the File Catalog table to be the mask file."} |
---|
| 1075 | |
---|
| 1076 | |
---|
[1040] | 1077 | Button pick_AVE,pos={188,401},size={150,20},proc=V_SetAverageParamsButtonProc,title="set AVERAGE params" |
---|
[1032] | 1078 | Button pick_AVE,help={"Prompts the user for the type of 1-D averaging to perform, as well as saving options"} |
---|
[1040] | 1079 | |
---|
[1032] | 1080 | |
---|
[1040] | 1081 | Button pick_trim,pos={264,454},size={70,20},proc=V_TrimDataProtoButton,title="Trim" |
---|
| 1082 | Button pick_trim,help={"This button will prompt the user for trimming parameters"} |
---|
| 1083 | |
---|
| 1084 | |
---|
| 1085 | SetVariable samStr,pos={6,90},size={250,15},title="file:" |
---|
[1032] | 1086 | SetVariable samStr,help={"Filename of the sample file(s) to be used in the data reduction"} |
---|
| 1087 | SetVariable samStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
[1040] | 1088 | SetVariable bgdStr,pos={7,186},size={250,15},title="file:" |
---|
[1025] | 1089 | SetVariable bgdStr,help={"Filename of the background file(s) to be used in the data reduction"} |
---|
| 1090 | SetVariable bgdStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
[1040] | 1091 | SetVariable empStr,pos={8,236},size={250,15},title="file:" |
---|
[1025] | 1092 | SetVariable empStr,help={"Filename of the empty cell file(s) to be used in the data reduction"} |
---|
| 1093 | SetVariable empStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
[1040] | 1094 | SetVariable divStr,pos={9,285},size={250,15},title="file:" |
---|
[1025] | 1095 | SetVariable divStr,help={"Filename of the detector sensitivity file to be used in the data reduction"} |
---|
| 1096 | SetVariable divStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
[1040] | 1097 | SetVariable maskStr,pos={9,377},size={250,15},title="file:" |
---|
[1025] | 1098 | SetVariable maskStr,help={"Filename of the mask file to be used in the data reduction"} |
---|
| 1099 | SetVariable maskStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
[1040] | 1100 | SetVariable absStr,pos={7,331},size={250,15},title="parameters:" |
---|
[1025] | 1101 | SetVariable absStr,help={"Keyword-string of values necessary for absolute scaling of data. Remaining parameters are taken from the sample file."} |
---|
| 1102 | SetVariable absStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
[1040] | 1103 | SetVariable aveStr,pos={9,424},size={250,15},title="parameters:" |
---|
[1025] | 1104 | SetVariable aveStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
| 1105 | SetVariable aveStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gAVE |
---|
[1032] | 1106 | |
---|
[1040] | 1107 | SetVariable begStr,pos={9,464},size={250,15},title="Beg Trim:" |
---|
| 1108 | SetVariable begStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
| 1109 | SetVariable begStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
| 1110 | SetVariable endStr,pos={9,484},size={250,15},title="End Trim:" |
---|
| 1111 | SetVariable endStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
| 1112 | SetVariable endStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
[1032] | 1113 | |
---|
| 1114 | |
---|
[1025] | 1115 | |
---|
| 1116 | //only show DRK if user wants to see it |
---|
| 1117 | //if global = 1,then show => set disable = 0 |
---|
| 1118 | // CheckBox prot_check_6,pos={6,363},size={113,14},proc=DrkCheckProc,title="Use DRK correction" |
---|
| 1119 | // CheckBox prot_check_6,help={"If checked, the selected file will be used for DRK correction. Typically this is NOT checked"} |
---|
| 1120 | // CheckBox prot_check_6,value= 0,disable = (!root:Packages:NIST:gAllowDRK) |
---|
| 1121 | // SetVariable drkStr,pos={120,363},size={150,15},title="." |
---|
| 1122 | // SetVariable drkStr,help={"DRK detector count file"},disable = (!root:Packages:NIST:gAllowDRK) |
---|
| 1123 | // SetVariable drkStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
| 1124 | |
---|
[1040] | 1125 | |
---|
| 1126 | Button export_button, size={120,20},pos={125,540},title="Export to Data",proc=V_ExportFileProtocol |
---|
| 1127 | Button export_button, help={"Exports the protocol to data file on disk for Importing into another experiment"} |
---|
| 1128 | Button import_button, size={120,20},pos={125,562},title="Import from Data",proc=V_ImportFileProtocol |
---|
| 1129 | Button import_button,help={"Imports a protocol from a data file on disk for use in this experiment"} |
---|
| 1130 | Button recallProt,pos={7,540},size={107,20},proc=V_RecallProtocolButton,title="Recall Protocol" |
---|
[1032] | 1131 | Button recallProt,help={"Resets the panel to the file choices in a previously saved protocol"} |
---|
[1040] | 1132 | Button del_protocol,pos={7,562},size={110,20},proc=V_DeleteProtocolButton,title="Delete Protocol" |
---|
[1032] | 1133 | Button del_protocol,help={"Use this to delete a previously saved protocol."} |
---|
[1040] | 1134 | Button done_protocol,pos={285,562},size={45,20},proc=V_DoneProtocolButton,title="Done" |
---|
[1032] | 1135 | Button done_protocol,help={"This button will close the panel. The panel can be recalled at any time from the SANS menu."} |
---|
[1040] | 1136 | Button saveProtocol,pos={7,518},size={100,20},proc=V_SaveProtocolButton,title="Save Protocol" |
---|
[1032] | 1137 | Button saveProtocol,help={"Saves the cerrent selections in the panel to a protocol which can be later recalled"} |
---|
[1040] | 1138 | Button ReduceOne,pos={240,518},size={100,20},proc=V_ReduceOneButton,title="Reduce A File" |
---|
[1032] | 1139 | Button ReduceOne,help={"Using the panel selections, the specified sample file will be reduced. If none is specified, the user will be prompted for a sample file"} |
---|
| 1140 | |
---|
[1025] | 1141 | EndMacro |
---|
| 1142 | |
---|
[1040] | 1143 | |
---|
| 1144 | |
---|
| 1145 | |
---|
| 1146 | |
---|
[1036] | 1147 | Function SAMFilePopMenuProc(pa) : PopupMenuControl |
---|
| 1148 | STRUCT WMPopupAction &pa |
---|
| 1149 | |
---|
| 1150 | switch( pa.eventCode ) |
---|
| 1151 | case 2: // mouse up |
---|
| 1152 | Variable popNum = pa.popNum |
---|
| 1153 | String popStr = pa.popStr |
---|
| 1154 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
| 1155 | tempStr = popStr |
---|
| 1156 | break |
---|
| 1157 | case -1: // control being killed |
---|
| 1158 | break |
---|
| 1159 | endswitch |
---|
| 1160 | |
---|
| 1161 | return 0 |
---|
| 1162 | End |
---|
| 1163 | |
---|
| 1164 | |
---|
[1032] | 1165 | Function BKGFilePopMenuProc(pa) : PopupMenuControl |
---|
| 1166 | STRUCT WMPopupAction &pa |
---|
| 1167 | |
---|
| 1168 | switch( pa.eventCode ) |
---|
| 1169 | case 2: // mouse up |
---|
| 1170 | Variable popNum = pa.popNum |
---|
| 1171 | String popStr = pa.popStr |
---|
| 1172 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
| 1173 | tempStr = popStr |
---|
| 1174 | break |
---|
| 1175 | case -1: // control being killed |
---|
| 1176 | break |
---|
| 1177 | endswitch |
---|
| 1178 | |
---|
| 1179 | return 0 |
---|
| 1180 | End |
---|
| 1181 | |
---|
| 1182 | Function EMPFilePopMenuProc(pa) : PopupMenuControl |
---|
| 1183 | STRUCT WMPopupAction &pa |
---|
| 1184 | |
---|
| 1185 | switch( pa.eventCode ) |
---|
| 1186 | case 2: // mouse up |
---|
| 1187 | Variable popNum = pa.popNum |
---|
| 1188 | String popStr = pa.popStr |
---|
| 1189 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
| 1190 | tempStr = popStr |
---|
| 1191 | break |
---|
| 1192 | case -1: // control being killed |
---|
| 1193 | break |
---|
| 1194 | endswitch |
---|
| 1195 | |
---|
| 1196 | return 0 |
---|
| 1197 | End |
---|
| 1198 | |
---|
| 1199 | Function DIVFilePopMenuProc(pa) : PopupMenuControl |
---|
| 1200 | STRUCT WMPopupAction &pa |
---|
| 1201 | |
---|
| 1202 | switch( pa.eventCode ) |
---|
| 1203 | case 2: // mouse up |
---|
| 1204 | Variable popNum = pa.popNum |
---|
| 1205 | String popStr = pa.popStr |
---|
| 1206 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
| 1207 | tempStr = popStr |
---|
| 1208 | break |
---|
| 1209 | case -1: // control being killed |
---|
| 1210 | break |
---|
| 1211 | endswitch |
---|
| 1212 | |
---|
| 1213 | return 0 |
---|
| 1214 | End |
---|
| 1215 | |
---|
| 1216 | Function MSKFilePopMenuProc(pa) : PopupMenuControl |
---|
| 1217 | STRUCT WMPopupAction &pa |
---|
| 1218 | |
---|
| 1219 | switch( pa.eventCode ) |
---|
| 1220 | case 2: // mouse up |
---|
| 1221 | Variable popNum = pa.popNum |
---|
| 1222 | String popStr = pa.popStr |
---|
| 1223 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
| 1224 | tempStr = popStr |
---|
| 1225 | break |
---|
| 1226 | case -1: // control being killed |
---|
| 1227 | break |
---|
| 1228 | endswitch |
---|
| 1229 | |
---|
| 1230 | return 0 |
---|
| 1231 | End |
---|
| 1232 | |
---|
[1025] | 1233 | ////activated when user checks/unchecks the box |
---|
| 1234 | ////either prompts for a file using a standard dialog, or removes the current file |
---|
| 1235 | //Function V_DrkCheckProc(ctrlName,checked) : CheckBoxControl |
---|
| 1236 | // String ctrlName |
---|
| 1237 | // Variable checked //Desired state, not previous state |
---|
| 1238 | // |
---|
| 1239 | // SVAR drkStr=root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
| 1240 | // if(checked==1) |
---|
| 1241 | // //print "Unchecked on call" |
---|
| 1242 | // //this just asks for the filename, doesn't open the file |
---|
| 1243 | // String msgStr="Select the DRK file",fullPath="",fileStr="" |
---|
| 1244 | // Variable refnum |
---|
| 1245 | // |
---|
| 1246 | // Open/D/R/T="????"/M=(msgStr)/P=catPathName refNum |
---|
| 1247 | // fullPath = S_FileName //fname is the full path |
---|
| 1248 | // if(cmpstr(fullpath,"")==0) |
---|
| 1249 | // //user cancelled |
---|
| 1250 | // CheckBox prot_check_6,value=0 //keep box unchecked |
---|
| 1251 | // return(0) |
---|
| 1252 | // Endif |
---|
| 1253 | // fileStr=V_GetFileNameFromPathNoSemi(fullPath) |
---|
| 1254 | // //Print fileStr |
---|
| 1255 | // //update the global string |
---|
| 1256 | // drkStr = ReplaceStringByKey("DRK",drkStr,fileStr,"=",",") |
---|
| 1257 | // drkStr = ReplaceNumberByKey("DRKMODE", drkStr, 10 ,"=",",") |
---|
| 1258 | // else |
---|
| 1259 | // //print "checked on call" |
---|
| 1260 | // drkStr="DRK=none,DRKMODE=0," //change the global |
---|
| 1261 | // endif |
---|
| 1262 | // |
---|
| 1263 | //End |
---|
| 1264 | |
---|
| 1265 | |
---|
| 1266 | Function V_ShowProtoHelp(ctrlName) : ButtonControl |
---|
| 1267 | String ctrlName |
---|
| 1268 | DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[VSANS Reduction Protocol]" |
---|
| 1269 | if(V_flag !=0) |
---|
| 1270 | DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found" |
---|
| 1271 | endif |
---|
| 1272 | End |
---|
| 1273 | |
---|
| 1274 | //button action procedure to get the type of average requested by the user |
---|
| 1275 | //presented as a missing parameter dialog, which is really user-UN-friendly |
---|
| 1276 | //and will need to be re-thought. Defaults of dialog are set for normal |
---|
| 1277 | //circular average, so typically click "continue" and proceed |
---|
| 1278 | // |
---|
| 1279 | Function V_SetAverageParamsButtonProc(ctrlName) : ButtonControl |
---|
| 1280 | String ctrlName |
---|
| 1281 | |
---|
[1027] | 1282 | // Execute "V_GetAvgInfo_Full()" |
---|
[1025] | 1283 | Execute "V_GetAvgInfo()" |
---|
| 1284 | |
---|
| 1285 | //set the global string |
---|
| 1286 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
| 1287 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = tempStr |
---|
| 1288 | |
---|
| 1289 | End |
---|
| 1290 | |
---|
[1027] | 1291 | // TODO |
---|
| 1292 | // -- this is a trimmed down version of the "full" set of averaging options |
---|
[1036] | 1293 | // add to this as needed as I figure out what functionality is appropriate |
---|
[1027] | 1294 | // |
---|
[1025] | 1295 | //procedure called by protocol panel to ask user for average type choices |
---|
| 1296 | // somewhat confusing and complex, but may be as good as it gets. |
---|
| 1297 | // |
---|
[1027] | 1298 | //Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) |
---|
[1057] | 1299 | Proc V_GetAvgInfo(av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup) |
---|
[1027] | 1300 | String av_typ,autoSave,AutoName,binType |
---|
| 1301 | // Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 |
---|
[1057] | 1302 | Variable Qctr=0.1,qDelta=0.01 |
---|
| 1303 | String detGroup="F" |
---|
[1027] | 1304 | |
---|
| 1305 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" |
---|
[1057] | 1306 | Prompt av_typ, "Type of Average",popup,"Circular;Annular;" |
---|
[1027] | 1307 | |
---|
| 1308 | // comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) |
---|
| 1309 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" |
---|
[1036] | 1310 | Prompt autoSave,"Save files to disk?",popup,"Yes - Concatenate;Yes - Individual;No" |
---|
[1027] | 1311 | Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" |
---|
| 1312 | // Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" |
---|
| 1313 | // Prompt side,"Include detector halves?",popup,"both;right;left" |
---|
| 1314 | // Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" |
---|
| 1315 | // Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" |
---|
| 1316 | // Prompt width, "Width of Rectangular average (1,128)" |
---|
[1035] | 1317 | Prompt binType,"Binning Type?",popup,ksBinTypeStr |
---|
[1027] | 1318 | |
---|
[1057] | 1319 | Prompt Qctr, "q-value of center of annulus" |
---|
| 1320 | Prompt Qdelta,"(+/-) q-width of annulus" |
---|
| 1321 | Prompt detGroup,"Group for annulus" |
---|
| 1322 | |
---|
[1027] | 1323 | //assign results of dialog to key=value string, semicolon separated |
---|
| 1324 | //do only what is necessary, based on av_typ |
---|
| 1325 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" |
---|
| 1326 | |
---|
| 1327 | // TODO: |
---|
| 1328 | // hard wired value |
---|
| 1329 | String autoPlot = "No" |
---|
| 1330 | |
---|
| 1331 | |
---|
| 1332 | // all averages need these values |
---|
| 1333 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" |
---|
| 1334 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" |
---|
| 1335 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" |
---|
| 1336 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" |
---|
| 1337 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "BINTYPE=" + binType + ";" |
---|
| 1338 | |
---|
| 1339 | // if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) |
---|
| 1340 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
| 1341 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
| 1342 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" |
---|
| 1343 | // Endif |
---|
| 1344 | // |
---|
| 1345 | // if(cmpstr(av_typ,"Rectangular")==0) |
---|
| 1346 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
| 1347 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
| 1348 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" |
---|
| 1349 | // Endif |
---|
| 1350 | // |
---|
[1057] | 1351 | if(cmpstr(av_typ,"Annular")==0) |
---|
| 1352 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" |
---|
| 1353 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" |
---|
| 1354 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DETGROUP=" + detGroup + ";" |
---|
| 1355 | Endif |
---|
[1027] | 1356 | End |
---|
| 1357 | |
---|
| 1358 | |
---|
| 1359 | // TODO |
---|
| 1360 | // -- this is the original(SANS) version, and needs to be updated for VSANS as the averaging options are |
---|
| 1361 | // worked out |
---|
[1057] | 1362 | // -- there have been changes made to V_GetAvgInfo() above -- so work from that version, NOT this one. |
---|
[1027] | 1363 | // |
---|
[1057] | 1364 | // |
---|
[1027] | 1365 | //procedure called by protocol panel to ask user for average type choices |
---|
| 1366 | // somewhat confusing and complex, but may be as good as it gets. |
---|
| 1367 | // |
---|
| 1368 | Proc V_GetAvgInfo_Full(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) |
---|
[1025] | 1369 | String av_typ,autoSave,AutoName,autoPlot,side |
---|
| 1370 | Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 |
---|
| 1371 | Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" |
---|
| 1372 | // comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) |
---|
| 1373 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" |
---|
| 1374 | Prompt autoSave,"Save files to disk?",popup,"Yes;No" |
---|
| 1375 | Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" |
---|
| 1376 | Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" |
---|
| 1377 | Prompt side,"Include detector halves?",popup,"both;right;left" |
---|
| 1378 | Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" |
---|
| 1379 | Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" |
---|
| 1380 | Prompt width, "Width of Rectangular average (1,128)" |
---|
| 1381 | Prompt Qctr, "q-value of center of annulus" |
---|
| 1382 | Prompt Qdelta,"Pixel width of annulus" |
---|
| 1383 | |
---|
| 1384 | //assign results of dialog to key=value string, semicolon separated |
---|
| 1385 | //do only what is necessary, based on av_typ |
---|
| 1386 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" |
---|
| 1387 | |
---|
| 1388 | // all averages need these four values |
---|
| 1389 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" |
---|
| 1390 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" |
---|
| 1391 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" |
---|
| 1392 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" |
---|
| 1393 | |
---|
| 1394 | if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) |
---|
| 1395 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
| 1396 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
| 1397 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" |
---|
| 1398 | Endif |
---|
| 1399 | |
---|
| 1400 | if(cmpstr(av_typ,"Rectangular")==0) |
---|
| 1401 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
| 1402 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
| 1403 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" |
---|
| 1404 | Endif |
---|
| 1405 | |
---|
| 1406 | if(cmpstr(av_typ,"Annular")==0) |
---|
| 1407 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" |
---|
| 1408 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" |
---|
| 1409 | Endif |
---|
| 1410 | End |
---|
| 1411 | |
---|
| 1412 | |
---|
| 1413 | //prompts the user to pick a previously created protocol from a popup list |
---|
| 1414 | //of given the option to create a new protocol |
---|
| 1415 | //the chosen protocol is passed back to the calling procedure by a global string |
---|
| 1416 | //the popup is presented as a missing parameter dialog (called with empty parameter list) |
---|
| 1417 | // |
---|
[1040] | 1418 | // MAXROWS is present to exclude the PanelNameW from appearing as a protocol |
---|
[1025] | 1419 | Proc V_PickAProtocol(protocol) |
---|
| 1420 | String Protocol |
---|
[1042] | 1421 | Prompt Protocol "Pick A Protocol",popup, V_RecallableProtocols() |
---|
[1025] | 1422 | |
---|
| 1423 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocol |
---|
| 1424 | End |
---|
| 1425 | |
---|
| 1426 | Proc V_DeleteAProtocol(protocol) |
---|
| 1427 | String Protocol |
---|
[1030] | 1428 | // Prompt Protocol "Delete A Protocol",popup, WaveList("*",";","TEXT:1") |
---|
[1025] | 1429 | Prompt Protocol "Delete A Protocol",popup, V_DeletableProtocols() |
---|
| 1430 | |
---|
| 1431 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocol |
---|
| 1432 | End |
---|
| 1433 | |
---|
| 1434 | Function/S V_DeletableProtocols() |
---|
[1040] | 1435 | String list=WaveList("*",";","TEXT:1,MAXROWS:13") |
---|
[1025] | 1436 | |
---|
| 1437 | list= RemoveFromList("Base", list , ";") |
---|
| 1438 | list= RemoveFromList("DoAll", list , ";") |
---|
| 1439 | list= RemoveFromList("CreateNew", list , ";") |
---|
| 1440 | list= RemoveFromList("tempProtocol", list , ";") |
---|
[1042] | 1441 | list= RemoveFromList("wTTmpWrite", list , ";") |
---|
[1025] | 1442 | if(cmpstr(list,"")==0) |
---|
| 1443 | list = "_no_protocols_;" |
---|
| 1444 | endif |
---|
| 1445 | |
---|
| 1446 | return(list) |
---|
| 1447 | End |
---|
| 1448 | |
---|
[1042] | 1449 | Function/S V_RecallableProtocols() |
---|
| 1450 | String list=WaveList("*",";","TEXT:1,MAXROWS:13") |
---|
| 1451 | |
---|
| 1452 | // list= RemoveFromList("Base", list , ";") |
---|
| 1453 | // list= RemoveFromList("DoAll", list , ";") |
---|
| 1454 | list= RemoveFromList("CreateNew", list , ";") |
---|
| 1455 | list= RemoveFromList("tempProtocol", list , ";") |
---|
| 1456 | list= RemoveFromList("wTTmpWrite", list , ";") |
---|
| 1457 | if(cmpstr(list,"")==0) |
---|
| 1458 | list = "_no_protocols_;" |
---|
| 1459 | endif |
---|
| 1460 | |
---|
| 1461 | return(list) |
---|
| 1462 | End |
---|
| 1463 | |
---|
| 1464 | |
---|
[1040] | 1465 | //missing parameter dialog to solicit user for a waveStr for the protocol |
---|
[1025] | 1466 | //about to be created |
---|
| 1467 | //name is passed back as a global string and calling procedure is responsible for |
---|
| 1468 | //checking for wave conflicts and valid names |
---|
| 1469 | // |
---|
| 1470 | Proc V_AskForName(protocol) |
---|
| 1471 | String Protocol |
---|
| 1472 | Prompt Protocol "Enter a new name for your protocol (no extension)" |
---|
| 1473 | |
---|
| 1474 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr = protocol |
---|
| 1475 | End |
---|
| 1476 | |
---|
| 1477 | //this is a lengthy procedure for sequentially polling the user about what data |
---|
| 1478 | //reduction steps they want to be performed during the protocol |
---|
| 1479 | //ensures that a valid protocol name was chosen, then fills out each "item" |
---|
| 1480 | //(6 total) needed for reduction |
---|
| 1481 | //it the user cancels at any point, the partial protocol will be deleted |
---|
| 1482 | // |
---|
| 1483 | Function V_ProtocolQuestionnaire(ctrlName) |
---|
| 1484 | String ctrlName |
---|
| 1485 | |
---|
| 1486 | String filename,cmd |
---|
| 1487 | Variable notDone,refnum |
---|
| 1488 | |
---|
| 1489 | //prompt for name of new protocol wave to save |
---|
| 1490 | do |
---|
| 1491 | Execute "V_AskForName()" |
---|
| 1492 | SVAR newProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gNewStr |
---|
| 1493 | |
---|
| 1494 | //make sure it's a valid IGOR name |
---|
| 1495 | newProtoStr = CleanupName(newProtoStr,0) //strict naming convention |
---|
| 1496 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr=newProtoStr //reassign, if changed |
---|
| 1497 | //Print "newProtoStr = ",newProtoStr |
---|
| 1498 | |
---|
| 1499 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 1500 | if(WaveExists( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) ) == 1) |
---|
| 1501 | //wave already exists |
---|
| 1502 | DoAlert 0,"that name is already in use. Please pick a new name" |
---|
| 1503 | notDone = 1 |
---|
| 1504 | else |
---|
| 1505 | //name is good |
---|
| 1506 | notDone = 0 |
---|
| 1507 | Endif |
---|
| 1508 | while(notDone) |
---|
| 1509 | |
---|
| 1510 | //Print "protocol questionnaire is "+newProtocol |
---|
| 1511 | |
---|
[1040] | 1512 | //make a new text wave (12 points) and fill it in, in response to questions |
---|
[1025] | 1513 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols //(redundant - full wave specs are used) |
---|
[1040] | 1514 | Make/O/T/N=(kNumProtocolSteps) $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) |
---|
[1025] | 1515 | Wave/T newProtocol = $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) |
---|
[1040] | 1516 | newProtocol = "" |
---|
[1025] | 1517 | |
---|
| 1518 | //ask the questions |
---|
| 1519 | ///// |
---|
| 1520 | //*****Multiple files in these lists are full paths/filenames which may or may not |
---|
| 1521 | //have semicolon version numbers in the filename. Therefore, construct the list with |
---|
| 1522 | //COMMAS as separators - to avoid messy parsing |
---|
| 1523 | /////// |
---|
| 1524 | |
---|
| 1525 | String fileFilters = "VSANS Data Files (*.ngv,*.h5):.ngv,.h5;" |
---|
| 1526 | // fileFilters += "HTML Files (*.htm,*.html):.htm,.html;" |
---|
| 1527 | fileFilters += "All Files:.*;" |
---|
| 1528 | ////////////////////////// |
---|
| 1529 | String drkStr="",fileStr="" |
---|
| 1530 | |
---|
| 1531 | |
---|
| 1532 | ////////////////////////// |
---|
| 1533 | // DoAlert 1,"Do you want to correct your data for DRK (beam off) counts?" |
---|
| 1534 | // if(V_flag == 1) //1=yes |
---|
| 1535 | // //prompt for DRK file, but don't actually open it (/D flag) |
---|
| 1536 | // Open/D/R/F=fileFilters/M="Select the DRK file"/P=catPathName refnum |
---|
| 1537 | // //check for cancel |
---|
| 1538 | // if(strlen(S_filename)==0) |
---|
| 1539 | // //user cancelled, abort |
---|
| 1540 | // KillWaves/Z newProtocol |
---|
| 1541 | // SetDataFolder root: |
---|
| 1542 | // Abort "Incomplete protocol has been deleted" |
---|
| 1543 | // Endif |
---|
| 1544 | // //assign filename (just the name) to [6] |
---|
| 1545 | // fileStr = V_GetFileNameFromPathNoSemi(S_filename) |
---|
| 1546 | // drkStr = "DRK=none,DRKMODE=0," |
---|
| 1547 | // drkStr = ReplaceStringByKey("DRK",drkStr,fileStr,"=",",") |
---|
| 1548 | // drkStr = ReplaceNumberByKey("DRKMODE", drkStr, 10 ,"=",",") |
---|
| 1549 | // newProtocol[6] = drkStr |
---|
| 1550 | // else |
---|
| 1551 | // //no Work.DRK desired |
---|
| 1552 | // newProtocol[6] = "DRK=none,DRKMODE=0," |
---|
| 1553 | // Endif |
---|
| 1554 | // |
---|
| 1555 | //////////// |
---|
| 1556 | |
---|
| 1557 | |
---|
| 1558 | // TODO: |
---|
| 1559 | // -- there is a lag in the V_pick() routine as it greps through all of the files. Several seconds even when there |
---|
| 1560 | // are 20-ish files. Pre-search for the strings? When to refresh them for new data? |
---|
| 1561 | ///////////////// |
---|
| 1562 | DoAlert 1,"Do you want to subtract background from your data?" |
---|
| 1563 | if(V_flag == 1) //1=yes |
---|
| 1564 | |
---|
| 1565 | Prompt filename,"BKG File",popup,V_PickBGDButton("") |
---|
| 1566 | DoPrompt "Select File",filename |
---|
| 1567 | if (V_Flag) |
---|
| 1568 | return 0 // user canceled |
---|
| 1569 | endif |
---|
| 1570 | // //assign filename to [0] |
---|
| 1571 | newProtocol[0] = V_GetFileNameFromPathNoSemi(fileName) |
---|
| 1572 | |
---|
| 1573 | |
---|
| 1574 | // OLD way, using an open file dialog |
---|
| 1575 | // and allowing for multiple files to be added together |
---|
| 1576 | // |
---|
| 1577 | // //prompt for background file, but don't actually open it (/D flag) |
---|
| 1578 | // Open/D/R/F=fileFilters/M="Select the Background data file"/P=catPathName refnum |
---|
| 1579 | // //check for cancel |
---|
| 1580 | // if(strlen(S_filename)==0) |
---|
| 1581 | // //user cancelled, abort |
---|
| 1582 | // KillWaves/Z newProtocol |
---|
| 1583 | // SetDataFolder root: |
---|
| 1584 | // Abort "Incomplete protocol has been deleted" |
---|
| 1585 | // Endif |
---|
| 1586 | // //assign filename (full path) to [0] |
---|
| 1587 | // newProtocol[0] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
| 1588 | |
---|
| 1589 | // notDone=1 |
---|
| 1590 | // do |
---|
| 1591 | // //prompt for additional background files |
---|
| 1592 | // DoAlert 1,"Do you want to add another background file?" |
---|
| 1593 | // if(V_flag == 1) //yes |
---|
| 1594 | // Open/D/R/F=fileFilters/M="Select another Background data file"/P=catPathName refnum |
---|
| 1595 | // //check for cancel |
---|
| 1596 | // if(strlen(S_filename)==0) |
---|
| 1597 | // //user cancelled, abort ********maybe just break out of the loop here |
---|
| 1598 | // KillWaves/Z newProtocol |
---|
| 1599 | // SetDataFolder root: |
---|
| 1600 | // Abort "Incomplete protocol has been deleted" |
---|
| 1601 | // Endif |
---|
| 1602 | // //assign filename (full path) to [0] |
---|
| 1603 | // newProtocol[0] += "," + V_GetFileNameFromPathNoSemi(S_filename) //***COMMA separated list |
---|
| 1604 | // notDone = 1 //keep going |
---|
| 1605 | // else |
---|
| 1606 | // notDone = 0 //no more to add |
---|
| 1607 | // Endif |
---|
| 1608 | // While(notDone) |
---|
| 1609 | ////// |
---|
| 1610 | |
---|
| 1611 | else //no background desired |
---|
| 1612 | newProtocol[0] = "none" |
---|
| 1613 | Endif |
---|
| 1614 | |
---|
| 1615 | |
---|
| 1616 | ////////////////////// |
---|
| 1617 | DoAlert 1,"Do you want to subtract empty cell scattering from your data?" |
---|
| 1618 | if(V_flag == 1) //1=yes |
---|
| 1619 | |
---|
| 1620 | Prompt filename,"EMP File",popup,V_PickEMPButton("") |
---|
| 1621 | DoPrompt "Select File",filename |
---|
| 1622 | if (V_Flag) |
---|
| 1623 | return 0 // user canceled |
---|
| 1624 | endif |
---|
| 1625 | // //assign filename to [1] |
---|
| 1626 | newProtocol[1] = V_GetFileNameFromPathNoSemi(fileName) |
---|
| 1627 | |
---|
| 1628 | |
---|
| 1629 | |
---|
| 1630 | // //prompt for Empty cell file, but don't actually open it (/D flag) |
---|
| 1631 | // Open/D/R/F=fileFilters/M="Select the Empty Cell data file"/P=catPathName refnum |
---|
| 1632 | // //check for cancel |
---|
| 1633 | // if(strlen(S_filename)==0) |
---|
| 1634 | // //user cancelled, abort |
---|
| 1635 | // KillWaves/Z newProtocol |
---|
| 1636 | // SetDataFolder root: |
---|
| 1637 | // Abort "Incomplete protocol has been deleted" |
---|
| 1638 | // Endif |
---|
| 1639 | // //assign filename (full path) to [1] |
---|
| 1640 | // newProtocol[1] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
| 1641 | // |
---|
| 1642 | // notDone=1 |
---|
| 1643 | // do |
---|
| 1644 | // //prompt for additional Empty Cell files |
---|
| 1645 | // DoAlert 1,"Do you want to add another Empty Cell file?" |
---|
| 1646 | // if(V_flag == 1) //yes |
---|
| 1647 | // Open/D/R/F=fileFilters/M="Select another Empty Cell data file"/P=catPathName refnum |
---|
| 1648 | // //check for cancel |
---|
| 1649 | // if(strlen(S_filename)==0) |
---|
| 1650 | // //user cancelled, abort ********maybe just break out of the loop here |
---|
| 1651 | // KillWaves/Z newProtocol |
---|
| 1652 | // SetDataFolder root: |
---|
| 1653 | // Abort "Incomplete protocol has been deleted" |
---|
| 1654 | // Endif |
---|
| 1655 | // //assign filename (full path) to [1] |
---|
| 1656 | // newProtocol[1] += "," + V_GetFileNameFromPathNoSemi(S_filename) //***COMMA separated list |
---|
| 1657 | // notDone = 1 //keep going |
---|
| 1658 | // else |
---|
| 1659 | // notDone = 0 //no more to add |
---|
| 1660 | // Endif |
---|
| 1661 | // While(notDone) |
---|
| 1662 | |
---|
| 1663 | |
---|
| 1664 | else //no background desired |
---|
| 1665 | newProtocol[1] = "none" |
---|
| 1666 | Endif |
---|
| 1667 | |
---|
| 1668 | |
---|
| 1669 | ////////////////////////// |
---|
| 1670 | DoAlert 1,"Do you want to correct your data for detector sensitivity?" |
---|
| 1671 | |
---|
| 1672 | if(V_flag == 1) //1=yes |
---|
| 1673 | |
---|
| 1674 | Prompt filename,"DIV File",popup,V_PickDIVButton("") |
---|
| 1675 | DoPrompt "Select File",filename |
---|
| 1676 | if (V_Flag) |
---|
| 1677 | return 0 // user canceled |
---|
| 1678 | endif |
---|
| 1679 | // //assign filename to [2] |
---|
| 1680 | newProtocol[2] = V_GetFileNameFromPathNoSemi(fileName) |
---|
| 1681 | |
---|
| 1682 | // //prompt for DIV file, but don't actually open it (/D flag) |
---|
| 1683 | // Open/D/R/F=fileFilters/M="Select the detector sensitivity file"/P=catPathName refnum |
---|
| 1684 | // //check for cancel |
---|
| 1685 | // if(strlen(S_filename)==0) |
---|
| 1686 | // //user cancelled, abort |
---|
| 1687 | // KillWaves/Z newProtocol |
---|
| 1688 | // SetDataFolder root: |
---|
| 1689 | // Abort "Incomplete protocol has been deleted" |
---|
| 1690 | // Endif |
---|
| 1691 | // //assign filename (full path) to [2] |
---|
| 1692 | // newProtocol[2] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
| 1693 | |
---|
| 1694 | |
---|
| 1695 | else |
---|
| 1696 | //no Work.DIV desired |
---|
| 1697 | newProtocol[2] = "none" |
---|
| 1698 | Endif |
---|
| 1699 | ////////////////////////// |
---|
| 1700 | DoAlert 1,"Do you want to mask your files before averaging?" |
---|
| 1701 | |
---|
| 1702 | if(V_flag == 1) //1=yes |
---|
| 1703 | |
---|
| 1704 | Prompt filename,"MASK File",popup,V_PickMASKButton("") |
---|
| 1705 | DoPrompt "Select File",filename |
---|
| 1706 | if (V_Flag) |
---|
| 1707 | return 0 // user canceled |
---|
| 1708 | endif |
---|
| 1709 | // //assign filename to [3] |
---|
| 1710 | newProtocol[3] = V_GetFileNameFromPathNoSemi(fileName) |
---|
| 1711 | |
---|
| 1712 | // //prompt for mask file, but don't actually open it (/D flag) |
---|
| 1713 | // Open/D/R/F=fileFilters/M="Select the mask file"/P=catPathName refnum |
---|
| 1714 | // //check for cancel |
---|
| 1715 | // if(strlen(S_filename)==0) |
---|
| 1716 | // //user cancelled, abort |
---|
| 1717 | // KillWaves/Z newProtocol |
---|
| 1718 | // SetDataFolder root: |
---|
| 1719 | // Abort "Incomplete protocol has been deleted" |
---|
| 1720 | // Endif |
---|
| 1721 | // //assign filename (full path) to [3] |
---|
| 1722 | // newProtocol[3] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
| 1723 | |
---|
| 1724 | |
---|
| 1725 | else |
---|
| 1726 | //no MASK desired |
---|
| 1727 | newProtocol[3] = "none" |
---|
| 1728 | Endif |
---|
| 1729 | |
---|
| 1730 | //absolute scaling |
---|
| 1731 | |
---|
| 1732 | ////////////////////////// |
---|
| 1733 | //ABS parameters stored as keyword=value string |
---|
| 1734 | DoAlert 1,"Do you want absolute scaling?" |
---|
| 1735 | if(V_flag == 1) //1=yes |
---|
| 1736 | //missing param - prompt for values, put in semicolon-separated list |
---|
| 1737 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
| 1738 | SVAR absStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
| 1739 | newProtocol[4] = absStr |
---|
| 1740 | else |
---|
| 1741 | //no absolute scaling desired |
---|
| 1742 | newProtocol[4] = "none" |
---|
| 1743 | Endif |
---|
| 1744 | |
---|
| 1745 | //type of average, plot?, auto/manual naming/saving... put in semicolon separated string |
---|
| 1746 | //of KEY=<value> format for easy parsing |
---|
| 1747 | //Kewords are: AVTYPE,PHI,DPHI,PLOT,SAVE,NAME,SIDE,WIDTH |
---|
| 1748 | //note that AVTYPE,NAME,SIDE have string values, others have numerical values |
---|
| 1749 | /////////////////////// |
---|
| 1750 | DoAlert 1,"Do you want to average your data to I vs. q?" |
---|
| 1751 | if(V_flag == 1) //1=yes |
---|
| 1752 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = "" |
---|
| 1753 | Execute "V_GetAvgInfo()" //will put up missing paramter dialog and do all the work |
---|
| 1754 | //:gAvgInfo is reset by the Proc(), copy this string tot he protocol |
---|
| 1755 | SVAR tempStr=root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
| 1756 | |
---|
| 1757 | //get a file path for saving files, if desired |
---|
| 1758 | /////no - save files to the same data folder as the one with the raw data |
---|
| 1759 | //then only one path to manage. |
---|
| 1760 | //String yesNo = StringByKey("SAVE", tempStr,"=", ";") |
---|
| 1761 | //if(cmpstr("Yes",yesNo) == 0) //0=yes |
---|
| 1762 | //NewPath/C/M="Select Folder"/O Save_path //Save_path is the symbolic path |
---|
| 1763 | //Endif |
---|
| 1764 | |
---|
| 1765 | newProtocol[5] = tempStr |
---|
| 1766 | KillStrings/Z tempStr |
---|
| 1767 | else |
---|
| 1768 | //no averaging desired |
---|
| 1769 | newProtocol[5] = "AVTYPE=none" |
---|
| 1770 | Endif |
---|
| 1771 | |
---|
| 1772 | //returns the name of the newly created (= currently in use) protocol wave through a global |
---|
| 1773 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtoStr |
---|
[1027] | 1774 | |
---|
| 1775 | //reset the panel based on the protocol textwave (currently a string) |
---|
| 1776 | V_ResetToSavedProtocol(newProtoStr) |
---|
| 1777 | |
---|
[1032] | 1778 | SetDataFolder root: |
---|
| 1779 | |
---|
[1027] | 1780 | return(0) |
---|
[1025] | 1781 | End |
---|
| 1782 | |
---|
| 1783 | |
---|
| 1784 | // TODO |
---|
| 1785 | // -- this function may not work properly for VSANS, but I haven't tested it yet |
---|
| 1786 | // -- I'd rather have some sort of display to show the current content of the WORK folders |
---|
| 1787 | // |
---|
| 1788 | // -- the global string fileList does not exist, so this will always fail and return zero |
---|
| 1789 | // |
---|
| 1790 | // |
---|
| 1791 | //function to check the work files (to see what's already there) |
---|
| 1792 | //and compare that with the files that are supposed to be there, according to the |
---|
| 1793 | //current protocol (to save unnecessary time re-loading files) |
---|
| 1794 | // |
---|
| 1795 | //the "type" folder is checked for all files in the list req(ested)Files |
---|
| 1796 | //note that the list of files is a full path:name;ver, while the |
---|
| 1797 | //fileList in the folder is just the name (or a list of names) |
---|
| 1798 | // |
---|
| 1799 | //returns 0 false, if files are NOT present |
---|
| 1800 | //or 1 = true, yes, the files are there as requested |
---|
| 1801 | // |
---|
| 1802 | Function V_AreFilesThere(type,reqFiles) |
---|
| 1803 | String type,reqFiles |
---|
| 1804 | |
---|
| 1805 | //in general, reqFiles is a list of full paths to files - which MAY include semicolon version numbers |
---|
| 1806 | //reqFiles MUST be constructed with COMMAS as list separators, to avoid disaster |
---|
| 1807 | //when the version numbers are interpreted as filenames |
---|
| 1808 | |
---|
| 1809 | //get the number of files requested |
---|
| 1810 | Variable nReq,nCur,match,ii |
---|
| 1811 | nReq = ItemsInList(reqFiles,",") |
---|
| 1812 | |
---|
| 1813 | //get the name of the file currently in BGD - in the global fileList |
---|
| 1814 | //fileList has NAMES ONLY - since it was derived from the file header |
---|
| 1815 | String testStr |
---|
| 1816 | testStr = "root:Packages:NIST:"+type+":fileList" |
---|
| 1817 | if(Exists(testStr) == 2) //2 if string variable exists |
---|
| 1818 | SVAR curFiles = $testStr |
---|
| 1819 | else |
---|
| 1820 | //no files currently in type folder, return zero |
---|
| 1821 | Return (0) |
---|
| 1822 | Endif |
---|
| 1823 | //get the number of files already in folder |
---|
| 1824 | nCur = ItemsInList(curFiles,";") |
---|
| 1825 | If(nCur != nReq) |
---|
| 1826 | Return (0) //quit now, the wrong number of files present |
---|
| 1827 | Endif |
---|
| 1828 | //right number of files... are the names right... |
---|
| 1829 | //check for a match (case-sensitive!!) of each requested file in the curFile string |
---|
| 1830 | //need to extract filenames from reqFiles, since they're the full path and name |
---|
| 1831 | |
---|
| 1832 | ii=0 |
---|
| 1833 | do |
---|
| 1834 | testStr = StringFromList(ii,reqFiles,",") //testStr is the Nth full path and filename |
---|
| 1835 | //testStr = GetFileNameFromPathNoSemi(testStr) //testStr will now be just the filename |
---|
| 1836 | match = stringmatch(curFiles,testStr) |
---|
| 1837 | If(!match) |
---|
| 1838 | Return (0) //req file was not found in curFile list - get out now |
---|
| 1839 | Endif |
---|
| 1840 | ii+=1 |
---|
| 1841 | while(ii<nreq) |
---|
| 1842 | |
---|
| 1843 | Return (1) //indicate that files are OK, no changes needed |
---|
| 1844 | End |
---|
| 1845 | |
---|
| 1846 | |
---|
| 1847 | // |
---|
| 1848 | //will add the files specified in the protocol to the "type" folder |
---|
| 1849 | //will add multiple files together if more than one file is requested |
---|
| 1850 | //(list is a comma delimited list of filenames, with NO path information) |
---|
| 1851 | // |
---|
| 1852 | // This routine NOW DOES check for the possibility that the filenames may have ";vers" from the |
---|
| 1853 | // VAX - data should be picked up from Charlotte, where it won't have version numbers. |
---|
| 1854 | // |
---|
| 1855 | Function V_AddFilesInList(type,list) |
---|
| 1856 | String type,list |
---|
| 1857 | |
---|
| 1858 | //type is the work folder to put the data into, and list is a COMMA delimited list of paths/names |
---|
| 1859 | Variable num,ii,err=0,refNum |
---|
| 1860 | String filename,pathStr="" |
---|
| 1861 | PathInfo catPathName //this is where the files are |
---|
| 1862 | pathstr=S_path |
---|
| 1863 | |
---|
| 1864 | num = ItemsInList(list,",") // comma delimited list |
---|
| 1865 | |
---|
| 1866 | ii=0 |
---|
| 1867 | do |
---|
| 1868 | //FindValidFilename only needed in case of vax version numbers |
---|
| 1869 | filename = pathStr + V_FindValidFilename(StringFromList(ii,list,",")) |
---|
| 1870 | Open/Z/R refnum as filename |
---|
| 1871 | if(V_flag != 0) //file not found |
---|
| 1872 | //Print "file not found AddFilesInList()" |
---|
| 1873 | //Print filename |
---|
| 1874 | err = 1 |
---|
| 1875 | return(err) |
---|
| 1876 | Endif |
---|
| 1877 | Close refnum //file was found and opened, so close it |
---|
| 1878 | |
---|
| 1879 | // Abort "Find equivalent to ReadHeaderAndData(filename)" |
---|
| 1880 | // ReadHeaderAndData(filename) |
---|
| 1881 | err = V_LoadHDF5Data(filename,"RAW") |
---|
| 1882 | |
---|
| 1883 | if(ii == 0) |
---|
| 1884 | //first pass, wipe out the old contents of the work file |
---|
| 1885 | err = V_Raw_to_work(type) |
---|
| 1886 | else |
---|
| 1887 | err = V_Add_raw_to_work(type) |
---|
| 1888 | Endif |
---|
| 1889 | ii+=1 |
---|
| 1890 | while(ii<num) |
---|
| 1891 | return(err) |
---|
| 1892 | End |
---|
| 1893 | |
---|
| 1894 | //function will reduce a sample file (or ask for file(s)) |
---|
| 1895 | //using the protocol named as "protoStr" in the Protocols subfolder |
---|
| 1896 | //samStr is the file(s) or "ask" to force prompt |
---|
| 1897 | //sequentially proceeds through flowchart, doing reduction steps as needed |
---|
| 1898 | //show Schematic to debug what steps/values were used |
---|
| 1899 | // |
---|
| 1900 | //function is long, but straightforward logic |
---|
| 1901 | // |
---|
| 1902 | Function V_ExecuteProtocol(protStr,samStr) |
---|
| 1903 | String protStr,samStr |
---|
| 1904 | //protStr is the full path to the selected protocol wave |
---|
| 1905 | //samStr is either "ask" or the name ONLY ofthe desired sample data file(s) (NO PATH) |
---|
| 1906 | WAVE/T prot = $protStr |
---|
| 1907 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 1908 | |
---|
| 1909 | Variable filesOK,err,notDone |
---|
| 1910 | String activeType, msgStr, junkStr, pathStr="" |
---|
| 1911 | PathInfo catPathName //this is where the files are |
---|
| 1912 | pathStr=S_path |
---|
| 1913 | |
---|
| 1914 | // NVAR useXMLOutput = root:Packages:NIST:gXML_Write |
---|
| 1915 | |
---|
| 1916 | //Parse the instructions in the prot wave |
---|
| 1917 | //0 - bkg |
---|
| 1918 | //1 - emp |
---|
| 1919 | //2 - div |
---|
| 1920 | //3 - mask |
---|
| 1921 | //4 - abs params c2-c5 |
---|
| 1922 | //5 - average params |
---|
| 1923 | //6 = DRK file (**out of sequence) |
---|
[1040] | 1924 | //7 = beginning trim points |
---|
| 1925 | //8 = end trim points |
---|
| 1926 | //9 = unused |
---|
| 1927 | //10 = unused |
---|
| 1928 | //11 = unused |
---|
[1025] | 1929 | |
---|
| 1930 | // for VSANS, DIV is used on each data file as it is converted to WORK, so it needs to be |
---|
| 1931 | // the first thing in place, before any data or backgrounds are loaded |
---|
| 1932 | |
---|
| 1933 | |
---|
| 1934 | // |
---|
| 1935 | // TODO: |
---|
| 1936 | // x- this is no longer done after the COR step, and CAL is not produced as output of DIV |
---|
| 1937 | // x- needs to be aware of the file name passed in |
---|
[1036] | 1938 | // x- PromptForPath does not exist in VSANS. Need a better (automated) way to find the file. |
---|
[1025] | 1939 | |
---|
| 1940 | //check for work.div file (prot[2]) |
---|
| 1941 | //load in if needed |
---|
[1036] | 1942 | // no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) |
---|
[1025] | 1943 | // |
---|
[1036] | 1944 | String divFileName = "" |
---|
[1025] | 1945 | |
---|
| 1946 | If(cmpstr("none",prot[2])!=0) // if !0, then there's a file requested |
---|
| 1947 | If(cmpstr("ask",prot[2]) == 0) |
---|
| 1948 | //ask user for file |
---|
| 1949 | // junkStr = PromptForPath("Select the detector sensitivity file") |
---|
[1036] | 1950 | Prompt divFileName,"DIV File",popup,V_PickDIVButton("") |
---|
| 1951 | DoPrompt "Select File",divFileName |
---|
| 1952 | |
---|
| 1953 | If(strlen(divFileName)==0) |
---|
[1025] | 1954 | SetDataFolder root: |
---|
| 1955 | Abort "No file selected, data reduction aborted" |
---|
| 1956 | Endif |
---|
[1036] | 1957 | V_LoadHDF5Data(divFileName,"DIV") |
---|
[1025] | 1958 | else |
---|
| 1959 | //assume it's a path, and that the first (and only) item is the path:file |
---|
| 1960 | //list processing is necessary to remove any final comma |
---|
| 1961 | junkStr = pathStr + StringFromList(0, prot[2],"," ) |
---|
| 1962 | V_LoadHDF5Data(junkStr,"DIV") |
---|
| 1963 | Endif |
---|
[1051] | 1964 | |
---|
| 1965 | else |
---|
| 1966 | // DIV step is being skipped |
---|
| 1967 | NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor |
---|
| 1968 | Variable saved_gDoDIVCor = gDoDIVCor |
---|
| 1969 | gDoDIVCor = 0 // protocol says to turn it off for now (reset later) |
---|
[1025] | 1970 | Endif |
---|
| 1971 | |
---|
| 1972 | |
---|
| 1973 | // TODO: |
---|
[1036] | 1974 | // -- currently does not allow adding RAW data files together, so no parsing is done |
---|
[1051] | 1975 | // -- NOTE detector corrections (including DIV) are done at the V_Raw_to_Work() step |
---|
| 1976 | // So if the DIV is not part of the protocol, be sure to set/reset the global preference |
---|
[1036] | 1977 | // |
---|
[1025] | 1978 | //prompt for sam data => read raw data, add to sam folder |
---|
| 1979 | //or parse file(s) from the input paramter string |
---|
| 1980 | activeType = "SAM" |
---|
| 1981 | msgStr = "Select sample data" |
---|
| 1982 | //Ask for SAM file or parse |
---|
| 1983 | do |
---|
| 1984 | if((cmpstr(samStr,"ask") == 0) || (cmpstr(samStr,"")==0) ) //zero if strings are equal |
---|
| 1985 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 1986 | if(err) |
---|
| 1987 | PathInfo/S catPathName |
---|
| 1988 | Abort "reduction sequence aborted" |
---|
| 1989 | endif |
---|
| 1990 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 1991 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
| 1992 | //Ask for another SAM file |
---|
| 1993 | do |
---|
| 1994 | DoAlert 1,"Do you want to add another Sample file?" |
---|
| 1995 | if(V_flag == 1) //yes |
---|
| 1996 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 1997 | if(err) |
---|
| 1998 | PathInfo/S catPathName |
---|
| 1999 | Abort "reduction sequence aborted" |
---|
| 2000 | endif |
---|
| 2001 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 2002 | err = V_Add_raw_to_work(activeType) |
---|
| 2003 | notDone = 1 |
---|
| 2004 | else |
---|
| 2005 | notDone = 0 |
---|
| 2006 | endif |
---|
| 2007 | while(notDone) |
---|
| 2008 | break |
---|
| 2009 | Endif |
---|
| 2010 | //"none" is not an option - you always need a sample file - "none" will never return zero |
---|
| 2011 | //if not "ask" AND not "none" then try to parse the filenames |
---|
| 2012 | If((cmpstr(samStr,"none") != 0) && (cmpstr(samStr,"ask") != 0)) |
---|
| 2013 | //filesOK = AreFilesThere(activeType,samStr) //return 1 if correct files are already there |
---|
| 2014 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
| 2015 | if(!filesOK) |
---|
| 2016 | //add the correct file(s) to SAM |
---|
| 2017 | |
---|
| 2018 | // TODO: only one file is allowed currently |
---|
| 2019 | err = V_AddFilesInList(activeType,samStr) |
---|
| 2020 | |
---|
| 2021 | if(err) |
---|
| 2022 | //Print "samstr = ",samStr |
---|
| 2023 | Abort "SAM file not found, reset SAM file" |
---|
| 2024 | Endif |
---|
| 2025 | Endif |
---|
| 2026 | Endif |
---|
| 2027 | While(0) |
---|
[1027] | 2028 | // TODO |
---|
[1036] | 2029 | // -- this may not be the most reliable way to pass the file name (for naming of the saved file later) |
---|
[1027] | 2030 | SVAR file_name = root:file_Name |
---|
[1036] | 2031 | String samFileLoaded = file_name //keep a copy of the sample file loaded |
---|
[1027] | 2032 | |
---|
[1025] | 2033 | //always update |
---|
| 2034 | V_UpdateDisplayInformation(ActiveType) |
---|
| 2035 | |
---|
| 2036 | //check for bkg file -- "ask" might not fail - "ask?" will - ? not allowed in VAX filenames |
---|
| 2037 | // add if needed |
---|
| 2038 | //use a "case" statement |
---|
| 2039 | msgStr = "Select background file" |
---|
| 2040 | activeType = "BGD" |
---|
| 2041 | do |
---|
| 2042 | if(cmpstr(prot[0],"ask") == 0) //zero if strings are equal |
---|
| 2043 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 2044 | if(err) |
---|
| 2045 | PathInfo/S catPathName |
---|
| 2046 | Abort "reduction sequence aborted" |
---|
| 2047 | endif |
---|
| 2048 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 2049 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
| 2050 | //Ask for another BGD file |
---|
| 2051 | do |
---|
| 2052 | DoAlert 1,"Do you want to add another Background file?" |
---|
| 2053 | if(V_flag == 1) //yes |
---|
| 2054 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 2055 | if(err) |
---|
| 2056 | PathInfo/S catPathName |
---|
| 2057 | Abort "reduction sequence aborted" |
---|
| 2058 | endif |
---|
| 2059 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 2060 | err = V_Add_raw_to_work(activeType) |
---|
| 2061 | notDone = 1 |
---|
| 2062 | else |
---|
| 2063 | notDone = 0 |
---|
| 2064 | endif |
---|
| 2065 | while(notDone) |
---|
| 2066 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2067 | break |
---|
| 2068 | Endif |
---|
| 2069 | If(cmpstr(prot[0],"none") == 0) |
---|
| 2070 | //clean out the BKG folder? |
---|
| 2071 | //KillDataFolder root:BKG |
---|
| 2072 | //NewDataFolder/O root:BKG |
---|
| 2073 | break |
---|
| 2074 | Endif |
---|
| 2075 | //if not "ask" AND not "none" then try to parse the filenames |
---|
| 2076 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[0],"ask") != 0)) |
---|
| 2077 | //filesOK = AreFilesThere(activeType,prot[0]) |
---|
| 2078 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
| 2079 | if(!filesOK) |
---|
| 2080 | //add the correct file(s) to BGD |
---|
| 2081 | string bgdStr = prot[0] |
---|
| 2082 | err = V_AddFilesInList(activeType,bgdStr) |
---|
| 2083 | If(err) |
---|
| 2084 | Abort "BGD file not found. Reset BGD file list" |
---|
| 2085 | Endif |
---|
| 2086 | Endif |
---|
| 2087 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2088 | Endif |
---|
| 2089 | While(0) |
---|
| 2090 | |
---|
| 2091 | |
---|
| 2092 | //check for emp file (prot[1]) |
---|
| 2093 | // add if needed |
---|
| 2094 | msgStr = "Select empty cell data" |
---|
| 2095 | activeType = "EMP" |
---|
| 2096 | do |
---|
| 2097 | if(cmpstr(prot[1],"ask") == 0) |
---|
| 2098 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 2099 | if(err) |
---|
| 2100 | PathInfo/S catPathName |
---|
| 2101 | Abort "reduction sequence aborted" |
---|
| 2102 | endif |
---|
| 2103 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 2104 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
| 2105 | //Ask for another EMP file |
---|
| 2106 | do |
---|
| 2107 | DoAlert 1,"Do you want to add another Empty Cell file?" |
---|
| 2108 | if(V_flag == 1) //yes |
---|
| 2109 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
| 2110 | if(err) |
---|
| 2111 | PathInfo/S catPathName |
---|
| 2112 | Abort "reduction sequence aborted" |
---|
| 2113 | endif |
---|
| 2114 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
| 2115 | err = V_Add_raw_to_work(activeType) |
---|
| 2116 | notDone = 1 |
---|
| 2117 | else |
---|
| 2118 | notDone = 0 |
---|
| 2119 | endif |
---|
| 2120 | while(notDone) |
---|
| 2121 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2122 | break |
---|
| 2123 | Endif |
---|
| 2124 | If(cmpstr(prot[1],"none") == 0) |
---|
| 2125 | //clean out the EMP folder? |
---|
| 2126 | //KillDataFolder root:Packages:NIST:EMP |
---|
| 2127 | //NewDataFolder/O root:Packages:NIST:EMP |
---|
| 2128 | break |
---|
| 2129 | Endif |
---|
| 2130 | //if not "ask" AND not "none" then try to parse the filenames |
---|
| 2131 | If((cmpstr(prot[1],"none") != 0) && (cmpstr(prot[1],"ask") != 0)) |
---|
| 2132 | //filesOK = AreFilesThere(activeType,prot[1]) |
---|
| 2133 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
| 2134 | if(!filesOK) |
---|
| 2135 | //add the correct file(s) to BGD |
---|
| 2136 | err = V_AddFilesInList(activeType,prot[1]) |
---|
| 2137 | If(err) |
---|
| 2138 | Abort "EMP file not found. Reset EMP file list" |
---|
| 2139 | Endif |
---|
| 2140 | Endif |
---|
| 2141 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2142 | Endif |
---|
| 2143 | While(0) |
---|
| 2144 | |
---|
| 2145 | //do the CORRECT step based on the answers to emp and bkg subtraction |
---|
| 2146 | //by setting the proper"mode" |
---|
| 2147 | //1 = both emp and bgd subtraction |
---|
| 2148 | //2 = only bgd subtraction |
---|
| 2149 | //3 = only emp subtraction |
---|
| 2150 | //4 = no subtraction |
---|
| 2151 | //additional modes 091301 |
---|
| 2152 | //11 = emp, bgd, drk |
---|
| 2153 | //12 = bgd and drk |
---|
| 2154 | //13 = emp and drk |
---|
| 2155 | //14 = no subtractions |
---|
| 2156 | //work.drk is from proto[6] |
---|
| 2157 | // |
---|
| 2158 | //subtracting just the DRK data is NOT an option - it doesnt' really make any physical sense |
---|
| 2159 | // - in this case, DRK is skipped (equivalent to mode==4) |
---|
| 2160 | // automatically accounts for attenuators given the lookup tables and the |
---|
| 2161 | //desired subtractions |
---|
| 2162 | //Attenuator lookup tables are alredy implemented (NG1 = NG7) |
---|
| 2163 | // |
---|
| 2164 | |
---|
| 2165 | |
---|
| 2166 | /////// DRK is SKIPPED |
---|
| 2167 | |
---|
| 2168 | // //read in the DRK data if necessary |
---|
| 2169 | // //only one file, assumed to be RAW data |
---|
| 2170 | // // |
---|
| 2171 | // String fname="",drkStr="" |
---|
| 2172 | // drkStr=StringByKey("DRK",prot[6],"=",",") |
---|
| 2173 | // if(cmpstr(drkStr,"none") != 0) |
---|
| 2174 | // err = ReadHeaderAndData( (pathStr+drkStr) ) |
---|
| 2175 | // if(err) |
---|
| 2176 | // PathInfo/S catPathName |
---|
| 2177 | // Abort "reduction sequence aborted" |
---|
| 2178 | // endif |
---|
| 2179 | // err = V_Raw_to_Work_NoNorm("DRK") |
---|
| 2180 | // endif |
---|
| 2181 | |
---|
| 2182 | |
---|
| 2183 | |
---|
| 2184 | //dispatch to the proper "mode" of Correct() |
---|
| 2185 | Variable mode=4,val |
---|
| 2186 | do |
---|
| 2187 | if( (cmpstr("none",prot[0]) == 0) && (cmpstr("none",prot[1]) == 0) ) |
---|
| 2188 | //no subtraction (mode = 4), |
---|
| 2189 | mode = 4 |
---|
| 2190 | Endif |
---|
| 2191 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") == 0)) |
---|
| 2192 | //subtract BGD only |
---|
| 2193 | mode=2 |
---|
| 2194 | Endif |
---|
| 2195 | If((cmpstr(prot[0],"none") == 0) && (cmpstr(prot[1],"none") != 0)) |
---|
| 2196 | //subtract EMP only |
---|
| 2197 | mode=3 |
---|
| 2198 | Endif |
---|
| 2199 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") != 0)) |
---|
| 2200 | // bkg and emp subtraction are to be done (BOTH not "none") |
---|
| 2201 | mode=1 |
---|
| 2202 | Endif |
---|
| 2203 | activeType = "COR" |
---|
| 2204 | //add in DRK mode (0= no used, 10 = used) |
---|
| 2205 | val = NumberByKey("DRKMODE",prot[6],"=","," ) |
---|
| 2206 | mode += val |
---|
| 2207 | // print "mode = ",mode |
---|
| 2208 | err = V_Correct(mode) |
---|
| 2209 | if(err) |
---|
| 2210 | SetDataFolder root: |
---|
| 2211 | Abort "error in Correct, called from executeprotocol, normal cor" |
---|
| 2212 | endif |
---|
| 2213 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2214 | While(0) |
---|
| 2215 | |
---|
| 2216 | |
---|
| 2217 | //////////////////////////////////////////////////////// |
---|
| 2218 | |
---|
[1027] | 2219 | // TODO: |
---|
| 2220 | // -- calculation works, needs proper inputs (solid angle aware) |
---|
[1036] | 2221 | // -- Open beam method needs to be verified in V_AskForAbsoluteParams_Quest() |
---|
[1025] | 2222 | Variable c2,c3,c4,c5,kappa_err |
---|
| 2223 | //do absolute scaling if desired |
---|
[1036] | 2224 | // DoAlert 0,"Abs step incomplete" |
---|
[1025] | 2225 | |
---|
| 2226 | if(cmpstr("none",prot[4])!=0) |
---|
| 2227 | if(cmpstr("ask",prot[4])==0) |
---|
| 2228 | //get the params from the user |
---|
| 2229 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
| 2230 | //then from the list |
---|
| 2231 | SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
| 2232 | c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";") //parse the list of values |
---|
| 2233 | c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";") |
---|
| 2234 | c4 = NumberByKey("IZERO", junkAbsStr, "=", ";") |
---|
| 2235 | c5 = NumberByKey("XSECT", junkAbsStr, "=", ";") |
---|
| 2236 | kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";") |
---|
| 2237 | else |
---|
| 2238 | //get the parames from the list |
---|
| 2239 | c2 = NumberByKey("TSTAND", prot[4], "=", ";") //parse the list of values |
---|
| 2240 | c3 = NumberByKey("DSTAND", prot[4], "=", ";") |
---|
| 2241 | c4 = NumberByKey("IZERO", prot[4], "=", ";") |
---|
| 2242 | c5 = NumberByKey("XSECT", prot[4], "=", ";") |
---|
| 2243 | kappa_err = NumberByKey("SDEV", prot[4], "=", ";") |
---|
| 2244 | Endif |
---|
| 2245 | //get the sample trans and thickness from the activeType folder |
---|
[1027] | 2246 | Variable c0 = V_getSampleTransmission(activeType) //sample transmission |
---|
| 2247 | Variable c1 = V_getSampleThickness(activeType) //sample thickness |
---|
[1025] | 2248 | |
---|
| 2249 | err = V_Absolute_Scale(activeType,c0,c1,c2,c3,c4,c5,kappa_err) |
---|
| 2250 | if(err) |
---|
| 2251 | SetDataFolder root: |
---|
[1027] | 2252 | Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" |
---|
[1025] | 2253 | endif |
---|
| 2254 | activeType = "ABS" |
---|
| 2255 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
| 2256 | Endif |
---|
| 2257 | |
---|
[1027] | 2258 | // |
---|
[1036] | 2259 | // TODO |
---|
| 2260 | // x- fill in the "ask" step |
---|
[1035] | 2261 | // -- none is OK, except if the kill fails for any reason |
---|
[1036] | 2262 | // x- the regular case of the file name specified by the protocol works correctly |
---|
| 2263 | // x- don't create a null mask if not used, it will handle the error and print out that the mask is missing |
---|
[1035] | 2264 | |
---|
[1036] | 2265 | //mask data if desired (this is done automatically when the data is binned to I(q)) and is |
---|
[1035] | 2266 | //not done explicitly here |
---|
[1027] | 2267 | |
---|
[1025] | 2268 | //check for mask |
---|
| 2269 | //doesn't change the activeType |
---|
[1036] | 2270 | String mskFileName="" |
---|
| 2271 | |
---|
[1025] | 2272 | if(cmpstr("none",prot[3])!=0) |
---|
| 2273 | If(cmpstr("ask",prot[3])==0) |
---|
| 2274 | //get file from user |
---|
[1036] | 2275 | // TODO |
---|
| 2276 | // x- fill in the get file prompt, and handle the result |
---|
| 2277 | Prompt mskFileName,"MASK File",popup,V_PickMASKButton("") |
---|
| 2278 | DoPrompt "Select File",mskFileName |
---|
| 2279 | // if (V_Flag) |
---|
| 2280 | // return 0 // user cancelled |
---|
| 2281 | // endif |
---|
[1025] | 2282 | |
---|
[1036] | 2283 | If(strlen(mskFileName)==0) //use cancelled |
---|
[1025] | 2284 | //if none desired, make sure that the old mask is deleted |
---|
[1035] | 2285 | KillDataFolder/Z root:Packages:NIST:VSANS:MSK: |
---|
| 2286 | NewDataFolder/O root:Packages:NIST:VSANS:MSK |
---|
[1036] | 2287 | |
---|
[1025] | 2288 | DoAlert 0,"No Mask file selected, data not masked" |
---|
| 2289 | else |
---|
[1036] | 2290 | //read in the file from the selection |
---|
| 2291 | V_LoadHDF5Data(mskFileName,"MSK") |
---|
[1025] | 2292 | Endif |
---|
| 2293 | else |
---|
| 2294 | //just read it in from the protocol |
---|
| 2295 | //list processing is necessary to remove any final comma |
---|
[1036] | 2296 | mskFileName = pathStr + StringFromList(0, prot[3],"," ) |
---|
| 2297 | V_LoadHDF5Data(mskFileName,"MSK") |
---|
[1025] | 2298 | Endif |
---|
[1036] | 2299 | |
---|
[1025] | 2300 | else |
---|
| 2301 | //if none desired, make sure that the old mask is deleted |
---|
[1027] | 2302 | // TODO |
---|
| 2303 | // x- clean out the data folder |
---|
| 2304 | // x- note that V_KillNamedDataFolder() points to RawVSANS, and won't work |
---|
| 2305 | // -- what happens if the kill fails? need error handling |
---|
| 2306 | // |
---|
| 2307 | KillDataFolder/Z root:Packages:NIST:VSANS:MSK: |
---|
[1035] | 2308 | NewDataFolder/O root:Packages:NIST:VSANS:MSK |
---|
| 2309 | |
---|
[1025] | 2310 | Endif |
---|
| 2311 | |
---|
| 2312 | |
---|
| 2313 | // average/save data as specified |
---|
| 2314 | //Parse the keyword=<Value> string as needed, based on AVTYPE |
---|
| 2315 | |
---|
| 2316 | //average/plot first |
---|
| 2317 | String av_type = StringByKey("AVTYPE",prot[5],"=",";") |
---|
| 2318 | If(cmpstr(av_type,"none") != 0) |
---|
| 2319 | If (cmpstr(av_type,"")==0) //if the key could not be found... (if "ask" the string) |
---|
[1036] | 2320 | //get the averaging parameters from the user, as if the set button was hit in the panel |
---|
[1025] | 2321 | V_SetAverageParamsButtonProc("dummy") //from "ProtocolAsPanel" |
---|
| 2322 | SVAR tempAveStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
| 2323 | av_type = StringByKey("AVTYPE",tempAveStr,"=",";") |
---|
| 2324 | else |
---|
| 2325 | //there is info in the string, use the protocol |
---|
| 2326 | //set the global keyword-string to prot[5] |
---|
| 2327 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = prot[5] |
---|
| 2328 | Endif |
---|
| 2329 | Endif |
---|
| 2330 | |
---|
| 2331 | //convert the folder to linear scale before averaging, then revert by calling the window hook |
---|
[1027] | 2332 | // (not needed for VSANS, data is always linear scale) |
---|
[1025] | 2333 | |
---|
[1035] | 2334 | // bin and plot the data |
---|
[1036] | 2335 | |
---|
[1035] | 2336 | // TODO |
---|
[1036] | 2337 | // -- this switch does nothing -- fill it in |
---|
| 2338 | // x- need to convert BINTYPE keyword into a numerical value to pass |
---|
| 2339 | // |
---|
| 2340 | |
---|
[1035] | 2341 | String binTypeStr = StringByKey("BINTYPE",prot[5],"=",";") |
---|
| 2342 | // plotting is not really necessary, and the graph may not be open - so skip for now? |
---|
| 2343 | Variable binType |
---|
| 2344 | binType = V_BinTypeStr2Num(binTypeStr) |
---|
| 2345 | if(binType == 0) |
---|
| 2346 | Abort "Binning mode not found in V_QBinAllPanels() "// when no case matches |
---|
| 2347 | endif |
---|
| 2348 | |
---|
| 2349 | |
---|
[1044] | 2350 | // |
---|
| 2351 | // TODO: |
---|
| 2352 | // -- do I calculate the proper resolution here? I've already decoded the binning type |
---|
| 2353 | // and the averaging type has been specified by the protocol |
---|
| 2354 | // -- if I calculate the resolution here, then the Trimming routines must be updated |
---|
| 2355 | // to trim the resolution waves also. This positioning may work for |
---|
| 2356 | // pinhole resolution, but anything using the matrix method - it won't work - and I'll need |
---|
| 2357 | // a different solution |
---|
| 2358 | // |
---|
[1025] | 2359 | strswitch(av_type) //dispatch to the proper routine to average to 1D data |
---|
| 2360 | case "none": |
---|
| 2361 | //still do nothing |
---|
| 2362 | break |
---|
| 2363 | case "2D_ASCII": |
---|
| 2364 | //do nothing |
---|
| 2365 | break |
---|
| 2366 | case "QxQy_ASCII": |
---|
| 2367 | //do nothing |
---|
| 2368 | break |
---|
| 2369 | case "PNG_Graphic": |
---|
| 2370 | //do nothing |
---|
| 2371 | break |
---|
| 2372 | case "Rectangular": |
---|
| 2373 | // RectangularAverageTo1D(activeType) |
---|
| 2374 | break |
---|
| 2375 | case "Annular": |
---|
| 2376 | // AnnularAverageTo1D(activeType) |
---|
[1057] | 2377 | String detGroup = StringByKey("DETGROUP",prot[5],"=",";") |
---|
| 2378 | Variable qCtr_Ann = NumberByKey("QCENTER",prot[5],"=",";") |
---|
| 2379 | Variable qWidth = NumberByKey("QDELTA",prot[5],"=",";") |
---|
| 2380 | V_QBinAllPanels_Annular(activeType,detGroup,qCtr_Ann,qWidth) |
---|
[1025] | 2381 | break |
---|
| 2382 | case "Circular": |
---|
[1044] | 2383 | |
---|
| 2384 | V_QBinAllPanels_Circular(activeType,binType) // this does a default circular average |
---|
[1025] | 2385 | break |
---|
| 2386 | case "Sector": |
---|
| 2387 | // CircularAverageTo1D(activeType) |
---|
| 2388 | break |
---|
| 2389 | case "Sector_PlusMinus": |
---|
| 2390 | // Sector_PlusMinus1D(activeType) |
---|
| 2391 | break |
---|
| 2392 | default: |
---|
| 2393 | //do nothing |
---|
| 2394 | endswitch |
---|
[1027] | 2395 | |
---|
[1036] | 2396 | // TODO |
---|
| 2397 | // x- this call will bin the active type, then the next call bins the active type |
---|
| 2398 | // x- then later, I dispatch to bin the active type... |
---|
| 2399 | // x- !!!need to split out the panel draw and the binning calls from V_PlotData_Panel |
---|
[1035] | 2400 | // |
---|
[1057] | 2401 | // TODO: |
---|
| 2402 | // -- BAD logic here, skipping the normal graph if annular is chosen. Go back and see how I do this |
---|
| 2403 | // in SANS for a better and more foolproof way to do this |
---|
| 2404 | // |
---|
| 2405 | if(cmpstr(av_type,"Annular") != 0) |
---|
| 2406 | V_PlotData_Panel() //this brings the plot window to the front, or draws it (ONLY) |
---|
| 2407 | V_Update1D_Graph(activeType,binType) //update the graph, data was already binned |
---|
| 2408 | endif |
---|
[1025] | 2409 | ///// end of averaging dispatch |
---|
| 2410 | |
---|
[1027] | 2411 | |
---|
| 2412 | // TODO |
---|
| 2413 | // x- how do I get the sample file name? |
---|
[1036] | 2414 | // local variable samFileLoaded is the file name loaded (contains the extension) |
---|
[1027] | 2415 | // |
---|
[1025] | 2416 | //save data if desired |
---|
| 2417 | String fullpath = "", newfileName="" |
---|
[1036] | 2418 | String saveType = StringByKey("SAVE",prot[5],"=",";") //does user want to save data? |
---|
| 2419 | If( (cmpstr(saveType[0,2],"Yes")==0) && (cmpstr(av_type,"none") != 0) ) |
---|
[1025] | 2420 | //then save |
---|
[1036] | 2421 | newFileName = RemoveEnding(samFileLoaded,".nxs.ngv") |
---|
[1025] | 2422 | |
---|
| 2423 | //pick ABS or AVE extension |
---|
| 2424 | String exten = activeType |
---|
| 2425 | if(cmpstr(exten,"ABS") != 0) |
---|
| 2426 | exten = "AVE" |
---|
| 2427 | endif |
---|
| 2428 | if(cmpstr(av_type,"2D_ASCII") == 0) |
---|
| 2429 | exten = "ASC" |
---|
| 2430 | endif |
---|
| 2431 | if(cmpstr(av_type,"QxQy_ASCII") == 0) |
---|
| 2432 | exten = "DAT" |
---|
| 2433 | endif |
---|
| 2434 | |
---|
| 2435 | // // add an "x" to the file extension if the output is XML |
---|
| 2436 | // // currently (2010), only for ABS and AVE (1D) output |
---|
| 2437 | // if( cmpstr(exten,"ABS") == 0 || cmpstr(exten,"AVE") == 0 ) |
---|
| 2438 | // if(useXMLOutput == 1) |
---|
| 2439 | // exten += "x" |
---|
| 2440 | // endif |
---|
| 2441 | // endif |
---|
| 2442 | |
---|
| 2443 | //Path is catPathName, symbolic path |
---|
| 2444 | //if this doesn't exist, a dialog will be presented by setting dialog = 1 |
---|
[1027] | 2445 | // |
---|
| 2446 | // |
---|
[1025] | 2447 | Variable dialog = 0 |
---|
[1036] | 2448 | |
---|
| 2449 | // TODO |
---|
| 2450 | // -- need to define nBeg and nEnd somewhere |
---|
| 2451 | // -- currently hard-wired |
---|
| 2452 | // --do I need to define these "per-panel"? |
---|
| 2453 | |
---|
[1025] | 2454 | PathInfo/S catPathName |
---|
[1036] | 2455 | String item = StringByKey("NAME",prot[5],"=",";") //Auto or Manual naming |
---|
[1025] | 2456 | String autoname = StringByKey("AUTONAME",prot[5],"=",";") //autoname - will get empty string if not present |
---|
| 2457 | If((cmpstr(item,"Manual")==0) || (cmpstr(newFileName,"") == 0)) |
---|
| 2458 | //manual name if requested or if no name can be derived from header |
---|
| 2459 | fullPath = newfileName + "."+ exten //puts possible new name or null string in dialog |
---|
| 2460 | dialog = 1 //force dialog for user to enter name |
---|
| 2461 | else |
---|
| 2462 | //auto-generate name and prepend path - won't put up any dialogs since it has all it needs |
---|
| 2463 | //use autoname if present |
---|
[1035] | 2464 | if (cmpstr(autoname,"") != 0) |
---|
| 2465 | fullPath = S_Path + autoname + "." +exten |
---|
| 2466 | else |
---|
| 2467 | fullPath = S_Path + newFileName+"." + exten |
---|
| 2468 | endif |
---|
[1025] | 2469 | Endif |
---|
| 2470 | // |
---|
| 2471 | strswitch(av_type) |
---|
| 2472 | case "Annular": |
---|
| 2473 | // WritePhiave_W_Protocol(activeType,fullPath,dialog) |
---|
[1057] | 2474 | V_fWrite1DAnnular("root:Packages:NIST:VSANS:",activeType,detGroup,newFileName+".phi") |
---|
| 2475 | Print "data written to: "+ newFileName+".phi" |
---|
| 2476 | |
---|
[1025] | 2477 | break |
---|
| 2478 | case "2D_ASCII": |
---|
| 2479 | // Fast2DExport(activeType,fullPath,dialog) |
---|
| 2480 | break |
---|
| 2481 | case "QxQy_ASCII": |
---|
| 2482 | // QxQy_Export(activeType,fullPath,dialog) |
---|
| 2483 | break |
---|
| 2484 | case "PNG_Graphic": |
---|
| 2485 | // SaveAsPNG(activeType,fullpath,dialog) |
---|
| 2486 | break |
---|
| 2487 | default: |
---|
| 2488 | // if (useXMLOutput == 1) |
---|
| 2489 | // WriteXMLWaves_W_Protocol(activeType,fullPath,dialog) |
---|
| 2490 | // else |
---|
| 2491 | // WriteWaves_W_Protocol(activeType,fullpath,dialog) |
---|
| 2492 | // endif |
---|
[1027] | 2493 | // |
---|
| 2494 | // TODO: |
---|
[1038] | 2495 | // -- fill in all of the cases, default is only the "standard" circular average I(q) |
---|
[1039] | 2496 | // -- get the trim strings from somewhere-- from the file or from the protocol?? |
---|
| 2497 | // then replace the null strings being passed |
---|
[1027] | 2498 | |
---|
[1036] | 2499 | if(cmpstr(saveType,"Yes - Concatenate")==0) |
---|
[1040] | 2500 | V_Trim1DDataStr(activeType,binType,prot[7],prot[8]) // TODO -- passing null strings uses global or default trim values |
---|
[1038] | 2501 | // V_Trim1DData(activeType,binType,nBeg,nEnd) |
---|
[1039] | 2502 | V_ConcatenateForSave("root:Packages:NIST:VSANS:",activeType,"",binType) // this removes q=0 point, concatenates, sorts |
---|
| 2503 | V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten) //don't pass the full path, just the name |
---|
[1036] | 2504 | else |
---|
| 2505 | // remove the q=0 point from the back detector, if it's there |
---|
| 2506 | // does not trim any of the data |
---|
| 2507 | V_RemoveQ0_B(activeType) |
---|
[1042] | 2508 | V_Write1DData_ITX("root:Packages:NIST:VSANS:",activeType,newFileName,binType) |
---|
[1036] | 2509 | endif |
---|
[1057] | 2510 | Print "data written to: "+ newFileName+"."+exten |
---|
[1036] | 2511 | |
---|
[1025] | 2512 | endswitch |
---|
| 2513 | |
---|
| 2514 | Endif |
---|
| 2515 | |
---|
| 2516 | //done with everything in protocol list |
---|
[1051] | 2517 | |
---|
| 2518 | |
---|
| 2519 | // reset any global preferences that I had changed |
---|
| 2520 | gDoDIVCor = saved_gDoDIVCor |
---|
| 2521 | |
---|
| 2522 | |
---|
[1025] | 2523 | Return(0) |
---|
| 2524 | End |
---|
| 2525 | |
---|
| 2526 | |
---|
[1036] | 2527 | |
---|
| 2528 | |
---|
| 2529 | |
---|
[1025] | 2530 | //missing parameter dialog to solicit the 4 absolute intensity parameters |
---|
| 2531 | //from the user |
---|
| 2532 | //values are passed back as a global string variable (keyword=value) |
---|
| 2533 | // |
---|
[1027] | 2534 | Proc V_AskForAbsoluteParams(c2,c3,c4,c5,I_err) |
---|
[1035] | 2535 | Variable c2=1,c3=1,c4=1e8,c5=1,I_err=1 |
---|
[1025] | 2536 | Prompt c2, "Standard Transmission" |
---|
| 2537 | Prompt c3, "Standard Thickness (cm)" |
---|
| 2538 | Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" |
---|
| 2539 | Prompt c5, "Standard Cross-Section (cm-1)" |
---|
[1027] | 2540 | Prompt I_err, "error in I(q=0) (one std dev)" |
---|
[1025] | 2541 | |
---|
| 2542 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="" |
---|
| 2543 | |
---|
| 2544 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "TSTAND="+num2str(c2) |
---|
| 2545 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "DSTAND="+num2str(c3) |
---|
| 2546 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "IZERO="+num2str(c4) |
---|
| 2547 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "XSECT="+num2str(c5) |
---|
[1027] | 2548 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "SDEV="+num2str(I_err) |
---|
[1025] | 2549 | |
---|
| 2550 | End |
---|
| 2551 | |
---|
| 2552 | |
---|
| 2553 | // |
---|
| 2554 | // TODO |
---|
| 2555 | // -- fill in all of the functionality for calculation from direct beam |
---|
[1036] | 2556 | // and verify that the calculations are numerically correct |
---|
[1025] | 2557 | // |
---|
| 2558 | //asks the user for absolute scaling information. the user can either |
---|
[1036] | 2559 | //enter the necessary values in manually (missing parameter dialog) |
---|
[1025] | 2560 | //or the user can select an empty beam file from a standard open dialog |
---|
| 2561 | //if an empty beam file is selected, the "kappa" value is automatically calculated |
---|
| 2562 | //in either case, the global keyword=value string is set. |
---|
| 2563 | // |
---|
| 2564 | Function V_AskForAbsoluteParams_Quest() |
---|
| 2565 | |
---|
[1027] | 2566 | Variable err,loc,refnum |
---|
[1071] | 2567 | |
---|
| 2568 | Variable ii |
---|
| 2569 | |
---|
| 2570 | Variable kappa=1 |
---|
| 2571 | Variable kappa_err |
---|
| 2572 | |
---|
| 2573 | //get the necessary variables for the calculation of kappa |
---|
| 2574 | Variable countTime,monCnt,sdd,pixel |
---|
| 2575 | String detStr,junkStr,errStr |
---|
| 2576 | |
---|
| 2577 | Variable empAttenFactor, emp_atten_err |
---|
| 2578 | |
---|
| 2579 | //get the XY box and files |
---|
| 2580 | Variable x1,x2,y1,y2,emptyCts,empty_ct_err |
---|
| 2581 | String emptyFileName,tempStr,divFileName,detPanel_toSum |
---|
| 2582 | |
---|
[1025] | 2583 | //ask user if he wants to use a transmision file for absolute scaling |
---|
| 2584 | //or if he wants to enter his own information |
---|
| 2585 | err = V_UseStdOrEmpForABS() |
---|
| 2586 | //DoAlert 1,"<Yes> to enter your own values, <No> to select an empty beam flux file" |
---|
| 2587 | If ( err==1 ) |
---|
| 2588 | //secondary standard selected, prompt for values |
---|
| 2589 | Execute "V_AskForAbsoluteParams()" //missing parameters |
---|
| 2590 | else |
---|
| 2591 | //empty beam flux file selected, prompt for file, and use this to calculate KAPPA |
---|
| 2592 | |
---|
[1036] | 2593 | // TODO |
---|
| 2594 | // x- need an empty beam file name |
---|
| 2595 | // |
---|
| 2596 | Prompt emptyFileName,"Empty Beam File",popup,V_PickEMPBeamButton("") |
---|
| 2597 | DoPrompt "Select File",emptyFileName |
---|
| 2598 | if (V_Flag) |
---|
| 2599 | return 0 // user canceled |
---|
| 2600 | endif |
---|
[1025] | 2601 | |
---|
[1071] | 2602 | // TODO |
---|
| 2603 | // x- need panel |
---|
| 2604 | // |
---|
| 2605 | Prompt detPanel_toSum,"Panel with Direct Beam",popup,ksDetectorListAll |
---|
| 2606 | DoPrompt "Select Panel",detPanel_toSum |
---|
| 2607 | if (V_Flag) |
---|
| 2608 | return 0 // user canceled |
---|
| 2609 | endif |
---|
| 2610 | |
---|
[1036] | 2611 | //need the detector sensitivity file - make a guess, allow to override |
---|
| 2612 | Prompt divFileName,"DIV File",popup,V_PickDIVButton("") |
---|
| 2613 | DoPrompt "Select File",divFileName |
---|
| 2614 | if (V_Flag) |
---|
| 2615 | return 0 // user canceled |
---|
| 2616 | endif |
---|
| 2617 | V_LoadHDF5Data(divFileName,"DIV") |
---|
[1025] | 2618 | |
---|
[1036] | 2619 | |
---|
| 2620 | WAVE xyBoxW = V_getBoxCoordinates(emptyFileName) |
---|
| 2621 | |
---|
[1025] | 2622 | |
---|
[1036] | 2623 | // load in the data, and use all of the corrections, especially DIV |
---|
| 2624 | // (be sure the corrections are actually set to "on", don't assume that they are) |
---|
| 2625 | // save preferences for file loading |
---|
| 2626 | Variable savDivPref,savSAPref |
---|
| 2627 | NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor |
---|
| 2628 | savDivPref = gDoDIVCor |
---|
| 2629 | NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor |
---|
| 2630 | savSAPref = gDoSolidAngleCor |
---|
| 2631 | |
---|
| 2632 | // set local preferences |
---|
| 2633 | gDoDIVCor = 1 |
---|
| 2634 | gDoSolidAngleCor = 1 |
---|
| 2635 | |
---|
| 2636 | V_LoadAndPlotRAW_wName(emptyFileName) |
---|
| 2637 | // convert raw->SAM |
---|
[1071] | 2638 | // V_Raw_to_work("SAM") |
---|
| 2639 | // V_UpdateDisplayInformation("SAM") |
---|
| 2640 | V_UpdateDisplayInformation("RAW") |
---|
[1036] | 2641 | |
---|
[1071] | 2642 | // do the DIV correction |
---|
| 2643 | if (gDoDIVCor == 1) |
---|
| 2644 | // need extra check here for file existence |
---|
| 2645 | // if not in DIV folder, load. |
---|
| 2646 | // if unable to load, skip correction and report error (Alert?) (Ask to Load?) |
---|
| 2647 | Print "Doing DIV correction"// for "+ detStr |
---|
| 2648 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
| 2649 | detStr = StringFromList(ii, ksDetectorListAll, ";") |
---|
| 2650 | Wave w = V_getDetectorDataW("RAW",detStr) |
---|
| 2651 | Wave w_err = V_getDetectorDataErrW("RAW",detStr) |
---|
| 2652 | |
---|
| 2653 | V_DIVCorrection(w,w_err,detStr,"RAW") // do the correction in-place |
---|
| 2654 | endfor |
---|
| 2655 | else |
---|
| 2656 | Print "DIV correction NOT DONE" // not an error since correction was unchecked |
---|
| 2657 | endif |
---|
| 2658 | |
---|
[1036] | 2659 | // and determine box sum and error |
---|
| 2660 | // store these locally |
---|
[1071] | 2661 | |
---|
| 2662 | // TODO |
---|
| 2663 | // x- need to get the panel string for the sum. |
---|
| 2664 | // x- the detector string is currently hard-wired |
---|
| 2665 | // detStr = "MR" |
---|
[1025] | 2666 | |
---|
[1071] | 2667 | emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"RAW",detPanel_toSum) |
---|
| 2668 | |
---|
[1036] | 2669 | Print "empty counts = ",emptyCts |
---|
| 2670 | Print "empty err/counts = ",empty_ct_err/emptyCts |
---|
[1025] | 2671 | |
---|
[1036] | 2672 | // TODO |
---|
| 2673 | // -- get all of the proper values for the calculation |
---|
[1071] | 2674 | // -x currently the attenuation is incorrect |
---|
[1056] | 2675 | // such that kappa_err = 1*kappa |
---|
[1071] | 2676 | // -- verify the calculation (no solid angle needed??) |
---|
[1025] | 2677 | |
---|
[1071] | 2678 | DoAlert 0,"This calculation is not reliable - something is wrong" |
---|
[1056] | 2679 | |
---|
[1036] | 2680 | // get the attenuation factor for the empty beam |
---|
[1071] | 2681 | // TODO -- the attenuation is not written by NICE to the file |
---|
| 2682 | // so I need to calculate it myself from the tables |
---|
| 2683 | // |
---|
| 2684 | // empAttenFactor = V_getAttenuator_transmission(emptyFileName) |
---|
| 2685 | // emp_atten_err = V_getAttenuator_trans_err(emptyFileName) |
---|
| 2686 | empAttenFactor = V_CalculateAttenuationFactor(emptyFileName) |
---|
| 2687 | emp_atten_err = V_CalculateAttenuationError(emptyFileName) |
---|
| 2688 | |
---|
[1036] | 2689 | countTime = V_getCount_time(emptyFileName) |
---|
| 2690 | |
---|
| 2691 | // TODO |
---|
[1071] | 2692 | // -- not sure if this is the correct monitor count to use |
---|
| 2693 | monCnt = V_getBeamMonNormData("RAW") |
---|
[1036] | 2694 | |
---|
[1071] | 2695 | pixel = V_getDet_x_pixel_size("RAW",detPanel_toSum) |
---|
| 2696 | pixel /= 10 //convert mm to cm, since sdd in cm |
---|
| 2697 | sdd = V_getDet_ActualDistance("RAW",detPanel_toSum) |
---|
[1036] | 2698 | |
---|
[1071] | 2699 | // kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime)*(pixel/sdd)^2 |
---|
[1036] | 2700 | kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime) |
---|
[1025] | 2701 | |
---|
[1071] | 2702 | |
---|
[1036] | 2703 | kappa_err = (empty_ct_err/emptyCts)^2 + (emp_atten_err/empAttenFactor)^2 |
---|
| 2704 | kappa_err = sqrt(kappa_err) * kappa |
---|
[1025] | 2705 | |
---|
[1036] | 2706 | // TODO |
---|
| 2707 | // -- set the parameters in the global string |
---|
| 2708 | junkStr = num2str(kappa) |
---|
| 2709 | errStr = num2Str(kappa_err) |
---|
| 2710 | Execute "V_AskForAbsoluteParams(1,1,"+junkStr+",1,"+errStr+")" //no missing parameters, no dialog |
---|
[1025] | 2711 | |
---|
| 2712 | |
---|
[1036] | 2713 | Printf "Kappa was (maybe) successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 |
---|
| 2714 | |
---|
| 2715 | // restore preferences on exit |
---|
| 2716 | gDoDIVCor = savDivPref |
---|
| 2717 | gDoSolidAngleCor = savSAPref |
---|
[1025] | 2718 | |
---|
| 2719 | Endif |
---|
| 2720 | |
---|
| 2721 | End |
---|
| 2722 | |
---|
| 2723 | Function V_UserSelectBox_Continue(ctrlName) :buttonControl |
---|
| 2724 | String ctrlName |
---|
| 2725 | |
---|
| 2726 | DoWindow/K junkWindow //kill panel |
---|
| 2727 | end |
---|
| 2728 | |
---|
| 2729 | Function V_SelectABS_XYBox(x1,x2,y1,y2) |
---|
| 2730 | Variable &x1,&x2,&y1,&y2 |
---|
| 2731 | |
---|
| 2732 | Variable err=0 |
---|
| 2733 | |
---|
| 2734 | Variable/G root:V_marquee=1 //sets the sneaky bit to automatically update marquee coords |
---|
| 2735 | Variable/G root:V_left,root:V_right,root:V_bottom,root:V_top //must be global for auto-update |
---|
| 2736 | DoWindow/F SANS_Data |
---|
| 2737 | NewPanel/K=2 /W=(139,341,382,432) as "Select the primary beam" |
---|
| 2738 | DoWindow/C junkWindow |
---|
| 2739 | AutoPositionWindow/E/M=1/R=SANS_Data |
---|
| 2740 | |
---|
| 2741 | Drawtext 21,20 ,"Select the primary beam with the" |
---|
| 2742 | DrawText 21,40, "marquee and press continue" |
---|
| 2743 | Button button0,pos={80,58},size={92,20},title="Continue" |
---|
| 2744 | Button button0,proc=V_UserSelectBox_Continue |
---|
| 2745 | |
---|
| 2746 | PauseForUser junkWindow,SANS_Data |
---|
| 2747 | |
---|
| 2748 | DoWindow/F SANS_Data |
---|
| 2749 | |
---|
| 2750 | //GetMarquee left,bottom //not needed |
---|
| 2751 | NVAR V_left=V_left |
---|
| 2752 | NVAR V_right=V_right |
---|
| 2753 | NVAR V_bottom=V_bottom |
---|
| 2754 | NVAR V_top=V_top |
---|
| 2755 | |
---|
| 2756 | x1 = V_left |
---|
| 2757 | x2 = V_right |
---|
| 2758 | y1 = V_bottom |
---|
| 2759 | y2 = V_top |
---|
| 2760 | // Print "new values,before rounding = ",x1,x2,y1,y2 |
---|
| 2761 | |
---|
| 2762 | // TODO -- replace this call |
---|
| 2763 | // KeepSelectionInBounds(x1,x2,y1,y2) |
---|
| 2764 | //Print "new values = ",x1,x2,y1,y2 |
---|
| 2765 | |
---|
| 2766 | KillVariables/Z root:V_Marquee,root:V_left,root:V_right,root:V_bottom,root:V_top |
---|
| 2767 | if((x1-x2)==0 || (y1-y2)==0) |
---|
| 2768 | err=1 |
---|
| 2769 | endif |
---|
| 2770 | return(err) |
---|
| 2771 | End |
---|
| 2772 | |
---|
| 2773 | Function V_UseStdOrEmpForABS() |
---|
| 2774 | |
---|
| 2775 | NewPanel/K=2 /W=(139,341,402,448) as "Absolute Scaling" |
---|
| 2776 | DoWindow/C junkABSWindow |
---|
| 2777 | ModifyPanel cbRGB=(57346,65535,49151) |
---|
| 2778 | SetDrawLayer UserBack |
---|
| 2779 | SetDrawEnv fstyle= 1 |
---|
| 2780 | DrawText 21,20,"Method of absolute calibration" |
---|
| 2781 | Button button0,pos={52,33},size={150,20},proc=V_UserSelectABS_Continue,title="Empty Beam Flux" |
---|
| 2782 | Button button1,pos={52,65},size={150,20},proc=V_UserSelectABS_Continue,title="Secondary Standard" |
---|
| 2783 | |
---|
| 2784 | PauseForUser junkABSWindow |
---|
| 2785 | NVAR val = root:Packages:NIST:VSANS:Globals:tmpAbsVal |
---|
| 2786 | return(val) |
---|
| 2787 | End |
---|
| 2788 | |
---|
| 2789 | //returns 0 if button0 (empty beam flux) |
---|
| 2790 | // or 1 if secondary standard |
---|
| 2791 | Function V_UserSelectABS_Continue(ctrlName) :buttonControl |
---|
| 2792 | String ctrlName |
---|
| 2793 | |
---|
| 2794 | variable val=0 |
---|
| 2795 | If(cmpstr(ctrlName,"button0")==0) |
---|
| 2796 | val=0 |
---|
| 2797 | else |
---|
| 2798 | val=1 |
---|
| 2799 | endif |
---|
| 2800 | // print "val = ",ctrlName,val |
---|
| 2801 | Variable/G root:Packages:NIST:VSANS:Globals:tmpAbsVal = val |
---|
| 2802 | DoWindow/K junkABSWindow //kill panel |
---|
| 2803 | return(0) |
---|
| 2804 | end |
---|
| 2805 | |
---|
| 2806 | |
---|
[1040] | 2807 | Function V_TrimDataProtoButton(ctrlName) :buttonControl |
---|
| 2808 | String ctrlName |
---|
| 2809 | |
---|
| 2810 | Execute "V_CombineDataGraph()" |
---|
| 2811 | return(0) |
---|
| 2812 | end |
---|
| 2813 | |
---|
| 2814 | // |
---|
| 2815 | // export protocol to a data file |
---|
| 2816 | // |
---|
| 2817 | // |
---|
| 2818 | Function V_ExportFileProtocol(ctrlName) : ButtonControl |
---|
| 2819 | String ctrlName |
---|
| 2820 | // get a list of protocols |
---|
| 2821 | String Protocol="" |
---|
| 2822 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
[1042] | 2823 | Prompt Protocol "Pick A Protocol",popup, V_DeletableProtocols() |
---|
[1040] | 2824 | DoPrompt "Pick A Protocol to Export",Protocol |
---|
| 2825 | if(V_flag==1) |
---|
| 2826 | //Print "user cancel" |
---|
| 2827 | SetDatafolder root: |
---|
| 2828 | return(1) |
---|
| 2829 | endif |
---|
| 2830 | |
---|
| 2831 | String fileName = V_DoSaveFileDialog("pick the file to write to") |
---|
| 2832 | print fileName |
---|
| 2833 | // |
---|
| 2834 | if(strlen(fileName) == 0) |
---|
| 2835 | return(0) |
---|
| 2836 | endif |
---|
| 2837 | |
---|
[1041] | 2838 | V_writeReductionProtocolWave(fileName,$("root:Packages:NIST:VSANS:Globals:Protocols:"+Protocol) ) |
---|
[1040] | 2839 | |
---|
| 2840 | setDataFolder root: |
---|
| 2841 | return(0) |
---|
| 2842 | |
---|
| 2843 | End |
---|
| 2844 | |
---|
| 2845 | // |
---|
| 2846 | // imports a protocol from a file on disk into the protocols folder |
---|
| 2847 | // |
---|
| 2848 | // |
---|
| 2849 | Function V_ImportFileProtocol(ctrlName) : ButtonControl |
---|
| 2850 | String ctrlName |
---|
| 2851 | |
---|
| 2852 | // SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 2853 | |
---|
| 2854 | String fullPath,fileName |
---|
| 2855 | fullPath = DoOpenFileDialog("Import Protocol from file") |
---|
| 2856 | print fullPath |
---|
| 2857 | // |
---|
| 2858 | if(strlen(fullPath) == 0) |
---|
| 2859 | return(0) |
---|
| 2860 | endif |
---|
| 2861 | |
---|
| 2862 | fileName = ParseFilePath(0, fullPath, ":", 1, 0) //just the file name at the end of the full path |
---|
| 2863 | |
---|
| 2864 | Wave/T tmpW = V_getReductionProtocolWave(fileName) |
---|
| 2865 | if(numpnts(tmpW) == 0) |
---|
| 2866 | DoAlert 0,"No protocol wave has been saved to this data file" |
---|
| 2867 | return(0) |
---|
| 2868 | endif |
---|
| 2869 | |
---|
| 2870 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 2871 | String newName |
---|
| 2872 | newName = CleanupName(fileName,0) + "_proto" |
---|
| 2873 | duplicate/o tmpw $newName |
---|
| 2874 | |
---|
| 2875 | |
---|
| 2876 | SetDataFolder root: |
---|
| 2877 | return(0) |
---|
| 2878 | end |
---|
| 2879 | |
---|
| 2880 | |
---|
| 2881 | // currently not used - and not updated to 12 point protocols (5/2017) |
---|
| 2882 | // |
---|
[1025] | 2883 | //save the protocol as an IGOR text wave (.itx) |
---|
| 2884 | // |
---|
| 2885 | // |
---|
| 2886 | Function V_ExportProtocol(ctrlName) : ButtonControl |
---|
| 2887 | String ctrlName |
---|
| 2888 | // get a list of protocols |
---|
| 2889 | String Protocol="" |
---|
| 2890 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 2891 | Prompt Protocol "Pick A Protocol",popup, WaveList("*",";","") |
---|
| 2892 | DoPrompt "Pick A Protocol to Export",Protocol |
---|
| 2893 | if(V_flag==1) |
---|
| 2894 | //Print "user cancel" |
---|
| 2895 | SetDatafolder root: |
---|
| 2896 | return(1) |
---|
| 2897 | endif |
---|
| 2898 | //get the selection, or exit |
---|
| 2899 | Wave/T pW= $protocol |
---|
| 2900 | Make/O/T/N=13 tw |
---|
| 2901 | // save in the proper format (must write manually, for demo version) |
---|
| 2902 | tw[0] = "IGOR" |
---|
| 2903 | tw[1] = "WAVES/T \t"+protocol |
---|
| 2904 | tw[2] = "BEGIN" |
---|
| 2905 | tw[3,10] = "\t\""+pW[p-3]+"\"" |
---|
| 2906 | tw[11] = "END" |
---|
| 2907 | tw[12] = "X SetScale/P x 0,1,\"\","+protocol+"; SetScale y 0,0,\"\","+protocol |
---|
| 2908 | |
---|
| 2909 | Variable refnum |
---|
| 2910 | String fullPath |
---|
| 2911 | |
---|
| 2912 | PathInfo/S catPathName |
---|
| 2913 | fullPath = DoSaveFileDialog("Export Protocol as",fname=Protocol,suffix="") |
---|
| 2914 | If(cmpstr(fullPath,"")==0) |
---|
| 2915 | //user cancel, don't write out a file |
---|
| 2916 | Close/A |
---|
| 2917 | Abort "no Protocol file was written" |
---|
| 2918 | Endif |
---|
| 2919 | |
---|
| 2920 | //actually open the file |
---|
| 2921 | Open refNum as fullpath+".itx" |
---|
| 2922 | |
---|
| 2923 | wfprintf refnum, "%s\r", tw |
---|
| 2924 | Close refnum |
---|
| 2925 | //Print "all is well ",protocol |
---|
| 2926 | KillWaves/Z tw |
---|
| 2927 | setDataFolder root: |
---|
| 2928 | return(0) |
---|
| 2929 | |
---|
| 2930 | End |
---|
| 2931 | |
---|
[1040] | 2932 | |
---|
| 2933 | // currently not used - and not updated to 12 point protocols (5/2017) |
---|
[1025] | 2934 | //imports a protocol from disk into the protocols folder |
---|
| 2935 | // |
---|
| 2936 | // will overwrite existing protocols if necessary |
---|
| 2937 | // |
---|
| 2938 | // |
---|
| 2939 | Function V_ImportProtocol(ctrlName) : ButtonControl |
---|
| 2940 | String ctrlName |
---|
| 2941 | |
---|
| 2942 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
| 2943 | |
---|
| 2944 | String fullPath |
---|
| 2945 | |
---|
| 2946 | PathInfo/S catPathName |
---|
| 2947 | fullPath = DoOpenFileDialog("Import Protocol") |
---|
| 2948 | If(cmpstr(fullPath,"")==0) |
---|
| 2949 | //user cancel, don't write out a file |
---|
| 2950 | Close/A |
---|
| 2951 | Abort "no protocol was loaded" |
---|
| 2952 | Endif |
---|
| 2953 | |
---|
| 2954 | LoadWave/O/T fullPath |
---|
| 2955 | |
---|
| 2956 | SetDataFolder root: |
---|
| 2957 | return(0) |
---|
| 2958 | end |
---|