Changeset 871 for sans/Dev/trunk


Ignore:
Timestamp:
Oct 17, 2012 5:01:03 PM (10 years ago)
Author:
srkline
Message:

A number of changes to provide the first - alpha version of event mode processing. Works for oscillatory mode data, and a continuous stream. Short on documentation, needs lots of testing.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/InstalledVersion.txt

    r870 r871  
    1 PACKAGE_VERSION=7.12;SANS_RED_VERSION=5.20;SANS_ANA_VERSION=4.10;USANS_RED_VERSION=2.3; 
     1PACKAGE_VERSION=7.13;SANS_RED_VERSION=5.20;SANS_ANA_VERSION=4.10;USANS_RED_VERSION=2.3; 
    22 
    33Only the first line of the file is read in. 
     
    66 
    77These are the current versions as of: 
    8 09 OCT 2012 SRK 
     817 OCT 2012 SRK 
    99 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/CatVSTable.ipf

    r861 r871  
    309309//      Variable ,lambda,sdd,,refNum,trans,thick,xcenter,ycenter,numatten 
    310310//      Variable lastPoint, beamstop,dum 
    311         Variable lastPoint,ctime,detcnt,cntrate 
     311        Variable lastPoint,ctime,detcnt,cntrate,instrumentNum 
    312312 
    313313        Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" 
     
    445445// number of guides and sample position, only for NCNR 
    446446#if (exists("NCNR")==6) 
     447        instrumentNum = str2num(getAcctName(fname)[3])          // "[NGxSANSxx]" -- [3] should be then instrument number 
     448        Variable/G root:Packages:NIST:SAS:instrument = instrumentNum            //so that Ng can be correctly calculated 
     449         
    447450        InsertPoints lastPoint,1,GNumGuides 
    448451        GNumGuides[lastPoint]  = numGuides(getSourceToSampleDist(fname)) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Includes_v520.ipf

    r693 r871  
    8484#include "WriteModelData_v40" 
    8585 
     86// SRK OCT 2012 - processing of event mode data 
     87#include "EventModeProcessing" 
     88 
    8689 
    8790// a simple list of items to add to the Beta menu 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Initialize.ipf

    r801 r871  
    9292        NewDataFolder/O root:Packages:NIST:SUB 
    9393        NewDataFolder/O root:Packages:NIST:DRK 
    94          
     94 
     95        NewDataFolder/O root:Packages:NIST:SAS 
     96 
    9597 
    9698         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_DataReadWrite.ipf

    r811 r871  
    24482448// simulated VAX data file. 
    24492449// 
    2450 // NCNR-Specific 
     2450// NCNR-Specific. is hard wired to the SAS folder. If saving from any other folder, set all of the header 
     2451// information before saving, and pass a null string to this procedure to bypass it entirely 
    24512452// 
    24522453Function SimulationVAXHeader(folder) 
    24532454        String folder 
    24542455 
     2456        if(cmpstr(folder,"SAS")!=0)             //if not the SAS folder passed in, get out now, and return 1 
     2457                return(1) 
     2458        endif 
     2459         
    24552460        Wave rw=root:Packages:NIST:SAS:realsRead 
    24562461        Wave iw=root:Packages:NIST:SAS:integersRead 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProDiv.ipf

    r794 r871  
    543543                        Execute "CopyWorkContents(\"DIV\",\"DRK\")"             //then data in DRK is guaranteed linear 
    544544 
    545                         WAVE sub_d = root:Packages:NIST:SUB:data 
    546                         WAVE sto_d = root:Packages:NIST:STO:data 
    547                         WAVE drk_d = root:Packages:NIST:DRK:data 
     545                        WAVE sub_d = root:Packages:NIST:SUB:linear_data 
     546                        WAVE sto_d = root:Packages:NIST:STO:linear_data 
     547                        WAVE drk_d = root:Packages:NIST:DRK:linear_data 
    548548                         
    549549                        sub_d = sto_d/drk_d 
    550550 
    551551//                      WaveStats root:Packages:NIST:DIV:data 
    552 //                      Print "*"                        
     552//                      Print "*"        
     553                        WAVE sub_data = root:Packages:NIST:SUB:data 
     554                        sub_data = sub_d                //data = linear_data 
     555                                         
    553556                        Execute "ChangeDisplay(\"SUB\")"         
    554557                        break 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/TISANE.ipf

    r862 r871  
    4848        NewDataFolder/O/S root:Packages:NIST:TISANE 
    4949         
    50         Make/O/N=(XBINS,YBINS,nslices) slicedData 
     50        Make/D/O/N=(XBINS,YBINS,nslices) slicedData 
    5151        Duplicate/O slicedData logslicedData 
    5252        Duplicate/O slicedData dispsliceData 
     
    9898        ModifyGraph btLen=3 
    9999        ModifyGraph tlOffset=-2 
    100         SetAxis/A/R left 
     100        SetAxis/A left 
    101101        SetActiveSubwindow ## 
    102102EndMacro 
     
    348348 
    349349 
    350 ////////// SRK - junk I'm testing 
    351  
    352 // 
    353 Function PreLoadEvents() 
    354          
    355         NVAR time_msw = root:Packages:NIST:gTISANE_time_msw 
    356         NVAR time_lsw = root:Packages:NIST:gTISANE_time_lsw 
    357         NVAR t_longest = root:Packages:NIST:gTISANE_t_longest 
    358          
    359         SVAR filepathstr = root:Packages:NIST:gTISANE_logfile 
    360         SetDataFolder root:Packages:NIST:TISANE 
    361  
    362         Variable fileref 
    363         String buffer 
    364         Variable dataval,timeval,type,numLines,verbose 
    365         Variable xval,yval,rollBit,nRoll,roll_time 
    366         Variable Xmax, yMax 
    367         xMax = 127              // number the detector from 0->127  
    368         yMax = 127 
    369          
    370         verbose = 0 
    371         numLines = 0 
    372  
    373 // this gets me the number of lines. not terribly useful         
    374 //      Open/R fileref as filepathstr 
    375 //      do 
    376 //              numLines += 1 
    377 //              FReadLine fileref, buffer 
    378 //              if (strlen(buffer) == 0) 
    379 //                      numLines -= 1                   //last FReadLine wasn't really a line 
    380 //                      break 
    381 //              endif 
    382 //      while(1) 
    383 //      Close fileref 
    384          
    385         // what I really need is the number of XY events 
    386         Variable numXYevents,num1,num2,num3,num0 
    387         numXYevents = 0 
    388         num0 = 0 
    389         num1 = 0 
    390         num2 = 0 
    391         num3 = 0 
    392          
    393         Open/R fileref as filepathstr 
    394         do 
    395                 do 
    396                         FReadLine fileref, buffer                       //skip the "blank" lines that have one character 
    397                 while(strlen(buffer) == 1)               
    398  
    399                 if (strlen(buffer) == 0) 
    400                         break 
    401                 endif 
    402                  
    403                 sscanf buffer,"%x",dataval 
    404                  
    405                 // two most sig bits (31-30) 
    406                 type = (dataval & 0xC0000000)/1073741824                //right shift by 2^30 
    407                  
    408                 if(type == 0) 
    409                         num0 += 1 
    410                         numXYevents += 1 
    411                 endif 
    412                 if(type == 2) 
    413                         num2 += 1 
    414                         numXYevents += 1 
    415                 endif 
    416                 if(type == 1) 
    417                         num1 += 1 
    418                 endif 
    419                 if(type == 3) 
    420                         num3 += 1 
    421                 endif    
    422                  
    423         while(1) 
    424         Close fileref 
    425 //              done counting the number of XY events 
    426  
    427  
    428 //       
    429         Printf "numXYevents = %d\r",numXYevents 
    430         Printf "XY = num0 = %d\r",num0 
    431         Printf "XY time = num2 = %d\r",num2 
    432         Printf "time MSW = num1 = %d\r",num1 
    433         Printf "Rollover = num3 = %d\r",num3 
    434  
    435         Printf "num0 + num2 = %d\r",num0+num2 
    436          
    437         Make/O/U/N=(numXYevents) xLoc,yLoc 
    438         Make/O/D/N=(numXYevents) timePt 
    439         xLoc=0 
    440         yLoc=0 
    441         timePt=0 
    442  
    443          
    444         Variable ii=0 
    445         nRoll = 0               //number of rollover events 
    446         roll_time = 2^26                //units of 10-7 sec 
    447          
    448         time_msw=0 
    449          
    450         Open/R fileref as filepathstr 
    451         do 
    452                 do 
    453                         FReadLine fileref, buffer                       //skip the "blank" lines that have one character 
    454                 while(strlen(buffer) == 1)               
    455  
    456                 if (strlen(buffer) == 0) 
    457                         break 
    458                 endif 
    459                  
    460                 sscanf buffer,"%x",dataval 
    461                  
    462                 //This is hideous, but that is what you get for IGOR not doing structs like C 
    463                 // 
    464                 //Constant ATXY = 0 
    465                 //Constant ATXYM = 2 
    466                 //Constant ATMIR = 1 
    467                 //Constant ATMAR = 3 
    468                 // 
    469 //              type = (dataval & ~(2^32 - 2^30 -1))/2^30 
    470  
    471                 // two most sig bits (31-30) 
    472                 type = (dataval & 0xC0000000)/1073741824                //right shift by 2^30 
    473                  
    474 //              if(ii<10) 
    475 //                      Print "buffer=", buffer//, type 
    476 //                      Print "strlen(buffer) =",strlen(buffer) 
    477 //                      printf "%b      %u\r",dataval,type 
    478 //              endif 
    479                  
    480                  
    481 // just to print out some of the diagnostic information  
    482 //              if(ii < 7) 
    483 //                      verbose = 1 
    484 //              else 
    485 //                      verbose = 0 
    486 //              endif 
    487                  
    488 //       
    489 // not sure that the XY positions are correctly interpreted              
    490 // X seems OK, but Y doesn't match teabag output (it does if the (yMax - ) is dropped, and just the 8 bits are used) 
    491 //               
    492                 switch(type) 
    493                         case ATXY: 
    494                                 if(verbose)              
    495                                         printf "XY : "           
    496                                 endif 
    497 //                              xval = ~(dataval & ~(2^32 - 2^8)) & 127 
    498 //                              yval = ((dataval & ~(2^32 - 2^16 ))/2^8) & 127 
    499 //                              time_lsw = (dataval & ~(2^32 - 2^29))/2^16 
    500  
    501                                 xval = xMax - (dataval & 255)                                           //last 8 bits (7-0) 
    502                                 yval = (dataval & 65280)/256                                            //bits 15-8, right shift by 2^8 
    503                                 time_lsw = (dataval & 536805376)/65536                  //13 bits, 28-16, right shift by 2^16 
    504  
    505                                 timeval = trunc( nRoll*roll_time + (time_msw * (8192)) + time_lsw )             //left shift msw by 2^13, then add in lsw, as an integer 
    506                                 if (timeval > t_longest)  
    507                                         t_longest = timeval 
    508                                 endif 
    509                                 xLoc[ii] = xval 
    510                                 yLoc[ii] = yval 
    511                                 timePt[ii] = timeval 
    512  
    513                                 if(verbose)              
    514 //                                      printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 
    515                                         printf "%u : %u : %u : %u\r",dataval,timeval,xval,yval 
    516                                 endif                            
    517  
    518 //                              b = FindBin(timeval,nslices) 
    519 //                              slicedData[xval][yval][b] += 1 
    520  
    521                                 ii+=1 
    522                                  
    523                                 break 
    524                         case ATXYM: 
    525                                 if(verbose) 
    526                                         printf "XYM : " 
    527                                 endif 
    528 //                              xval = ~(dataval & ~(2^32 - 2^8)) & 127 
    529 //                              yval = ((dataval & ~(2^32 - 2^16 ))/2^8) & 127 
    530 //                              time_lsw =  (dataval & ~(2^32 - 2^29 ))/2^16 
    531  
    532                                 xval = xMax - (dataval & 255)                                           //last 8 bits (7-0) 
    533                                 yval = (dataval & 65280)/256                                            //bits 15-8, right shift by 2^8 
    534  
    535                                 time_lsw = (dataval & 536805376)/65536                  //13 bits, 28-16, right shift by 2^16 
    536  
    537                                 if(verbose) 
    538 //                                      printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 
    539                                         printf "%u : %u : %u : %u\r",dataval,timeval,xval,yval 
    540                                 endif 
    541                                  
    542                                 xLoc[ii] = xval 
    543                                 yLoc[ii] = yval 
    544                                  
    545                                 // don't fill in the time yet, or increment the index ii 
    546                                 // the next event MUST be ATMIR with the MSW time bits 
    547                                 // 
    548                                 break 
    549                         case ATMIR: 
    550                                 if(verbose) 
    551                                         printf "MIR : " 
    552                                 endif 
    553 //                              time_msw =  (dataval & ~(2^32 - 2^29 ))/2^16 
    554                                 time_msw =  (dataval & 536805376)/65536                 //13 bits, 28-16, right shift by 2^16 
    555                                 timeval = trunc( nRoll*roll_time + (time_msw * (8192)) + time_lsw ) 
    556                                 if (timeval > t_longest)  
    557                                         t_longest = timeval 
    558                                 endif 
    559                                 if(verbose) 
    560 //                                      printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 
    561                                         printf "%u : %u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval,t_longest 
    562                                 endif 
    563                                  
    564                                 // the XY position was in the previous event ATXYM 
    565                                 timePt[ii] = timeval 
    566                                  
    567                                 ii+=1 
    568                                  
    569 //                              b = FindBin(timeval,nslices) 
    570 //                              slicedData[xval][yval][b] += 1 
    571  
    572                                 break 
    573                         case ATMAR: 
    574                                 if(verbose) 
    575                                         printf "MAR : " 
    576                                 endif 
    577                                  
    578                                 // do something with the rollover event? 
    579                                  
    580                                 // check bit 29 
    581                                 rollBit = (dataval & 0x20000000)/536870912              //bit 29 only , shift by 2^29 
    582                                 nRoll += 1 
    583                                  
    584                                 if(verbose) 
    585                                         printf "%u : %u \r",rollBit,nRoll 
    586                                 endif 
    587                                  
    588                                 break 
    589                 endswitch 
    590                                  
    591         while(1) 
    592          
    593          
    594         Close fileref 
    595          
    596         SetDataFolder root: 
    597 End  
    598  
    599 /// 
Note: See TracChangeset for help on using the changeset viewer.