Changeset 1100 for sans/Dev


Ignore:
Timestamp:
May 18, 2018 10:32:22 AM (5 years ago)
Author:
srkline
Message:

Significant restructuring of V_ExecuteProtocol to make the logic of the flow more tractable and adaptable in the future.

Added major change to VSANS event mode reduction panel to allow F and M binned events to be saved to a copy of the correspondng data file. A new data reduction panel for multiple slice reduction is now presented for Event data. This allows reduction of a single slice (all 8 F,M panels, back ignored), or all of the slices.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf

    r1099 r1100  
    361361                                dQv = -$w3[0] 
    362362 
    363 //TODO: be sure that this works correctly and can be included in either 
     363//DONE: this works correctly and can be included in either 
    364364// a VSANS reduction experiment, or a standalone analysis package 
    365365// -- since this is a Proc, not a function, #conditional compile does not work, 
    366366// but, since it's a Proc, it is not compiled, so missing functions aren't flagged as a compile error 
    367                                 if (exists("NCNR_VSANS")==6)                    //defined in the main  VSANS #includes file. 
    368                                         DoAlert 0,"**Treating data as VSANS data**" 
     367//                              if (exists("NCNR_VSANS")==6)                    //defined in the main  VSANS #includes file. 
     368//                                      DoAlert 0,"**Treating data as VSANS data**" 
    369369                                        Duplicate/O $w3,$(baseStr+"_dQv")                       //save a copy for VSANS 
    370370                                        $(baseStr+"_dQv") = -$(baseStr+"_dQv") 
    371                                         V_USANS_CalcWeights(baseStr,dQv) 
    372                                 else 
    373                                         DoAlert 0,"Treating data as USANS (normal slit-smeared data)" 
    374371                                        USANS_CalcWeights(baseStr,dQv) 
    375                                 endif                            
     372//                              else 
     373//                                      DoAlert 0,"Treating data as USANS (normal slit-smeared data)" 
     374//                                      USANS_CalcWeights(baseStr,dQv) 
     375//                              endif                            
    376376 
    377377                                 
  • sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/USANS_SlitSmearing_v40.ipf

    r616 r1100  
    22#pragma version=3.00 
    33#pragma IgorVersion=6.1 
     4 
     5/////// 
     6// JAN-MAY 2018 
     7// 
     8// 
     9// This is a first approximation to model slit smeared VSANS data 
     10// - the dQv value is now a "per-Q" quantity, rather than a single global value 
     11// - the wavelength smearing must be accounted for by a separate numerical integral 
     12//   BEFORE this step is applied. 
     13//  -- this is significant issue for White Beam conditions 
     14// 
     15 
     16 
     17 
     18 
    419 
    520//Functions for doing USANS Slit smearing by method of weight matrix 
     
    360375End 
    361376 
     377// MAY 2018 
     378// updated to use dQv as a per-q wave, not a single global value 
    362379Function CalcW1(i,j) 
    363380        Variable i,j 
     
    368385 
    369386         
    370          
    371         NVAR dQv = USANS_dQv 
     387// replaced with a wave  
     388//      NVAR dQv = USANS_dQv 
    372389         
    373390        Variable UU,UL,dqj,rU,rL,wU,wL,dqw 
    374391        Wave Qval = $(USANS_basestr+"_q"+trimStr) 
     392        Wave dQv = $(USANS_basestr+"_dQv"+trimStr) 
    375393         
    376394        UU =sqrt(Qval[j+1]^2-Qval[i]^2) 
     
    380398        rL = sqrt(UL^2+Qval[i]^2) 
    381399         
    382         wU = (1.0/dQv)*(Qval[j+1]*UU/dqw - 0.5*UU*rU/dqw - 0.5*Qval[i]^2*ln(UU+rU)/dqw ) 
    383         wL = (1.0/dQv)*(Qval[j+1]*UL/dqw - 0.5*UL*rL/dqw - 0.5*Qval[i]^2*ln(UL+rL)/dqw ) 
     400        wU = (1.0/dQv[i])*(Qval[j+1]*UU/dqw - 0.5*UU*rU/dqw - 0.5*Qval[i]^2*ln(UU+rU)/dqw ) 
     401        wL = (1.0/dQv[i])*(Qval[j+1]*UL/dqw - 0.5*UL*rL/dqw - 0.5*Qval[i]^2*ln(UL+rL)/dqw ) 
    384402         
    385403        Return wU-wL 
     
    387405End 
    388406 
     407// MAY 2018 
     408// updated to use dQv as a per-q wave, not a single global value 
    389409Function CalcW2(i,j) 
    390410        Variable i,j 
     
    395415 
    396416 
    397  
    398         NVAR dQv = USANS_dQv 
     417// replaced with a wave  
     418//      NVAR dQv = USANS_dQv 
    399419         
    400420        variable UU,UL,dqw,rU,rL,wU,wL 
    401421         
    402422        Wave Qval = $(USANS_basestr+"_q"+trimStr) 
     423        Wave dQv = $(USANS_basestr+"_dQv"+trimStr) 
    403424 
    404425        UU = sqrt(Qval[j]^2-Qval[i]^2)                   
     
    407428        rU = sqrt(UU^2+Qval[i]^2) 
    408429        rL = sqrt(UL^2+Qval[i]^2) 
    409         wU = (1.0/dQv)*( -Qval[j-1]*UU/dqw + 0.5*UU*rU/dqw + 0.5*Qval[i]^2*ln(UU+rU)/dqw ) 
    410         wL = (1.0/dQv)*( -Qval[j-1]*UL/dqw + 0.5*UL*rL/dqw + 0.5*Qval[i]^2*ln(UL+rL)/dqw ) 
     430        wU = (1.0/dQv[i])*( -Qval[j-1]*UU/dqw + 0.5*UU*rU/dqw + 0.5*Qval[i]^2*ln(UU+rU)/dqw ) 
     431        wL = (1.0/dQv[i])*( -Qval[j-1]*UL/dqw + 0.5*UL*rL/dqw + 0.5*Qval[i]^2*ln(UL+rL)/dqw ) 
    411432 
    412433        Return wU-wL 
     
    414435End 
    415436 
     437// MAY 2018 
     438// updated to use dQv as a per-q wave, not a single global value 
    416439Function CalcR(i) 
    417440        Variable i 
     
    424447        NVAR m = USANS_m 
    425448        NVAR N = USANS_N 
    426         NVAR dQv = USANS_dQv 
     449// replaced with a wave  
     450//      NVAR dQv = USANS_dQv 
    427451         
    428452        Variable retval 
     
    430454        Wave Ival = $(USANS_basestr+"_i"+trimStr) 
    431455        Variable/G USANS_intQpt = Qval[i] 
     456        Wave dQv = $(USANS_basestr+"_dQv"+trimStr) 
     457 
    432458         
    433459        Variable lower = sqrt(qval[N-1]^2-qval[i]^2) 
    434         Variable upper = dQv 
     460        Variable upper 
     461        upper = dQv[i] 
    435462 
    436463        if (i == N) 
     
    440467        retval = Integrate1D(Remainder,lower,upper) 
    441468         
    442         retval *= 1/dQv 
     469        retval *= 1/dQv[i] 
    443470         
    444471        Return retval 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf

    r1099 r1100  
    2020// 
    2121// TODO -- be sure that the absolute scaling of this is correct. Right now, something is off. 
    22 //  -- so write up the documentaiton for this operation, and try to find the error in the process... 
     22//  -- so write up the documentation for this operation, and try to find the error in the process... 
    2323// 
    2424// 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r1099 r1100  
    6161                        break 
    6262                case "Big Sphere": 
    63                         tmpInten = VC_SphereForm(1,900,1e-6,0.01,qTot[p][q])     
     63                        tmpInten = VC_SphereForm(1,2000,1e-6,0.01,qTot[p][q])    
    6464                        break 
    6565                case "Debye": 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r1097 r1100  
    815815 
    816816// pixel beam center - HDF style 
    817         Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 340           // == x beam center, in pixels 
    818         Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 828           // == y beam center, in pixels 
     817        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 340.1 // == x beam center, in pixels 
     818        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 828.1         // == y beam center, in pixels 
    819819 
    820820 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r1099 r1100  
    113113// for loading of slit-smeared VSANS data 
    114114// and generating the smearing matrix 
    115 #include "V_USANS_SlitSmearing_v40" 
     115// as of MAY 2018, this has been merged with USANS_SlitSmearing_v40.ipf 
     116//#include "V_USANS_SlitSmearing_v40" 
    116117 
    117118// for smearing of White beam data 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_BeamCenter.ipf

    r1094 r1100  
    907907        return 
    908908End 
     909 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_EventModeProcessing.ipf

    r1091 r1100  
    22#pragma IgorVersion=6.22 
    33 
     4 
     5 
    46// 
    57// Event mode prcessing for VSANS 
     
    79// First pass, getting the basics to work 
    810// 
    9 // -- need TOF processing for wavelength calibration 
    10 //  -- document this so it can be done quickly and easily. 
     11// x- need TOF processing for wavelength calibration 
     12//  x- document this so it can be done quickly and easily. 
    1113// 
    1214 
     
    5052 
    5153//   
    52 // x- these dimensions are hard-wired (OK for now, will need to be additional definitions for Back detector) 
     54// x- these dimensions are hard-wired 
    5355// 
    5456// XBINS is for an individual panel 
     
    98100        String/G root:Packages:NIST:VSANS:Event:gVsansStr="" 
    99101        Variable/G root:Packages:NIST:VSANS:Event:gRevision = 0 
    100         Variable/G root:Packages:NIST:VSANS:Event:gOffset=0             // = 22 bytes if no disabled tubes 
     102        Variable/G root:Packages:NIST:VSANS:Event:gOffset=0             // = 25 bytes if no disabled tubes 
    101103        Variable/G root:Packages:NIST:VSANS:Event:gTime1=0 
    102104        Variable/G root:Packages:NIST:VSANS:Event:gTime2=0 
     
    117119        Variable/G root:Packages:NIST:VSANS:Event:gEvent_logint = 1 
    118120 
    119         Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 3                               // ==0 for "stream", ==1 for Oscillatory 
     121        Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 0                               // ==0 for "stream", ==1 for Oscillatory 
    120122        Variable/G root:Packages:NIST:VSANS:Event:gRemoveBadEvents = 1          // ==1 to remove "bad" events, ==0 to read "as-is" 
    121123        Variable/G root:Packages:NIST:VSANS:Event:gSortStreamEvents = 0         // ==1 to sort the event stream, a last resort for a stream of data 
     
    131133 
    132134 
    133 // for decimation (not used for VSANS - may be added back in the future 
     135// for decimation (not used for VSANS - may be added back in the future) 
    134136        Variable/G root:Packages:NIST:VSANS:Event:gEventFileTooLarge = 1500             // 1500 MB considered too large 
    135137        Variable/G root:Packages:NIST:VSANS:Event:gDecimation = 100 
     
    157159        ModifyPanel fixedSize=1,noEdit =1 
    158160 
    159         SetDrawLayer UserBack 
    160         DrawText 479,345,"Stream Data" 
    161         DrawLine 563,338,775,338 
    162         DrawText 479,419,"Oscillatory or Stream Data" 
    163         DrawLine 647,411,775,411 
     161//      SetDrawLayer UserBack 
     162//      DrawText 479,345,"Stream Data" 
     163//      DrawLine 563,338,775,338 
     164//      DrawText 479,419,"Oscillatory or Stream Data" 
     165//      DrawLine 647,411,775,411 
    164166 
    165167//      ShowTools/A 
    166         Button button0,pos={14,87},size={150,20},proc=V_LoadEventLog_Button,title="Load Event Log File" 
     168        Button button0,pos={14,70},size={150,20},proc=V_LoadEventLog_Button,title="Load Event Log File" 
    167169        Button button0,fSize=12 
     170        Button button23,pos={14,100},size={150,20},proc=V_LoadEventLog_Button,title="Load From RAW" 
     171        Button button23,fSize=12 
    168172        TitleBox tb1,pos={475,500},size={266,86},fSize=10 
    169173        TitleBox tb1,variable= root:Packages:NIST:VSANS:Event:gEventDisplayString 
     
    171175        CheckBox chkbox2,pos={376,151},size={81,15},proc=V_LogIntEvent_Proc,title="Log Intensity" 
    172176        CheckBox chkbox2,fSize=10,variable= root:Packages:NIST:VSANS:Event:gEvent_logint 
    173         CheckBox chkbox3,pos={14,125},size={119,15},title="Remove Bad Events?",fSize=10 
     177        CheckBox chkbox3,pos={14,150},size={119,15},title="Remove Bad Events?",fSize=10 
    174178        CheckBox chkbox3,variable= root:Packages:NIST:VSANS:Event:gRemoveBadEvents 
    175179         
    176180        Button doneButton,pos={738,36},size={50,20},proc=V_EventDone_Proc,title="Done" 
    177181        Button doneButton,fSize=12 
    178         Button button2,pos={486,200},size={140,20},proc=V_ShowEventDataButtonProc,title="Show Event Data" 
    179         Button button3,pos={486,228},size={140,20},proc=V_ShowBinDetailsButtonProc,title="Show Bin Details" 
    180         Button button5,pos={633,228},size={140,20},proc=V_ExportSlicesButtonProc,title="Export Slices as VAX",disable=2 
    181182        Button button6,pos={748,9},size={40,20},proc=V_EventModeHelpButtonProc,title="?" 
    182                  
     183 
     184//      Button button5,pos={633,228},size={140,20},proc=V_ExportSlicesButtonProc,title="Export Slices as VAX",disable=2 
     185 
     186        Button button8,pos={570,35},size={120,20},proc=V_CustomBinButtonProc,title="Custom Bins" 
     187        Button button2,pos={570,65},size={140,20},proc=V_ShowEventDataButtonProc,title="Show Event Data" 
     188        Button button3,pos={570,95},size={140,20},proc=V_ShowBinDetailsButtonProc,title="Show Bin Details" 
     189 
     190                         
    183191        Button button7,pos={211,33},size={120,20},proc=V_AdjustEventDataButtonProc,title="Adjust Events" 
    184         Button button8,pos={653,201},size={120,20},proc=V_CustomBinButtonProc,title="Custom Bins" 
    185192        Button button4,pos={211,63},size={120,20},proc=V_UndoTimeSortButtonProc,title="Undo Time Sort" 
    186193        Button button18,pos={211,90},size={120,20},proc=V_EC_ImportWavesButtonProc,title="Import Edited" 
     
    200207 
    201208// NEW FOR VSANS 
    202         Button button21,pos={580,70},size={120,20},proc=V_SplitToPanels_Button,title="Split to Panels" 
    203         Button button22,pos={580,90},size={120,20},proc=V_GraphPanels_Button,title="Show Panels" 
    204  
    205         Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 
    206         Button button14,pos={488,350},size={120,20},proc=V_Stream_LoadDecim,title="Load Split List",disable=2 
    207         Button button19,pos={649,350},size={120,20},proc=V_Stream_LoadAdjustedList,title="Load Edited List",disable=2 
    208         Button button20,pos={680,376},size={90,20},proc=V_ShowList_ToLoad,title="Show List",disable=2 
    209         SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor",disable=2 
    210         SetVariable setvar3,fSize=10 
    211         SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:VSANS:Event:gDecimation 
    212  
    213         Button button15_0,pos={488,425},size={110,20},proc=V_AccumulateSlicesButton,title="Add First Slice",disable=2 
    214         Button button16_1,pos={488,450},size={110,20},proc=V_AccumulateSlicesButton,title="Add Next Slice",disable=2 
    215         Button button17_2,pos={620,425},size={110,20},proc=V_AccumulateSlicesButton,title="Display Total",disable=2 
    216  
    217         CheckBox chkbox1_0,pos={25,34},size={69,14},title="Oscillatory",fSize=10 
     209        Button button21,pos={488,205},size={120,20},proc=V_SplitToPanels_Button,title="Split to Panels" 
     210        Button button22,pos={488,240},size={120,20},proc=V_GraphPanels_Button,title="Show Panels" 
     211         
     212        Button button24,pos={488,270},size={180,20},proc=V_DuplRAWForExport_Button,title="Duplicate RAW for Export" 
     213        Button button25,pos={488,300},size={180,20},proc=V_CopySlicesForExport_Button,title="Copy Slices for Export" 
     214        Button button26,pos={488,330},size={180,20},proc=V_SaveExportedNexus_Button,title="Save Exported to Nexus" 
     215 
     216//      Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 
     217//      Button button14,pos={488,350},size={120,20},proc=V_Stream_LoadDecim,title="Load Split List",disable=2 
     218//      Button button19,pos={649,350},size={120,20},proc=V_Stream_LoadAdjustedList,title="Load Edited List",disable=2 
     219//      Button button20,pos={680,376},size={90,20},proc=V_ShowList_ToLoad,title="Show List",disable=2 
     220//      SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor",disable=2 
     221//      SetVariable setvar3,fSize=10 
     222//      SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:VSANS:Event:gDecimation 
     223// 
     224//      Button button15_0,pos={488,425},size={110,20},proc=V_AccumulateSlicesButton,title="Add First Slice",disable=2 
     225//      Button button16_1,pos={488,450},size={110,20},proc=V_AccumulateSlicesButton,title="Add Next Slice",disable=2 
     226//      Button button17_2,pos={620,425},size={110,20},proc=V_AccumulateSlicesButton,title="Display Total",disable=2 
     227 
     228        CheckBox chkbox1_0,pos={25,30},size={69,14},title="Oscillatory",fSize=10 
    218229        CheckBox chkbox1_0,mode=1,proc=V_EventModeRadioProc,value=0 
    219         CheckBox chkbox1_1,pos={25,59},size={53,14},title="Stream",fSize=10 
    220         CheckBox chkbox1_1,proc=V_EventModeRadioProc,value=0,mode=1 
    221         CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 
    222         CheckBox chkbox1_2,proc=V_EventModeRadioProc,value=0,mode=1 
    223         CheckBox chkbox1_3,pos={104,34},size={37,14},title="TOF",fSize=10 
    224         CheckBox chkbox1_3,proc=V_EventModeRadioProc,value=1,mode=1 
    225          
    226         GroupBox group0_0,pos={5,5},size={174,112},title="(1) Loading Mode",fSize=12,fStyle=1 
    227         GroupBox group0_1,pos={372,5},size={192,127},title="(3) Bin Events",fSize=12,fStyle=1 
    228         GroupBox group0_2,pos={477,169},size={310,92},title="(4) View / Export",fSize=12,fStyle=1 
    229         GroupBox group0_3,pos={191,5},size={165,117},title="(2) Edit Events",fSize=12,fStyle=1 
    230         GroupBox group0_4,pos={474,278},size={312,200},title="Split / Accumulate Files",fSize=12 
    231         GroupBox group0_4,fStyle=1 
     230        CheckBox chkbox1_1,pos={25,50},size={53,14},title="Stream",fSize=10 
     231        CheckBox chkbox1_1,proc=V_EventModeRadioProc,value=1,mode=1 
     232//      CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 
     233//      CheckBox chkbox1_2,proc=V_EventModeRadioProc,value=0,mode=1 
     234        CheckBox chkbox1_3,pos={104,30},size={37,14},title="TOF",fSize=10 
     235        CheckBox chkbox1_3,proc=V_EventModeRadioProc,value=0,mode=1 
     236         
     237        CheckBox chkbox1_4,pos={30,125},size={37,14},title="F",fSize=10 
     238        CheckBox chkbox1_4,proc=V_EventCarrRadioProc,value=1,mode=1 
     239        CheckBox chkbox1_5,pos={90,125},size={37,14},title="M",fSize=10 
     240        CheckBox chkbox1_5,proc=V_EventCarrRadioProc,value=0,mode=1 
     241         
     242        GroupBox group0_0,pos={5,5},size={174,140},title="(1) Loading Mode",fSize=12,fStyle=1 
     243        GroupBox group0_3,pos={191,5},size={165,130},title="(2) Edit Events",fSize=12,fStyle=1 
     244        GroupBox group0_1,pos={372,5},size={350,130},title="(3) Bin Events",fSize=12,fStyle=1 
     245        GroupBox group0_2,pos={477,169},size={310,300},title="(4) View / Export",fSize=12,fStyle=1 
     246 
     247//      GroupBox group0_4,pos={474,278},size={312,200},title="Split / Accumulate Files",fSize=12 
     248//      GroupBox group0_4,fStyle=1 
    232249         
    233250        Display/W=(10,170,460,610)/HOST=#  
     
    248265EndMacro 
    249266 
    250 // 
    251 // takes the data that is loaded and binned as a fake 
     267 
     268// 
     269// 
     270Function V_DuplRAWForExport_Button(ba) : ButtonControl 
     271        STRUCT WMButtonAction &ba 
     272 
     273        switch( ba.eventCode ) 
     274                case 2: // mouse up 
     275                        // click code here 
     276                        V_DuplicateRAWForExport() 
     277                        // 
     278                        break 
     279                case -1: // control being killed 
     280                        break 
     281        endswitch 
     282 
     283        return 0 
     284End 
     285 
     286 
     287// 
     288// 
     289Function V_CopySlicesForExport_Button(ba) : ButtonControl 
     290        STRUCT WMButtonAction &ba 
     291 
     292        switch( ba.eventCode ) 
     293                case 2: // mouse up 
     294                        // click code here 
     295                        String detStr="" 
     296                        ControlInfo chkbox1_4 
     297                        if(V_value == 1) 
     298                                detStr = "F" 
     299                        else 
     300                                detStr = "M" 
     301                        endif 
     302                        // 
     303                        V_CopySlicesForExport(detStr) 
     304                        // 
     305                        break 
     306                case -1: // control being killed 
     307                        break 
     308        endswitch 
     309 
     310        return 0 
     311End 
     312 
     313 
     314// 
     315// 
     316Function V_SaveExportedNexus_Button(ba) : ButtonControl 
     317        STRUCT WMButtonAction &ba 
     318 
     319        switch( ba.eventCode ) 
     320                case 2: // mouse up 
     321                        // click code here 
     322                        String detStr="" 
     323                         
     324                        // 
     325                        Execute "V_SaveExportedEvents()" 
     326                        // 
     327                        break 
     328                case -1: // control being killed 
     329                        break 
     330        endswitch 
     331 
     332        return 0 
     333End 
     334 
     335 
     336 
     337 
     338 
     339// 
     340// takes the event data that is loaded and binned as a combined 
    252341// (192 x 128) panel to the four LRTB panels, each with 48 tubes 
    253342// 
     
    311400                        gEventModeRadioVal= MODE_STREAM 
    312401                        break 
    313                 case "chkbox1_2": 
    314                         gEventModeRadioVal= MODE_TISANE 
    315                         break 
     402//              case "chkbox1_2": 
     403//                      gEventModeRadioVal= MODE_TISANE 
     404//                      break 
    316405                case "chkbox1_3": 
    317406                        gEventModeRadioVal= MODE_TOF 
     
    320409        CheckBox chkbox1_0,value= gEventModeRadioVal==MODE_OSCILL 
    321410        CheckBox chkbox1_1,value= gEventModeRadioVal==MODE_STREAM 
    322         CheckBox chkbox1_2,value= gEventModeRadioVal==MODE_TISANE 
     411//      CheckBox chkbox1_2,value= gEventModeRadioVal==MODE_TISANE 
    323412        CheckBox chkbox1_3,value= gEventModeRadioVal==MODE_TOF 
    324413 
    325414        return(0) 
    326415End 
     416 
     417Function V_EventCarrRadioProc(name,value) 
     418        String name 
     419        Variable value 
     420                 
     421        strswitch (name) 
     422                case "chkbox1_4": 
     423                        CheckBox chkbox1_4,value= 1 
     424                        CheckBox chkbox1_5,value= 0 
     425                        break 
     426                case "chkbox1_5": 
     427                        CheckBox chkbox1_4,value= 0 
     428                        CheckBox chkbox1_5,value= 1 
     429                        break 
     430        endswitch 
     431 
     432        return(0) 
     433End 
     434 
    327435 
    328436Function V_AdjustEventDataButtonProc(ba) : ButtonControl 
     
    9401048        endif 
    9411049         
    942         Open/R/D/P=catPathName/F=fileFilters fileref 
    943         filename = S_filename 
    944         if(strlen(S_filename) == 0) 
    945                 // user cancelled 
    946                 DoAlert 0,"No file selected, no file loaded." 
    947                 return(1) 
     1050        // load from raw? 
     1051        // if so, which carriage? 
     1052        String loadFromRAW 
     1053        String detStr 
     1054        if(cmpstr(ctrlName,"button23")==0) 
     1055                loadFromRAW = "Yes" 
     1056                ControlInfo chkbox1_4 
     1057                if(V_value == 1) 
     1058                        detStr = "F" 
     1059                else 
     1060                        detStr = "M" 
     1061                endif            
    9481062        endif 
    949  
     1063         
     1064//      Prompt loadFromRAW,"Load from RAW?",popup,"Yes;No;" 
     1065//      Prompt detStr,"Carriage",popup,"M;F;" 
     1066//      DoPrompt "Load data from...",loadFromRAW,detStr 
     1067         
     1068//      if(V_flag)              //user cancel 
     1069//              return(0) 
     1070//      endif 
     1071         
     1072        if(cmpstr(loadFromRAW,"Yes")==0) 
     1073                PathInfo catPathName 
     1074                filename = S_Path + V_getDetEventFileName("RAW",detStr+"L") 
     1075                 
     1076                // check here to see if the file can be found. if not report the error and exit 
     1077                Open/R/Z=1 fileref as fileName 
     1078                if(V_flag == 0) 
     1079                        Close fileref 
     1080                else 
     1081                        DoAlert 0,"The event file associated with RAW cannot be found.       "+filename 
     1082                        return(0) 
     1083                endif 
     1084        else 
     1085                Open/R/D/P=catPathName/F=fileFilters fileref 
     1086                filename = S_filename 
     1087                if(strlen(S_filename) == 0) 
     1088                        // user cancelled 
     1089                        DoAlert 0,"No file selected, no file loaded." 
     1090                        return(1) 
     1091                endif 
     1092        endif 
    9501093//  keep this   , but set to 1.5 GB 
    9511094// since I'm now in 64-bit space 
     
    10211164        NVAR gResol = root:Packages:NIST:VSANS:Event:gResol             //timeStep in clock frequency (Hz) 
    10221165        Printf "Time Step = 1/Frequency (ns) = %g\r",(1/gResol)*1e9 
     1166        variable timeStep_s = (1/gResol) 
     1167 
     1168// DONE: 
     1169//  x- the time scaling is done.  
     1170// TODO: VERIFY 
     1171// ??? timeStep from the clock frequency is not right--- the step appears to be 100 ns??? 
     1172//       
     1173        timeStep_s = 100e-9 
    10231174         
    10241175///// 
     
    10261177//       
    10271178 
    1028 // TODO: 
    1029 //  -- the time scaling is NOT done. it is still in raw ticks. 
    1030 // 
     1179 
    10311180 
    10321181        if(mode == MODE_STREAM)         // continuous "Stream" mode - start from zero 
     
    10371186        v_tic() 
    10381187        printf "rescale time = " 
    1039                 rescaledTime = 1*(timePt-timePt[0])             //convert to nanoseconds and start from zero 
     1188//              rescaledTime = 1*(timePt-timePt[0])             //convert to nanoseconds and start from zero 
     1189                rescaledTime = timeStep_s*(timePt-timePt[0])            //convert to seconds and start from zero 
    10401190        v_toc() 
    10411191        v_tic() 
     
    10481198        if(mode == MODE_OSCILL)         // oscillatory mode - don't adjust the times, we get periodic t0 to reset t=0 
    10491199                Duplicate/O timePt rescaledTime 
    1050                 rescaledTime *= 1                       //convert to nanoseconds and that's all 
     1200                rescaledTime *= timeStep_s                      //convert to seconds and that's all 
    10511201                t_longest = waveMax(rescaledTime)               //if oscillatory, won't be the last point, so get it this way 
    10521202         
     
    10601210        if(mode == MODE_TOF)            // TOF mode - don't adjust the times, we get periodic t0 to reset t=0 
    10611211                Duplicate/O timePt rescaledTime 
    1062                 rescaledTime *= 1                       //convert to nanoseconds and that's all 
     1212                rescaledTime *= timeStep_s              //convert to seconds and that's all 
    10631213                t_longest = waveMax(rescaledTime)               //if oscillatory, won't be the last point, so get it this way 
    10641214         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_EventMode_Utils.ipf

    r1060 r1100  
    11#pragma TextEncoding = "MacRoman" 
    22#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
     3 
     4 
     5 
     6 
    37 
    48 
     
    556560        return(0) 
    557561End 
    558  
    559  
    560  
    561  
    562  
    563  
    564562 
    565563 
     
    881879End 
    882880 
    883  
     881// 
     882/////// to copy a sliced data set to a folder to save 
     883// 
     884 
     885 
     886// load event file from RAW data loaded 
     887        // pick either the front or middle carriage 
     888        // pick the "mode" of loading data (osc, stream, etc.) 
     889// process the event data 
     890// split to panels 
     891// move slices to "export" location 
     892// move bin details to export location 
     893// repeat load + process + move with the 2nd carriage, using the same time binning 
     894// 
     895// save the data file, giving a new name to not overwrite the original data file 
     896// 
     897 
     898 
     899// 
     900// root:Packages:NIST:VSANS:RAW:gFileList               //name of the data file(s) in raw (take 1st from semi-list) 
     901// 
     902 
     903Function V_DuplicateRAWForExport() 
     904        KillDataFolder/Z root:export 
     905        DuplicateDataFolder root:Packages:NIST:VSANS:RAW: root:export 
     906        return(0) 
     907end 
     908 
     909Function V_CopySlicesForExport(detStr) 
     910        String detStr 
     911         
     912        if(cmpstr(detStr,"M") == 0) 
     913                Duplicate/O root:Packages:NIST:VSANS:Event:slices_B root:export:entry:instrument:detector_MB:slices 
     914                Duplicate/O root:Packages:NIST:VSANS:Event:slices_T root:export:entry:instrument:detector_MT:slices 
     915                Duplicate/O root:Packages:NIST:VSANS:Event:slices_L root:export:entry:instrument:detector_ML:slices 
     916                Duplicate/O root:Packages:NIST:VSANS:Event:slices_R root:export:entry:instrument:detector_MR:slices 
     917        else 
     918                Duplicate/O root:Packages:NIST:VSANS:Event:slices_B root:export:entry:instrument:detector_FB:slices 
     919                Duplicate/O root:Packages:NIST:VSANS:Event:slices_T root:export:entry:instrument:detector_FT:slices 
     920                Duplicate/O root:Packages:NIST:VSANS:Event:slices_L root:export:entry:instrument:detector_FL:slices 
     921                Duplicate/O root:Packages:NIST:VSANS:Event:slices_R root:export:entry:instrument:detector_FR:slices 
     922        endif 
     923         
     924        Duplicate/O root:Packages:NIST:VSANS:Event:binEndTime root:export:entry:reduction:binEndTime 
     925        Duplicate/O root:Packages:NIST:VSANS:Event:timeWidth root:export:entry:reduction:timeWidth       
     926         
     927        return(0) 
     928end 
     929 
     930// 
     931// data is intact in the file so that it can still be read in as a regular raw data file. 
     932// 
     933Proc V_SaveExportedEvents() 
     934 
     935        String filename = root:Packages:NIST:VSANS:RAW:gFileList                //name of the data file(s) in raw (take 1st from semi-list) 
     936        String saveName 
     937 
     938        saveName = StringFromList(0, fileName) 
     939        Save_VSANS_file("root:export", "Events_"+saveName) 
     940 
     941End 
     942 
     943 
     944 
     945 
     946////////////////////////////////////////////////////////////// 
     947// 
     948// 
     949// Panel for reducing event data 
     950// 
     951// 
     952// 
     953//              Panel to have readout/buttons for: 
     954//                      # slices 
     955//                      timing information (table, graph) 
     956//                      protocol to use (popup) 
     957//                      Event_ file (popup) 
     958// 
     959//                      Manually advance slice and display in RAW (for testing) 
     960// 
     961// 
     962 
     963// 
     964//              Save the total monitor count 
     965//              Save the total count time 
     966//              Save the sample label 
     967// 
     968//              ? Don't need to save the original detector data (I can sum the slices) 
     969// 
     970// 
     971// for each slice(N) 
     972//              find the binWidth -> bin fraction 
     973//              adjust count time 
     974//      adjust monitor count 
     975//              ? adjust integrated detector count 
     976//      adjust sample label (mark as slice(N)?) 
     977// 
     978//              copy slice(N) to each detector panel (ignore B) 
     979// 
     980//              Process through reduction protocol 
     981// 
     982//              give appropriate output name (N) 
     983// 
     984// 
     985 
     986 
     987//************************* 
     988// 
     989// Procedures to allow batch reduction of Event data files 
     990// 
     991//****note that much of this file is becoming obsolete as improved methods for  
     992//reducing multiple files are introduced. Some of these procedures may not last long*** 
     993// 
     994//************************** 
     995 
     996// 
     997//panel to allow reduction of a series of files using a selected  protocol 
     998// 
     999//main entry procedure to open the panel, initializing if necessary 
     1000Macro V_ReduceEventFiles() 
     1001         
     1002        DoWindow/F V_Event_Reduce_Panel 
     1003        If(V_flag == 0) 
     1004                V_InitializeEventReducePanel() 
     1005                //draw panel 
     1006                V_Event_Reduce_Panel() 
     1007                //pop the protocol list 
     1008                V_EVR_ProtoPopMenuProc("",1,"") 
     1009                //then update the popup list 
     1010                V_EVR_RedPopMenuProc("ERFilesPopup",1,"") 
     1011        Endif 
     1012End 
     1013 
     1014//create the global variables needed to run the MReduce Panel 
     1015//all are kept in root:Packages:NIST:VSANS:Globals:MRED 
     1016// 
     1017Proc V_InitializeEventReducePanel() 
     1018 
     1019        If(DataFolderExists("root:Packages:NIST:VSANS:Globals:EVRED")) 
     1020                //ok, do nothing 
     1021        else 
     1022                //no, create the folder and the globals 
     1023                NewDataFolder/O root:Packages:NIST:VSANS:Globals:EVRED 
     1024//              String/G root:Packages:NIST:VSANS:Globals:MRED:gMRedMatchStr = "*" 
     1025                PathInfo catPathName 
     1026                If(V_flag==1) 
     1027                        String dum = S_path 
     1028                        String/G root:Packages:NIST:VSANS:Globals:EVRED:gCatPathStr = dum 
     1029                else 
     1030                        String/G root:Packages:NIST:VSANS:Globals:EVRED:gCatPathStr = "no path selected" 
     1031                endif 
     1032                String/G root:Packages:NIST:VSANS:Globals:EVRED:gMRedList = "none" 
     1033                String/G root:Packages:NIST:VSANS:Globals:EVRED:gMRProtoList = "none" 
     1034                String/G root:Packages:NIST:VSANS:Globals:EVRED:gFileNumList="" 
     1035                Variable/G root:Packages:NIST:VSANS:Globals:EVRED:gNumSlices=1 
     1036                Variable/G root:Packages:NIST:VSANS:Globals:EVRED:gCurSlice=1 
     1037 
     1038 
     1039        Endif  
     1040End 
     1041 
     1042 
     1043// 
     1044// borrows some of the basic functions from the MRED panel 
     1045// 
     1046Window V_Event_Reduce_Panel() 
     1047        PauseUpdate; Silent 1           // building window... 
     1048        NewPanel /W=(535,72,951,288) /K=1 as "Event File File Reduction" 
     1049        ModifyPanel cbRGB=(60535,51151,51490) 
     1050        ModifyPanel fixedSize=1 
     1051        SetDrawLayer UserBack 
     1052        DrawLine 7,30,422,30 
     1053        SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" 
     1054        SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while reducing. If no files appear in the popup, make sure that this folder is set correctly"} 
     1055        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:EVRED:gCatPathStr 
     1056        Button PathButton,pos={3,3},size={70,20},proc=V_PickEVRPathButton,title="Pick Path" 
     1057        Button PathButton,help={"Select the folder containing the raw SANS data files"} 
     1058        Button helpButton,pos={385,3},size={25,20},proc=V_ShowEVRHelp,title="?" 
     1059        Button helpButton,help={"Show the help file for reducing event files"} 
     1060        PopupMenu ERFilesPopup,pos={3,45},size={167,19},proc=V_EVR_RedPopMenuProc,title="File to Reduce" 
     1061        PopupMenu ERFilesPopup,help={"The displayed file is the one that will be reduced."} 
     1062        PopupMenu ERFilesPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:EVRED:gMRedList" 
     1063 
     1064        SetVariable ERSlices,pos={3,75},size={100,15},title="# of slices" 
     1065        SetVariable ERSlices,limits={0,1000,0},value=root:Packages:NIST:VSANS:Globals:EVRED:gNumSlices 
     1066         
     1067        SetVariable ERSelSlice,pos={150,75},size={100,15},title="current slice" 
     1068        SetVariable ERSelSlice,limits={0,1000,1},value=root:Packages:NIST:VSANS:Globals:EVRED:gCurSlice 
     1069        SetVariable ERSelSlice,proc=V_ChangeSliceViewSetVar 
     1070 
     1071        Button ToSTOButton,pos={305,45},size={100,20},proc=V_EVR_LoadAndSTO,title="to STO" 
     1072        Button ToSTOButton,help={"Load the event file and copy to STO"} 
     1073 
     1074        Button TimeBinButton,pos={305,75},size={100,20},proc=V_EVR_TimeBins,title="Time Bins" 
     1075        Button TimeBinButton,help={"Display the time bins"} 
     1076                                 
     1077//      SetVariable ERList,pos={3,48},size={350,13},proc=V_FileNumberListProc,title="File number list: " 
     1078//      SetVariable ERList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
     1079//      SetVariable ERList,limits={-Inf,Inf,1},value= root:Packages:NIST:VSANS:Globals:EVRED:gFileNumList 
     1080 
     1081        PopupMenu ERProto_pop,pos={3,118},size={119,19},proc=V_EVR_ProtoPopMenuProc,title="Protocol " 
     1082        PopupMenu ERProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
     1083        PopupMenu ERProto_pop,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:EVRED:gMRProtoList" 
     1084        Button ReduceAllButton,pos={3,178},size={180,20},proc=V_EVR_ReduceAllSlices,title="Reduce All Slices" 
     1085        Button ReduceAllButton,help={"This will reduce all slices."} 
     1086        Button ReduceOneButton,pos={3,148},size={180,20},proc=V_EVR_ReduceTopSlice,title="Reduce Selected Slice" 
     1087        Button ReduceOneButton,help={"This will reduce the selected slice."} 
     1088         
     1089        Button DoneButton,pos={290,178},size={110,20},proc=V_EVR_DoneButtonProc,title="Done Reducing" 
     1090        Button DoneButton,help={"When done reducing files, this will close this control panel."} 
     1091EndMacro 
     1092 
     1093 
     1094//allows the user to set the path to the local folder that contains the SANS data 
     1095//2 global strings are reset after the path "catPathName" is reset in the function PickPath() 
     1096// this path is the only one, the globals are simply for convenience 
     1097// 
     1098Function V_PickEVRPathButton(PathButton) : ButtonControl 
     1099        String PathButton 
     1100         
     1101        V_PickPath()            //sets the main global path string for catPathName 
     1102         
     1103        //then update the "local" copy in the MRED subfolder 
     1104        PathInfo/S catPathName 
     1105        String dum = S_path 
     1106        if (V_flag == 0) 
     1107                //path does not exist - no folder selected 
     1108                String/G root:Packages:NIST:VSANS:Globals:EVRED:gCatPathStr = "no folder selected" 
     1109        else 
     1110                String/G root:Packages:NIST:VSANS:Globals:EVRED:gCatPathStr = dum 
     1111        endif 
     1112         
     1113        //Update the pathStr variable box 
     1114        ControlUpdate/W=V_Event_Reduce_Panel $"PathDisplay" 
     1115         
     1116        //then update the popup list 
     1117        V_EVR_RedPopMenuProc("ERFilesPopup",1,"") 
     1118End 
     1119 
     1120// 
     1121// loads the file in the popup (to RAW as usual) 
     1122// then copies the data to STO 
     1123// 
     1124//      updates the total number of slices 
     1125// 
     1126// resets the slice view to 0 
     1127//              changes the limits on the SetVar control {0,n,1} 
     1128// 
     1129Function V_EVR_LoadAndSTO(PathButton) : ButtonControl 
     1130        String PathButton 
     1131 
     1132        String fileName 
     1133        Variable err 
     1134 
     1135        ControlInfo ERFilesPopup 
     1136        fileName = S_Value 
     1137         
     1138        err = V_LoadHDF5Data(FileName,"RAW") 
     1139        if(!err)                //directly from, and the same steps as DisplayMainButtonProc(ctrlName) 
     1140                SVAR hdfDF = root:file_name                     // last file loaded, may not be the safest way to pass 
     1141                String folder = StringFromList(0,hdfDF,".") 
     1142                 
     1143                // this (in SANS) just passes directly to fRawWindowHook() 
     1144                V_UpdateDisplayInformation("RAW")               // plot the data in whatever folder type 
     1145                                                                 
     1146                // set the global to display ONLY if the load was called from here, not from the  
     1147                // other routines that load data (to read in values) 
     1148                SVAR gLast = root:Packages:NIST:VSANS:Globals:gLastLoadedFile 
     1149                gLast = hdfDF 
     1150                                                 
     1151        endif 
     1152         
     1153        // now copy RAW to STO for safe keeping... 
     1154        //V_CopyHDFToWorkFolder(oldtype,newtype) 
     1155        V_CopyHDFToWorkFolder("RAW","STO") 
     1156 
     1157        // read the number of slices from FL 
     1158        WAVE/Z w = root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:slices 
     1159        NVAR num = root:Packages:NIST:VSANS:Globals:EVRED:gNumSlices 
     1160         
     1161        num = DimSize(w, 2) 
     1162         
     1163        //change the slice view to slice 0 
     1164        SetVariable ERSelSlice,win=V_Event_Reduce_Panel,limits={0,(num-1),1} 
     1165        NVAR value=root:Packages:NIST:VSANS:Globals:EVRED:gCurSlice 
     1166        value=0 
     1167        V_ChangeSliceViewSetVar("",0,"","") 
     1168         
     1169        return(0) 
     1170End 
     1171 
     1172// given a file already loaded into RAW (and copied to STO) 
     1173// display a selected slice (8 panels) 
     1174// rescale the monitor count 
     1175// rescale the count time 
     1176// update the sample label 
     1177// 
     1178// TODO -- and I missing anything that is done at the normal RAW load time 
     1179// that I am not doing here simply by copying over 
     1180// -- like... data error, nonlinear corrections, etc. 
     1181// the nonlinear corrections need only be done once, since the detector is the same for all slices. 
     1182// 
     1183Function V_ChangeSliceViewSetVar(ctrlName,varNum,varStr,varName) : SetVariableControl 
     1184        String ctrlName 
     1185        Variable varNum 
     1186        String varStr 
     1187        String varName 
     1188         
     1189        Variable ii 
     1190        String detStr,fname      
     1191        // varNum is the only meaningful input, the slice number 
     1192         
     1193        // copy STO to RAW 
     1194        V_CopyHDFToWorkFolder("STO","RAW") 
     1195         
     1196         
     1197        // switch data to point to the correct slice 
     1198        string tmpStr = "root:Packages:NIST:VSANS:RAW:entry:instrument:"  
     1199 
     1200        fname="RAW" 
     1201        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     1202                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     1203                Wave data = V_getDetectorDataW(fname,detStr) 
     1204                 
     1205                WAVE/Z slices = $("root:Packages:NIST:VSANS:RAW:entry:instrument:detector_"+detStr+":slices") 
     1206                data = slices[p][q][varNum] 
     1207                V_MakeDataError(tmpStr+"detector_"+detStr)              //update the error wave to match the slice 
     1208        endfor 
     1209                 
     1210        // TODO: update the times and counts 
     1211        // use a special "put", not "write" so it is written to the RAW folder, not the file 
     1212        // 
     1213        wave binEnd = root:Packages:NIST:VSANS:RAW:entry:reduction:binEndTime 
     1214        wave timeWidth = root:Packages:NIST:VSANS:RAW:entry:reduction:timeWidth 
     1215         
     1216        Variable timeFract,num 
     1217        num = numpnts(binEnd) 
     1218        timeFract = timeWidth[varNum]/binEnd[num-1] 
     1219 
     1220// get values from STO 
     1221        Variable mon_STO,ctTime_STO 
     1222        String label_STO 
     1223 
     1224        ctTime_STO = V_getCount_time("STO") 
     1225        mon_STO = V_getBeamMonNormData("STO") 
     1226        label_STO = V_getSampleDescription("STO") 
     1227         
     1228// mon ct 
     1229        V_putBeamMonNormData("RAW",mon_STO*timeFract) 
     1230// ct time 
     1231        V_putCount_time("RAW",ctTime_STO*timeFract) 
     1232// label 
     1233        V_putSampleDescription("RAW",label_STO+" slice "+num2str(varNum)) 
     1234         
     1235        return(0) 
     1236End 
     1237 
     1238 
     1239// 
     1240// locates the time bins and shows the time bin table (and plot?) 
     1241// 
     1242Function V_EVR_TimeBins(PathButton) : ButtonControl 
     1243        String PathButton 
     1244 
     1245        wave binEnd = root:Packages:NIST:VSANS:RAW:entry:reduction:binEndTime 
     1246        wave timeWidth = root:Packages:NIST:VSANS:RAW:entry:reduction:timeWidth 
     1247 
     1248        edit binEnd,timeWidth 
     1249         
     1250        return(0) 
     1251End 
     1252 
     1253Proc V_ShowEVRHelp(ctrlName) : ButtonControl 
     1254        String ctrlName 
     1255 
     1256        DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[Reduce Event Files]" 
     1257        if(V_flag !=0) 
     1258                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found" 
     1259        endif 
     1260End 
     1261 
     1262 
     1263 
     1264 
     1265// 
     1266// 
     1267// 
     1268Function V_EVR_RedPopMenuProc(ERFilesPopup,popNum,popStr) : PopupMenuControl 
     1269        String ERFilesPopup 
     1270        Variable popNum 
     1271        String popStr 
     1272 
     1273        String list = V_GetValidEVRedPopupList() 
     1274//       
     1275        SVAR str= root:Packages:NIST:VSANS:Globals:EVRED:gMredList 
     1276        str=list 
     1277        ControlUpdate ERFilesPopup 
     1278        return(0) 
     1279End 
     1280 
     1281// get a  list of all of the sample files, based on intent 
     1282// 
     1283// 
     1284// only accepts files in the list that are purpose=scattering 
     1285// 
     1286Function/S V_GetValidEVRedPopupList() 
     1287 
     1288        String semiList="" 
     1289 
     1290        semiList = V_GetSAMList() 
     1291        return(semiList) 
     1292 
     1293End 
     1294 
     1295//returns a list of the available protocol waves in the protocols folder 
     1296//removes "CreateNew", "tempProtocol" and "fakeProtocol" from list (if they exist) 
     1297//since these waves do not contain valid protocol instructions 
     1298// 
     1299// also removes Base and DoAll since for event file reduction, speed is of the essence 
     1300// and there is no provision in the protocol for "asking" for the files to be identified 
     1301// 
     1302Function V_EVR_ProtoPopMenuProc(ERProto_pop,popNum,popStr) : PopupMenuControl 
     1303        String ERProto_pop 
     1304        Variable popNum 
     1305        String popStr 
     1306 
     1307        //get list of currently valid protocols, and put it in the popup (the global list) 
     1308        //excluding "tempProtocol" and "CreateNew" if they exist 
     1309        SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols 
     1310        String list = WaveList("*",";","") 
     1311        SetDataFolder root: 
     1312         
     1313        //remove items from the list (list is unchanged if the items are not present) 
     1314        list = RemoveFromList("CreateNew", list, ";") 
     1315        list = RemoveFromList("tempProtocol", list, ";") 
     1316        list = RemoveFromList("fakeProtocol", list, ";") 
     1317        list = RemoveFromList("PanelNameW", list, ";") 
     1318        list = RemoveFromList("Beg_pts", list, ";") 
     1319        list = RemoveFromList("End_pts", list, ";") 
     1320        list = RemoveFromList("trimUpdate", list, ";") 
     1321        list = RemoveFromList("Base", list, ";") 
     1322        list = RemoveFromList("DoAll", list, ";") 
     1323         
     1324        String/G root:Packages:NIST:VSANS:Globals:EVRED:gMRProtoList = list 
     1325        ControlUpdate ERProto_pop 
     1326 
     1327End 
     1328 
     1329// 
     1330//button procedure to close the panel,  
     1331// 
     1332Function V_EVR_DoneButtonProc(ctrlName) : ButtonControl 
     1333        String ctrlName 
     1334 
     1335        // this button will make sure all files are closed  
     1336        //and close the panel 
     1337 
     1338        Close/A 
     1339        DoWindow/K V_Event_Reduce_Panel 
     1340         
     1341        KillDataFolder root:Packages:NIST:VSANS:Globals:EVRED 
     1342End 
     1343 
     1344 
     1345 
     1346 
     1347// 
     1348// reduce just the selected slice 
     1349// 
     1350// Assumes that: 
     1351// - the event data file has been loaded and copied to STO for repeated access 
     1352// - the protocol has been properly and completely defined (test one slice first!) 
     1353// 
     1354// 
     1355Function V_EVR_ReduceTopSlice(ctrlName) : ButtonControl 
     1356        String ctrlName 
     1357 
     1358        //get the selected protocol 
     1359        ControlInfo ERProto_pop 
     1360        String protocolNameStr = S_Value 
     1361         
     1362        //also set this as the current protocol, for the function that writes the averaged waves 
     1363        String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocolNameStr 
     1364         
     1365        // get the file name from the popup 
     1366        ControlInfo ERFilesPopup 
     1367        String samStr = S_Value 
     1368         
     1369        // get the current slice number 
     1370        NVAR curSlice = root:Packages:NIST:VSANS:Globals:EVRED:gCurSlice 
     1371        // get the total number of slices 
     1372        NVAR totalSlices = root:Packages:NIST:VSANS:Globals:EVRED:gNumSlices 
     1373         
     1374        //reduce all the files in the list here, using the global protocol(the full reference) 
     1375        //see -- DoReduceList is found in MultipleReduce.ipf 
     1376         
     1377//      V_DoReduceList(commaList) 
     1378        Variable skipLoad = 0 
     1379        V_ExecuteProtocol_Event(protocolNameStr,samStr,curSlice,skipLoad) 
     1380         
     1381        Return 0 
     1382End 
     1383 
     1384 
     1385 
     1386// 
     1387// reduce all slices 
     1388// 
     1389Function V_EVR_ReduceAllSlices(ctrlName) : ButtonControl 
     1390        String ctrlName 
     1391 
     1392        //get the selected protocol 
     1393        ControlInfo ERProto_pop 
     1394        String protocolNameStr = S_Value 
     1395         
     1396        //also set this as the current protocol, for the function that writes the averaged waves 
     1397        String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocolNameStr 
     1398         
     1399        // get the file name from the popup 
     1400        ControlInfo ERFilesPopup 
     1401        String samStr = S_Value 
     1402         
     1403        // get the total number of slices 
     1404        NVAR totalSlices = root:Packages:NIST:VSANS:Globals:EVRED:gNumSlices 
     1405         
     1406         
     1407        Variable skipLoad = 0 
     1408        Variable curSlice = 0 
     1409        // do the first one (slice 0) 
     1410        V_ExecuteProtocol_Event(protocolNameStr,samStr,curSlice,skipLoad) 
     1411         
     1412        skipLoad = 1 
     1413        for(curSlice = 1;curSlice<totalSlices; curSlice +=1) 
     1414                V_ExecuteProtocol_Event(protocolNameStr,samStr,curSlice,skipLoad) 
     1415        endfor 
     1416         
     1417         
     1418        Return 0 
     1419End 
     1420 
     1421 
     1422 
     1423////////////////////////////////// 
     1424// 
     1425// This is the Event-equivalent version of ExecuteProtocol 
     1426// with special handling for shuffling the event slices from STO to RAW->SAM 
     1427// -skips repetitive loads 
     1428// -adjusts timing 
     1429// -names slices 
     1430 
     1431//protStr is the full path to the selected protocol wave 
     1432//samStr is the name of the event data file "Event_sansNNNN.nxs.ngv" 
     1433// SliceNum is the number of slice to reduce (copy it from STO) 
     1434// skipLoad is a flag (0|1) to allow skip of loading EMP, BGD, etc. on repeated passes 
     1435Function V_ExecuteProtocol_Event(protStr,samStr,sliceNum,skipLoad) 
     1436        String protStr,samStr 
     1437        Variable sliceNum 
     1438        Variable skipLoad 
     1439 
     1440        String protoPath = "root:Packages:NIST:VSANS:Globals:Protocols:" 
     1441        WAVE/T prot = $(protoPath+protStr) 
     1442//      SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols 
     1443         
     1444        Variable filesOK,err,notDone 
     1445        String activeType, msgStr, junkStr, pathStr="" 
     1446        PathInfo catPathName                    //this is where the files are 
     1447        pathStr=S_path 
     1448         
     1449//      NVAR useXMLOutput = root:Packages:NIST:gXML_Write 
     1450         
     1451        //Parse the instructions in the prot wave 
     1452        //0 - bkg 
     1453        //1 - emp 
     1454        //2 - div 
     1455        //3 - mask 
     1456        //4 - abs params c2-c5 
     1457        //5 - average params 
     1458        //6 = DRK file (**out of sequence) 
     1459        //7 = beginning trim points 
     1460        //8 = end trim points 
     1461        //9 = unused 
     1462        //10 = unused 
     1463        //11 = unused 
     1464 
     1465////////////////////////////// 
     1466// DIV 
     1467////////////////////////////// 
     1468// for VSANS, DIV is used on each data file as it is converted to WORK, so it needs to be 
     1469//  the first thing in place, before any data or backgrounds are loaded 
     1470 
     1471        //check for work.div file (prot[2]) 
     1472        //load in if needed 
     1473        // no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) 
     1474        // 
     1475                // save the state of the DIV preference 
     1476        NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor 
     1477        Variable saved_gDoDIVCor = gDoDIVCor 
     1478         
     1479        if(!skipLoad) 
     1480                 
     1481                err = V_Proto_LoadDIV(prot[2]) 
     1482                 
     1483                if(err) 
     1484                        SetDataFolder root: 
     1485                        Abort "No file selected, data reduction aborted" 
     1486                endif 
     1487        endif 
     1488         
     1489////////////////////////////// 
     1490// SAM 
     1491////////////////////////////// 
     1492 
     1493        // move the selected slice number to RAW, then to SAM 
     1494        V_ChangeSliceViewSetVar("",sliceNum,"","") 
     1495         
     1496        //Execute "V_Convert_to_Workfile()" 
     1497        err = V_Raw_to_work("SAM") 
     1498         
     1499        //always update 
     1500        activeType = "SAM" 
     1501        V_UpdateDisplayInformation(ActiveType) 
     1502 
     1503 
     1504////////////////////////////// 
     1505// BGD 
     1506////////////////////////////// 
     1507         
     1508        //check for BGD file  -- "ask" might not fail - "ask?" will - ? not allowed in VAX filenames 
     1509        // add if needed 
     1510        //use a "case" statement 
     1511        if(!skipLoad) 
     1512         
     1513                msgStr = "Select background file" 
     1514                activeType = "BGD" 
     1515                 
     1516                err = V_Proto_LoadFile(prot[0],activeType,msgStr) 
     1517                if(err) 
     1518                        PathInfo/S catPathName 
     1519                        SetDataFolder root: 
     1520                        Abort "No file selected, data reduction aborted" 
     1521                endif 
     1522         
     1523        //      //Loader is in charge of updating, since it knows if data was loaded 
     1524        //      V_UpdateDisplayInformation(ActiveType) 
     1525        endif 
     1526 
     1527////////////////////////////// 
     1528// EMP 
     1529//////////////////////////////   
     1530         
     1531        //check for emp file (prot[1]) 
     1532        // add if needed 
     1533        if(!skipLoad) 
     1534 
     1535                msgStr = "Select empty cell data" 
     1536                activeType = "EMP" 
     1537                 
     1538                err = V_Proto_LoadFile(prot[1],activeType,msgStr) 
     1539                if(err) 
     1540                        PathInfo/S catPathName 
     1541                        SetDataFolder root: 
     1542                        Abort "No file selected, data reduction aborted" 
     1543                endif 
     1544         
     1545        //      //Loader is in charge of updating, since it knows if data was loaded 
     1546        //      V_UpdateDisplayInformation(ActiveType) 
     1547        endif 
     1548 
     1549////////////////////////////// 
     1550// CORRECT 
     1551////////////////////////////// 
     1552 
     1553        //do the CORRECT step based on the answers to emp and bkg subtraction 
     1554        //by setting the proper"mode" 
     1555        //1 = both emp and bgd subtraction 
     1556        //2 = only bgd subtraction 
     1557        //3 = only emp subtraction 
     1558        //4 = no subtraction  
     1559        //additional modes 091301 
     1560        //11 = emp, bgd, drk 
     1561        //12 = bgd and drk 
     1562        //13 = emp and drk 
     1563        //14 = no subtractions 
     1564        //work.drk is from proto[6] 
     1565        // 
     1566        //subtracting just the DRK data is NOT an option - it doesnt' really make any physical sense 
     1567        // - in this case, DRK is skipped (equivalent to mode==4) 
     1568        // automatically accounts for attenuators given the lookup tables and the  
     1569        //desired subtractions 
     1570        //Attenuator lookup tables are alredy implemented (NG1 = NG7) 
     1571        // 
     1572 
     1573 
     1574/////// DRK is SKIPPED 
     1575         
     1576//      //read in the DRK data if necessary 
     1577//      //only one file, assumed to be RAW data 
     1578//      // 
     1579//      String fname="",drkStr="" 
     1580//      drkStr=StringByKey("DRK",prot[6],"=",",") 
     1581//      if(cmpstr(drkStr,"none") != 0) 
     1582//              err = ReadHeaderAndData( (pathStr+drkStr) ) 
     1583//              if(err) 
     1584//                      PathInfo/S catPathName 
     1585//                      Abort "reduction sequence aborted" 
     1586//              endif 
     1587//              err = V_Raw_to_Work_NoNorm("DRK") 
     1588//      endif 
     1589 
     1590        //dispatch to the proper "mode" of Correct() 
     1591//      V_Dispatch_to_Correct(bgdStr,empStr,drkStr) 
     1592        V_Dispatch_to_Correct(prot[0],prot[1],prot[6]) 
     1593         
     1594        if(err) 
     1595                PathInfo/S catPathName 
     1596                SetDataFolder root: 
     1597                Abort "error in Correct, called from executeprotocol, normal cor" 
     1598        endif 
     1599        activeType = "COR" 
     1600 
     1601// always update - COR will always be generated 
     1602        V_UpdateDisplayInformation(ActiveType)           
     1603 
     1604 
     1605////////////////////////////// 
     1606//  ABSOLUTE SCALE 
     1607////////////////////////////// 
     1608 
     1609        err = V_Proto_ABS_Scale(prot[4],activeType) 
     1610         
     1611        if(err) 
     1612                SetDataFolder root: 
     1613                Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" 
     1614        endif 
     1615//      activeType = "ABS" 
     1616 
     1617 
     1618////////////////////////////// 
     1619// MASK 
     1620////////////////////////////// 
     1621// 
     1622// DONE 
     1623//              x- fill in the "ask" step 
     1624//  x- none is OK, except if the kill fails for any reason 
     1625// x- the regular case of the file name specified by the protocol works correctly 
     1626// x- don't create a null mask if not used, it will handle the error and print out that the mask is missing 
     1627// 
     1628//mask data if desired (mask is applied when the data is binned to I(q)) and is 
     1629//not done explicitly here 
     1630         
     1631        //check for mask 
     1632        //doesn't change the activeType 
     1633        if(!skipLoad) 
     1634 
     1635                V_Proto_ReadMask(prot[3]) 
     1636        endif 
     1637         
     1638////////////////////////////// 
     1639// AVERAGING 
     1640////////////////////////////// 
     1641 
     1642        // average/save data as specified 
     1643        //Parse the keyword=<Value> string as needed, based on AVTYPE 
     1644         
     1645        //average/plot first  
     1646        String av_type = StringByKey("AVTYPE",prot[5],"=",";") 
     1647        If(cmpstr(av_type,"none") != 0) 
     1648                If (cmpstr(av_type,"")==0)              //if the key could not be found... (if "ask" the string) 
     1649                        //get the averaging parameters from the user, as if the set button was hit in the panel 
     1650                        V_SetAverageParamsButtonProc("dummy")           //from "ProtocolAsPanel" 
     1651                        SVAR tempAveStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr 
     1652                        av_type = StringByKey("AVTYPE",tempAveStr,"=",";") 
     1653                else 
     1654                        //there is info in the string, use the protocol 
     1655                        //set the global keyword-string to prot[5] 
     1656                        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = prot[5] 
     1657                Endif 
     1658        Endif 
     1659 
     1660 
     1661        String detGroup = StringByKey("DETGROUP",prot[5],"=",";")               //only for annular, null if not present 
     1662 
     1663         
     1664//convert the folder to linear scale before averaging, then revert by calling the window hook 
     1665// (not needed for VSANS, data is always linear scale) 
     1666 
     1667// 
     1668// (DONE) 
     1669// -x this generates a "Bin Type Not Found" error if reducing only to a 2D level (like for DIV) 
     1670//              because binTypeStr is null 
     1671        String binTypeStr = StringByKey("BINTYPE",prot[5],"=",";") 
     1672        // plotting is not really necessary, and the graph may not be open - so skip for now? 
     1673        Variable binType 
     1674        // only get the binning type if user asks for averaging 
     1675        If(cmpstr(av_type,"none") != 0) 
     1676                binType = V_BinTypeStr2Num(binTypeStr) 
     1677                if(binType == 0) 
     1678                                Abort "Binning mode not found in V_QBinAllPanels() "// when no case matches 
     1679                endif 
     1680        endif 
     1681 
     1682 
     1683// identify the collimation type 
     1684// this will be a string used to determine how the resolution information is to be calculated 
     1685// and written to the reduced data file 
     1686// 
     1687// possible values are: 
     1688// 
     1689// pinhole 
     1690// pinhole_whiteBeam 
     1691// narrowSlit 
     1692// narrowSlit_whiteBeam 
     1693// convergingPinholes 
     1694// 
     1695 
     1696        String collimationStr 
     1697        collimationStr = V_IdentifyCollimation(activeType) 
     1698         
     1699 
     1700//////////////////////////////////////// 
     1701// DISPATCH TO AVERAGING 
     1702///////////////////////////////////////// 
     1703// 
     1704// TODO: 
     1705// -- do I calculate the proper resolution here?, YES, I've already decoded the binning type 
     1706//   and the averaging type has been specified by the protocol. 
     1707// 
     1708// so currently, the resolution is calculated every time that the data is averaged (in VC_fDoBinning_QxQy2D) 
     1709// 
     1710// -- if I calculate the resolution here, then the Trimming routines must be updated 
     1711//    to trim the resolution waves also. This will work for the columns present in 
     1712//    pinhole resolution, but anything using the matrix method - it won't work - and I'll need  
     1713//    a different solution 
     1714// 
     1715 
     1716        V_Proto_doAverage(prot[5],av_type,activeType,binType,collimationStr) 
     1717 
     1718 
     1719 
     1720//////////////////////// 
     1721// PLOT THE DATA 
     1722//////////////////////// 
     1723 
     1724        V_Proto_doPlot(prot[5],av_type,activeType,binType,detGroup) 
     1725         
     1726         
     1727 
     1728////////////////////     
     1729// SAVE THE DATA 
     1730//////////////////// 
     1731 
     1732//  
     1733// x- how do I get the sample file name? 
     1734//    local variable samFileLoaded is the file name loaded (contains the extension) 
     1735// 
     1736// V_Proto_SaveFile(avgStr,activeType,samFileLoaded,av_type,binType,detGroup,trimBegStr,trimEndStr) 
     1737 
     1738        prot[9] = collimationStr 
     1739        String outputFileName 
     1740        outputFileName = RemoveEnding(samStr,".nxs.ngv") + "_SL"+num2str(sliceNum) 
     1741        //? remove the "Events_" from the beginning? some other naming scheme entirely? 
     1742         
     1743        V_Proto_SaveFile(prot[5],activeType,outputFileName,av_type,binType,detGroup,prot[7],prot[8]) 
     1744         
     1745////////////////////////////// 
     1746// DONE WITH THE PROTOCOL 
     1747//////////////////////////////   
     1748         
     1749        // reset any global preferences that I had changed 
     1750        gDoDIVCor = saved_gDoDIVCor 
     1751         
     1752         
     1753        Return(0) 
     1754End 
     1755 
     1756 
     1757 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r1095 r1100  
    678678end 
    679679 
     680// fname is a local WORK folder 
     681Function V_putCount_time(fname,val) 
     682        String fname 
     683        Variable val 
     684 
     685//root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:beam_center_x 
     686        String path = "root:Packages:NIST:VSANS:"+fname+":" 
     687        path += "entry:control:count_time" 
     688         
     689        Wave/Z w = $path 
     690        if(waveExists(w) == 0) 
     691                return(1) 
     692        else 
     693        w[0] = val 
     694                return(0) 
     695        endif 
     696 
     697End 
    680698 
    681699Function V_writeCount_time_preset(fname,val) 
     
    31233141End 
    31243142 
     3143// fname is a local WORK folder 
     3144Function V_putBeamMonNormData(fname,val) 
     3145        String fname 
     3146        Variable val 
     3147 
     3148        String path = "root:Packages:NIST:VSANS:"+fname+":" 
     3149        path += "entry:instrument:beam_monitor_norm:data" 
     3150         
     3151        Wave/Z w = $path 
     3152        if(waveExists(w) == 0) 
     3153                return(1) 
     3154        else 
     3155        w[0] = val 
     3156                return(0) 
     3157        endif 
     3158 
     3159End 
     3160 
     3161 
    31253162Function V_writeBeamMonNormDistance(fname,val) 
    31263163        String fname 
     
    57875824        return(err) 
    57885825End 
     5826 
     5827// fname is a local WORK folder 
     5828Function V_putSampleDescription(fname,str) 
     5829        String fname,str 
     5830 
     5831        String path = "root:Packages:NIST:VSANS:"+fname+":" 
     5832        path += "entry:sample:description" 
     5833         
     5834        Wave/Z/T w = $path 
     5835        if(waveExists(w) == 0) 
     5836                return(1) 
     5837        else 
     5838        w[0] = str 
     5839                return(0) 
     5840        endif 
     5841 
     5842End 
     5843 
     5844 
    57895845 
    57905846// for a z-stage?? 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf

    r1091 r1100  
    422422        Printf "Hook cleaned out RawVSANS, experiment saved\r" 
    423423 
    424 End 
     424        KillDataFolder/Z root:Packages:NIST:VSANS:RAW 
     425        KillDataFolder/Z root:Packages:NIST:VSANS:SAM 
     426        KillDataFolder/Z root:Packages:NIST:VSANS:EMP 
     427        KillDataFolder/Z root:Packages:NIST:VSANS:BGD 
     428        KillDataFolder/Z root:Packages:NIST:VSANS:COR 
     429        KillDataFolder/Z root:Packages:NIST:VSANS:DIV 
     430        KillDataFolder/Z root:Packages:NIST:VSANS:MSK 
     431        KillDataFolder/Z root:Packages:NIST:VSANS:ABS 
     432        KillDataFolder/Z root:Packages:NIST:VSANS:CAL 
     433        KillDataFolder/Z root:Packages:NIST:VSANS:STO 
     434        KillDataFolder/Z root:Packages:NIST:VSANS:SUB 
     435        KillDataFolder/Z root:Packages:NIST:VSANS:DRK 
     436        KillDataFolder/Z root:Packages:NIST:VSANS:ADJ 
     437 
     438// re-create anthing that was killed 
     439        V_initFolders() 
     440 
     441End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MultipleReduce.ipf

    r1092 r1100  
    162162        //input filenames must be full path:file;ext, so they can be found on disk 
    163163         
    164         String cmdTemplate = "V_ExecuteProtocol(\"" + gMredProtoStr + "\",\"%s\")" 
     164//      String cmdTemplate = "V_ExecuteProtocol(\"" + gMredProtoStr + "\",\"%s\")" 
    165165        String theItem 
    166166        Variable index=0 
     
    170170                theItem = StringFromList(index,list,",")        //COMMA separated list 
    171171                if(strlen(theItem)!=0) 
    172                         sprintf cmd,cmdTemplate,theItem         //null string items will be skipped 
     172                        //sprintf cmd,cmdTemplate,theItem               //null string items will be skipped 
    173173                        //Print "cmd = ",cmd 
    174                         Execute cmd 
     174                        //Execute cmd 
     175                        V_ExecuteProtocol(gMredProtoStr,theItem) 
    175176                endif 
    176177                index +=1 
     
    265266Function/S V_GetValidMRedPopupList() 
    266267 
    267 //      String semiList = V_GetSAMList() 
    268268 
    269269        String commaList="",semiList="",fname="",purpose="" 
    270270        SVAR numList=root:Packages:NIST:VSANS:Globals:MRED:gFileNumList 
     271         
     272        // if a "*" is entered, return all of the SAMPLE+SCATTERING files 
     273        if(cmpstr(numList,"*") == 0) 
     274                semiList = V_GetSAMList() 
     275                return(semiList) 
     276        endif 
    271277         
    272278        commaList = V_ParseRunNumberList(numList) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1098 r1100  
    10091009 
    10101010 
    1011         PopupMenu popup_sam,pos={85,68},size={51,23},proc=SAMFilePopMenuProc 
     1011        PopupMenu popup_sam,pos={85,68},size={51,23},proc=V_SAMFilePopMenuProc 
    10121012        PopupMenu popup_sam,mode=1,value= #"V_getSAMList()"      
    1013         PopupMenu popup_bkg,pos={85,164},size={51,23},proc=BKGFilePopMenuProc 
     1013        PopupMenu popup_bkg,pos={85,164},size={51,23},proc=V_BKGFilePopMenuProc 
    10141014        PopupMenu popup_bkg,mode=1,value= #"V_getBGDList()" 
    1015         PopupMenu popup_emp,pos={85,213},size={51,23},proc=EMPFilePopMenuProc 
     1015        PopupMenu popup_emp,pos={85,213},size={51,23},proc=V_EMPFilePopMenuProc 
    10161016        PopupMenu popup_emp,mode=1,value= #"V_getEMPList()" 
    1017         PopupMenu popup_div,pos={85,263},size={51,23},proc=DIVFilePopMenuProc 
     1017        PopupMenu popup_div,pos={85,263},size={51,23},proc=V_DIVFilePopMenuProc 
    10181018        PopupMenu popup_div,mode=1,value= #"V_getDIVList()" 
    1019         PopupMenu popup_msk,pos={85,356},size={51,23},proc=MSKFilePopMenuProc 
     1019        PopupMenu popup_msk,pos={85,356},size={51,23},proc=V_MSKFilePopMenuProc 
    10201020        PopupMenu popup_msk,mode=1,value= #"V_getMSKList()"      
    10211021                 
     
    11281128 
    11291129 
    1130 Function SAMFilePopMenuProc(pa) : PopupMenuControl 
     1130Function V_SAMFilePopMenuProc(pa) : PopupMenuControl 
    11311131        STRUCT WMPopupAction &pa 
    11321132 
     
    11461146 
    11471147 
    1148 Function BKGFilePopMenuProc(pa) : PopupMenuControl 
     1148Function V_BKGFilePopMenuProc(pa) : PopupMenuControl 
    11491149        STRUCT WMPopupAction &pa 
    11501150 
     
    11631163End 
    11641164 
    1165 Function EMPFilePopMenuProc(pa) : PopupMenuControl 
     1165Function V_EMPFilePopMenuProc(pa) : PopupMenuControl 
    11661166        STRUCT WMPopupAction &pa 
    11671167 
     
    11801180End 
    11811181 
    1182 Function DIVFilePopMenuProc(pa) : PopupMenuControl 
     1182Function V_DIVFilePopMenuProc(pa) : PopupMenuControl 
    11831183        STRUCT WMPopupAction &pa 
    11841184 
     
    11971197End 
    11981198 
    1199 Function MSKFilePopMenuProc(pa) : PopupMenuControl 
     1199Function V_MSKFilePopMenuProc(pa) : PopupMenuControl 
    12001200        STRUCT WMPopupAction &pa 
    12011201 
     
    19111911        //11 = unused 
    19121912 
     1913////////////////////////////// 
     1914// DIV 
     1915////////////////////////////// 
    19131916// for VSANS, DIV is used on each data file as it is converted to WORK, so it needs to be 
    19141917//  the first thing in place, before any data or backgrounds are loaded 
    19151918 
    1916  
    1917 // 
    1918 // DONE: 
    1919 // x- this is no longer done after the COR step, and CAL is not produced as output of DIV        
    1920 // x- needs to be aware of the file name passed in 
    1921 // x- PromptForPath does not exist in VSANS. Need a better (automated) way to find the file. 
    1922  
    1923 //check for work.div file (prot[2]) 
    1924 //load in if needed 
    1925 // no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) 
    1926 // 
    1927         String divFileName = "" 
    1928  
    1929         If(cmpstr("none",prot[2])!=0)           // if !0, then there's a file requested 
    1930                 If(cmpstr("ask",prot[2]) == 0) 
    1931                         //ask user for file 
    1932 //                       junkStr = PromptForPath("Select the detector sensitivity file") 
    1933                         Prompt divFileName,"DIV File",popup,V_GetDIVList() 
    1934                         DoPrompt "Select File",divFileName 
    1935  
    1936                         If(strlen(divFileName)==0) 
    1937                                 SetDataFolder root: 
    1938                                 Abort "No file selected, data reduction aborted" 
    1939                         Endif 
    1940                         V_LoadHDF5Data(divFileName,"DIV") 
    1941                 else 
    1942                         //assume it's a path, and that the first (and only) item is the path:file 
    1943                         //list processing is necessary to remove any final comma 
    1944                         junkStr = pathStr + StringFromList(0, prot[2],"," ) 
    1945                         V_LoadHDF5Data(junkStr,"DIV") 
    1946                 Endif 
    1947          
    1948         else 
    1949         // DIV step is being skipped 
    1950                 NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor 
    1951                 Variable saved_gDoDIVCor = gDoDIVCor 
    1952                 gDoDIVCor = 0                   // protocol says to turn it off for now (reset later) 
    1953         Endif 
    1954  
     1919        //check for work.div file (prot[2]) 
     1920        //load in if needed 
     1921        // no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) 
     1922        // 
     1923 
     1924        // save the state of the DIV preference 
     1925        NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor 
     1926        Variable saved_gDoDIVCor = gDoDIVCor 
     1927         
     1928        err = V_Proto_LoadDIV(prot[2]) 
     1929         
     1930        if(err) 
     1931                SetDataFolder root: 
     1932                Abort "No file selected, data reduction aborted" 
     1933        endif 
     1934 
     1935////////////////////////////// 
     1936// SAM 
     1937////////////////////////////// 
    19551938 
    19561939// TODO: 
     
    19631946        activeType = "SAM" 
    19641947        msgStr = "Select sample data" 
    1965         //Ask for SAM file or parse 
    1966         do 
    1967                 if((cmpstr(samStr,"ask") == 0) || (cmpstr(samStr,"")==0) )              //zero if strings are equal 
    1968                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    1969                         if(err) 
    1970                                 PathInfo/S catPathName 
    1971                                 Abort "reduction sequence aborted" 
    1972                         endif 
    1973                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    1974                         err =  V_Raw_to_work(activeType)                //this is the first file (default) 
    1975                         //Ask for another SAM file 
    1976                         do 
    1977                                 DoAlert 1,"Do you want to add another Sample file?" 
    1978                                 if(V_flag == 1)         //yes 
    1979                                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    1980                                         if(err) 
    1981                                                 PathInfo/S catPathName 
    1982                                                 Abort "reduction sequence aborted" 
    1983                                         endif 
    1984                                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    1985                                         err = V_Add_raw_to_work(activeType) 
    1986                                         notDone = 1 
    1987                                 else 
    1988                                         notDone = 0 
    1989                                 endif 
    1990                         while(notDone) 
    1991                         break 
    1992                 Endif 
    1993                 //"none" is not an option - you always need a sample file - "none" will never return zero 
    1994                 //if not "ask" AND not "none" then try to parse the filenames 
    1995                 If((cmpstr(samStr,"none") != 0) && (cmpstr(samStr,"ask") != 0)) 
    1996                         //filesOK = AreFilesThere(activeType,samStr)            //return 1 if correct files are already there 
    1997                         filesOK = 0             // Feb 2008, always force a reload of files. Maybe slow, but always correct  
    1998                         if(!filesOK) 
    1999                                 //add the correct file(s) to SAM 
    2000                                  
    2001                                 // TODO: only one file is allowed currently 
    2002                                 err = V_AddFilesInList(activeType,samStr) 
    2003                                  
    2004                                 if(err) 
    2005                                         //Print "samstr = ",samStr 
    2006                                         Abort "SAM file not found, reset SAM file" 
    2007                                 Endif 
    2008                         Endif 
    2009                 Endif 
    2010         While(0) 
     1948         
     1949        err = V_Proto_LoadFile(samStr,activeType,msgStr) 
     1950        if(err) 
     1951                PathInfo/S catPathName 
     1952                SetDataFolder root: 
     1953                Abort "No file selected, data reduction aborted" 
     1954        endif 
     1955         
    20111956        // TODO 
    20121957        // -- this may not be the most reliable way to pass the file name (for naming of the saved file later) 
     
    20161961        //always update 
    20171962        V_UpdateDisplayInformation(ActiveType) 
    2018          
    2019         //check for bkg file  -- "ask" might not fail - "ask?" will - ? not allowed in VAX filenames 
     1963 
     1964 
     1965////////////////////////////// 
     1966// BGD 
     1967////////////////////////////// 
     1968         
     1969        //check for BGD file  -- "ask" might not fail - "ask?" will - ? not allowed in VAX filenames 
    20201970        // add if needed 
    20211971        //use a "case" statement 
    20221972        msgStr = "Select background file" 
    20231973        activeType = "BGD" 
    2024         do 
    2025                 if(cmpstr(prot[0],"ask") == 0)          //zero if strings are equal 
    2026                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    2027                         if(err) 
    2028                                 PathInfo/S catPathName 
    2029                                 Abort "reduction sequence aborted" 
    2030                         endif 
    2031                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    2032                         err =  V_Raw_to_work(activeType)                //this is the first file (default) 
    2033                         //Ask for another BGD file 
    2034                         do 
    2035                                 DoAlert 1,"Do you want to add another Background file?" 
    2036                                 if(V_flag == 1)         //yes 
    2037                                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    2038                                         if(err) 
    2039                                                 PathInfo/S catPathName 
    2040                                                 Abort "reduction sequence aborted" 
    2041                                         endif 
    2042                                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    2043                                         err = V_Add_raw_to_work(activeType) 
    2044                                         notDone = 1 
    2045                                 else 
    2046                                         notDone = 0 
    2047                                 endif 
    2048                         while(notDone) 
    2049                         V_UpdateDisplayInformation(ActiveType)  //update before breaking from loop 
    2050                         break 
    2051                 Endif 
    2052                 If(cmpstr(prot[0],"none") == 0) 
    2053                         //clean out the BKG folder? 
    2054                         //KillDataFolder root:BKG 
    2055                         //NewDataFolder/O root:BKG 
    2056                         break 
    2057                 Endif 
    2058                 //if not "ask" AND not "none" then try to parse the filenames 
    2059                 If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[0],"ask") != 0)) 
    2060                         //filesOK = AreFilesThere(activeType,prot[0]) 
    2061                         filesOK = 0             // Feb 2008, always force a reload of files. Maybe slow, but always correct  
    2062                         if(!filesOK) 
    2063                                 //add the correct file(s) to BGD 
    2064                                 string bgdStr = prot[0] 
    2065                                 err = V_AddFilesInList(activeType,bgdStr) 
    2066                                 If(err) 
    2067                                         Abort "BGD file not found. Reset BGD file list" 
    2068                                 Endif 
    2069                         Endif 
    2070                         V_UpdateDisplayInformation(ActiveType)          //update before breaking from loop 
    2071                 Endif 
    2072         While(0) 
    2073          
     1974         
     1975        err = V_Proto_LoadFile(prot[0],activeType,msgStr) 
     1976        if(err) 
     1977                PathInfo/S catPathName 
     1978                SetDataFolder root: 
     1979                Abort "No file selected, data reduction aborted" 
     1980        endif 
     1981 
     1982//      //Loader is in charge of updating, since it knows if data was loaded 
     1983//      V_UpdateDisplayInformation(ActiveType) 
     1984 
     1985 
     1986////////////////////////////// 
     1987// EMP 
     1988//////////////////////////////   
    20741989         
    20751990        //check for emp file (prot[1]) 
     
    20771992        msgStr = "Select empty cell data" 
    20781993        activeType = "EMP" 
    2079         do 
    2080                 if(cmpstr(prot[1],"ask") == 0) 
    2081                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    2082                         if(err) 
    2083                                 PathInfo/S catPathName 
    2084                                 Abort "reduction sequence aborted" 
    2085                         endif 
    2086                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    2087                         err =  V_Raw_to_work(activeType)                //this is the first file (default) 
    2088                         //Ask for another EMP file 
    2089                         do 
    2090                                 DoAlert 1,"Do you want to add another Empty Cell file?" 
    2091                                 if(V_flag == 1)         //yes 
    2092                                         err = V_LoadHDF5Data("","RAW")          //will prompt for file 
    2093                                         if(err) 
    2094                                                 PathInfo/S catPathName 
    2095                                                 Abort "reduction sequence aborted" 
    2096                                         endif 
    2097                                         V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
    2098                                         err = V_Add_raw_to_work(activeType) 
    2099                                         notDone = 1 
    2100                                 else 
    2101                                         notDone = 0 
    2102                                 endif 
    2103                         while(notDone) 
    2104                         V_UpdateDisplayInformation(ActiveType)          //update before breaking from loop 
    2105                         break 
    2106                 Endif 
    2107                 If(cmpstr(prot[1],"none") == 0) 
    2108                         //clean out the EMP folder? 
    2109                         //KillDataFolder root:Packages:NIST:EMP 
    2110                         //NewDataFolder/O root:Packages:NIST:EMP 
    2111                         break 
    2112                 Endif 
    2113                 //if not "ask" AND not "none" then try to parse the filenames 
    2114                 If((cmpstr(prot[1],"none") != 0) && (cmpstr(prot[1],"ask") != 0)) 
    2115                         //filesOK = AreFilesThere(activeType,prot[1]) 
    2116                         filesOK = 0             // Feb 2008, always force a reload of files. Maybe slow, but always correct  
    2117                         if(!filesOK) 
    2118                                 //add the correct file(s) to BGD 
    2119                                 err = V_AddFilesInList(activeType,prot[1]) 
    2120                                 If(err) 
    2121                                         Abort "EMP file not found. Reset EMP file list" 
    2122                                 Endif 
    2123                         Endif 
    2124                         V_UpdateDisplayInformation(ActiveType)  //update before breaking from loop 
    2125                 Endif 
    2126         While(0) 
    2127          
     1994         
     1995        err = V_Proto_LoadFile(prot[1],activeType,msgStr) 
     1996        if(err) 
     1997                PathInfo/S catPathName 
     1998                SetDataFolder root: 
     1999                Abort "No file selected, data reduction aborted" 
     2000        endif 
     2001 
     2002//      //Loader is in charge of updating, since it knows if data was loaded 
     2003//      V_UpdateDisplayInformation(ActiveType) 
     2004 
     2005 
     2006////////////////////////////// 
     2007// CORRECT 
     2008////////////////////////////// 
     2009 
    21282010        //do the CORRECT step based on the answers to emp and bkg subtraction 
    21292011        //by setting the proper"mode" 
     
    21632045//      endif 
    21642046 
    2165  
    2166          
    21672047        //dispatch to the proper "mode" of Correct() 
    2168         Variable mode=4,val 
    2169         do 
    2170                 if( (cmpstr("none",prot[0]) == 0)       && (cmpstr("none",prot[1]) == 0) ) 
    2171                         //no subtraction (mode = 4), 
    2172                         mode = 4 
    2173                 Endif 
    2174                 If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") == 0)) 
    2175                         //subtract BGD only 
    2176                         mode=2 
    2177                 Endif 
    2178                 If((cmpstr(prot[0],"none") == 0) && (cmpstr(prot[1],"none") != 0)) 
    2179                         //subtract EMP only 
    2180                         mode=3 
    2181                 Endif 
    2182                 If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") != 0)) 
    2183                         // bkg and emp subtraction are to be done (BOTH not "none") 
    2184                         mode=1 
    2185                 Endif 
    2186                 activeType = "COR" 
    2187                 //add in DRK mode (0= no used, 10 = used) 
    2188                 val = NumberByKey("DRKMODE",prot[6],"=","," ) 
    2189                 mode += val 
    2190 //              print "mode = ",mode 
    2191                 err = V_Correct(mode) 
    2192                 if(err) 
    2193                         SetDataFolder root: 
    2194                         Abort "error in Correct, called from executeprotocol, normal cor" 
    2195                 endif 
    2196                 V_UpdateDisplayInformation(ActiveType)          //update before breaking from loop 
    2197         While(0) 
    2198  
    2199  
    2200 //////////////////////////////////////////////////////// 
    2201 // Absolute scale 
    2202  
    2203 // x- calculation works, needs proper inputs (solid angle aware) 
    2204 // x-   Open beam method needs to be verified in V_AskForAbsoluteParams_Quest() 
    2205         Variable c2,c3,c4,c5,kappa_err 
    2206         //do absolute scaling if desired 
    2207 //              DoAlert 0,"Abs step incomplete" 
    2208  
    2209         if(cmpstr("none",prot[4])!=0) 
    2210                 if(cmpstr("ask",prot[4])==0) 
    2211                         //get the params from the user 
    2212                         Execute "V_AskForAbsoluteParams_Quest()" 
    2213                         //then from the list 
    2214                         SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr 
    2215                         c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";")        //parse the list of values 
    2216                         c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";") 
    2217                         c4 = NumberByKey("IZERO", junkAbsStr, "=", ";") 
    2218                         c5 = NumberByKey("XSECT", junkAbsStr, "=", ";") 
    2219                         kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";") 
    2220                 else 
    2221                         //get the parames from the list 
    2222                         c2 = NumberByKey("TSTAND", prot[4], "=", ";")   //parse the list of values 
    2223                         c3 = NumberByKey("DSTAND", prot[4], "=", ";") 
    2224                         c4 = NumberByKey("IZERO", prot[4], "=", ";") 
    2225                         c5 = NumberByKey("XSECT", prot[4], "=", ";") 
    2226                         kappa_err = NumberByKey("SDEV", prot[4], "=", ";") 
    2227                 Endif 
    2228                 //get the sample trans and thickness from the activeType folder 
    2229                 Variable c0 = V_getSampleTransmission(activeType)               //sample transmission 
    2230                 Variable c1 = V_getSampleThickness(activeType)          //sample thickness 
    2231                  
    2232                 err = V_Absolute_Scale(activeType,c0,c1,c2,c3,c4,c5,kappa_err) 
    2233                 if(err) 
    2234                         SetDataFolder root: 
    2235                         Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" 
    2236                 endif 
    2237                 activeType = "ABS" 
    2238                 V_UpdateDisplayInformation(ActiveType)                  //update before breaking from loop 
    2239         Endif 
    2240  
     2048//      V_Dispatch_to_Correct(bgdStr,empStr,drkStr) 
     2049        V_Dispatch_to_Correct(prot[0],prot[1],prot[6]) 
     2050         
     2051        if(err) 
     2052                PathInfo/S catPathName 
     2053                SetDataFolder root: 
     2054                Abort "error in Correct, called from executeprotocol, normal cor" 
     2055        endif 
     2056        activeType = "COR" 
     2057 
     2058// always update - COR will always be generated 
     2059        V_UpdateDisplayInformation(ActiveType)           
     2060 
     2061 
     2062////////////////////////////// 
     2063//  ABSOLUTE SCALE 
     2064////////////////////////////// 
     2065 
     2066        err = V_Proto_ABS_Scale(prot[4],activeType)             //activeType is pass-by-reference and updated IF ABS is used 
     2067         
     2068        if(err) 
     2069                SetDataFolder root: 
     2070                Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" 
     2071        endif 
     2072//      activeType = "ABS" 
     2073 
     2074 
     2075////////////////////////////// 
     2076// MASK 
     2077////////////////////////////// 
    22412078// 
    22422079// DONE 
     
    22452082// x- the regular case of the file name specified by the protocol works correctly 
    22462083// x- don't create a null mask if not used, it will handle the error and print out that the mask is missing 
    2247  
    2248 //mask data if desired (this is done automatically when the data is binned to I(q)) and is 
     2084// 
     2085//mask data if desired (mask is applied when the data is binned to I(q)) and is 
    22492086//not done explicitly here 
    22502087         
    22512088        //check for mask 
    22522089        //doesn't change the activeType 
    2253         String mskFileName="" 
    2254          
    2255         if(cmpstr("none",prot[3])!=0) 
    2256                 If(cmpstr("ask",prot[3])==0) 
    2257                         //get file from user 
    2258                         // x- fill in the get file prompt, and handle the result 
    2259                         Prompt mskFileName,"MASK File",popup,V_PickMASKButton("") 
    2260                         DoPrompt "Select File",mskFileName 
    2261 //                      if (V_Flag) 
    2262 //                              return 0                                                                        // user cancelled 
    2263 //                      endif 
    2264  
    2265                         If(strlen(mskFileName)==0)              //use cancelled 
    2266                                 //if none desired, make sure that the old mask is deleted 
    2267                                 KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
    2268                                 NewDataFolder/O root:Packages:NIST:VSANS:MSK 
    2269                                  
    2270                                 DoAlert 0,"No Mask file selected, data not masked" 
    2271                         else 
    2272                                 //read in the file from the selection 
    2273                                 V_LoadHDF5Data(mskFileName,"MSK") 
    2274                         Endif 
    2275                 else 
    2276                         //just read it in from the protocol 
    2277                         //list processing is necessary to remove any final comma 
    2278                         mskFileName = pathStr + StringFromList(0, prot[3],"," ) 
    2279                         V_LoadHDF5Data(mskFileName,"MSK") 
    2280                 Endif 
    2281                  
    2282         else 
    2283                 //if none desired, make sure that the old mask is deleted 
    2284 // TODO 
    2285 // x- clean out the data folder 
    2286 // x- note that V_KillNamedDataFolder() points to RawVSANS, and won't work 
    2287 // -- what happens if the kill fails? need error handling 
    2288 // 
    2289                 KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
    2290                 NewDataFolder/O root:Packages:NIST:VSANS:MSK 
    2291  
    2292         Endif 
    2293          
     2090        V_Proto_ReadMask(prot[3]) 
     2091 
     2092         
     2093////////////////////////////// 
     2094// AVERAGING 
     2095////////////////////////////// 
    22942096 
    22952097        // average/save data as specified 
     
    23102112                Endif 
    23112113        Endif 
     2114 
     2115 
     2116        String detGroup = StringByKey("DETGROUP",prot[5],"=",";")               //only for annular, null if not present 
     2117 
    23122118         
    23132119//convert the folder to linear scale before averaging, then revert by calling the window hook 
    23142120// (not needed for VSANS, data is always linear scale) 
    2315  
    2316 // 
    2317 //       x- need to convert BINTYPE keyword into a numerical value to pass 
    2318 // 
    23192121 
    23202122// 
     
    23492151        String collimationStr 
    23502152        collimationStr = V_IdentifyCollimation(activeType) 
    2351  
    2352  
     2153         
    23532154 
    23542155//////////////////////////////////////// 
    2355 // dispatch to averaging and resolution 
     2156// DISPATCH TO AVERAGING 
    23562157///////////////////////////////////////// 
    23572158// 
    23582159// TODO: 
    2359 // -- do I calculate the proper resolution here? I've already decoded the binning type 
     2160// -- do I calculate the proper resolution here?, YES, I've already decoded the binning type 
    23602161//   and the averaging type has been specified by the protocol. 
    23612162// 
    2362 // currently, the resolution is calculated every time that the data is averaged (in VC_fDoBinning_QxQy2D) 
     2163// so currently, the resolution is calculated every time that the data is averaged (in VC_fDoBinning_QxQy2D) 
    23632164// 
    23642165// -- if I calculate the resolution here, then the Trimming routines must be updated 
     
    23672168//    a different solution 
    23682169// 
    2369         strswitch(av_type)      //dispatch to the proper routine to average to 1D data 
    2370                 case "none":             
    2371                         //still do nothing 
    2372                         // set binType and binTypeStr to bad flags 
    2373                         binTypeStr = "none" 
    2374                         binType = -999999 
    2375                         break                    
    2376  
    2377                 case "Circular": 
    2378                         V_QBinAllPanels_Circular(activeType,binType,collimationStr)             // this does a default circular average 
    2379                         break 
    2380                          
    2381                 case "Sector": 
    2382 //                      CircularAverageTo1D(activeType) 
    2383                         break 
    2384                 case "Sector_PlusMinus": 
    2385 //                      Sector_PlusMinus1D(activeType) 
    2386                         break 
    2387                 case "Rectangular": 
    2388 //                      RectangularAverageTo1D(activeType) 
    2389                         break 
    2390  
    2391                 case "Annular": 
    2392                         String detGroup = StringByKey("DETGROUP",prot[5],"=",";") 
    2393                         Variable qCtr_Ann = NumberByKey("QCENTER",prot[5],"=",";") 
    2394                         Variable qWidth = NumberByKey("QDELTA",prot[5],"=",";") 
    2395                         V_QBinAllPanels_Annular(activeType,detGroup,qCtr_Ann,qWidth) 
    2396                         break 
    2397  
    2398                 case "Narrow_Slit": 
    2399                         V_QBinAllPanels_Slit(activeType,binType)                // this does a tall, narrow slit average 
    2400                         break 
    2401                          
    2402                 case "2D_ASCII":         
    2403                         //do nothing 
    2404                         break 
    2405                 case "QxQy_ASCII": 
    2406                         //do nothing 
    2407                         break 
    2408                 case "PNG_Graphic": 
    2409                         //do nothing 
    2410                         break 
    2411                 default:         
    2412                         //do nothing 
    2413         endswitch 
     2170 
     2171        V_Proto_doAverage(prot[5],av_type,activeType,binType,collimationStr) 
    24142172 
    24152173 
    24162174 
    24172175//////////////////////// 
    2418 // plotting of the data, another strswitch (with an if() out front) 
     2176// PLOT THE DATA 
    24192177//////////////////////// 
    24202178 
    2421         String doPlot = StringByKey("PLOT",prot[5],"=",";") 
    2422          
    2423         If( (cmpstr(doPlot,"Yes")==0) && (cmpstr(av_type,"none") != 0) )         
    2424                  
    2425                 strswitch(av_type)      //dispatch to the proper routine to PLOT 1D data 
    2426                         case "none":             
    2427                                 //still do nothing 
    2428                                 break                    
    2429  
    2430                         case "Circular": 
    2431                                 V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
    2432                                 V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned                              
    2433                                 break 
    2434                         case "Sector": 
    2435         //                      CircularAverageTo1D(activeType) 
    2436                                 break 
    2437                         case "Sector_PlusMinus": 
    2438         //                      Sector_PlusMinus1D(activeType) 
    2439                                 break 
    2440                         case "Rectangular": 
    2441         //                      RectangularAverageTo1D(activeType) 
    2442                                 break 
    2443  
    2444                         case "Annular": 
    2445                                 V_Phi_Graph_Proc(activeType,detGroup) 
    2446                                 break 
    2447  
    2448                         case "Narrow_Slit": 
    2449                         // these are the same plotting routines as for standard circular average 
    2450                                 V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
    2451                                 V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned 
    2452                                 break 
    2453                          
    2454                         case "2D_ASCII":         
    2455                                 //do nothing 
    2456                                 break 
    2457                         case "QxQy_ASCII": 
    2458                                 //do nothing 
    2459                                 break 
    2460                         case "PNG_Graphic": 
    2461                                 //do nothing 
    2462                                 break 
    2463                         default:         
    2464                                 //do nothing 
    2465                 endswitch 
    2466  
    2467         endif           // end of plotting switch 
    2468  
    2469  
     2179        V_Proto_doPlot(prot[5],av_type,activeType,binType,detGroup) 
     2180         
     2181         
    24702182 
    24712183////////////////////     
    2472 //save data if desired - dispatch as needed 
     2184// SAVE THE DATA 
    24732185//////////////////// 
    24742186 
     
    24772189//    local variable samFileLoaded is the file name loaded (contains the extension) 
    24782190// 
    2479         String fullpath = "", newfileName="" 
    2480         String saveType = StringByKey("SAVE",prot[5],"=",";")           //does user want to save data? 
    2481  
    2482         If( (cmpstr(saveType[0,2],"Yes")==0) && (cmpstr(av_type,"none") != 0) )          
    2483                 //then save 
    2484                 newFileName = RemoveEnding(samFileLoaded,".nxs.ngv") 
    2485                  
    2486                 //pick ABS or AVE extension 
    2487                 String exten = activeType 
    2488                 if(cmpstr(exten,"ABS") != 0) 
    2489                         exten = "AVE" 
    2490                 endif 
    2491 //              if(cmpstr(av_type,"2D_ASCII") == 0) 
    2492 //                      exten = "ASC" 
    2493 //              endif 
    2494 //              if(cmpstr(av_type,"QxQy_ASCII") == 0) 
    2495 //                      exten = "DAT" 
    2496 //              endif 
    2497                  
    2498 //              // add an "x" to the file extension if the output is XML 
    2499 //              // currently (2010), only for ABS and AVE (1D) output 
    2500 //              if( cmpstr(exten,"ABS") == 0 || cmpstr(exten,"AVE") == 0 ) 
    2501 //                      if(useXMLOutput == 1) 
    2502 //                              exten += "x" 
    2503 //                      endif 
    2504 //              endif 
    2505                                  
    2506                 //Path is catPathName, symbolic path 
    2507                 //if this doesn't exist, a dialog will be presented by setting dialog = 1 
    2508                 // 
    2509                 Variable dialog = 0 
    2510  
    2511                 PathInfo/S catPathName 
    2512                 String item = StringByKey("NAME",prot[5],"=",";")               //Auto or Manual naming 
    2513                 String autoname = StringByKey("AUTONAME",prot[5],"=",";")               //autoname -  will get empty string if not present 
    2514                 If((cmpstr(item,"Manual")==0) || (cmpstr(newFileName,"") == 0)) 
    2515                         //manual name if requested or if no name can be derived from header 
    2516                         fullPath = newfileName + "."+ exten //puts possible new name or null string in dialog 
    2517                         dialog = 1              //force dialog for user to enter name 
    2518                 else 
    2519                         //auto-generate name and prepend path - won't put up any dialogs since it has all it needs 
    2520                         //use autoname if present 
    2521                         if (cmpstr(autoname,"") != 0) 
    2522                                 fullPath = S_Path + autoname + "." +exten 
    2523                         else 
    2524                                 fullPath = S_Path + newFileName+"." + exten 
    2525                         endif    
    2526                 Endif 
    2527                 // 
    2528                 strswitch(av_type)       
    2529                         case "Annular": 
    2530                                 V_fWrite1DAnnular("root:Packages:NIST:VSANS:",activeType,detGroup,newFileName+".phi") 
    2531                                 Print "data written to:  "+ newFileName+".phi" 
    2532  
    2533                                 break 
    2534  
    2535                         case "Circular":                //in SANS, this was the default, but is dangerous, so make it explicit here 
    2536                         case "Sector":          // TODO: this falls through - which luckily works for now... 
    2537                         case "Rectangular":             // TODO: this falls through - which luckily works for now... 
    2538                         case "Narrow_Slit":             // TODO: this falls through - which luckily works for now... 
    2539  
    2540 // no VSANS support of XML output at this point                  
    2541 //                              if (useXMLOutput == 1) 
    2542 //                                      WriteXMLWaves_W_Protocol(activeType,fullPath,dialog) 
    2543 //                              else 
    2544 //                                      WriteWaves_W_Protocol(activeType,fullpath,dialog) 
    2545 //                              endif 
    2546 // 
    2547                                 if(cmpstr(saveType,"Yes - Concatenate")==0) 
    2548                                         V_Trim1DDataStr(activeType,binType,prot[7],prot[8])                     // x- passing null strings uses global or default trim values 
    2549  
    2550                                         V_ConcatenateForSave("root:Packages:NIST:VSANS:",activeType,"",binType)         // this removes q=0 point, concatenates, sorts 
    2551                                  
    2552                                         prot[9] = collimationStr 
    2553                                          
    2554                                         V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten)             //don't pass the full path, just the name 
    2555                                  
    2556                                 endif 
    2557                                  
    2558                                 if(cmpstr(saveType,"Yes - Individual")==0) 
    2559                                         // remove the q=0 point from the back detector, if it's there 
    2560                                         // does not trim any other points from the data 
    2561                                         V_RemoveQ0_B(activeType) 
    2562                                         V_Write1DData_ITX("root:Packages:NIST:VSANS:",activeType,newFileName,binType) 
    2563                                 endif 
    2564                                 Print "data written to:  "+ newFileName+"."+exten 
    2565  
    2566                                 break 
    2567          
    2568                                  
    2569                                 case "2D_ASCII": 
    2570 //                              Fast2DExport(activeType,fullPath,dialog) 
    2571                                 break 
    2572                         case "QxQy_ASCII": 
    2573 //                              QxQy_Export(activeType,fullPath,dialog) 
    2574                                 break 
    2575                         case "PNG_Graphic": 
    2576 //                              SaveAsPNG(activeType,fullpath,dialog) 
    2577                                 break 
    2578  
    2579                         default: 
    2580                                 DoAlert 0, "av_type not found in dispatch to write file" 
    2581                 endswitch 
    2582                  
    2583         Endif 
    2584          
    2585         //done with everything in protocol list 
    2586          
     2191// V_Proto_SaveFile(avgStr,activeType,samFileLoaded,av_type,binType,detGroup,trimBegStr,trimEndStr) 
     2192 
     2193        prot[9] = collimationStr 
     2194 
     2195        V_Proto_SaveFile(prot[5],activeType,samFileLoaded,av_type,binType,detGroup,prot[7],prot[8]) 
     2196         
     2197////////////////////////////// 
     2198// DONE WITH THE PROTOCOL 
     2199//////////////////////////////   
    25872200         
    25882201        // reset any global preferences that I had changed 
     
    30302643        return(0) 
    30312644end 
     2645 
     2646 
     2647/////////////////////////////////////// 
     2648// 
     2649// individual steps in the protocol 
     2650// 
     2651////////////////////////////////////// 
     2652 
     2653Function V_Proto_LoadDIV(protStr) 
     2654        String protStr 
     2655         
     2656        String divFileName = "",junkStr="",pathStr="" 
     2657        PathInfo catPathName                    //this is where the files are 
     2658        pathStr=S_path 
     2659 
     2660        If(cmpstr("none",protStr)!=0)           // if !0, then there's a file requested 
     2661                If(cmpstr("ask",protStr) == 0) 
     2662                        //ask user for file 
     2663//                       junkStr = PromptForPath("Select the detector sensitivity file") 
     2664                        Prompt divFileName,"DIV File",popup,V_GetDIVList() 
     2665                        DoPrompt "Select File",divFileName 
     2666 
     2667                        If(strlen(divFileName)==0) 
     2668                                // 
     2669                                return(1)               //error 
     2670//                              SetDataFolder root: 
     2671//                              Abort "No file selected, data reduction aborted" 
     2672                        Endif 
     2673                        V_LoadHDF5Data(divFileName,"DIV") 
     2674                else 
     2675                        //assume it's a path, and that the first (and only) item is the path:file 
     2676                        //list processing is necessary to remove any final comma 
     2677                        junkStr = pathStr + StringFromList(0, protStr,"," ) 
     2678                        V_LoadHDF5Data(junkStr,"DIV") 
     2679                Endif 
     2680         
     2681        else 
     2682        // DIV step is being skipped 
     2683                NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor 
     2684//              Variable saved_gDoDIVCor = gDoDIVCor 
     2685                gDoDIVCor = 0                   // protocol says to turn it off for now (reset later) 
     2686        Endif 
     2687         
     2688        return(0) 
     2689End 
     2690 
     2691// 
     2692// fileStr is the file name (or list of names) 
     2693// activeType is the target work folder 
     2694// msgStr is the string for the prompt 
     2695// 
     2696Function V_Proto_LoadFile(fileStr,activeType,msgStr) 
     2697        String fileStr,activeType,msgStr 
     2698         
     2699        Variable err,filesOK,notDone 
     2700         
     2701        //Ask for Type file or parse 
     2702        do 
     2703                if((cmpstr(fileStr,"ask") == 0) || (cmpstr(fileStr,"")==0) )            //zero if strings are equal 
     2704                        err = V_LoadHDF5Data("","RAW")          //will prompt for file 
     2705                        if(err) 
     2706                                return(err)     //error 
     2707                                //PathInfo/S catPathName 
     2708                                //Abort "reduction sequence aborted" 
     2709                        endif 
     2710                        V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
     2711                        err =  V_Raw_to_work(activeType)                //this is the first file (default) 
     2712                        //Ask for another TYPE file 
     2713                        do 
     2714                                DoAlert 1,"Do you want to add another "+activeType+" file?" 
     2715                                if(V_flag == 1)         //yes 
     2716                                        err = V_LoadHDF5Data("","RAW")          //will prompt for file 
     2717                                        if(err) 
     2718                                                return(1)               //error 
     2719                                                //PathInfo/S catPathName 
     2720                                                //Abort "reduction sequence aborted" 
     2721                                        endif 
     2722                                        V_UpdateDisplayInformation("RAW")                       //display the new type of data that was loaded 
     2723                                        err = V_Add_raw_to_work(activeType) 
     2724                                        notDone = 1 
     2725                                else 
     2726                                        notDone = 0 
     2727                                endif 
     2728                        while(notDone) 
     2729                        //Loader is in charge of updating, since it knows if data was loaded 
     2730                        V_UpdateDisplayInformation(ActiveType) 
     2731                        break 
     2732                Endif 
     2733                //"none" is not an option - you always need a sample file - "none" will never return zero 
     2734                //if not "ask" AND not "none" then try to parse the filenames 
     2735                If((cmpstr(fileStr,"none") != 0) && (cmpstr(fileStr,"ask") != 0)) 
     2736                        //filesOK = AreFilesThere(activeType,fileStr)           //return 1 if correct files are already there 
     2737                        filesOK = 0             // Feb 2008, always force a reload of files. Maybe slow, but always correct  
     2738                        if(!filesOK) 
     2739                                //add the correct file(s) to Type 
     2740                                 
     2741                                // TODO: only one file is allowed currently 
     2742                                err = V_AddFilesInList(activeType,fileStr) 
     2743                                 
     2744                                if(err) 
     2745                                        //Print "fileStr = ",fileStr 
     2746                                        DoAlert 0, fileStr + " file not found, reset file" 
     2747                                        return(err)             //error 
     2748                                Endif 
     2749                        Endif 
     2750                        //Loader is in charge of updating, since it knows if data was loaded 
     2751                        V_UpdateDisplayInformation(ActiveType) 
     2752                Endif 
     2753        While(0) 
     2754         
     2755 
     2756         
     2757        return(0) 
     2758End 
     2759 
     2760Function V_Dispatch_to_Correct(bgdStr,empStr,drkStr) 
     2761        String bgdStr,empStr,drkStr 
     2762         
     2763        Variable mode=4,val,err 
     2764         
     2765        if( (cmpstr("none",bgdStr) == 0)        && (cmpstr("none",empStr) == 0) ) 
     2766        //no subtraction (mode = 4), 
     2767                mode = 4 
     2768        Endif 
     2769        If((cmpstr(bgdStr,"none") != 0) && (cmpstr(empStr,"none") == 0)) 
     2770                //subtract BGD only 
     2771                mode=2 
     2772        Endif 
     2773        If((cmpstr(bgdStr,"none") == 0) && (cmpstr(empStr,"none") != 0)) 
     2774                //subtract EMP only 
     2775                mode=3 
     2776        Endif 
     2777        If((cmpstr(bgdStr,"none") != 0) && (cmpstr(empStr,"none") != 0)) 
     2778                // bkg and emp subtraction are to be done (BOTH not "none") 
     2779                mode=1 
     2780        Endif 
     2781//      activeType = "COR" 
     2782        //add in DRK mode (0= not used, 10 = used) 
     2783        val = NumberByKey("DRKMODE",drkStr,"=","," ) 
     2784        mode += val 
     2785//              print "mode = ",mode 
     2786        err = V_Correct(mode) 
     2787        if(err) 
     2788                return(err) 
     2789//              SetDataFolder root: 
     2790//              Abort "error in Correct, called from executeprotocol, normal cor" 
     2791        endif 
     2792 
     2793//      //Loader is in charge of updating, since it knows if data was loaded 
     2794//      V_UpdateDisplayInformation("COR") 
     2795 
     2796         
     2797        return(0) 
     2798End 
     2799 
     2800 
     2801 
     2802 
     2803Function V_Proto_ABS_Scale(absStr,activeType) 
     2804        String absStr,&activeType 
     2805         
     2806        Variable c2,c3,c4,c5,kappa_err,err 
     2807        //do absolute scaling if desired 
     2808//              DoAlert 0,"Abs step incomplete" 
     2809 
     2810        if(cmpstr("none",absStr)!=0) 
     2811                if(cmpstr("ask",absStr)==0) 
     2812                        //get the params from the user 
     2813                        Execute "V_AskForAbsoluteParams_Quest()" 
     2814                        //then from the list 
     2815                        SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr 
     2816                        c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";")        //parse the list of values 
     2817                        c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";") 
     2818                        c4 = NumberByKey("IZERO", junkAbsStr, "=", ";") 
     2819                        c5 = NumberByKey("XSECT", junkAbsStr, "=", ";") 
     2820                        kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";") 
     2821                else 
     2822                        //get the parames from the list 
     2823                        c2 = NumberByKey("TSTAND", absStr, "=", ";")    //parse the list of values 
     2824                        c3 = NumberByKey("DSTAND", absStr, "=", ";") 
     2825                        c4 = NumberByKey("IZERO", absStr, "=", ";") 
     2826                        c5 = NumberByKey("XSECT", absStr, "=", ";") 
     2827                        kappa_err = NumberByKey("SDEV", absStr, "=", ";") 
     2828                Endif 
     2829                //get the sample trans and thickness from the activeType folder 
     2830                Variable c0 = V_getSampleTransmission(activeType)               //sample transmission 
     2831                Variable c1 = V_getSampleThickness(activeType)          //sample thickness 
     2832                 
     2833                err = V_Absolute_Scale(activeType,c0,c1,c2,c3,c4,c5,kappa_err) 
     2834                if(err) 
     2835                        return(err) 
     2836                        SetDataFolder root: 
     2837                        Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" 
     2838                endif 
     2839                activeType = "ABS" 
     2840                V_UpdateDisplayInformation(ActiveType)                  //update before breaking from loop 
     2841        Endif 
     2842         
     2843        return(0) 
     2844End 
     2845 
     2846 
     2847Function V_Proto_ReadMask(maskStr) 
     2848        String maskStr 
     2849         
     2850        //check for mask 
     2851        //doesn't change the activeType 
     2852        String mskFileName="",pathStr="" 
     2853        PathInfo catPathName                    //this is where the files are 
     2854        pathStr=S_path 
     2855                 
     2856        if(cmpstr("none",maskStr)!=0) 
     2857                If(cmpstr("ask",maskStr)==0) 
     2858                        //get file from user 
     2859                        // x- fill in the get file prompt, and handle the result 
     2860                        Prompt mskFileName,"MASK File",popup,V_PickMASKButton("") 
     2861                        DoPrompt "Select File",mskFileName 
     2862//                      if (V_Flag) 
     2863//                              return 0                                                                        // user cancelled 
     2864//                      endif 
     2865 
     2866                        If(strlen(mskFileName)==0)              //use cancelled 
     2867                                //if none desired, make sure that the old mask is deleted 
     2868                                KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
     2869                                NewDataFolder/O root:Packages:NIST:VSANS:MSK 
     2870                                 
     2871                                DoAlert 0,"No Mask file selected, data not masked" 
     2872                        else 
     2873                                //read in the file from the selection 
     2874                                V_LoadHDF5Data(mskFileName,"MSK") 
     2875                        Endif 
     2876                else 
     2877                        //just read it in from the protocol 
     2878                        //list processing is necessary to remove any final comma 
     2879                        mskFileName = pathStr + StringFromList(0, maskStr,"," ) 
     2880                        V_LoadHDF5Data(mskFileName,"MSK") 
     2881                Endif 
     2882                 
     2883        else 
     2884                //if none desired, make sure that the old mask is deleted 
     2885// TODO 
     2886// x- clean out the data folder 
     2887// x- note that V_KillNamedDataFolder() points to RawVSANS, and won't work 
     2888// -- what happens if the kill fails? need error handling 
     2889// 
     2890                KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
     2891                NewDataFolder/O root:Packages:NIST:VSANS:MSK 
     2892 
     2893        Endif 
     2894         
     2895        return(0) 
     2896End 
     2897 
     2898 
     2899Function V_Proto_doAverage(avgStr,av_type,activeType,binType,collimationStr) 
     2900        String avgStr,av_type,activeType 
     2901        Variable binType 
     2902        String collimationStr 
     2903         
     2904         
     2905        strswitch(av_type)      //dispatch to the proper routine to average to 1D data 
     2906                case "none":             
     2907                        //still do nothing 
     2908                        // set binType and binTypeStr to bad flags 
     2909                        String binTypeStr = "none" 
     2910                        binType = -999999 
     2911                        break                    
     2912 
     2913                case "Circular": 
     2914                        V_QBinAllPanels_Circular(activeType,binType,collimationStr)             // this does a default circular average 
     2915                        break 
     2916                         
     2917                case "Sector": 
     2918//                      CircularAverageTo1D(activeType) 
     2919                        break 
     2920                case "Sector_PlusMinus": 
     2921//                      Sector_PlusMinus1D(activeType) 
     2922                        break 
     2923                case "Rectangular": 
     2924//                      RectangularAverageTo1D(activeType) 
     2925                        break 
     2926 
     2927                case "Annular": 
     2928                        String detGroup = StringByKey("DETGROUP",avgStr,"=",";") 
     2929                        Variable qCtr_Ann = NumberByKey("QCENTER",avgStr,"=",";") 
     2930                        Variable qWidth = NumberByKey("QDELTA",avgStr,"=",";") 
     2931                        V_QBinAllPanels_Annular(activeType,detGroup,qCtr_Ann,qWidth) 
     2932                        break 
     2933 
     2934                case "Narrow_Slit": 
     2935                        V_QBinAllPanels_Slit(activeType,binType)                // this does a tall, narrow slit average 
     2936                        break 
     2937                         
     2938                case "2D_ASCII":         
     2939                        //do nothing 
     2940                        break 
     2941                case "QxQy_ASCII": 
     2942                        //do nothing 
     2943                        break 
     2944                case "PNG_Graphic": 
     2945                        //do nothing 
     2946                        break 
     2947                default:         
     2948                        //do nothing 
     2949        endswitch 
     2950 
     2951         
     2952        return(0) 
     2953End 
     2954 
     2955 
     2956 
     2957 
     2958 
     2959Function V_Proto_doPlot(plotStr,av_type,activeType,binType,detGroup) 
     2960        String plotStr,av_type,activeType 
     2961        Variable binType 
     2962        String detGroup 
     2963         
     2964        String doPlot = StringByKey("PLOT",plotStr,"=",";") 
     2965         
     2966        If( (cmpstr(doPlot,"Yes")==0) && (cmpstr(av_type,"none") != 0) )         
     2967                 
     2968                strswitch(av_type)      //dispatch to the proper routine to PLOT 1D data 
     2969                        case "none":             
     2970                                //still do nothing 
     2971                                break                    
     2972 
     2973                        case "Circular": 
     2974                                V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     2975                                V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned                              
     2976                                break 
     2977                        case "Sector": 
     2978        //                      CircularAverageTo1D(activeType) 
     2979                                break 
     2980                        case "Sector_PlusMinus": 
     2981        //                      Sector_PlusMinus1D(activeType) 
     2982                                break 
     2983                        case "Rectangular": 
     2984        //                      RectangularAverageTo1D(activeType) 
     2985                                break 
     2986 
     2987                        case "Annular": 
     2988                                V_Phi_Graph_Proc(activeType,detGroup) 
     2989                                break 
     2990 
     2991                        case "Narrow_Slit": 
     2992                        // these are the same plotting routines as for standard circular average 
     2993                                V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     2994                                V_Update1D_Graph(activeType,binType)            //update the graph, data was already binned 
     2995                                break 
     2996                         
     2997                        case "2D_ASCII":         
     2998                                //do nothing 
     2999                                break 
     3000                        case "QxQy_ASCII": 
     3001                                //do nothing 
     3002                                break 
     3003                        case "PNG_Graphic": 
     3004                                //do nothing 
     3005                                break 
     3006                        default:         
     3007                                //do nothing 
     3008                endswitch 
     3009 
     3010        endif           // end of plotting switch 
     3011         
     3012        return(0) 
     3013end 
     3014 
     3015 
     3016Function V_Proto_SaveFile(avgStr,activeType,samFileLoaded,av_type,binType,detGroup,trimBegStr,trimEndStr) 
     3017        String avgStr,activeType,samFileLoaded,av_type 
     3018        Variable binType 
     3019        String detGroup,trimBegStr,trimEndStr 
     3020         
     3021        String fullpath = "", newfileName="" 
     3022        String saveType = StringByKey("SAVE",avgStr,"=",";")            //does user want to save data? 
     3023 
     3024        If( (cmpstr(saveType[0,2],"Yes")==0) && (cmpstr(av_type,"none") != 0) )          
     3025                //then save 
     3026                newFileName = RemoveEnding(samFileLoaded,".nxs.ngv") 
     3027                 
     3028                //pick ABS or AVE extension 
     3029                String exten = activeType 
     3030                if(cmpstr(exten,"ABS") != 0) 
     3031                        exten = "AVE" 
     3032                endif 
     3033//              if(cmpstr(av_type,"2D_ASCII") == 0) 
     3034//                      exten = "ASC" 
     3035//              endif 
     3036//              if(cmpstr(av_type,"QxQy_ASCII") == 0) 
     3037//                      exten = "DAT" 
     3038//              endif 
     3039                 
     3040//              // add an "x" to the file extension if the output is XML 
     3041//              // currently (2010), only for ABS and AVE (1D) output 
     3042//              if( cmpstr(exten,"ABS") == 0 || cmpstr(exten,"AVE") == 0 ) 
     3043//                      if(useXMLOutput == 1) 
     3044//                              exten += "x" 
     3045//                      endif 
     3046//              endif 
     3047                                 
     3048                //Path is catPathName, symbolic path 
     3049                //if this doesn't exist, a dialog will be presented by setting dialog = 1 
     3050                // 
     3051                Variable dialog = 0 
     3052 
     3053                PathInfo/S catPathName 
     3054                String item = StringByKey("NAME",avgStr,"=",";")                //Auto or Manual naming 
     3055                String autoname = StringByKey("AUTONAME",avgStr,"=",";")                //autoname -  will get empty string if not present 
     3056                If((cmpstr(item,"Manual")==0) || (cmpstr(newFileName,"") == 0)) 
     3057                        //manual name if requested or if no name can be derived from header 
     3058                        fullPath = newfileName + "."+ exten //puts possible new name or null string in dialog 
     3059                        dialog = 1              //force dialog for user to enter name 
     3060                else 
     3061                        //auto-generate name and prepend path - won't put up any dialogs since it has all it needs 
     3062                        //use autoname if present 
     3063                        if (cmpstr(autoname,"") != 0) 
     3064                                fullPath = S_Path + autoname + "." +exten 
     3065                        else 
     3066                                fullPath = S_Path + newFileName+"." + exten 
     3067                        endif    
     3068                Endif 
     3069                // 
     3070                strswitch(av_type)       
     3071                        case "Annular": 
     3072                                V_fWrite1DAnnular("root:Packages:NIST:VSANS:",activeType,detGroup,newFileName+".phi") 
     3073                                Print "data written to:  "+ newFileName+".phi" 
     3074 
     3075                                break 
     3076 
     3077                        case "Circular":                //in SANS, this was the default, but is dangerous, so make it explicit here 
     3078                        case "Sector":          // TODO: this falls through - which luckily works for now... 
     3079                        case "Rectangular":             // TODO: this falls through - which luckily works for now... 
     3080                        case "Narrow_Slit":             // TODO: this falls through - which luckily works for now... 
     3081 
     3082// no VSANS support of XML output at this point                  
     3083//                              if (useXMLOutput == 1) 
     3084//                                      WriteXMLWaves_W_Protocol(activeType,fullPath,dialog) 
     3085//                              else 
     3086//                                      WriteWaves_W_Protocol(activeType,fullpath,dialog) 
     3087//                              endif 
     3088// 
     3089                                if(cmpstr(saveType,"Yes - Concatenate")==0) 
     3090                                        V_Trim1DDataStr(activeType,binType,trimBegStr,trimEndStr)                       // x- passing null strings uses global or default trim values 
     3091 
     3092                                        V_ConcatenateForSave("root:Packages:NIST:VSANS:",activeType,"",binType)         // this removes q=0 point, concatenates, sorts 
     3093                                 
     3094//                                      prot[9] = collimationStr 
     3095                                         
     3096                                        V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten)             //don't pass the full path, just the name 
     3097                                 
     3098                                endif 
     3099                                 
     3100                                if(cmpstr(saveType,"Yes - Individual")==0) 
     3101                                        // remove the q=0 point from the back detector, if it's there 
     3102                                        // does not trim any other points from the data 
     3103                                        V_RemoveQ0_B(activeType) 
     3104                                        V_Write1DData_ITX("root:Packages:NIST:VSANS:",activeType,newFileName,binType) 
     3105                                endif 
     3106                                Print "data written to:  "+ newFileName+"."+exten 
     3107 
     3108                                break 
     3109         
     3110                                 
     3111                                case "2D_ASCII": 
     3112//                              Fast2DExport(activeType,fullPath,dialog) 
     3113                                break 
     3114                        case "QxQy_ASCII": 
     3115//                              QxQy_Export(activeType,fullPath,dialog) 
     3116                                break 
     3117                        case "PNG_Graphic": 
     3118//                              SaveAsPNG(activeType,fullpath,dialog) 
     3119                                break 
     3120 
     3121                        default: 
     3122                                DoAlert 0, "av_type not found in dispatch to write file" 
     3123                endswitch 
     3124                 
     3125        Endif    
     3126        return(0) 
     3127End 
     3128 
     3129 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WhiteBeamSmear.ipf

    r1095 r1100  
    5151// 
    5252// 
    53 Macro V_Calc_WB_Smearing_top() 
     53Proc V_Calc_WB_Smearing_top() 
    5454 
    5555        String folderStr,funcStr,coefStr 
     
    7070 
    7171 
    72 Macro V_Calc_WB_Smearing_mid() 
     72Proc V_Calc_WB_Smearing_mid() 
    7373 
    7474        String folderStr,funcStr,coefStr 
     
    8888End 
    8989 
    90 Macro V_Calc_WB_Smearing_interp() 
     90Proc V_Calc_WB_Smearing_interp() 
    9191 
    9292        String folderStr,funcStr,coefStr 
     
    106106End 
    107107 
    108 Macro V_Calc_WB_Smearing_triang() 
     108Proc V_Calc_WB_Smearing_triang() 
    109109 
    110110        String folderStr,funcStr,coefStr 
Note: See TracChangeset for help on using the changeset viewer.