Changeset 862 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- Aug 13, 2012 12:30:32 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/TISANE.ipf
r656 r862 346 346 SetDataFolder root: 347 347 End 348 349 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.