Changeset 884 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- Dec 10, 2012 4:22:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf
r882 r884 2 2 #pragma IgorVersion=6.22 3 3 4 // vers 7.13 d4 // vers 7.13e 5 5 6 6 // TODO: … … 14 14 // -- examples? 15 15 // 16 // -- add the XOP to the distribution package16 // x- add the XOP to the distribution package 17 17 // 18 18 // -- Need to make sure that the rescaledTime and the differentiated time graphs are … … 95 95 Static Constant YBINS=128 96 96 // 97 98 Menu "Macros" 99 "Split Large File",SplitBigFile() 100 "Accumulate First Slice",AccumulateSlices(0) 101 "Add Current Slice",AccumulateSlices(1) 102 "Display Accumulated Slices",AccumulateSlices(2) 103 End 97 104 98 105 … … 175 182 Button button1,pos = {10,50}, size={150,20},title="Process Data",fSize=12 176 183 Button button1,proc=ProcessEventLog_Button 177 SetVariable setvar1,pos={170,50},size={160,20},title="Number of slices",fSize=12 184 SetVariable setvar1,pos={170,50},size={160,20},title="Number of slices",fSize=12,limits={1,1000,1} 178 185 SetVariable setvar1,value=root:Packages:NIST:gEvent_nslices 179 186 SetVariable setvar2,pos={330,50},size={160,20},title="Max Time (s)",fSize=12 … … 186 193 CheckBox chkbox2,variable=root:Packages:NIST:gEvent_logint,proc=LogIntEvent_Proc 187 194 SetVariable setvar0,pos={320,90},size={160,20},title="Display Time Slice",fSize=12 188 SetVariable setvar0, value= root:Packages:NIST:gEvent_tsdisp195 SetVariable setvar0,limits={0,1000,1},value= root:Packages:NIST:gEvent_tsdisp 189 196 SetVariable setvar0,proc=sliceSelectEvent_Proc 190 197 Display/W=(20,180,480,640)/HOST=EventModePanel/N=Event_slicegraph … … 212 219 case 2: // mouse up 213 220 // click code here 214 Execute " EventCorrectionPanel()"221 Execute "ShowEventCorrectionPanel()" 215 222 // 216 223 break … … 237 244 return 0 238 245 End 239 Show_CustomBinPanel()240 246 241 247 … … 1902 1908 1903 1909 ////////////// Post-processing of the event mode data 1910 Proc ShowEventCorrectionPanel() 1911 DoWindow/F EventCorrectionPanel 1912 if(V_flag ==0) 1913 EventCorrectionPanel() 1914 EndIf 1915 End 1904 1916 1905 1917 Proc EventCorrectionPanel() … … 2107 2119 endif 2108 2120 2121 // clear out the old sort index, if present, since new data is being loaded 2122 KillWaves/Z OscSortIndex 2109 2123 Wave timePt=timePt 2110 2124 … … 2452 2466 2453 2467 /////////////////// 2468 // 2469 // utility to split a large file 2470 // 100 MB is the recommended size 2471 // events can be clipped here, so be sure to trim the ends of the 2472 // resulting files as needed. 2473 // 2474 // - works like the unix 'split' command 2475 // 2476 // 2477 2478 Macro SplitBigFile(splitSize, baseStr) 2479 Variable splitSize = 100 2480 String baseStr="split" 2481 Prompt splitSize,"Target file size, in MB" 2482 Prompt baseStr,"File prefix, number will be appended" 2483 2484 fSplitBigFile(splitSize, baseStr) 2485 End 2486 2487 Function fSplitBigFile(splitSize, baseStr) 2488 Variable splitSize 2489 String baseStr 2490 2491 2492 String fileName="" // File name, partial path, full path or "" for dialog. 2493 String pathName="" 2494 Variable refNum 2495 String str 2496 2497 Variable readSize=1e6 //1 MB 2498 Make/O/B/U/N=(readSize) aBlob //1MB worth 2499 Variable numSplit 2500 Variable num,ii,jj,outRef,frac 2501 String thePath 2502 2503 Printf "SplitSize = %u MB\r",splitSize 2504 splitSize = trunc(splitSize) * 1e6 // now in bytes 2505 2506 2507 // Open file for read. 2508 Open/R/Z=2/F="????"/P=$pathName refNum as fileName 2509 thePath = ParseFilePath(1, fileName, ":", 1, 0) 2510 2511 // Store results from Open in a safe place. 2512 Variable err = V_flag 2513 String fullPath = S_fileName 2514 2515 if (err == -1) 2516 Print "cancelled by user." 2517 return -1 2518 endif 2519 2520 FStatus refNum 2521 2522 Printf "total # bytes = %u\r",V_logEOF 2523 2524 numSplit=0 2525 if(V_logEOF > splitSize) 2526 numSplit = trunc(V_logEOF/splitSize) 2527 endif 2528 2529 frac = V_logEOF - numSplit*splitSize 2530 Print "numSplit = ",numSplit 2531 Printf "frac = %u\r",frac 2532 2533 num=0 2534 if(frac > readSize) 2535 num = trunc(frac/readSize) 2536 endif 2537 2538 2539 frac = frac - num*readSize 2540 2541 Print "num = ",num 2542 Printf "frac = %u\r",frac 2543 2544 baseStr = "split" 2545 2546 for(ii=0;ii<numSplit;ii+=1) 2547 Open outRef as (thePath+baseStr+num2str(ii)) 2548 2549 for(jj=0;jj<(splitSize/readSize);jj+=1) 2550 FBinRead refNum,aBlob 2551 FBinWrite outRef,aBlob 2552 endfor 2553 2554 Close outRef 2555 endfor 2556 2557 Make/O/B/U/N=(frac) leftover 2558 // ii was already incremented past the loop 2559 Open outRef as (thePath+baseStr+num2str(ii)) 2560 for(jj=0;jj<num;jj+=1) 2561 FBinRead refNum,aBlob 2562 FBinWrite outRef,aBlob 2563 endfor 2564 FBinRead refNum,leftover 2565 FBinWrite outRef,leftover 2566 2567 Close outRef 2568 2569 2570 FSetPos refNum,V_logEOF 2571 Close refNum 2572 2573 2574 return 0 2575 End 2576 2577 2578 2579 //// save the sliced data, and accumulate slices 2580 // 2581 // need some way of ensuring that the slices match up since I' blindly adding them together. 2582 // 2583 // 2584 // 2585 // 2586 // mode = 0 wipe out the old accumulated, copy slicedData to accumulatedData 2587 // mode = 1 add current slicedData to accumulatedData 2588 // mode = 2 copy accumulatedData to slicedData in preparation of export or display 2589 // mode = 3 sing a song 2590 // 2591 Function AccumulateSlices(mode) 2592 Variable mode 2593 2594 SetDataFolder root:Packages:NIST:Event: 2595 2596 switch(mode) 2597 case 0: 2598 KillWaves/Z accumulatedData 2599 Duplicate/O slicedData accumulatedData 2600 break 2601 case 1: 2602 Wave acc=accumulatedData 2603 Wave cur=slicedData 2604 acc += cur 2605 break 2606 case 2: 2607 Duplicate/O accumulatedData slicedData 2608 break 2609 default: 2610 2611 endswitch 2612 2613 SetDataFolder root: 2614 return(0) 2615 end
Note: See TracChangeset
for help on using the changeset viewer.