Ignore:
Timestamp:
Dec 10, 2012 4:22:20 PM (10 years ago)
Author:
srkline
Message:

Added the binning of QxQy? data to 1D as a menu option under SANSModels->2D utilities. Mostly as a consistency check for the 2D data.

Added a package loader for the Event Mode Processing to the NCNR package loader, so that it behaves like the real spaces modeling and the polarization.

Added routines that split large event files, and then allow the accumulation of the slices from each chunk as it is processed. Eliminates the need to add a large number of split files together during the reduction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf

    r882 r884  
    22#pragma IgorVersion=6.22 
    33 
    4 // vers 7.13d 
     4// vers 7.13e 
    55 
    66// TODO: 
     
    1414// -- examples? 
    1515// 
    16 // -- add the XOP to the distribution package 
     16// x- add the XOP to the distribution package 
    1717// 
    1818// -- Need to make sure that the rescaledTime and the differentiated time graphs are 
     
    9595Static Constant YBINS=128 
    9696// 
     97 
     98Menu "Macros" 
     99        "Split Large File",SplitBigFile() 
     100        "Accumulate First Slice",AccumulateSlices(0) 
     101        "Add Current Slice",AccumulateSlices(1) 
     102        "Display Accumulated Slices",AccumulateSlices(2)         
     103End 
    97104 
    98105 
     
    175182        Button button1,pos = {10,50}, size={150,20},title="Process Data",fSize=12 
    176183        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} 
    178185        SetVariable setvar1,value=root:Packages:NIST:gEvent_nslices 
    179186        SetVariable setvar2,pos={330,50},size={160,20},title="Max Time (s)",fSize=12 
     
    186193        CheckBox chkbox2,variable=root:Packages:NIST:gEvent_logint,proc=LogIntEvent_Proc 
    187194        SetVariable setvar0,pos={320,90},size={160,20},title="Display Time Slice",fSize=12 
    188         SetVariable setvar0,value= root:Packages:NIST:gEvent_tsdisp 
     195        SetVariable setvar0,limits={0,1000,1},value= root:Packages:NIST:gEvent_tsdisp 
    189196        SetVariable setvar0,proc=sliceSelectEvent_Proc 
    190197        Display/W=(20,180,480,640)/HOST=EventModePanel/N=Event_slicegraph 
     
    212219                case 2: // mouse up 
    213220                        // click code here 
    214                         Execute "EventCorrectionPanel()" 
     221                        Execute "ShowEventCorrectionPanel()" 
    215222                        // 
    216223                        break 
     
    237244        return 0 
    238245End 
    239 Show_CustomBinPanel() 
    240246 
    241247 
     
    19021908 
    19031909////////////// Post-processing of the event mode data 
     1910Proc ShowEventCorrectionPanel() 
     1911        DoWindow/F EventCorrectionPanel 
     1912        if(V_flag ==0) 
     1913                EventCorrectionPanel() 
     1914        EndIf 
     1915End 
    19041916 
    19051917Proc EventCorrectionPanel() 
     
    21072119                        endif 
    21082120                         
     2121                        // clear out the old sort index, if present, since new data is being loaded 
     2122                        KillWaves/Z OscSortIndex 
    21092123                        Wave timePt=timePt 
    21102124 
     
    24522466 
    24532467/////////////////// 
     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 
     2478Macro 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) 
     2485End 
     2486 
     2487Function 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 
     2575End 
     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// 
     2591Function 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) 
     2615end 
Note: See TracChangeset for help on using the changeset viewer.