Changeset 370 for sans/Dev


Ignore:
Timestamp:
May 28, 2008 1:18:14 PM (15 years ago)
Author:
srkline
Message:

changes to ILL- files to properly read in DIV data, and XY box.

Some minor changes to NCNR-files for consistency of reading the XY box.

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  
    109109        textw[0]= v0 
    110110         
    111         print "function read raw used" 
     111//      print "function read raw used" 
    112112         
    113113        // date and time of collection 
     
    257257// 
    258258// type is "DIV" on input 
    259 Function ReadHeaderAndWork(type,fname) 
     259Function ReadHeaderAndWork1(type,fname) 
    260260        String type,fname 
    261261         
     
    291291         
    292292         
    293         print "function used" 
     293//      print "function used" 
    294294         
    295295 
     
    318318        Return(0) 
    319319End 
     320 
     321 
     322/////////DIV file created with NIST reduction so has the VAX format.... painful 
     323 
     324Function 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) 
     669End 
     670 
     671 
    320672 
    321673 
     
    499851        // your writer here 
    500852         
    501         WriteReal(fname,trans,6644) 
     853        WriteReal(fname,trans,5589)     //I will define at position 10 lines   by myself 
    502854         
    503855        return(0) 
     
    511863         
    512864        // do nothing for now 
     865        WriteReal(fname,trans,6885) 
    513866         
    514867        return(0) 
     
    523876        // do nothing if not using NCNR Transmission module 
    524877         
    525         WriteReal(fname,counts,6660) 
     878        WriteReal(fname,counts,6868) 
    526879         
    527880        return(0) 
     
    548901        // your code here 
    549902         
    550         WriteReal(fname,num,6677)  
     903        WriteReal(fname,num,5508)  //define at 9 lines  just above transmission 
    551904         
    552905        return(0) 
     
    573926        // your code here 
    574927         
    575         WriteReal(fname,num,5689) 
     928        WriteReal(fname,num,5686) 
    576929         
    577930        return(0) 
     
    633986         
    634987        // your code here 
    635         WriteReal(fname,num,7504) 
     988        WriteReal(fname,num,5702) 
    636989         
    637990        return(0) 
     
    645998        // your code here 
    646999         
    647         WriteReal(fname,num,7520) 
     1000        WriteReal(fname,num,5718) 
    6481001         
    6491002        return(0) 
     
    7711124End 
    7721125 
    773 // total counting time (seconds) 
     1126// total counting time (stored here as seconds/10??) 
    7741127Function WriteCountTimeToHeader(fname,num) 
    7751128        String fname 
     
    7771130         
    7781131        // your code here 
    779         WriteReal(fname,num,4894) 
     1132//      WriteReal(fname,num,4894) 
     1133        WriteReal(fname,num,4892) 
    7801134         
    7811135         
     
    8391193         
    8401194        // your code, returning str 
    841         str = (getStringFromHeader(fname,2025,30))  /// 25*81 
     1195        str = (getStringFromHeader(fname,2075,30))  /// 25*81  +  50////+51 30 lines before the end 
    8421196         
    8431197         
     
    9431297        // your code returning value 
    9441298         
    945         value = 1 
     1299        value = getRealValueFromHeader(fname,45) 
    9461300         
    9471301        return(value) 
     
    9561310         
    9571311        // your code returning value 
    958         value = getRealValueFromHeader(fname,114) 
     1312        value = getRealValueFromHeader(fname,124) 
    9591313         
    9601314        return(value) 
     
    9801334         
    9811335        // your code returning value 
    982         value = 1  //mm 
     1336        value = getRealValueFromHeader(fname,40)  //mm 
    9831337         
    9841338        return(value) 
     
    11101464        value = getRealValueFromHeader(fname,72) 
    11111465         
     1466        value = 5 
     1467         
    11121468        return(value) 
    11131469end 
     
    11941550 
    11951551//total count time (seconds) 
     1552// stored here as (s/10), so multiply by 10 ? 
    11961553Function getCountTime(fname) 
    11971554        String fname 
     
    12031560//      value = getRealValueFromHeader_2(fname,60,28,5,1,3)  ///  line 1 col 3 
    12041561         
    1205         value = getRealValueFromHeader(fname,2) 
     1562        value = getRealValueFromHeader(fname,2)/10 
    12061563         
    12071564        return(value) 
     
    12441601// if not using the NCNR Transmission module, this function default to  
    12451602// returning 0000, and no changes needed 
     1603// 
     1604// filename is the full path:name to the file 
    12461605Function getXYBoxFromFile(filename,x1,x2,y1,y2) 
    12471606        String filename 
    12481607        Variable &x1,&x2,&y1,&y2 
    1249          
    1250         Variable refnum 
    1251         String tmpFile = FindValidFilename(filename) 
    1252         // tmpFile is only a parital path 
    12531608 
    12541609        // 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 
    12591616         
    12601617        return(0) 
     
    12661623// 
    12671624// if not using the NCNR Transmission module, this function is null 
     1625// 
     1626// filename as passed in is a full path:filename 
     1627// 
    12681628Function WriteXYBoxToHeader(filename,x1,x2,y1,y2) 
    12691629        String filename 
     
    12711631         
    12721632        // 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 
    12731644         
    12741645        return(0) 
     
    15281899                valuesRead = V_flag 
    15291900//              print valuesRead                 
    1530 //              print buffer             
     1901//              buffer          
    15311902                //valuesRead = V_flag 
    15321903//              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  
    2929        Variable/G root:myGlobals:DeadtimeDefault = 0.9e-6              //deadtime in seconds 
    3030         
    31         Variable/G root:myGlobals:BeamstopYTol = 150     
     31        Variable/G root:myGlobals:BeamstopYTol = 100     
    3232 
    3333        Variable/G root:myGlobals:apOff = 5.0           // (cm) distance from sample aperture to sample position 
     
    367367//      print ypos 
    368368 
    369 //print ytol 
     369//  print ytol 
    370370         
    371371        if(abs(ypos)>=ytol) 
     
    831831         
    832832        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 
    835838         
    836839        // your code here 
    837840 
    838         return(attenFactor) 
     841        return(1/attenFactor) 
    839842End 
    840843 
  • sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/Marquee.ipf

    r328 r370  
    7575        Endif 
    7676        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" 
    7979                return(1) 
    8080        endif 
  • sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/NCNR_DataReadWrite.ipf

    r328 r370  
    15801580/////   TRANSMISSION RELATED FUNCTIONS    //////// 
    15811581//box coordinate are returned by reference 
     1582// filename is the full path:name  
    15821583Function getXYBoxFromFile(filename,x1,x2,y1,y2) 
    15831584        String filename 
     
    15851586         
    15861587        Variable refnum 
    1587         String tmpFile = FindValidFilename(filename) 
     1588//      String tmpFile = FindValidFilename(filename) 
    15881589                 
    1589         Open/R/P=catPathName refnum as tmpFile 
     1590//      Open/R/P=catPathName refnum as tmpFile 
     1591        Open/R refnum as filename 
    15901592        FSetPos refnum,478 
    15911593        FBinRead/F=3/B=3 refnum, x1 
  • sans/Dev/trunk/NCNR_User_Procedures/SANS/Reduction/ProtocolAsPanel.ipf

    r328 r370  
    20072007                pixel = rw[10]/10                       // header value (X) is in mm, want cm here 
    20082008         
    2009                 countTime = iw[1] 
     2009                countTime = iw[2] 
    20102010                //detCnt = rw[2]                //080802 -use sum of data, not scaler from header 
    20112011                monCnt = rw[0] 
     
    20232023                Variable x1,x2,y1,y2 
    20242024                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 
    20262028                Print x1,x2,y1,y2 
    20272029 
     
    20322034                        Endif 
    20332035                        //box is OK, write box values to file 
    2034                         PathInfo/S catPathName 
    2035                         String tempName = S_Path + FindValidFilename(filename) 
    20362036                        WriteXYBoxToHeader(tempName,x1,x2,y1,y2) 
    20372037                else 
Note: See TracChangeset for help on using the changeset viewer.