[575] | 1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
| 2 | #pragma version=5.0 |
---|
| 3 | #pragma IgorVersion=6.1 |
---|
| 4 | |
---|
| 5 | // this file contains globals and functions that are specific to a |
---|
| 6 | // particular facility or data file format |
---|
| 7 | // branched out 29MAR07 - SRK |
---|
| 8 | // |
---|
| 9 | // functions are either labeled with the procedure file that calls them, |
---|
| 10 | // or noted that they are local to this file |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | // initializes globals that are specific to a particular facility |
---|
| 14 | // - number of XY pixels |
---|
| 15 | // - pixexl resolution [cm] |
---|
| 16 | // - detector deadtime constant [s] |
---|
| 17 | // |
---|
| 18 | // called by Initialize.ipf |
---|
| 19 | // |
---|
| 20 | Function InitFacilityGlobals() |
---|
| 21 | |
---|
| 22 | //Detector -specific globals |
---|
| 23 | Variable/G root:myGlobals:gNPixelsX=192 // number of X and Y pixels |
---|
| 24 | Variable/G root:myGlobals:gNPixelsY=192 |
---|
| 25 | |
---|
| 26 | // pixel dimensions are now read directly from the file header. |
---|
| 27 | // Variable/G root:myGlobals:PixelResDefault = 0.5 //pixel resolution in cm |
---|
| 28 | |
---|
| 29 | Variable/G root:myGlobals:DeadtimeDefault = 3.4e-6 //deadtime in seconds ???nha |
---|
| 30 | |
---|
| 31 | Variable/G root:myGlobals:apOff = 5.0 // (cm) distance from sample aperture to sample position |
---|
| 32 | |
---|
| 33 | End |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | //********************** |
---|
| 37 | // Resolution calculation - used by the averaging routines |
---|
| 38 | // to calculate the resolution function at each q-value |
---|
| 39 | // - the return value is not used |
---|
| 40 | // |
---|
| 41 | // equivalent to John's routine on the VAX Q_SIGMA_AVE.FOR |
---|
| 42 | // Incorporates eqn. 3-15 from J. Appl. Cryst. (1995) v. 28 p105-114 |
---|
| 43 | // |
---|
| 44 | // - 21 MAR 07 uses projected BS diameter on the detector |
---|
| 45 | // - APR 07 still need to add resolution with lenses. currently there is no flag in the |
---|
| 46 | // raw data header to indicate the presence of lenses. |
---|
| 47 | // |
---|
| 48 | // - Aug 07 - added input to switch calculation based on lenses (==1 if in) |
---|
| 49 | // |
---|
| 50 | // - called by CircSectAvg.ipf and RectAnnulAvg.ipf |
---|
| 51 | // |
---|
| 52 | // passed values are read from RealsRead |
---|
| 53 | // except DDet and apOff, which are set from globals before passing |
---|
| 54 | // |
---|
| 55 | // |
---|
| 56 | Function/S getResolution(inQ,lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,SigmaQ,QBar,fSubS) |
---|
| 57 | Variable inQ, lambda, lambdaWidth, DDet, apOff, S1, S2, L1, L2, BS, del_r,usingLenses |
---|
| 58 | Variable &fSubS, &QBar, &SigmaQ //these are the output quantities at the input Q value |
---|
| 59 | |
---|
| 60 | //lots of calculation variables |
---|
| 61 | Variable a2, q_small, lp, v_lambda, v_b, v_d, vz, yg, v_g |
---|
| 62 | Variable r0, delta, inc_gamma, fr, fv, rmd, v_r1, rm, v_r |
---|
| 63 | |
---|
| 64 | //Constants |
---|
| 65 | Variable vz_1 = 3.956e5 //velocity [cm/s] of 1 A neutron |
---|
| 66 | Variable g = 981.0 //gravity acceleration [cm/s^2] |
---|
| 67 | |
---|
| 68 | String results |
---|
| 69 | results ="Failure" |
---|
| 70 | |
---|
| 71 | S1 *= 0.5*0.1 //convert to radius and [cm] |
---|
| 72 | S2 *= 0.5*0.1 |
---|
| 73 | |
---|
| 74 | L1 *= 100.0 // [cm] |
---|
| 75 | L1 -= apOff //correct the distance |
---|
| 76 | |
---|
| 77 | L2 *= 100.0 |
---|
| 78 | L2 += apOff |
---|
| 79 | del_r *= 0.1 //width of annulus, convert mm to [cm] |
---|
| 80 | |
---|
| 81 | BS *= 0.5*0.1 //nominal BS diameter passed in, convert to radius and [cm] |
---|
| 82 | // 21 MAR 07 SRK - use the projected BS diameter, based on a point sample aperture |
---|
| 83 | Variable LB |
---|
| 84 | LB = 20.1 + 1.61*BS //distance in cm from beamstop to anode plane (empirical) |
---|
| 85 | BS = bs + bs*lb/(l2-lb) //adjusted diameter of shadow from parallax |
---|
| 86 | |
---|
| 87 | //Start resolution calculation |
---|
| 88 | a2 = S1*L2/L1 + S2*(L1+L2)/L1 |
---|
| 89 | q_small = 2.0*Pi*(BS-a2)*(1.0-lambdaWidth)/(lambda*L2) |
---|
| 90 | lp = 1.0/( 1.0/L1 + 1.0/L2) |
---|
| 91 | |
---|
| 92 | v_lambda = lambdaWidth^2/6.0 |
---|
| 93 | |
---|
| 94 | // if(usingLenses==1) //SRK 2007 |
---|
| 95 | if(usingLenses != 0) //SRK 2008 allows for the possibility of different numbers of lenses in header |
---|
| 96 | v_b = 0.25*(S1*L2/L1)^2 +0.25*(2/3)*(lambdaWidth/lambda)^2*(S2*L2/lp)^2 //correction to 2nd term |
---|
| 97 | else |
---|
| 98 | v_b = 0.25*(S1*L2/L1)^2 +0.25*(S2*L2/lp)^2 //original form |
---|
| 99 | endif |
---|
| 100 | |
---|
| 101 | v_d = (DDet/2.3548)^2 + del_r^2/12.0 |
---|
| 102 | vz = vz_1 / lambda |
---|
| 103 | yg = 0.5*g*L2*(L1+L2)/vz^2 |
---|
| 104 | v_g = 2.0*(2.0*yg^2*v_lambda) //factor of 2 correction, B. Hammouda, 2007 |
---|
| 105 | |
---|
| 106 | r0 = L2*tan(2.0*asin(lambda*inQ/(4.0*Pi) )) |
---|
| 107 | delta = 0.5*(BS - r0)^2/v_d |
---|
| 108 | |
---|
| 109 | if (r0 < BS) |
---|
| 110 | inc_gamma=exp(gammln(1.5))*(1-gammp(1.5,delta)) |
---|
| 111 | else |
---|
| 112 | inc_gamma=exp(gammln(1.5))*(1+gammp(1.5,delta)) |
---|
| 113 | endif |
---|
| 114 | |
---|
| 115 | fSubS = 0.5*(1.0+erf( (r0-BS)/sqrt(2.0*v_d) ) ) |
---|
| 116 | if (fSubS <= 0.0) |
---|
| 117 | fSubS = 1.e-10 |
---|
| 118 | endif |
---|
| 119 | fr = 1.0 + sqrt(v_d)*exp(-1.0*delta) /(r0*fSubS*sqrt(2.0*Pi)) |
---|
| 120 | fv = inc_gamma/(fSubS*sqrt(Pi)) - r0^2*(fr-1.0)^2/v_d |
---|
| 121 | |
---|
| 122 | rmd = fr*r0 |
---|
| 123 | v_r1 = v_b + fv*v_d +v_g |
---|
| 124 | |
---|
| 125 | rm = rmd + 0.5*v_r1/rmd |
---|
| 126 | v_r = v_r1 - 0.5*(v_r1/rmd)^2 |
---|
| 127 | if (v_r < 0.0) |
---|
| 128 | v_r = 0.0 |
---|
| 129 | endif |
---|
| 130 | QBar = (4.0*Pi/lambda)*sin(0.5*atan(rm/L2)) |
---|
| 131 | SigmaQ = QBar*sqrt(v_r/rmd^2 +v_lambda) |
---|
| 132 | |
---|
| 133 | results = "success" |
---|
| 134 | Return results |
---|
| 135 | End |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | //Utility function that returns the detector resolution (in cm) |
---|
| 139 | //Global values are set in the Initialize procedure |
---|
| 140 | // |
---|
| 141 | // - called by CircSectAvg.ipf, RectAnnulAvg.ipf, and ProtocolAsPanel.ipf |
---|
| 142 | // |
---|
| 143 | // fileStr is passed as TextRead[3] |
---|
| 144 | // detStr is passed as TextRead[9] |
---|
| 145 | // |
---|
| 146 | // *** as of Jan 2008, depricated. Now detector pixel sizes are read from the file header |
---|
| 147 | // rw[10] = x size (mm); rw[13] = y size (mm) |
---|
| 148 | // |
---|
| 149 | // depricated - pixel dimensions are read directly from the file header |
---|
| 150 | Function xDetectorPixelResolution(fileStr,detStr) |
---|
| 151 | String fileStr,detStr |
---|
| 152 | |
---|
| 153 | Variable DDet |
---|
| 154 | |
---|
| 155 | //your code here |
---|
| 156 | |
---|
| 157 | return(DDet) |
---|
| 158 | End |
---|
| 159 | |
---|
| 160 | //Utility function that returns the detector deadtime (in seconds) |
---|
| 161 | //Global values are set in the Initialize procedure |
---|
| 162 | // |
---|
| 163 | // - called by WorkFileUtils.ipf |
---|
| 164 | // |
---|
| 165 | // fileStr is passed as TextRead[3] and is the filename |
---|
| 166 | // detStr is passed as TextRead[9] and is an identifier for the detector |
---|
| 167 | // |
---|
[795] | 168 | // [dateAndTimeStr] is optional, and could be used as a switch for |
---|
| 169 | // different historical detector configurations |
---|
| 170 | Function DetectorDeadtime(fileStr,detStr,[dateAndTimeStr]) |
---|
| 171 | String fileStr,detStr,dateAndTimeStr |
---|
[575] | 172 | |
---|
| 173 | Variable deadtime |
---|
| 174 | |
---|
| 175 | // your code here |
---|
| 176 | |
---|
| 177 | return(deadtime) |
---|
| 178 | End |
---|
| 179 | |
---|
| 180 | |
---|
[715] | 181 | //given a filename of a SANS data filename of the form |
---|
| 182 | //QKKNNNNNNN.nx.hdf |
---|
| 183 | //returns the prefix |
---|
| 184 | Function/S GetPrefixStrFromFile(item) |
---|
| 185 | String item |
---|
| 186 | String invalid = "" //"" is not a valid run prefix, since it's text |
---|
| 187 | Variable num=-1 |
---|
| 188 | |
---|
| 189 | //find the "dot" |
---|
| 190 | String runStr="" |
---|
| 191 | |
---|
| 192 | Variable pos = strsearch(item,".",0) |
---|
| 193 | if(pos == -1) |
---|
| 194 | //"dot" not found |
---|
| 195 | return (invalid) |
---|
| 196 | else |
---|
| 197 | //found, skip the three characters preceeding it |
---|
| 198 | if (pos <=7) |
---|
| 199 | //not enough characters |
---|
| 200 | return (invalid) |
---|
| 201 | else |
---|
| 202 | runStr = item[0,pos-8] |
---|
| 203 | return (runStr) |
---|
| 204 | Endif |
---|
| 205 | Endif |
---|
| 206 | End |
---|
| 207 | |
---|
| 208 | Function/S RunDigitString(num) |
---|
| 209 | Variable num |
---|
| 210 | |
---|
| 211 | String numStr="" |
---|
| 212 | |
---|
| 213 | //make 7 digit string from run number |
---|
| 214 | sprintf numStr,"%07u",num |
---|
| 215 | |
---|
| 216 | //Print "numstr = ",numstr |
---|
| 217 | return(numstr) |
---|
| 218 | End |
---|
| 219 | |
---|
| 220 | |
---|
[575] | 221 | // item is a filename |
---|
| 222 | // |
---|
| 223 | // this function extracts some sort of number from the file |
---|
| 224 | // presumably some sort of automatically incrementing run number set by the |
---|
| 225 | // acquisition system |
---|
| 226 | // |
---|
| 227 | // this run number should be a unique identifier for the file |
---|
| 228 | // |
---|
| 229 | Function GetRunNumFromFile(item) |
---|
| 230 | String item |
---|
| 231 | |
---|
[707] | 232 | Variable invalid = -1 |
---|
[575] | 233 | Variable num=-1 // an invalid return value |
---|
| 234 | |
---|
[707] | 235 | String runStr="" |
---|
| 236 | Variable pos = strsearch(item,".",0) |
---|
| 237 | if(pos == -1) |
---|
| 238 | //"dot" not found |
---|
| 239 | return (invalid) |
---|
| 240 | else |
---|
| 241 | //found, get the three characters preceeding it |
---|
| 242 | if (pos <=6) |
---|
| 243 | //not enough characters |
---|
| 244 | return (invalid) |
---|
| 245 | else |
---|
| 246 | runStr = item[pos-7,pos-1] |
---|
| 247 | //convert to a number |
---|
| 248 | num = str2num(runStr) |
---|
| 249 | //if valid, return it |
---|
| 250 | if (num == NaN) |
---|
[715] | 251 | //7 characters were not a number |
---|
[707] | 252 | return (invalid) |
---|
| 253 | else |
---|
| 254 | //run was OK |
---|
| 255 | return (num) |
---|
| 256 | Endif |
---|
| 257 | Endif |
---|
| 258 | Endif |
---|
[575] | 259 | return (num) |
---|
| 260 | End |
---|
| 261 | |
---|
| 262 | // item is a filename |
---|
| 263 | // |
---|
| 264 | // this function extracts some sort of number from the file |
---|
| 265 | // presumably some sort of automatically incrementing run number set by the |
---|
| 266 | // acquisition system |
---|
| 267 | // |
---|
| 268 | // this run number should be a unique identifier for the file |
---|
| 269 | // |
---|
| 270 | // same as GetRunNumFromFile(0), just with a string return |
---|
| 271 | // |
---|
| 272 | // "ABC" returned as an invalid result |
---|
| 273 | Function/S GetRunNumStrFromFile(item) |
---|
| 274 | String item |
---|
| 275 | |
---|
| 276 | String invalid = "ABC" //"ABC" is not a valid run number, since it's text |
---|
| 277 | String retStr |
---|
| 278 | retStr=invalid |
---|
| 279 | |
---|
[707] | 280 | String runStr = "" |
---|
| 281 | Variable pos = strsearch(item,".",0) |
---|
| 282 | if(pos == -1) |
---|
| 283 | //"dot" not found |
---|
| 284 | return (invalid) |
---|
| 285 | else |
---|
| 286 | //found, get the three characters preceeding it |
---|
| 287 | if (pos <=6) |
---|
| 288 | //not enough characters |
---|
| 289 | return (invalid) |
---|
| 290 | else |
---|
| 291 | runStr = item[pos-7,pos-1] |
---|
| 292 | return (runStr) |
---|
| 293 | Endif |
---|
| 294 | Endif |
---|
[575] | 295 | End |
---|
| 296 | |
---|
| 297 | //returns a string containing the full path to the file containing the |
---|
| 298 | //run number "num". The null string is returned if no valid file can be found. |
---|
| 299 | // |
---|
| 300 | // |
---|
| 301 | // search in the path "catPathName" (hard-wired), will abort if this path does not exist |
---|
| 302 | //the file returned will be a RAW SANS data file, other types of files are |
---|
| 303 | //filtered out. |
---|
| 304 | // |
---|
| 305 | // called by Buttons.ipf and Transmission.ipf, and locally by parsing routines |
---|
| 306 | // |
---|
| 307 | Function/S FindFileFromRunNumber(num) |
---|
| 308 | Variable num |
---|
| 309 | |
---|
[707] | 310 | String fullName="",partialName="",item="",numStr="" |
---|
[575] | 311 | |
---|
| 312 | //make sure that path exists |
---|
| 313 | PathInfo catPathName |
---|
| 314 | String path = S_path |
---|
| 315 | if (V_flag == 0) |
---|
| 316 | Abort "folder path does not exist - use Pick Path button" |
---|
| 317 | Endif |
---|
| 318 | |
---|
[707] | 319 | //make 7 digit string from run number |
---|
| 320 | sprintf numStr,"%07u",num |
---|
[575] | 321 | |
---|
[707] | 322 | //partialname = "QKK"+tmp_num+".nx.hdf" |
---|
| 323 | |
---|
| 324 | String list="",newList="",testStr="" |
---|
| 325 | |
---|
| 326 | list = IndexedFile(catPathName,-1,"????") //get all files in folder |
---|
| 327 | //find (the) one with the number in the run # location in the name |
---|
| 328 | Variable numItems,ii,runFound,isRAW |
---|
| 329 | numItems = ItemsInList(list,";") //get the new number of items in the list |
---|
| 330 | ii=0 |
---|
| 331 | do |
---|
| 332 | //parse through the list in this order: |
---|
| 333 | // 1 - does item contain run number (as a string) "QKKXXXXXXX.nx.hdf" |
---|
| 334 | // 2 - exclude by isRaw? (to minimize disk access) |
---|
| 335 | item = StringFromList(ii, list ,";" ) |
---|
| 336 | if(strlen(item) != 0) |
---|
| 337 | //find the run number, if it exists as a three character string |
---|
| 338 | testStr = GetRunNumStrFromFile(item) |
---|
| 339 | runFound= cmpstr(numStr,testStr) //compare the three character strings, 0 if equal |
---|
| 340 | if(runFound == 0) |
---|
| 341 | //the run Number was found |
---|
| 342 | //build valid filename |
---|
| 343 | partialName = FindValidFileName(item) |
---|
| 344 | if(strlen(partialName) != 0) //non-null return from FindValidFileName() |
---|
| 345 | fullName = path + partialName |
---|
| 346 | //check if RAW, if so,this must be the file! |
---|
| 347 | isRAW = CheckIfRawData(fullName) |
---|
| 348 | if(isRaw) |
---|
| 349 | //stop here |
---|
| 350 | return(fullname) |
---|
| 351 | Endif |
---|
| 352 | Endif |
---|
| 353 | Endif |
---|
| 354 | Endif |
---|
| 355 | ii+=1 |
---|
| 356 | while(ii<numItems) //process all items in list |
---|
| 357 | Return ("") //null return if file not found in list |
---|
[575] | 358 | End |
---|
| 359 | |
---|
| 360 | //function to test a file to see if it is a RAW SANS file |
---|
| 361 | // |
---|
| 362 | // returns truth 0/1 |
---|
| 363 | // |
---|
| 364 | // called by many procedures (both external and local) |
---|
| 365 | // |
---|
| 366 | Function CheckIfRawData(fname) |
---|
| 367 | String fname |
---|
| 368 | Variable value = 0 |
---|
| 369 | |
---|
[707] | 370 | Variable hdfID,hdfgID |
---|
| 371 | Variable isNXHDF = 0 |
---|
| 372 | |
---|
| 373 | //nha. look for non-NeXus files |
---|
| 374 | if (strsearch(fname, "nx.hdf", 0) >= 0) |
---|
| 375 | isNXHDF = 1 |
---|
[575] | 376 | endif |
---|
[707] | 377 | |
---|
| 378 | if(isNXHDF == 1) |
---|
| 379 | //Need to actually determine if file is RAW data. |
---|
| 380 | HDF5OpenFile/Z hdfID as fname |
---|
| 381 | HDF5OpenGroup/Z hdfID, "/data", hdfgID |
---|
| 382 | if (V_Flag == 0) |
---|
| 383 | //DIV file (with nx.hdf suffix) |
---|
| 384 | value = 0 |
---|
| 385 | else |
---|
| 386 | //Some other nx.hdf file |
---|
| 387 | value = 1 |
---|
| 388 | endif |
---|
| 389 | HDF5CloseGroup/Z hdfgID |
---|
| 390 | HDF5CloseFile/Z hdfID |
---|
| 391 | else |
---|
| 392 | value = 0 |
---|
| 393 | endif |
---|
| 394 | |
---|
[575] | 395 | return(value) |
---|
| 396 | End |
---|
| 397 | |
---|
[857] | 398 | |
---|
| 399 | //function to test a file to see if it is a DIV file |
---|
| 400 | // |
---|
| 401 | // returns truth 0/1 |
---|
| 402 | // |
---|
| 403 | // called by many procedures (both external and local) |
---|
| 404 | // |
---|
| 405 | Function CheckIfDIVData(fname) |
---|
| 406 | String fname |
---|
| 407 | |
---|
| 408 | |
---|
| 409 | // if(your test here) |
---|
| 410 | // //true, is DIV data file |
---|
| 411 | Return(1) |
---|
| 412 | // else |
---|
| 413 | // //some other file |
---|
| 414 | // Return(0) |
---|
| 415 | // Endif |
---|
| 416 | |
---|
| 417 | End |
---|
| 418 | |
---|
[575] | 419 | Function isScatFile(fname) |
---|
| 420 | String fname |
---|
| 421 | Variable isTrans, isEmp |
---|
| 422 | Variable value =1 |
---|
| 423 | |
---|
| 424 | isTrans = isTransFile(fname) |
---|
| 425 | isEmp = isEmpFile(fname) |
---|
| 426 | |
---|
| 427 | if(isTrans) |
---|
| 428 | value = 0 |
---|
| 429 | endif |
---|
| 430 | if(isEmp) |
---|
| 431 | value = 0 |
---|
| 432 | endif |
---|
| 433 | return(value) |
---|
| 434 | End |
---|
| 435 | |
---|
| 436 | Function isEmpFile(fName) |
---|
| 437 | String fname |
---|
| 438 | |
---|
| 439 | variable err |
---|
| 440 | string dfName = "" |
---|
| 441 | variable value = 0 |
---|
| 442 | |
---|
| 443 | err = hdfRead(fname, dfName) |
---|
| 444 | //err not handled here |
---|
| 445 | |
---|
[707] | 446 | Wave/T wSampleName = $(dfName+":sample:name") |
---|
[575] | 447 | String sampleName = wSampleName[0] |
---|
| 448 | |
---|
| 449 | if (cmpstr(sampleName,"MT beam")==0) |
---|
| 450 | value = 1 |
---|
| 451 | endif |
---|
| 452 | |
---|
| 453 | return(value) |
---|
| 454 | End |
---|
| 455 | |
---|
| 456 | |
---|
| 457 | // function returns 1 if file is a transmission file, 0 if not |
---|
| 458 | // |
---|
| 459 | // called by Transmission.ipf, CatVSTable.ipf, NSORT.ipf |
---|
| 460 | // |
---|
| 461 | Function isTransFile(fName) |
---|
| 462 | String fname |
---|
| 463 | |
---|
| 464 | // nha. TO DO. entry1 will have to change when the new naming convention for nxentry is implemented. |
---|
| 465 | |
---|
| 466 | variable err |
---|
| 467 | string dfName = "" |
---|
| 468 | variable value = 0 |
---|
| 469 | |
---|
| 470 | err = hdfRead(fname, dfName) |
---|
| 471 | //err not handled here |
---|
| 472 | |
---|
[707] | 473 | Wave wTransmission_Flag = $(dfName+":sample:TransmissionFlag") //is only being set after 27/5/2009. ??? |
---|
[575] | 474 | value = wTransmission_Flag[0] |
---|
[707] | 475 | // |
---|
| 476 | // AJJ June 2nd 2010 - Unclear that this check is correct. Certainly BSPosXmm is not correct parameter in current data format... |
---|
| 477 | // if (value == 0) |
---|
| 478 | // //workaround - determine by bsx position |
---|
| 479 | // Wave wBSX = $(dfName+":instrument:beam_stop:geometry:position:BSPosXmm") |
---|
| 480 | // variable bsx = wBSX[0] |
---|
| 481 | // |
---|
| 482 | // if (bsx >= -10 ) |
---|
| 483 | // value = 1 |
---|
| 484 | // endif |
---|
| 485 | // endif |
---|
[575] | 486 | |
---|
| 487 | return(value) |
---|
| 488 | End |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | //function to remove all spaces from names when searching for filenames |
---|
| 492 | //the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn) |
---|
| 493 | //but the text field in the header may |
---|
| 494 | // |
---|
| 495 | //returns a string identical to the original string, except with the interior spaces removed |
---|
| 496 | // |
---|
| 497 | // local function for file name manipulation |
---|
| 498 | // |
---|
| 499 | // no change needed here |
---|
| 500 | Function/S RemoveAllSpaces(str) |
---|
| 501 | String str |
---|
| 502 | |
---|
| 503 | String tempstr = str |
---|
| 504 | Variable ii,spc,len //should never be more than 2 or 3 trailing spaces in a filename |
---|
| 505 | ii=0 |
---|
| 506 | do |
---|
| 507 | len = strlen(tempStr) |
---|
| 508 | spc = strsearch(tempStr," ",0) //is the last character a space? |
---|
| 509 | if (spc == -1) |
---|
| 510 | break //no more spaces found, get out |
---|
| 511 | endif |
---|
| 512 | str = tempstr |
---|
| 513 | tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string |
---|
| 514 | While(1) //should never be more than 2 or 3 |
---|
| 515 | |
---|
| 516 | If(strlen(tempStr) < 1) |
---|
| 517 | tempStr = "" //be sure to return a null string if problem found |
---|
| 518 | Endif |
---|
| 519 | |
---|
| 520 | //Print strlen(tempstr) |
---|
| 521 | |
---|
| 522 | Return(tempStr) |
---|
| 523 | |
---|
| 524 | End |
---|
| 525 | |
---|
| 526 | |
---|
| 527 | //Function attempts to find valid filename from partial name by checking for |
---|
| 528 | // the existence of the file on disk |
---|
| 529 | // |
---|
| 530 | // returns a valid filename (No path prepended) or a null string |
---|
| 531 | // |
---|
| 532 | // called by any functions, both external and local |
---|
| 533 | // |
---|
| 534 | Function/S FindValidFilename(partialName) |
---|
| 535 | String PartialName |
---|
| 536 | |
---|
| 537 | String retStr="" |
---|
| 538 | |
---|
[715] | 539 | //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 |
---|
| 540 | retStr = ValidFileString(partialName) |
---|
| 541 | if(cmpstr(retStr,"") !=0) |
---|
| 542 | //non-null return |
---|
| 543 | return(retStr) |
---|
| 544 | Endif |
---|
| 545 | |
---|
| 546 | //if the partial name is derived from the file header, there can be spaces at the beginning |
---|
| 547 | //or in the middle of the filename - depending on the prefix and initials used |
---|
| 548 | // |
---|
| 549 | //remove any leading spaces from the name before starting |
---|
| 550 | partialName = RemoveAllSpaces(partialName) |
---|
| 551 | |
---|
| 552 | //try name with no spaces |
---|
| 553 | retStr = ValidFileString(partialName) |
---|
| 554 | if(cmpstr(retStr,"") !=0) |
---|
| 555 | //non-null return |
---|
| 556 | return(retStr) |
---|
| 557 | Endif |
---|
| 558 | |
---|
| 559 | //try all UPPERCASE |
---|
| 560 | partialName = UpperStr(partialName) |
---|
| 561 | retStr = ValidFileString(partialName) |
---|
| 562 | if(cmpstr(retStr,"") !=0) |
---|
| 563 | //non-null return |
---|
| 564 | return(retStr) |
---|
| 565 | Endif |
---|
| 566 | |
---|
| 567 | //try all lowercase (ret null if failure) |
---|
| 568 | partialName = LowerStr(partialName) |
---|
| 569 | retStr = ValidFileString(partialName) |
---|
| 570 | if(cmpstr(retStr,"") !=0) |
---|
| 571 | //non-null return |
---|
| 572 | return(retStr) |
---|
| 573 | else |
---|
| 574 | return(retStr) |
---|
| 575 | Endif |
---|
[575] | 576 | |
---|
| 577 | End |
---|
| 578 | |
---|
[715] | 579 | // Function checks for the existence of a file |
---|
| 580 | // partialName;vers (to account for VAX filenaming conventions) |
---|
| 581 | // The partial name is tried first with no version number |
---|
| 582 | // |
---|
| 583 | // *** the PATH is hard-wired to catPathName (which is assumed to exist) |
---|
| 584 | // version numers up to ;10 are tried |
---|
| 585 | // only the "name;vers" is returned if successful. The path is not prepended |
---|
| 586 | // |
---|
| 587 | // local function |
---|
| 588 | // |
---|
| 589 | Function/S ValidFileString(partialName) |
---|
| 590 | String partialName |
---|
| 591 | |
---|
| 592 | String tempName = "",msg="" |
---|
| 593 | Variable ii,refnum |
---|
| 594 | |
---|
| 595 | ii=0 |
---|
| 596 | do |
---|
| 597 | if(ii==0) |
---|
| 598 | //first pass, try the partialName |
---|
| 599 | tempName = partialName |
---|
| 600 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName //Does open file (/Z flag) |
---|
| 601 | if(V_flag == 0) |
---|
| 602 | //file exists |
---|
| 603 | Close refnum //YES needed, |
---|
| 604 | break |
---|
| 605 | endif |
---|
| 606 | else |
---|
| 607 | tempName = partialName + ";" + num2str(ii) |
---|
| 608 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName |
---|
| 609 | if(V_flag == 0) |
---|
| 610 | //file exists |
---|
| 611 | Close refnum |
---|
| 612 | break |
---|
| 613 | endif |
---|
| 614 | Endif |
---|
| 615 | ii+=1 |
---|
| 616 | //print "ii=",ii |
---|
| 617 | while(ii<11) |
---|
| 618 | //go get the selected bits of information, using tempName, which exists |
---|
| 619 | if(ii>=11) |
---|
| 620 | //msg = partialName + " not found. is version number > 11?" |
---|
| 621 | //DoAlert 0, msg |
---|
| 622 | //PathInfo catPathName |
---|
| 623 | //Print S_Path |
---|
| 624 | Return ("") //use null string as error condition |
---|
| 625 | Endif |
---|
| 626 | |
---|
| 627 | Return (tempName) |
---|
| 628 | End |
---|
[575] | 629 | |
---|
[715] | 630 | |
---|
[575] | 631 | //returns a string containing filename (WITHOUT the ;vers) |
---|
| 632 | //the input string is a full path to the file (Mac-style, still works on Win in IGOR) |
---|
| 633 | //with the folders separated by colons |
---|
| 634 | // |
---|
| 635 | // called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf |
---|
| 636 | // |
---|
| 637 | // NEEDS NO CHANGES |
---|
| 638 | // |
---|
| 639 | Function/S GetFileNameFromPathNoSemi(fullPath) |
---|
| 640 | String fullPath |
---|
| 641 | |
---|
| 642 | Variable offset1,offset2 |
---|
| 643 | String filename="" |
---|
| 644 | //String PartialPath |
---|
| 645 | offset1 = 0 |
---|
| 646 | do |
---|
| 647 | offset2 = StrSearch(fullPath, ":", offset1) |
---|
| 648 | if (offset2 == -1) // no more colons ? |
---|
| 649 | fileName = FullPath[offset1,strlen(FullPath) ] |
---|
| 650 | //PartialPath = FullPath[0, offset1-1] |
---|
| 651 | break |
---|
| 652 | endif |
---|
| 653 | offset1 = offset2+1 |
---|
| 654 | while (1) |
---|
| 655 | |
---|
| 656 | //remove version number from name, if it's there - format should be: filename;N |
---|
| 657 | filename = StringFromList(0,filename,";") //returns null if error |
---|
| 658 | |
---|
| 659 | Return filename |
---|
| 660 | End |
---|
| 661 | |
---|
| 662 | //returns a string containing filename (INCLUDING the ;vers) |
---|
| 663 | //the input string is a full path to the file (Mac-style, still works on Win in IGOR) |
---|
| 664 | //with the folders separated by colons |
---|
| 665 | // |
---|
| 666 | // local, currently unused |
---|
| 667 | // |
---|
| 668 | // NEEDS NO CHANGES |
---|
| 669 | // |
---|
| 670 | Function/S GetFileNameFromPathKeepSemi(fullPath) |
---|
| 671 | String fullPath |
---|
| 672 | |
---|
| 673 | Variable offset1,offset2 |
---|
| 674 | String filename |
---|
| 675 | //String PartialPath |
---|
| 676 | offset1 = 0 |
---|
| 677 | do |
---|
| 678 | offset2 = StrSearch(fullPath, ":", offset1) |
---|
| 679 | if (offset2 == -1) // no more colons ? |
---|
| 680 | fileName = FullPath[offset1,strlen(FullPath) ] |
---|
| 681 | //PartialPath = FullPath[0, offset1-1] |
---|
| 682 | break |
---|
| 683 | endif |
---|
| 684 | offset1 = offset2+1 |
---|
| 685 | while (1) |
---|
| 686 | |
---|
| 687 | //keep version number from name, if it's there - format should be: filename;N |
---|
| 688 | |
---|
| 689 | Return filename |
---|
| 690 | End |
---|
| 691 | |
---|
| 692 | //given the full path and filename (fullPath), strips the data path |
---|
| 693 | //(Mac-style, separated by colons) and returns this path |
---|
| 694 | //this partial path is the same string that would be returned from PathInfo, for example |
---|
| 695 | // |
---|
| 696 | // - allows the user to save to a different path than catPathName |
---|
| 697 | // |
---|
| 698 | // called by WriteQIS.ipf |
---|
| 699 | // |
---|
| 700 | // NEEDS NO CHANGES |
---|
| 701 | // |
---|
| 702 | Function/S GetPathStrFromfullName(fullPath) |
---|
| 703 | String fullPath |
---|
| 704 | |
---|
| 705 | Variable offset1,offset2 |
---|
| 706 | //String filename |
---|
| 707 | String PartialPath |
---|
| 708 | offset1 = 0 |
---|
| 709 | do |
---|
| 710 | offset2 = StrSearch(fullPath, ":", offset1) |
---|
| 711 | if (offset2 == -1) // no more colons ? |
---|
| 712 | //fileName = FullPath[offset1,strlen(FullPath) ] |
---|
| 713 | PartialPath = FullPath[0, offset1-1] |
---|
| 714 | break |
---|
| 715 | endif |
---|
| 716 | offset1 = offset2+1 |
---|
| 717 | while (1) |
---|
| 718 | |
---|
| 719 | Return PartialPath |
---|
| 720 | End |
---|
| 721 | |
---|
| 722 | //given the filename trim or modify the filename to get a new |
---|
| 723 | //file string that can be used for naming averaged 1-d files |
---|
| 724 | // |
---|
| 725 | // called by ProtocolAsPanel.ipf and Tile_2D.ipf |
---|
| 726 | // |
---|
| 727 | Function/S GetNameFromHeader(fullName) |
---|
[707] | 728 | // given the fully qualified path and filename ie. fullName, return just the filename |
---|
[575] | 729 | String fullName |
---|
| 730 | String newName = "" |
---|
| 731 | |
---|
| 732 | //your code here |
---|
[707] | 733 | newName = ParseFilePath(0, fullName, ":", 1, 0) |
---|
| 734 | |
---|
[575] | 735 | Return(newName) |
---|
| 736 | End |
---|
| 737 | |
---|
| 738 | //list (input) is a list, typically returned from IndexedFile() |
---|
| 739 | //which is semicolon-delimited, and may contain filenames from the VAX |
---|
| 740 | //that contain version numbers, where the version number appears as a separate list item |
---|
| 741 | //(and also as a non-existent file) |
---|
| 742 | //these numbers must be purged from the list, especially for display in a popup |
---|
| 743 | //or list processing of filenames |
---|
| 744 | //the function returns the list, cleaned of version numbers (up to 11) |
---|
| 745 | //raw data files will typically never have a version number other than 1. |
---|
| 746 | // |
---|
| 747 | // if there are no version numbers in the list, the input list is returned |
---|
| 748 | // |
---|
| 749 | // called by CatVSTable.ipf, NSORT.ipf, Transmission.ipf, WorkFileUtils.ipf |
---|
| 750 | // |
---|
| 751 | // |
---|
| 752 | // NO CHANGE NEEDED |
---|
| 753 | // |
---|
| 754 | Function/S RemoveVersNumsFromList(list) |
---|
| 755 | String list |
---|
| 756 | |
---|
| 757 | //get rid of version numbers first (up to 11) |
---|
| 758 | Variable ii,num |
---|
| 759 | String item |
---|
| 760 | num = ItemsInList(list,";") |
---|
| 761 | ii=1 |
---|
| 762 | do |
---|
| 763 | item = num2str(ii) |
---|
| 764 | list = RemoveFromList(item, list ,";" ) |
---|
| 765 | ii+=1 |
---|
| 766 | while(ii<12) |
---|
| 767 | |
---|
| 768 | return (list) |
---|
| 769 | End |
---|
| 770 | |
---|
| 771 | //input is a list of run numbers, and output is a list of filenames (not the full path) |
---|
| 772 | //*** input list must be COMMA delimited*** |
---|
| 773 | //output is equivalent to selecting from the CAT table |
---|
| 774 | //if some or all of the list items are valid filenames, keep them... |
---|
| 775 | //if an error is encountered, notify of the offending element and return a null list |
---|
| 776 | // |
---|
| 777 | //output is COMMA delimited |
---|
| 778 | // |
---|
| 779 | // this routine is expecting that the "ask", "none" special cases are handled elsewhere |
---|
| 780 | //and not passed here |
---|
| 781 | // |
---|
| 782 | // called by Marquee.ipf, MultipleReduce.ipf, ProtocolAsPanel.ipf |
---|
| 783 | // |
---|
| 784 | // NO CHANGE NEEDED |
---|
| 785 | // |
---|
| 786 | Function/S ParseRunNumberList(list) |
---|
| 787 | String list |
---|
| 788 | |
---|
| 789 | String newList="",item="",tempStr="" |
---|
| 790 | Variable num,ii,runNum |
---|
| 791 | |
---|
| 792 | //expand number ranges, if any |
---|
| 793 | list = ExpandNumRanges(list) |
---|
| 794 | |
---|
| 795 | num=itemsinlist(list,",") |
---|
| 796 | |
---|
| 797 | for(ii=0;ii<num;ii+=1) |
---|
| 798 | //get the item |
---|
| 799 | item = StringFromList(ii,list,",") |
---|
| 800 | |
---|
| 801 | tempStr=FindValidFilename(item) //returns filename if good, null if error |
---|
[707] | 802 | |
---|
[575] | 803 | if(strlen(tempstr)!=0) |
---|
| 804 | //valid name, add to list |
---|
| 805 | //Print "it's a file" |
---|
[707] | 806 | if(strlen(newList)==0) |
---|
| 807 | newList = tempStr |
---|
| 808 | else |
---|
| 809 | newList += "," + tempStr |
---|
| 810 | endif |
---|
| 811 | else |
---|
[575] | 812 | //not a valid name |
---|
| 813 | //is it a number? |
---|
| 814 | runNum=str2num(item) |
---|
| 815 | //print runnum |
---|
| 816 | if(numtype(runNum) != 0) |
---|
| 817 | //not a number - maybe an error |
---|
| 818 | DoAlert 0,"List item "+item+" is not a valid run number or filename. Please enter a valid number or filename." |
---|
| 819 | return("") |
---|
| 820 | else |
---|
| 821 | //a run number or an error |
---|
| 822 | tempStr = GetFileNameFromPathNoSemi( FindFileFromRunNumber(runNum) ) |
---|
| 823 | if(strlen(tempstr)==0) |
---|
| 824 | //file not found, error |
---|
| 825 | DoAlert 0,"List item "+item+" is not a valid run number. Please enter a valid number." |
---|
| 826 | return("") |
---|
| 827 | else |
---|
| 828 | newList += tempStr + "," |
---|
| 829 | endif |
---|
| 830 | endif |
---|
| 831 | endif |
---|
| 832 | endfor //loop over all items in list |
---|
| 833 | |
---|
| 834 | return(newList) |
---|
| 835 | End |
---|
| 836 | |
---|
| 837 | //takes a comma delimited list that MAY contain number range, and |
---|
| 838 | //expands any range of run numbers into a comma-delimited list... |
---|
| 839 | //and returns the new list - if not a range, return unchanged |
---|
| 840 | // |
---|
| 841 | // local function |
---|
| 842 | // |
---|
| 843 | // NO CHANGE NEEDED |
---|
| 844 | // |
---|
| 845 | Function/S ExpandNumRanges(list) |
---|
| 846 | String list |
---|
| 847 | |
---|
| 848 | String newList="",dash="-",item,str |
---|
| 849 | Variable num,ii,hasDash |
---|
| 850 | |
---|
| 851 | num=itemsinlist(list,",") |
---|
| 852 | // print num |
---|
| 853 | for(ii=0;ii<num;ii+=1) |
---|
| 854 | //get the item |
---|
| 855 | item = StringFromList(ii,list,",") |
---|
| 856 | //does it contain a dash? |
---|
| 857 | hasDash = strsearch(item,dash,0) //-1 if no dash found |
---|
| 858 | if(hasDash == -1) |
---|
| 859 | //not a range, keep it in the list |
---|
| 860 | newList += item + "," |
---|
| 861 | else |
---|
| 862 | //has a dash (so it's a range), expand (or add null) |
---|
| 863 | newList += ListFromDash(item) |
---|
| 864 | endif |
---|
| 865 | endfor |
---|
| 866 | |
---|
| 867 | return newList |
---|
| 868 | End |
---|
| 869 | |
---|
| 870 | //be sure to add a trailing comma to the return string... |
---|
| 871 | // |
---|
| 872 | // local function |
---|
| 873 | // |
---|
| 874 | // NO CHANGE NEEDED |
---|
| 875 | // |
---|
| 876 | Function/S ListFromDash(item) |
---|
| 877 | String item |
---|
| 878 | |
---|
| 879 | String numList="",loStr="",hiStr="" |
---|
| 880 | Variable lo,hi,ii |
---|
| 881 | |
---|
| 882 | loStr=StringFromList(0,item,"-") //treat the range as a list |
---|
| 883 | hiStr=StringFromList(1,item,"-") |
---|
| 884 | lo=str2num(loStr) |
---|
| 885 | hi=str2num(hiStr) |
---|
| 886 | if( (numtype(lo) != 0) || (numtype(hi) !=0 ) || (lo > hi) ) |
---|
| 887 | numList="" |
---|
| 888 | return numList |
---|
| 889 | endif |
---|
| 890 | for(ii=lo;ii<=hi;ii+=1) |
---|
| 891 | numList += num2str(ii) + "," |
---|
| 892 | endfor |
---|
| 893 | |
---|
| 894 | Return numList |
---|
| 895 | End |
---|
| 896 | |
---|
| 897 | |
---|
| 898 | //returns the proper attenuation factor based on the instrument |
---|
| 899 | // |
---|
| 900 | // filestr is passed from TextRead[3] = the default directory, used to identify the instrument |
---|
| 901 | // lam is passed from RealsRead[26] |
---|
| 902 | // AttenNo is passed from ReaslRead[3] |
---|
| 903 | // |
---|
| 904 | // Attenuation factor as defined here is <= 1 |
---|
| 905 | // |
---|
| 906 | // Facilities can pass ("",1,attenuationFactor) and have this function simply |
---|
| 907 | // spit back the attenuationFactor (that was read into rw[3]) |
---|
| 908 | // |
---|
| 909 | // called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf |
---|
| 910 | // |
---|
[795] | 911 | // atten_err is one std. deviation, passed back by reference |
---|
| 912 | Function AttenuationFactor(fileStr,lam,attenNo,atten_err) |
---|
[575] | 913 | String fileStr // |
---|
[795] | 914 | Variable lam,attenNo, &atten_err |
---|
[575] | 915 | |
---|
| 916 | Variable attenFactor=1 |
---|
| 917 | |
---|
| 918 | // your code here |
---|
| 919 | attenFactor = LookupAtten(lam,attenNo) |
---|
| 920 | |
---|
[795] | 921 | // Change April 2011 - now returns error in atten trans |
---|
| 922 | atten_err = 0 |
---|
| 923 | |
---|
[575] | 924 | return(attenFactor) |
---|
| 925 | End |
---|
| 926 | |
---|
| 927 | Function LookupAtten(lambda,attenNo) |
---|
| 928 | Variable lambda, attenNo |
---|
| 929 | |
---|
| 930 | Variable trans |
---|
| 931 | String attStr="root:myGlobals:Attenuators:att"+num2str(trunc(attenNo)) |
---|
| 932 | String lamStr = "root:myGlobals:Attenuators:lambda" |
---|
| 933 | |
---|
| 934 | if(attenNo == 0) |
---|
| 935 | return (1) //no attenuation, return trans == 1 |
---|
| 936 | endif |
---|
| 937 | |
---|
[707] | 938 | // if( (lambda < 5) || (lambda > 5 ) ) |
---|
| 939 | // Abort "Wavelength out of calibration range (5A). You must manually enter the absolute parameters" |
---|
| 940 | // Endif |
---|
[575] | 941 | |
---|
| 942 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
| 943 | Execute "MakeAttenTable()" |
---|
| 944 | Endif |
---|
| 945 | //just in case creating the tables fails.... |
---|
| 946 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
| 947 | Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" |
---|
| 948 | Endif |
---|
| 949 | |
---|
| 950 | //lookup the value by interpolating the wavelength |
---|
| 951 | //the attenuator must always be an integer |
---|
| 952 | |
---|
| 953 | |
---|
| 954 | Wave att = $attStr |
---|
| 955 | Wave lam = $lamstr |
---|
| 956 | //nha - commented below out until we have attenuation factors over multiple lambda values |
---|
| 957 | //trans = interp(lambda,lam,att) |
---|
| 958 | |
---|
| 959 | // Print "trans = ",trans |
---|
| 960 | //nha - delete this line when multiple lambda values |
---|
| 961 | trans = att |
---|
| 962 | |
---|
| 963 | return trans |
---|
| 964 | End |
---|
| 965 | |
---|
| 966 | Proc MakeAttenTable() |
---|
| 967 | |
---|
| 968 | NewDataFolder/O root:myGlobals:Attenuators |
---|
| 969 | //do explicitly to avoid data folder problems, redundant, but it must work without fail |
---|
| 970 | |
---|
| 971 | //Quokka specific nha. |
---|
| 972 | Variable num=12 |
---|
| 973 | |
---|
| 974 | Make/O/N=(num) root:myGlobals:Attenuators:att0 |
---|
| 975 | Make/O/N=(num) root:myGlobals:Attenuators:att1 |
---|
| 976 | Make/O/N=(num) root:myGlobals:Attenuators:att2 |
---|
| 977 | Make/O/N=(num) root:myGlobals:Attenuators:att3 |
---|
| 978 | Make/O/N=(num) root:myGlobals:Attenuators:att4 |
---|
| 979 | Make/O/N=(num) root:myGlobals:Attenuators:att5 |
---|
| 980 | Make/O/N=(num) root:myGlobals:Attenuators:att6 |
---|
| 981 | Make/O/N=(num) root:myGlobals:Attenuators:att7 |
---|
| 982 | Make/O/N=(num) root:myGlobals:Attenuators:att8 |
---|
| 983 | Make/O/N=(num) root:myGlobals:Attenuators:att9 |
---|
| 984 | Make/O/N=(num) root:myGlobals:Attenuators:att10 |
---|
| 985 | Make/O/N=(num) root:myGlobals:Attenuators:att11 |
---|
| 986 | |
---|
| 987 | // epg |
---|
| 988 | // note 5A only at this stage but other wavelengths as measured |
---|
| 989 | // these values have to be re-determined as were measured on time and not monitor counts |
---|
[707] | 990 | //Make/O/N=(num) root:myGlobals:Attenuators:lambda={5} |
---|
| 991 | Make/O/N=(num) root:myGlobals:Attenuators:lambda={4.94} |
---|
[575] | 992 | |
---|
| 993 | //Quokka attenuator factors. 19/1/09 nha |
---|
| 994 | //20/3/09 nha updated to |
---|
| 995 | //file://fianna/Sections/Bragg/Data_Analysis_Team/Project/P025 Quokka Commissioning DRV/3_Development/ATTest-timeseries.pdf |
---|
[707] | 996 | //updated by epg 13-02-2010 to reflect kwo measurements at g7 |
---|
[575] | 997 | |
---|
[707] | 998 | root:myGlobals:Attenuators:att0 = {1} |
---|
| 999 | root:myGlobals:Attenuators:att1 = {0.498782} |
---|
| 1000 | root:myGlobals:Attenuators:att2 = {0.176433} |
---|
| 1001 | root:myGlobals:Attenuators:att3 = {0.0761367} |
---|
| 1002 | root:myGlobals:Attenuators:att4 = {0.0353985} |
---|
| 1003 | root:myGlobals:Attenuators:att5 = {0.0137137} |
---|
| 1004 | root:myGlobals:Attenuators:att6 = {0.00614167} |
---|
| 1005 | root:myGlobals:Attenuators:att7 = {0.00264554} |
---|
| 1006 | root:myGlobals:Attenuators:att8 = {0.000994504} |
---|
| 1007 | root:myGlobals:Attenuators:att9 = {0.000358897} |
---|
| 1008 | root:myGlobals:Attenuators:att10 = {7.2845e-05} |
---|
| 1009 | root:myGlobals:Attenuators:att11 = {1.67827e-06} |
---|
[575] | 1010 | |
---|
| 1011 | End |
---|
| 1012 | |
---|
| 1013 | //function called by the popups to get a file list of data that can be sorted |
---|
| 1014 | // this procedure simply removes the raw data files from the string - there |
---|
| 1015 | //can be lots of other junk present, but this is very fast... |
---|
| 1016 | // |
---|
| 1017 | // could also use the alternate procedure of keeping only file with the proper extension |
---|
| 1018 | // |
---|
| 1019 | // another possibility is to get a listing of the text files, but is unreliable on |
---|
| 1020 | // Windows, where the data file must be .txt (and possibly OSX) |
---|
| 1021 | // |
---|
| 1022 | // called by FIT_Ops.ipf, NSORT.ipf, PlotUtils.ipf |
---|
| 1023 | // |
---|
| 1024 | // modify for specific facilities by changing the "*.SA1*","*.SA2*","*.SA3*" stringmatch |
---|
| 1025 | // items which are specific to NCNR |
---|
| 1026 | // |
---|
| 1027 | Function/S ReducedDataFileList(ctrlName) |
---|
| 1028 | String ctrlName |
---|
| 1029 | |
---|
| 1030 | String list="",newList="",item="" |
---|
| 1031 | Variable num,ii |
---|
| 1032 | |
---|
| 1033 | //check for the path |
---|
| 1034 | PathInfo catPathName |
---|
| 1035 | if(V_Flag==0) |
---|
| 1036 | DoAlert 0, "Data path does not exist - pick the data path from the button on the main panel" |
---|
| 1037 | Return("") |
---|
| 1038 | Endif |
---|
| 1039 | |
---|
| 1040 | list = IndexedFile(catpathName,-1,"????") |
---|
| 1041 | num=ItemsInList(list,";") |
---|
| 1042 | //print "num = ",num |
---|
| 1043 | for(ii=(num-1);ii>=0;ii-=1) |
---|
| 1044 | item = StringFromList(ii, list ,";") |
---|
| 1045 | //simply remove all that are not raw data files (SA1 SA2 SA3) |
---|
| 1046 | if( !stringmatch(item,"*.SA1*") && !stringmatch(item,"*.SA2*") && !stringmatch(item,"*.SA3*") ) |
---|
| 1047 | if( !stringmatch(item,".*") && !stringmatch(item,"*.pxp") && !stringmatch(item,"*.DIV")) //eliminate mac "hidden" files, pxp, and div files |
---|
[715] | 1048 | if (!stringmatch(item,"*.nx.hdf") && !stringmatch(item,"*.bin") && !stringmatch(item,"*.mask")) |
---|
| 1049 | newlist += item + ";" |
---|
| 1050 | endif |
---|
[575] | 1051 | endif |
---|
| 1052 | endif |
---|
| 1053 | endfor |
---|
| 1054 | //remove VAX version numbers |
---|
| 1055 | newList = RemoveVersNumsFromList(newList) |
---|
| 1056 | //sort |
---|
| 1057 | newList = SortList(newList,";",0) |
---|
| 1058 | |
---|
| 1059 | return newlist |
---|
| 1060 | End |
---|
| 1061 | |
---|
| 1062 | // returns a list of raw data files in the catPathName directory on disk |
---|
| 1063 | // - list is SEMICOLON-delimited |
---|
| 1064 | // |
---|
| 1065 | // called by PatchFiles.ipf, Tile_2D.ipf |
---|
| 1066 | // |
---|
| 1067 | Function/S GetRawDataFileList() |
---|
| 1068 | |
---|
| 1069 | //nha. Reads Quokka file names 5/2/09 |
---|
| 1070 | |
---|
| 1071 | //make sure that path exists |
---|
| 1072 | PathInfo catPathName |
---|
| 1073 | if (V_flag == 0) |
---|
| 1074 | Abort "Folder path does not exist - use Pick Path button on Main Panel" |
---|
| 1075 | Endif |
---|
| 1076 | |
---|
| 1077 | String list=IndexedFile(catPathName,-1,"????") |
---|
| 1078 | String newList="",item="" |
---|
| 1079 | Variable num=ItemsInList(list,";"),ii |
---|
| 1080 | for(ii=0;ii<num;ii+=1) |
---|
| 1081 | item = StringFromList(ii, list ,";") |
---|
| 1082 | if( stringmatch(item,"*.nx.hdf") ) |
---|
| 1083 | newlist += item + ";" |
---|
| 1084 | endif |
---|
| 1085 | //print "ii=",ii |
---|
| 1086 | endfor |
---|
| 1087 | newList = SortList(newList,";",0) |
---|
| 1088 | return(newList) |
---|
| 1089 | |
---|
| 1090 | // your code here |
---|
| 1091 | |
---|
| 1092 | return(list) |
---|
| 1093 | End |
---|
| 1094 | |
---|
| 1095 | //********************** |
---|
| 1096 | // 2D resolution function calculation - in terms of X and Y |
---|
| 1097 | // |
---|
| 1098 | // based on notes from David Mildner, 2008 |
---|
| 1099 | // |
---|
| 1100 | // the final NCNR version is located in NCNR_Utils.ipf |
---|
| 1101 | // |
---|
| 1102 | Function/S get2DResolution(inQ,phi,lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,r_dist,SigmaQX,SigmaQY,fSubS) |
---|
| 1103 | Variable inQ, phi,lambda, lambdaWidth, DDet, apOff, S1, S2, L1, L2, BS, del_r,usingLenses,r_dist |
---|
| 1104 | Variable &SigmaQX,&SigmaQY,&fSubS //these are the output quantities at the input Q value |
---|
| 1105 | |
---|
| 1106 | return("Function Empty") |
---|
| 1107 | End |
---|
[683] | 1108 | |
---|
| 1109 | // Return the filename that represents the previous or next file. |
---|
| 1110 | // Input is current filename and increment. |
---|
| 1111 | // Increment should be -1 or 1 |
---|
| 1112 | // -1 => previous file |
---|
| 1113 | // 1 => next file |
---|
| 1114 | Function/S GetPrevNextRawFile(curfilename, prevnext) |
---|
| 1115 | String curfilename |
---|
| 1116 | Variable prevnext |
---|
| 1117 | |
---|
| 1118 | String filename |
---|
| 1119 | |
---|
| 1120 | //get the run number |
---|
| 1121 | Variable num = GetRunNumFromFile(curfilename) |
---|
| 1122 | |
---|
| 1123 | //find the next specified file by number |
---|
| 1124 | fileName = FindFileFromRunNumber(num+prevnext) |
---|
| 1125 | |
---|
| 1126 | if(cmpstr(fileName,"")==0) |
---|
| 1127 | //null return, do nothing |
---|
| 1128 | fileName = FindFileFromRunNumber(num) |
---|
| 1129 | Endif |
---|
| 1130 | |
---|
| 1131 | // print "in FU "+filename |
---|
| 1132 | |
---|
| 1133 | Return filename |
---|
| 1134 | End |
---|