Changeset 484 for sans/Dev/trunk/NCNR_User_Procedures/Reduction
 Timestamp:
 Apr 1, 2009 4:18:42 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/RealTimeUpdate_RT.ipf
r482 r484 297 297 //ReadOrdelaHST(filename) 298 298 299 ReadHeaderAndData(filename) 300 Raw_to_Work("RealTime") 299 //ReadHeaderAndData(filename) 300 //Raw_to_Work("RealTime") 301 ReadRTAndData(filename) 301 302 302 303 //the calling macro must change the display type … … 512 513 ControlUpdate/W=SANS_Data/A 513 514 515 //Copy file from ICE server 516 ExecuteScriptText/B "\"C:\\Documents and Settings\\user\\Desktop\\ICE Test\\getdata.bat\"" 517 514 518 //err = ReadOrdelaHST(RT_fileStr) 515 err = ReadHeaderAndData(RT_fileStr) 519 //err = ReadHeaderAndData(RT_fileStr) 520 err = ReadRTAndData(RT_fileStr) 516 521 if(err==1) 517 522 Button $"bkgStop",win=RT_Panel,title="Start Updating",rename=bkgStart 518 523 return(err) //file not found 519 524 Endif 520 Raw_to_work("RealTime")525 //Raw_to_work("RealTime") 521 526 // for testing only... 522 527 // data += abs(enoise(data)) … … 544 549 545 550 End 551 552 Function ReadRTAndData(fname) 553 String fname 554 //this function is for reading in RAW data only, so it will always put data in RAW folder 555 String curPath = "root:Packages:NIST:RealTime:" 556 SetDataFolder curPath //use the full path, so it will always work 557 //Variable/G root:Packages:NIST:RAW:gIsLogScale = 0 //initial state is linear, keep this in RAW folder 558 Variable isLogScale=NumVarOrDefault("root:Packages:NIST:RealTime:gIsLogScale", 0) 559 Variable/G root:Packages:NIST:RealTime:gIsLogScale = isLogScale 560 561 Variable refNum,integer,realval 562 String sansfname,textstr 563 564 Make/O/N=23 $"root:Packages:NIST:RealTime:IntegersRead" 565 Make/O/N=52 $"root:Packages:NIST:RealTime:RealsRead" 566 Make/O/T/N=11 $"root:Packages:NIST:RealTime:TextRead" 567 568 Wave intw=$"root:Packages:NIST:RealTime:IntegersRead" 569 Wave realw=$"root:Packages:NIST:RealTime:RealsRead" 570 Wave/T textw=$"root:Packages:NIST:RealTime:TextRead" 571 572 //***NOTE **** 573 // the "current path" gets mysteriously reset to "root:" after the SECOND pass through 574 // this read routine, after the open dialog is presented 575 // the "read" waves end up in the correct folder, but the data does not! Why? 576 //must reset data folder before writing data array (done below) 577 578 //full filename and path is now passed in... 579 //actually open the file 580 Open/R refNum as fname 581 //skip first two bytes (VAX record length markers, not needed here) 582 FSetPos refNum, 2 583 //read the next 21 bytes as characters (fname) 584 FReadLine/N=21 refNum,textstr 585 textw[0]= textstr 586 //read four i*4 values /F=3 flag, B=3 flag 587 FBinRead/F=3/B=3 refNum, integer 588 intw[0] = integer 589 // 590 FBinRead/F=3/B=3 refNum, integer 591 intw[1] = integer 592 // 593 FBinRead/F=3/B=3 refNum, integer 594 intw[2] = integer 595 // 596 FBinRead/F=3/B=3 refNum, integer 597 intw[3] = integer 598 // 6 text fields 599 FSetPos refNum,55 //will start reading at byte 56 600 FReadLine/N=20 refNum,textstr 601 textw[1]= textstr 602 FReadLine/N=3 refNum,textstr 603 textw[2]= textstr 604 FReadLine/N=11 refNum,textstr 605 textw[3]= textstr 606 FReadLine/N=1 refNum,textstr 607 textw[4]= textstr 608 FReadLine/N=8 refNum,textstr 609 textw[5]= textstr 610 FReadLine/N=60 refNum,textstr 611 textw[6]= textstr 612 613 //3 integers 614 FSetPos refNum,174 615 FBinRead/F=3/B=3 refNum, integer 616 intw[4] = integer 617 FBinRead/F=3/B=3 refNum, integer 618 intw[5] = integer 619 FBinRead/F=3/B=3 refNum, integer 620 intw[6] = integer 621 622 //2 integers, 3 text fields 623 FSetPos refNum,194 624 FBinRead/F=3/B=3 refNum, integer 625 intw[7] = integer 626 FBinRead/F=3/B=3 refNum, integer 627 intw[8] = integer 628 FReadLine/N=6 refNum,textstr 629 textw[7]= textstr 630 FReadLine/N=6 refNum,textstr 631 textw[8]= textstr 632 FReadLine/N=6 refNum,textstr 633 textw[9]= textstr 634 635 //2 integers 636 FSetPos refNum,244 637 FBinRead/F=3/B=3 refNum, integer 638 intw[9] = integer 639 FBinRead/F=3/B=3 refNum, integer 640 intw[10] = integer 641 642 //2 integers 643 FSetPos refNum,308 644 FBinRead/F=3/B=3 refNum, integer 645 intw[11] = integer 646 FBinRead/F=3/B=3 refNum, integer 647 intw[12] = integer 648 649 //2 integers 650 FSetPos refNum,332 651 FBinRead/F=3/B=3 refNum, integer 652 intw[13] = integer 653 FBinRead/F=3/B=3 refNum, integer 654 intw[14] = integer 655 656 //3 integers 657 FSetPos refNum,376 658 FBinRead/F=3/B=3 refNum, integer 659 intw[15] = integer 660 FBinRead/F=3/B=3 refNum, integer 661 intw[16] = integer 662 FBinRead/F=3/B=3 refNum, integer 663 intw[17] = integer 664 665 //1 text field  the file association for transmission are the first 4 bytes 666 FSetPos refNum,404 667 FReadLine/N=42 refNum,textstr 668 textw[10]= textstr 669 670 //1 integer 671 FSetPos refNum,458 672 FBinRead/F=3/B=3 refNum, integer 673 intw[18] = integer 674 675 //4 integers 676 FSetPos refNum,478 677 FBinRead/F=3/B=3 refNum, integer 678 intw[19] = integer 679 FBinRead/F=3/B=3 refNum, integer 680 intw[20] = integer 681 FBinRead/F=3/B=3 refNum, integer 682 intw[21] = integer 683 FBinRead/F=3/B=3 refNum, integer 684 intw[22] = integer 685 686 Close refNum 687 688 //now get all of the reals 689 // 690 //Do all the GBLoadWaves at the end 691 // 692 //FBinRead Cannot handle 32 bit VAX floating point 693 //GBLoadWave, however, can properly read it 694 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 695 String strToExecute 696 //append "/S=offset/U=numofreals" to control the read 697 // then append fname to give the full file path 698 // then execute 699 700 Variable a=0,b=0 701 702 SetDataFolder curPath 703 704 // 4 R*4 values 705 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 706 Execute strToExecute 707 Wave w=$"root:Packages:NIST:RealTime:tempGBWave0" 708 b=4 //num of reals read 709 realw[a,a+b1] = w[pa] 710 a+=b 711 712 // 4 R*4 values 713 SetDataFolder curPath 714 strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\"" 715 Execute strToExecute 716 b=4 717 realw[a,a+b1] = w[pa] 718 a+=b 719 720 /////////// 721 // 2 R*4 values 722 SetDataFolder curPath 723 strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 724 Execute strToExecute 725 b=2 726 realw[a,a+b1] = w[pa] 727 a+=b 728 729 // 6 R*4 values 730 SetDataFolder curPath 731 strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\"" 732 Execute strToExecute 733 b=6 734 realw[a,a+b1] = w[pa] 735 a+=b 736 737 // 13 R*4 values 738 SetDataFolder curPath 739 strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\"" 740 Execute strToExecute 741 b=13 742 realw[a,a+b1] = w[pa] 743 a+=b 744 745 // 3 R*4 values 746 SetDataFolder curPath 747 strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\"" 748 Execute strToExecute 749 b=3 750 realw[a,a+b1] = w[pa] 751 a+=b 752 753 // 7 R*4 values 754 SetDataFolder curPath 755 strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\"" 756 Execute strToExecute 757 b=7 758 realw[a,a+b1] = w[pa] 759 a+=b 760 761 // 4 R*4 values 762 SetDataFolder curPath 763 strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\"" 764 Execute strToExecute 765 b=4 766 realw[a,a+b1] = w[pa] 767 a+=b 768 769 // 2 R*4 values 770 SetDataFolder curPath 771 strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\"" 772 Execute strToExecute 773 b=2 774 realw[a,a+b1] = w[pa] 775 a+=b 776 777 // 2 R*4 values 778 SetDataFolder curPath 779 strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\"" 780 Execute strToExecute 781 b=2 782 realw[a,a+b1] = w[pa] 783 a+=b 784 785 // 5 R*4 values 786 SetDataFolder curPath 787 strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\"" 788 Execute strToExecute 789 b=5 790 realw[a,a+b1] = w[pa] 791 792 //if the binary VAX data ws transferred to a MAC, all is OK 793 //if the data was trasnferred to an Intel machine (IBM), all the real values must be 794 //divided by 4 to get the correct floating point values 795 // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly 796 // on an Intel machine. 797 //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read 798 //VAX reals correctly, and no checking is necessary 12 APR 99 799 //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 800 //do nothing 801 //else 802 //either Windows or Windows NT 803 //realw /= 4 804 //endif 805 806 SetDataFolder curPath 807 //read in the data 808 strToExecute = "GBLoadWave/O/N=tempGBwave/B/T={16,2}/S=514/Q" + "\"" + fname + "\"" 809 Execute strToExecute 810 811 SetDataFolder curPath //use the full path, so it will always work 812 813 Make/O/N=16384 $"root:Packages:NIST:RealTime:data" 814 WAVE data=$"root:Packages:NIST:RealTime:data" 815 SkipAndDecompressVAX(w,data) 816 Redimension/N=(128,128) data //NIST raw data is 128x128  do not generalize 817 818 Duplicate/O data,$"root:Packages:NIST:RealTime:linear_data" 819 WAVE lin_data=$"root:Packages:NIST:RealTime:linear_data" 820 if(isLogScale) 821 data=log(lin_data) 822 else 823 data=lin_data 824 Endif 825 826 //keep a string with the filename in the RAW folder 827 String/G root:Packages:NIST:RealTime:fileList = textw[0] 828 829 //set the globals to the detector dimensions (pixels) 830 Variable/G root:myGlobals:gNPixelsX=128 //default for Ordela data (also set in Initialize/NCNR_Utils.ipf) 831 Variable/G root:myGlobals:gNPixelsY=128 832 // if(cmpstr(textW[9],"ILL ")==0) //override if OLD Cerca data 833 // Variable/G root:myGlobals:gNPixelsX=64 834 // Variable/G root:myGlobals:gNPixelsY=64 835 // endif 836 837 //clean up  get rid of w = $"root:Packages:NIST:RAW:tempGBWave0" 838 // KillWaves/Z w 839 840 //return the data folder to root 841 SetDataFolder root: 842 843 Return 0 844 845 End
Note: See TracChangeset
for help on using the changeset viewer.