- Timestamp:
- May 28, 2008 1:18:14 PM (15 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/ILL_DataReadWrite.ipf
r353 r370 109 109 textw[0]= v0 110 110 111 print "function read raw used"111 // print "function read raw used" 112 112 113 113 // date and time of collection … … 257 257 // 258 258 // type is "DIV" on input 259 Function ReadHeaderAndWork (type,fname)259 Function ReadHeaderAndWork1(type,fname) 260 260 String type,fname 261 261 … … 291 291 292 292 293 print "function used"293 // print "function used" 294 294 295 295 … … 318 318 Return(0) 319 319 End 320 321 322 /////////DIV file created with NIST reduction so has the VAX format.... painful 323 324 Function ReadHeaderAndWork(type,fname) 325 String type,fname 326 327 //type is the desired folder to read the workfile to 328 //this data will NOT be automatically displayed gDataDisplayType is unchanged 329 330 // SVAR cur_folder=root:myGlobals:gDataDisplayType 331 String cur_folder = type 332 String curPath = "root:"+cur_folder 333 SetDataFolder curPath //use the full path, so it will always work 334 335 Variable refNum,integer,realval 336 String sansfname,textstr 337 Variable/G $(curPath + ":gIsLogScale") = 0 //initial state is linear, keep this in DIV folder 338 339 Make/O/N=23 $(curPath + ":IntegersRead") 340 Make/O/N=52 $(curPath + ":RealsRead") 341 Make/O/T/N=11 $(curPath + ":TextRead") 342 343 WAVE intw=$(curPath + ":IntegersRead") 344 WAVE realw=$(curPath + ":RealsRead") 345 WAVE/T textw=$(curPath + ":TextRead") 346 347 //***NOTE **** 348 // the "current path" gets mysteriously reset to "root:" after the SECOND pass through 349 // this read routine, after the open dialog is presented 350 // the "--read" waves end up in the correct folder, but the data does not! Why? 351 //must re-set data folder before writing data array (done below) 352 353 SetDataFolder curPath 354 355 //actually open the file 356 Open/R refNum as fname 357 //skip first two bytes 358 FSetPos refNum, 2 359 //read the next 21 bytes as characters (fname) 360 FReadLine/N=21 refNum,textstr 361 textw[0]= textstr 362 //read four i*4 values /F=3 flag, B=3 flag 363 FBinRead/F=3/B=3 refNum, integer 364 intw[0] = integer 365 // 366 FBinRead/F=3/B=3 refNum, integer 367 intw[1] = integer 368 // 369 FBinRead/F=3/B=3 refNum, integer 370 intw[2] = integer 371 // 372 FBinRead/F=3/B=3 refNum, integer 373 intw[3] = integer 374 // 6 text fields 375 FSetPos refNum,55 //will start reading at byte 56 376 FReadLine/N=20 refNum,textstr 377 textw[1]= textstr 378 FReadLine/N=3 refNum,textstr 379 textw[2]= textstr 380 FReadLine/N=11 refNum,textstr 381 textw[3]= textstr 382 FReadLine/N=1 refNum,textstr 383 textw[4]= textstr 384 FReadLine/N=8 refNum,textstr 385 textw[5]= textstr 386 FReadLine/N=60 refNum,textstr 387 textw[6]= textstr 388 389 //3 integers 390 FSetPos refNum,174 391 FBinRead/F=3/B=3 refNum, integer 392 intw[4] = integer 393 FBinRead/F=3/B=3 refNum, integer 394 intw[5] = integer 395 FBinRead/F=3/B=3 refNum, integer 396 intw[6] = integer 397 398 //2 integers, 3 text fields 399 FSetPos refNum,194 400 FBinRead/F=3/B=3 refNum, integer 401 intw[7] = integer 402 FBinRead/F=3/B=3 refNum, integer 403 intw[8] = integer 404 FReadLine/N=6 refNum,textstr 405 textw[7]= textstr 406 FReadLine/N=6 refNum,textstr 407 textw[8]= textstr 408 FReadLine/N=6 refNum,textstr 409 textw[9]= textstr 410 411 //2 integers 412 FSetPos refNum,244 413 FBinRead/F=3/B=3 refNum, integer 414 intw[9] = integer 415 FBinRead/F=3/B=3 refNum, integer 416 intw[10] = integer 417 418 //2 integers 419 FSetPos refNum,308 420 FBinRead/F=3/B=3 refNum, integer 421 intw[11] = integer 422 FBinRead/F=3/B=3 refNum, integer 423 intw[12] = integer 424 425 //2 integers 426 FSetPos refNum,332 427 FBinRead/F=3/B=3 refNum, integer 428 intw[13] = integer 429 FBinRead/F=3/B=3 refNum, integer 430 intw[14] = integer 431 432 //3 integers 433 FSetPos refNum,376 434 FBinRead/F=3/B=3 refNum, integer 435 intw[15] = integer 436 FBinRead/F=3/B=3 refNum, integer 437 intw[16] = integer 438 FBinRead/F=3/B=3 refNum, integer 439 intw[17] = integer 440 441 //1 text field - the file association for transmission are the first 4 bytes 442 FSetPos refNum,404 443 FReadLine/N=42 refNum,textstr 444 textw[10]= textstr 445 446 //1 integer 447 FSetPos refNum,458 448 FBinRead/F=3/B=3 refNum, integer 449 intw[18] = integer 450 451 //4 integers 452 FSetPos refNum,478 453 FBinRead/F=3/B=3 refNum, integer 454 intw[19] = integer 455 FBinRead/F=3/B=3 refNum, integer 456 intw[20] = integer 457 FBinRead/F=3/B=3 refNum, integer 458 intw[21] = integer 459 FBinRead/F=3/B=3 refNum, integer 460 intw[22] = integer 461 462 Close refNum 463 464 //now get all of the reals 465 // 466 //Do all the GBLoadWaves at the end 467 // 468 //FBinRead Cannot handle 32 bit VAX floating point 469 //GBLoadWave, however, can properly read it 470 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 471 String strToExecute 472 //append "/S=offset/U=numofreals" to control the read 473 // then append fname to give the full file path 474 // then execute 475 476 Variable a=0,b=0 477 478 SetDataFolder curPath 479 // 4 R*4 values 480 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 481 Execute strToExecute 482 483 SetDataFolder curPath 484 Wave w=$(curPath + ":tempGBWave0") 485 b=4 //num of reals read 486 realw[a,a+b-1] = w[p-a] 487 a+=b 488 489 // 4 R*4 values 490 SetDataFolder curPath 491 strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\"" 492 Execute strToExecute 493 b=4 494 realw[a,a+b-1] = w[p-a] 495 a+=b 496 497 /////////// 498 // 2 R*4 values 499 SetDataFolder curPath 500 strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 501 Execute strToExecute 502 b=2 503 realw[a,a+b-1] = w[p-a] 504 a+=b 505 506 // 6 R*4 values 507 SetDataFolder curPath 508 strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\"" 509 Execute strToExecute 510 b=6 511 realw[a,a+b-1] = w[p-a] 512 a+=b 513 514 // 13 R*4 values 515 SetDataFolder curPath 516 strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\"" 517 Execute strToExecute 518 b=13 519 realw[a,a+b-1] = w[p-a] 520 a+=b 521 522 // 3 R*4 values 523 SetDataFolder curPath 524 strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\"" 525 Execute strToExecute 526 b=3 527 realw[a,a+b-1] = w[p-a] 528 a+=b 529 530 // 7 R*4 values 531 SetDataFolder curPath 532 strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\"" 533 Execute strToExecute 534 b=7 535 realw[a,a+b-1] = w[p-a] 536 a+=b 537 538 // 4 R*4 values 539 SetDataFolder curPath 540 strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\"" 541 Execute strToExecute 542 b=4 543 realw[a,a+b-1] = w[p-a] 544 a+=b 545 546 // 2 R*4 values 547 SetDataFolder curPath 548 strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\"" 549 Execute strToExecute 550 b=2 551 realw[a,a+b-1] = w[p-a] 552 a+=b 553 554 // 2 R*4 values 555 SetDataFolder curPath 556 strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\"" 557 Execute strToExecute 558 b=2 559 realw[a,a+b-1] = w[p-a] 560 a+=b 561 562 // 5 R*4 values 563 SetDataFolder curPath 564 strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\"" 565 Execute strToExecute 566 b=5 567 realw[a,a+b-1] = w[p-a] 568 569 //if the binary VAX data ws transferred to a MAC, all is OK 570 //if the data was trasnferred to an Intel machine (IBM), all the real values must be 571 //divided by 4 to get the correct floating point values 572 // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly 573 // on an Intel machine. 574 //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read 575 //VAX reals correctly, and no checking is necessary 12 APR 99 576 //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 577 //do nothing 578 //else 579 //either Windows or Windows NT 580 //realw /= 4 581 //endif 582 583 //read in the data 584 GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 585 586 curPath = "root:"+cur_folder 587 SetDataFolder curPath //use the full path, so it will always work 588 589 Make/O/N=16384 $(curPath + ":data") 590 WAVE data = $(curPath + ":data") 591 592 Variable skip,ii,offset 593 594 //read in a total of 16384 values (ii) 595 //as follows : 596 // skip first 2 bytes 597 // skip 512 byte header 598 // skip first 2 bytes of data 599 //(read 511 reals, skip 2b, 510 reals, skip 2b) -16 times = 16336 values 600 // read the final 48 values in seperately to avoid EOF error 601 602 ///////////// 603 SetDataFolder curPath 604 skip = 0 605 ii=0 606 offset = 514 +2 607 a=0 608 do 609 SetDataFolder curPath 610 611 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=511" + "\"" + fname + "\"" 612 Execute strToExecute 613 //Print strToExecute 614 b=511 615 data[a,a+b-1] = w[p-a] 616 a+=b 617 618 offset += 511*4 +2 619 620 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=510" + "\"" + fname + "\"" 621 SetDataFolder curPath 622 Execute strToExecute 623 //Print strToExecute 624 b=510 625 data[a,a+b-1] = w[p-a] 626 a+=b 627 628 offset += 510*4 +2 629 630 ii+=1 631 //Print "inside do, data[2] =",data[2] 632 //Print "inside do, tempGBwave0[0] = ",w[0] 633 while(ii<16) 634 635 // 16336 values have been read in -- 636 //read in last 64 values 637 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=48" + "\"" + fname + "\"" 638 639 SetDataFolder curPath 640 Execute strToExecute 641 b=48 642 data[a,a+b-1] = w[p-a] 643 a+=b 644 // 645 /// done reading in raw data 646 // 647 //Print "in workdatareader , data = ", data[1][1] 648 649 Redimension/n=(128,128) data 650 651 //clean up - get rid of w = $"tempGBWave0" 652 KillWaves w 653 654 //divide the FP data by 4 if read from a PC (not since GBLoadWave update) 655 //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 656 //do nothing 657 //else 658 //either Windows or Windows NT 659 //data /= 4 660 //endif 661 662 //keep a string with the filename in the DIV folder 663 String/G $(curPath + ":fileList") = textw[0] 664 665 //return the data folder to root 666 SetDataFolder root: 667 668 Return(0) 669 End 670 671 320 672 321 673 … … 499 851 // your writer here 500 852 501 WriteReal(fname,trans, 6644)853 WriteReal(fname,trans,5589) //I will define at position 10 lines by myself 502 854 503 855 return(0) … … 511 863 512 864 // do nothing for now 865 WriteReal(fname,trans,6885) 513 866 514 867 return(0) … … 523 876 // do nothing if not using NCNR Transmission module 524 877 525 WriteReal(fname,counts,6 660)878 WriteReal(fname,counts,6868) 526 879 527 880 return(0) … … 548 901 // your code here 549 902 550 WriteReal(fname,num, 6677)903 WriteReal(fname,num,5508) //define at 9 lines just above transmission 551 904 552 905 return(0) … … 573 926 // your code here 574 927 575 WriteReal(fname,num,568 9)928 WriteReal(fname,num,5686) 576 929 577 930 return(0) … … 633 986 634 987 // your code here 635 WriteReal(fname,num, 7504)988 WriteReal(fname,num,5702) 636 989 637 990 return(0) … … 645 998 // your code here 646 999 647 WriteReal(fname,num, 7520)1000 WriteReal(fname,num,5718) 648 1001 649 1002 return(0) … … 771 1124 End 772 1125 773 // total counting time (s econds)1126 // total counting time (stored here as seconds/10??) 774 1127 Function WriteCountTimeToHeader(fname,num) 775 1128 String fname … … 777 1130 778 1131 // your code here 779 WriteReal(fname,num,4894) 1132 // WriteReal(fname,num,4894) 1133 WriteReal(fname,num,4892) 780 1134 781 1135 … … 839 1193 840 1194 // your code, returning str 841 str = (getStringFromHeader(fname,20 25,30)) /// 25*811195 str = (getStringFromHeader(fname,2075,30)) /// 25*81 + 50////+51 30 lines before the end 842 1196 843 1197 … … 943 1297 // your code returning value 944 1298 945 value = 11299 value = getRealValueFromHeader(fname,45) 946 1300 947 1301 return(value) … … 956 1310 957 1311 // your code returning value 958 value = getRealValueFromHeader(fname,1 14)1312 value = getRealValueFromHeader(fname,124) 959 1313 960 1314 return(value) … … 980 1334 981 1335 // your code returning value 982 value = 1//mm1336 value = getRealValueFromHeader(fname,40) //mm 983 1337 984 1338 return(value) … … 1110 1464 value = getRealValueFromHeader(fname,72) 1111 1465 1466 value = 5 1467 1112 1468 return(value) 1113 1469 end … … 1194 1550 1195 1551 //total count time (seconds) 1552 // stored here as (s/10), so multiply by 10 ? 1196 1553 Function getCountTime(fname) 1197 1554 String fname … … 1203 1560 // value = getRealValueFromHeader_2(fname,60,28,5,1,3) /// line 1 col 3 1204 1561 1205 value = getRealValueFromHeader(fname,2) 1562 value = getRealValueFromHeader(fname,2)/10 1206 1563 1207 1564 return(value) … … 1244 1601 // if not using the NCNR Transmission module, this function default to 1245 1602 // returning 0000, and no changes needed 1603 // 1604 // filename is the full path:name to the file 1246 1605 Function getXYBoxFromFile(filename,x1,x2,y1,y2) 1247 1606 String filename 1248 1607 Variable &x1,&x2,&y1,&y2 1249 1250 Variable refnum1251 String tmpFile = FindValidFilename(filename)1252 // tmpFile is only a parital path1253 1608 1254 1609 // return your bounding box coordinates or default values of 0 1255 x1=0 1256 y1=0 1257 x2=0 1258 y2=0 1610 x1=getRealValueFromHeader(filename,120) 1611 x2=getRealValueFromHeader(filename,121) 1612 y1=getRealValueFromHeader(filename,122) 1613 y2=getRealValueFromHeader(filename,123) 1614 1615 // print "in get", x1,x2,y1,y2 1259 1616 1260 1617 return(0) … … 1266 1623 // 1267 1624 // if not using the NCNR Transmission module, this function is null 1625 // 1626 // filename as passed in is a full path:filename 1627 // 1268 1628 Function WriteXYBoxToHeader(filename,x1,x2,y1,y2) 1269 1629 String filename … … 1271 1631 1272 1632 // your code to write bounding box to the header, or nothing 1633 1634 WriteReal(filename,x1,6804) 1635 WriteReal(filename,x2,6820) 1636 WriteReal(filename,y1,6836) 1637 WriteReal(filename,y2,6852) 1638 1639 print "in write",x1,x2,y1,y2 1640 1641 // should start at 120 for read and line 25 1642 1643 /// 84 *81 1273 1644 1274 1645 return(0) … … 1528 1899 valuesRead = V_flag 1529 1900 // print valuesRead 1530 // printbuffer1901 // buffer 1531 1902 //valuesRead = V_flag 1532 1903 // print ii,refnum,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9 -
sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/ILL_Utils.ipf
r353 r370 29 29 Variable/G root:myGlobals:DeadtimeDefault = 0.9e-6 //deadtime in seconds 30 30 31 Variable/G root:myGlobals:BeamstopYTol = 1 5031 Variable/G root:myGlobals:BeamstopYTol = 100 32 32 33 33 Variable/G root:myGlobals:apOff = 5.0 // (cm) distance from sample aperture to sample position … … 367 367 // print ypos 368 368 369 // print ytol369 // print ytol 370 370 371 371 if(abs(ypos)>=ytol) … … 831 831 832 832 Variable attenFactor 833 834 attenFactor = 1 833 make/O/N=3 Attenuators_ILL={147,902,2874} 834 835 attenFactor = Attenuators_ILL[attenNo-1] 836 837 // print attenfactor 835 838 836 839 // your code here 837 840 838 return( attenFactor)841 return(1/attenFactor) 839 842 End 840 843 -
sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/Marquee.ipf
r328 r370 75 75 Endif 76 76 SVAR dispType=root:myGlobals:gDataDisplayType 77 if(cmpstr(dispType," RealTime")==0)78 Print "Can't SetXYBox for a RealTime file"77 if(cmpstr(dispType,"SAM")!=0) 78 DoAlert 0, "You can only use SetXYBox on SAM data files" 79 79 return(1) 80 80 endif -
sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/NCNR_DataReadWrite.ipf
r328 r370 1580 1580 ///// TRANSMISSION RELATED FUNCTIONS //////// 1581 1581 //box coordinate are returned by reference 1582 // filename is the full path:name 1582 1583 Function getXYBoxFromFile(filename,x1,x2,y1,y2) 1583 1584 String filename … … 1585 1586 1586 1587 Variable refnum 1587 String tmpFile = FindValidFilename(filename)1588 // String tmpFile = FindValidFilename(filename) 1588 1589 1589 Open/R/P=catPathName refnum as tmpFile 1590 // Open/R/P=catPathName refnum as tmpFile 1591 Open/R refnum as filename 1590 1592 FSetPos refnum,478 1591 1593 FBinRead/F=3/B=3 refnum, x1 -
sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/ProtocolAsPanel.ipf
r328 r370 2007 2007 pixel = rw[10]/10 // header value (X) is in mm, want cm here 2008 2008 2009 countTime = iw[ 1]2009 countTime = iw[2] 2010 2010 //detCnt = rw[2] //080802 -use sum of data, not scaler from header 2011 2011 monCnt = rw[0] … … 2023 2023 Variable x1,x2,y1,y2 2024 2024 String filename=tw[0],tempStr 2025 err = GetXYBoxFromFile(filename,x1,x2,y1,y2) //xy's are passed/returned by reference 2025 PathInfo/S catPathName 2026 String tempName = S_Path + FindValidFilename(filename) 2027 err = GetXYBoxFromFile(tempName,x1,x2,y1,y2) //xy's are passed/returned by reference 2026 2028 Print x1,x2,y1,y2 2027 2029 … … 2032 2034 Endif 2033 2035 //box is OK, write box values to file 2034 PathInfo/S catPathName2035 String tempName = S_Path + FindValidFilename(filename)2036 2036 WriteXYBoxToHeader(tempName,x1,x2,y1,y2) 2037 2037 else
Note: See TracChangeset
for help on using the changeset viewer.