Changeset 1027


Ignore:
Timestamp:
Mar 13, 2017 1:39:33 PM (6 years ago)
Author:
srkline
Message:

adding to the functionality of the data reduction protocol

getting the 1D plotting to work both as a standalone plot and part of the reduction protocol (where the choices are all made and fed in)

added log/lin toggle to 1D display. abc exponent scaling is fundamentally more messy, and has been shelved for now. Revisit if demand is there.

fixed bug in how raw data files are identified, to prevent .abs files from being incorrectly identified as raw (if same name before extension). Works correctly now, but may need tweak in future if naming scheme changes.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.ipf

    r1023 r1027  
    55 
    66// 
    7 // functions to plot the averaged data in various views. 
     7// functions to plot the averaged data in various views and binning types 
    88// 
    99 
     
    2020// -- color coding of the different panels (data tags/arrows/toggle on/off)? 
    2121// -- VERIFY accuracy 
     22// 
    2223// -- decide what to add to the control bar 
     24// ()()() In SANS, there are only 3 waves (q-i-s) and these are copied over to the plot1D folder, and the copy 
     25//    of the data is plotted, not the data in the WORK folder. Then for rescaling, a "fresh" copy of the data is 
     26//    fetched, and then rescaled. The plot automatically reflects these changes. 
     27//  --- for VSANS, this is much more difficult since there are multiple possibilites of 1D data, depending on the 
     28//     binning chosen. Currently, the data is plotted directly from the WORK folder, so this would need to be changed 
     29//     at the start, then deciding which waves to copy over. Messy. Very Messy. For now, simply toggle log/lin 
     30// 
    2331// -- at the very least, add a log/lin toggle for the axes 
    2432// 
     
    3038//    and to the function Draw_Plot1D() for the drawing of the plot 
    3139// 
    32 Function V_PlotData_Panel() 
    33  
     40// If -9999 is passed in as the "binType", then read the proper value from the popup on the graph. 
     41//  otherwise, assume that a proper value has been passed in, say from the reduction protocol 
     42// 
     43Function V_PlotData_Panel(binType) 
     44        Variable binType 
    3445 
    3546        DoWindow/F V_1D_Data 
    3647        if(V_flag==0) 
    3748         
     49//              NewDataFolder/O root:Packages:NIST:VSANS:Globals:Plot_1D 
     50//              Variable/G root:Packages:NIST:VSANS:Globals:Plot_1D:gYMode = 1 
     51//              Variable/G root:Packages:NIST:VSANS:Globals:Plot_1D:gXMode = 1 
     52//              Variable/G root:Packages:NIST:VSANS:Globals:Plot_1D:gExpA = 1 
     53//              Variable/G root:Packages:NIST:VSANS:Globals:Plot_1D:gExpB = 1 
     54//              Variable/G root:Packages:NIST:VSANS:Globals:Plot_1D:gExpC = 1 
     55                 
     56                 
    3857                Display /W=(277,526,748,938)/N=V_1D_Data/K=1 
    39 //              Display /W=(476,96,850,429)/N=V_1D_Data/K=1 
     58 
    4059                ControlBar 70 
    4160                 
     
    4463                PopupMenu popup0,value= "One;Two;Four;Slit Mode;" 
    4564                PopupMenu popup0,mode=1,proc=V_BinningModePopup 
    46 //              PopupMenu ymodel,pos={16,5},size={71,20},title="y-axis" 
     65                 
     66                CheckBox check0,pos={18.00,36.00},size={57.00,16.00},proc=V_Plot1D_LogCheckProc,title="Log Axes" 
     67                CheckBox check0,value= 1 
     68         
     69//              PopupMenu ymodel,pos={150,5},size={71,20},title="y-axis" 
    4770//              PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"} 
    4871//              PopupMenu ymodel,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\"" 
    49 //              PopupMenu ymodel,mode=NumVarOrDefault("root:myGlobals:Plot_1d:gYMode", 1 ),proc=YMode_PopMenuProc 
    50 //              PopupMenu xmodel,pos={150,5},size={74,20},title="x-axis" 
     72//              PopupMenu ymodel,mode=NumVarOrDefault("root:Packages:NIST:VSANS:Globals:Plot_1d:gYMode", 1 ),proc=V_YMode_PopMenuProc 
     73//              PopupMenu xmodel,pos={220,5},size={74,20},title="x-axis" 
    5174//              PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"} 
    5275//              PopupMenu xmodel,value= #"\"q;log(q);q^2;q^c\"" 
    53 //              PopupMenu xmodel,mode=NumVarOrDefault("root:myGlobals:Plot_1d:gXMode", 1 ),proc=XMode_PopMenuProc 
    54 //              Button Rescale,pos={281,4},size={70,20},proc=Rescale_Plot_1D_ButtonProc,title="Rescale" 
    55 //              Button Rescale,help={"Rescale the x and y-axes of the data"},disable=1 
    56  
    57 //              SetVariable expa,pos={28,28},size={80,15},title="pow \"a\"" 
     76//              PopupMenu xmodel,mode=NumVarOrDefault("root:Packages:NIST:VSANS:Globals:Plot_1d:gXMode", 1 ),proc=V_XMode_PopMenuProc 
     77////            Button Rescale,pos={281,5},size={70,20},proc=V_Rescale_Plot_1D_ButtonProc,title="Rescale" 
     78////            Button Rescale,help={"Rescale the x and y-axes of the data"},disable=1 
     79// 
     80//              SetVariable expa,pos={120,28},size={80,15},title="pow \"a\"" 
    5881//              SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"} 
    59 //              SetVariable expa,limits={-2,10,0},value= root:myGlobals:Plot_1d:gExpA 
    60 //              SetVariable expb,pos={27,46},size={80,15},title="pow \"b\"" 
     82//              SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpA 
     83//              SetVariable expb,pos={120,46},size={80,15},title="pow \"b\"" 
    6184//              SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"} 
    62 //              SetVariable expb,limits={0,10,0},value= root:myGlobals:Plot_1d:gExpB 
    63 // 
    64 //              SetVariable expc,pos={167,28},size={80,15},title="pow \"c\"" 
     85//              SetVariable expb,limits={0,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpB 
     86// 
     87//              SetVariable expc,pos={220,28},size={80,15},title="pow \"c\"" 
    6588//              SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"} 
    66 //              SetVariable expc,limits={-10,10,0},value= root:myGlobals:Plot_1d:gExpC 
    67                  
    68                 Button AllQ,pos={281,28},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q" 
     89//              SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpC 
     90                 
     91                Button AllQ,pos={320,28},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q" 
    6992                Button AllQ,help={"Show the full q-range of the dataset"} 
    7093                 
    71         endif 
    72                  
    73          
    74         SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType 
    75  
    76         V_QBinAllPanels(type) 
     94                Legend/C/N=text0/J/X=72.00/Y=60.00 
     95        endif 
     96                 
     97         
     98        SVAR workType = root:Packages:NIST:VSANS:Globals:gCurDispType 
     99 
     100        if(binType == -9999) 
     101                binType = V_GetBinningPopMode()         //dummy passed in, replace with value from panel 
     102        endif 
     103        V_QBinAllPanels(workType,binType) 
    77104 
    78105// TODO: 
    79106// x- "B" detector is currently skipped - Q is not yet calculated 
    80         Execute ("V_Back_IQ_Graph(\""+type+"\")") 
    81         Execute ("V_Middle_IQ_Graph(\""+type+"\")") 
    82         Execute ("V_Front_IQ_Graph(\""+type+"\")") 
    83          
     107        String str 
     108        sprintf str,"(\"%s\",%d)",workType,binType 
     109         
     110        Execute ("V_Back_IQ_Graph"+str) 
     111//      Print "V_Back_IQ_Graph"+str 
     112        Execute ("V_Middle_IQ_Graph"+str) 
     113        Execute ("V_Front_IQ_Graph"+str) 
     114 
    84115         
    85116End 
     117 
     118Function V_Plot1D_LogCheckProc(cba) : CheckBoxControl 
     119        STRUCT WMCheckboxAction &cba 
     120 
     121        switch( cba.eventCode ) 
     122                case 2: // mouse up 
     123                        Variable checked = cba.checked 
     124                                 
     125                                ModifyGraph log=(checked) 
     126                         
     127                        break 
     128                case -1: // control being killed 
     129                        break 
     130        endswitch 
     131 
     132        return 0 
     133End 
     134 
     135// 
     136////function to set the popItem (mode) of the graph, to re-create the graph based on user preferences 
     137//Function V_YMode_PopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl 
     138//      String ctrlName 
     139//      Variable popNum 
     140//      String popStr 
     141// 
     142//      Variable/G root:Packages:NIST:VSANS:Globals:Plot_1d:gYMode=popNum 
     143//      V_Rescale_Plot_1D_ButtonProc("") 
     144//End 
     145// 
     146////function to set the popItem (mode) of the graph, to re-create the graph based on user preferences 
     147//Function V_XMode_PopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl 
     148//      String ctrlName 
     149//      Variable popNum 
     150//      String popStr 
     151// 
     152//      Variable/G root:Packages:NIST:VSANS:Globals:Plot_1d:gXMode=popNum 
     153//      V_Rescale_Plot_1D_ButtonProc("") 
     154//End 
     155 
     156 
     157//function to rescale the axes of the graph as selected from the popups and the  
     158// entered values of the exponents 
     159//** assumes the current waves are unknown, so it goes and gets a "fresh" copy from 
     160//the data folder specified by the waves on the graph, which is the same folder that 
     161//contains the "fresh" copy of the 1D data 
     162// 
     163// for log(10) scaling, simply modify the axes, not the data - gives better plots 
     164// 
     165//Function V_Rescale_Plot_1D_ButtonProc(ctrlName) : ButtonControl 
     166//      String ctrlName 
     167//       
     168//      DoWindow/F V_1D_Data 
     169////Scaling exponents and background value 
     170//      Variable pow_a,pow_b,pow_c 
     171//      ControlInfo expa 
     172//      pow_a = V_value 
     173//      ControlInfo expb 
     174//      pow_b = V_value 
     175//      ControlInfo expc 
     176//      pow_c = V_value 
     177//       
     178////check for physical limits on exponent values, abort if bad values found 
     179//      if((pow_a < -2) || (pow_a > 10)) 
     180//              Abort "Exponent a must be in the range (-2,10)" 
     181//      endif 
     182//      if((pow_b < 0) || (pow_b > 10)) 
     183//              Abort "Exponent b must be in the range (0,10)" 
     184//      endif 
     185//      //if q^c is the x-scaling, c must be be within limits and also non-zero 
     186//      ControlInfo xModel 
     187//      If (cmpstr("q^c",S_Value) == 0) 
     188//              if(pow_c == 0)  
     189//                      Abort "Exponent c must be non-zero, q^0 = 1" 
     190//              endif 
     191//              if((pow_c < -10) || (pow_c > 10)) 
     192//                      Abort "Exponent c must be in the range (-10,10)" 
     193//              endif 
     194//      endif           //check q^c exponent 
     195//       
     196//// get the current experimental q, I, and std dev. waves 
     197//      SVAR curFolder=root:Packages:NIST:VSANS:Globals:gDataDisplayType 
     198// 
     199//// what is the binning? == what waves do we need to copy over 
     200//       
     201// 
     202//      //get the untarnished data, so we can rescale it freshly here 
     203//      Wave yw = $("root:Packages:NIST:"+curFolder+":aveint") 
     204//      Wave ew = $("root:Packages:NIST:"+curFolder+":sigave") 
     205//      //get the correct x values 
     206//      NVAR isPhiAve= root:myGlobals:Plot_1d:isPhiAve  //0 signifies (normal) x=qvals 
     207//      if(isPhiAve) 
     208//              //x is angle 
     209//              Wave xw=$("root:Packages:NIST:"+curFolder+":phival") 
     210//      else 
     211//              //x is q-values 
     212//              Wave xw=$("root:Packages:NIST:"+curFolder+":qval") 
     213//      endif 
     214//      Wave yAxisWave=root:myGlobals:Plot_1d:yAxisWave         //refs to waves to be modified, hard-wired positions 
     215//      Wave xAxisWave=root:myGlobals:Plot_1d:xAxisWave 
     216//      Wave yErrWave=root:myGlobals:Plot_1d:yErrWave 
     217//       
     218//      //variables set for each model to control look of graph 
     219//      String xlabel,ylabel,xstr,ystr 
     220//      Variable logLeft=0,logBottom=0 
     221//      //check for proper y-scaling selection, make the necessary waves 
     222//      ControlInfo yModel 
     223//      ystr = S_Value 
     224//      do 
     225//              If (cmpstr("I",S_Value) == 0) 
     226//                      SetScale d 0,0,"1/cm",yAxisWave 
     227//                      yErrWave = ew 
     228//                      yAxisWave = yw 
     229//                      ylabel = "I(q)" 
     230//                      break    
     231//              endif 
     232//              If (cmpstr("ln(I)",S_Value) == 0) 
     233//                      SetScale d 0,0,"",yAxisWave 
     234//                      yErrWave = ew/yw 
     235//                      yAxisWave = ln(yw) 
     236//                      ylabel = "ln(I)" 
     237//                      break    
     238//              endif 
     239//              If (cmpstr("log(I)",S_Value) == 0) 
     240//                      SetScale d 0,0,"",yAxisWave 
     241//                      yAxisWave = yw 
     242//                      yErrWave = ew 
     243//                      logLeft=1                               //scale the axis, not the wave 
     244//                      ylabel = "I(q)" 
     245////                    yErrWave = ew/(2.30*yw) 
     246////                    yAxisWave = log(yw) 
     247////                    ylabel = "log(I)" 
     248//                      break    
     249//              endif 
     250//              If (cmpstr("1/I",S_Value) == 0) 
     251//                      SetScale d 0,0,"",yAxisWave 
     252//                      yErrWave = ew/yw^2 
     253//                      yAxisWave = 1/yw 
     254//                      ylabel = "1/I" 
     255//                      break 
     256//              endif 
     257//              If (cmpstr("I^a",S_Value) == 0) 
     258//                      SetScale d 0,0,"",yAxisWave 
     259//                      yErrWave = ew*abs(pow_a*(yw^(pow_a-1))) 
     260//                      yAxisWave = yw^pow_a 
     261//                      ylabel = "I^"+num2str(pow_a) 
     262//                      break 
     263//              endif 
     264//              If (cmpstr("Iq^a",S_Value) == 0) 
     265//                      SetScale d 0,0,"",yAxisWave 
     266//                      yErrWave = ew*xw^pow_a 
     267//                      yAxisWave = yw*xw^pow_a 
     268//                      ylabel = "I*q^"+num2str(pow_a) 
     269//                      break 
     270//              endif 
     271//              If (cmpstr("I^a q^b",S_Value) == 0) 
     272//                      SetScale d 0,0,"",yAxisWave 
     273//                      yErrWave = ew*abs(pow_a*(yw^(pow_a-1)))*xw^pow_b 
     274//                      yAxisWave = yw^pow_a*xw^pow_b 
     275//                      ylabel = "I^" + num2str(pow_a) + "q^"+num2str(pow_b) 
     276//                      break 
     277//              endif 
     278//              If (cmpstr("1/sqrt(I)",S_Value) == 0) 
     279//                      SetScale d 0,0,"",yAxisWave 
     280//                      yErrWave = 0.5*ew*yw^(-1.5) 
     281//                      yAxisWave = 1/sqrt(yw) 
     282//                      ylabel = "1/sqrt(I)" 
     283//                      break 
     284//              endif 
     285//              If (cmpstr("ln(Iq)",S_Value) == 0) 
     286//                      SetScale d 0,0,"",yAxisWave 
     287//                      yErrWave =ew/yw 
     288//                      yAxisWave = ln(xw*yw) 
     289//                      ylabel = "ln(q*I)" 
     290//                      break 
     291//              endif 
     292//              If (cmpstr("ln(Iq^2)",S_Value) == 0) 
     293//                      SetScale d 0,0,"",yAxisWave 
     294//                      yErrWave = ew/yw 
     295//                      yAxisWave = ln(xw*xw*yw) 
     296//                      ylabel = "ln(I*q^2)" 
     297//                      break 
     298//              endif 
     299//              //more ifs for each case as they are added 
     300//               
     301//              // if selection not found, abort 
     302//              DoAlert 0,"Y-axis scaling incorrect. Aborting" 
     303//              Abort 
     304//      while(0)        //end of "case" statement for y-axis scaling 
     305//       
     306//      //check for proper x-scaling selection 
     307//      SVAR/Z angst = root:Packages:NIST:gAngstStr  
     308//      String dum 
     309//       
     310//      ControlInfo xModel 
     311//      xstr = S_Value 
     312//      do 
     313//              If (cmpstr("q",S_Value) == 0)    
     314//                      SetScale d 0,0,"",xAxisWave 
     315//                      xAxisWave = xw 
     316//                      if(isPhiAve) 
     317//                              xlabel="Angle (deg)" 
     318//                      else 
     319//                              xlabel = "q ("+angst+"\\S-1\\M)" 
     320//                      endif 
     321//                      break    
     322//              endif 
     323//              If (cmpstr("q^2",S_Value) == 0)  
     324//                      SetScale d 0,0,"",xAxisWave 
     325//                      xAxisWave = xw*xw 
     326//                      if(isPhiAve) 
     327//                              xlabel="(Angle (deg) )^2" 
     328//                      else 
     329//                              xlabel = "q^2 ("+angst+"\\S-2\\M)" 
     330//                      endif 
     331//                      break    
     332//              endif 
     333//              If (cmpstr("log(q)",S_Value) == 0)       
     334//                      SetScale d 0,0,"",xAxisWave 
     335//                      xAxisWave = xw          //scale the axis, not the wave 
     336//                      //xAxisWave = log(xw) 
     337//                      logBottom=1 
     338//                      if(isPhiAve) 
     339//                              //xlabel="log(Angle (deg))" 
     340//                              xlabel="Angle (deg)" 
     341//                      else 
     342//                              //xlabel = "log(q)" 
     343//                              xlabel = "q ("+angst+"\\S-1\\M)" 
     344//                      endif 
     345//                      break    
     346//              endif 
     347//              If (cmpstr("q^c",S_Value) == 0) 
     348//                      SetScale d 0,0,"",xAxisWave 
     349//                      xAxisWave = xw^pow_c 
     350//                      dum = num2str(pow_c) 
     351//                      if(isPhiAve) 
     352//                              xlabel="Angle^"+dum 
     353//                      else 
     354//                              xlabel = "q^"+dum+" ("+angst+"\\S-"+dum+"\\M)" 
     355//                      endif 
     356//                      break 
     357//              endif 
     358//       
     359//              //more ifs for each case 
     360//               
     361//              // if selection not found, abort 
     362//              DoAlert 0,"X-axis scaling incorrect. Aborting" 
     363//              Abort 
     364//      while(0)        //end of "case" statement for x-axis scaling 
     365//       
     366//      Label left ylabel 
     367//      Label bottom xlabel     //E denotes "scaling"  - may want to use "units" instead         
     368//      ModifyGraph log(left)=(logLeft) 
     369//      ModifyGraph log(bottom)=(logBottom) 
     370//       
     371//End 
     372 
    86373 
    87374//function to restore the graph axes to full scale, undoing any zooming 
     
    104391        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType 
    105392 
    106         V_QBinAllPanels(type) 
    107  
    108         Execute ("V_Back_IQ_Graph(\""+type+"\")") 
    109         Execute ("V_Middle_IQ_Graph(\""+type+"\")") 
    110         Execute ("V_Front_IQ_Graph(\""+type+"\")") 
     393        V_QBinAllPanels(type,popNum) 
     394 
     395        String str 
     396        sprintf str,"(\"%s\",%d)",Type,popNum 
     397 
     398        Execute ("V_Back_IQ_Graph"+str) 
     399        Execute ("V_Middle_IQ_Graph"+str) 
     400        Execute ("V_Front_IQ_Graph"+str) 
     401                 
     402//      Execute ("V_Back_IQ_Graph(\""+type+"\")") 
     403//      Execute ("V_Middle_IQ_Graph(\""+type+"\")") 
     404//      Execute ("V_Front_IQ_Graph(\""+type+"\")") 
    111405         
    112406        return(0)        
     
    116410 
    117411        Variable binType 
     412         
     413        if(WinType("V_1D_Data")==0) 
     414                DoAlert 0,"V_1D_Data window is not open, called from V_GetBinningPopMode()" 
     415                return(0) 
     416        endif 
     417         
    118418        ControlInfo/W=V_1D_Data popup0 
    119419        strswitch(S_Value)      // string switch 
     
    133433                default:                        // optional default expression executed 
    134434                        binType = 0 
    135                         Abort "Binning mode not found in        V_QBinAllPanels() "// when no case matches 
     435                        Abort "Binning mode not found in V_GetBinningPopMode() "// when no case matches 
    136436        endswitch 
    137437         
     
    151451// input "type" is the data type and defines the folder 
    152452// 
    153 Proc V_Middle_IQ_Graph(type)  
     453Proc V_Middle_IQ_Graph(type,binType)  
    154454        String type 
    155  
    156455        Variable binType 
    157456 
    158         binType = V_GetBinningPopMode() 
     457//      binType = V_GetBinningPopMode() 
    159458        SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
    160459 
     
    316615// 
    317616// 
    318 Proc V_Front_IQ_Graph(type)  
     617Proc V_Front_IQ_Graph(type,binType)  
    319618        String type 
    320  
    321619        Variable binType 
    322620 
    323621 
    324         binType = V_GetBinningPopMode() 
     622//      binType = V_GetBinningPopMode() 
    325623        SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
    326624 
     
    486784// 
    487785////////////to plot the back panel I(q) 
    488 Proc V_Back_IQ_Graph(type) 
     786Proc V_Back_IQ_Graph(type,binType) 
    489787        String type 
     788        Variable binType 
    490789         
    491790//      SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B 
    492791 
    493         Variable binType 
    494  
    495         binType = V_GetBinningPopMode() 
     792//      Variable binType 
     793 
     794//      binType = V_GetBinningPopMode() 
    496795         
    497796        SetDataFolder $("root:Packages:NIST:VSANS:"+type)        
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r1024 r1027  
    891891// 
    892892//test procedure, not called anymore 
    893 Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5) 
     893Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5,I_err) 
    894894        String type 
    895         Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0 
     895        Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0,I_err=0.32 
    896896        Prompt type,"WORK data type",popup,"CAL;COR;SAM" 
    897897        Prompt c0, "Sample Transmission" 
     
    901901        Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" 
    902902        Prompt c5, "Standard Cross-Section (cm-1)" 
     903        Prompt I_err, "error in I(q=0) (one std dev)" 
    903904 
    904905        Variable err 
    905906        //call the function to do the math 
    906907        //data from "type" will be scaled and deposited in ABS 
    907         err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5) 
     908        err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5,I_err) 
    908909         
    909910        if(err) 
    910                 Abort "Error in Absolute_Scale()" 
     911                Abort "Error in V_Absolute_Scale()" 
    911912        endif 
    912913         
    913914        //contents are always dumped to ABS 
    914915        type = "ABS" 
    915          
    916         String newTitle = "WORK_"+type 
    917         DoWindow/F SANS_Data 
    918         DoWindow/T SANS_Data, newTitle 
    919         KillStrings/Z newTitle 
    920916         
    921917        //need to update the display with "data" from the correct dataFolder 
     
    924920        gCurDispType = Type      
    925921         
    926         V_fRawWindowHook() 
     922        V_UpdateDisplayInformation(Type) 
    927923         
    928924End 
     
    930926// 
    931927// TODO: 
    932 //   --         DoAlert 0,"This has not yet been updated for VSANS" 
    933 // 
     928// 
     929// kappa comes in as s_izero, so be sure to use 1/kappa_err 
     930// 
     931//convert the "type" data to absolute scale using the given standard information 
    934932//s_ is the standard 
    935933//w_ is the "work" file 
     
    939937        Variable w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err 
    940938 
    941         DoAlert 0,"This has not yet been updated for VSANS" 
     939 
     940        Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 
     941        Variable scale,trans_err 
     942        Variable err,ii 
     943        String detStr 
     944         
     945        // be sure that the starting data exists 
     946        err = V_WorkDataExists(type) 
     947        if(err==1) 
     948                return(err) 
     949        endif 
    942950                 
    943         //convert the "type" data to absolute scale using the given standard information 
    944         //copying the "type" waves to ABS 
    945          
    946         //check for existence of data, rescale to linear if needed 
    947         String destPath 
    948         //check for "type" 
    949         if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0) 
    950                 Print "There is no work file in "+type+"--Aborting" 
    951                 Return(1)               //error condition 
    952         Endif 
    953         //check for log-scaling of the "type" data and adjust if necessary 
    954         destPath = "root:Packages:NIST:"+Type 
    955         NVAR gIsLogScale = $(destPath + ":gIsLogScale") 
    956         if(gIsLogScale) 
    957                 Duplicate/O $(destPath + ":linear_data") $(destPath + ":data")//back to linear scale 
    958                 Variable/G $(destPath + ":gIsLogScale")=0       //the "type" data is not logscale anymore 
    959         endif 
    960          
    961         //copy "oldtype" information to ABS 
    962         //overwriting out the old contents of the ABS folder (/O option in Duplicate) 
    963         //copy over the waves data,vlegend,text,integers,reals(read) 
    964  
    965         String oldType= "root:Packages:NIST:"+type              //this is where the data to be absoluted is  
    966         //copy from current dir (type) to ABS, defined by destPath 
    967         Duplicate/O $(oldType + ":data"),$"root:Packages:NIST:ABS:data" 
    968         Duplicate/O $(oldType + ":linear_data"),$"root:Packages:NIST:ABS:linear_data" 
    969         Duplicate/O $(oldType + ":linear_data_error"),$"root:Packages:NIST:ABS:linear_data_error" 
    970 //      Duplicate/O $(oldType + ":vlegend"),$"root:Packages:NIST:ABS:vlegend" 
    971         Duplicate/O $(oldType + ":textread"),$"root:Packages:NIST:ABS:textread" 
    972         Duplicate/O $(oldType + ":integersread"),$"root:Packages:NIST:ABS:integersread" 
    973         Duplicate/O $(oldType + ":realsread"),$"root:Packages:NIST:ABS:realsread" 
    974         //need to save a copy of filelist string too (from the current type folder) 
    975         SVAR oldFileList = $(oldType + ":fileList") 
    976         //need to copy filelist string too 
    977         String/G $"root:Packages:NIST:ABS:fileList" = oldFileList 
    978          
    979         //now switch to ABS folder 
    980         //make appropriate wave references 
    981         WAVE data=$"root:Packages:NIST:ABS:linear_data"                                 // these wave references point to the "type" data in ABS 
    982         WAVE data_err=$"root:Packages:NIST:ABS:linear_data_error"                                       // these wave references point to the "type" data in ABS 
    983         WAVE data_copy=$"root:Packages:NIST:ABS:data"                                   // just for display 
    984         WAVE/T textread=$"root:Packages:NIST:ABS:textread"                      //that are to be directly operated on 
    985         WAVE integersread=$"root:Packages:NIST:ABS:integersread" 
    986         WAVE realsread=$"root:Packages:NIST:ABS:realsread" 
    987         Variable/G $"root:Packages:NIST:ABS:gIsLogscale"=0                      //make new flag in ABS folder, data is linear scale 
    988          
    989         //do the actual absolute scaling here, modifying the data in ABS 
    990         Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 
    991          
    992         w_moncount = realsread[0]               //monitor count in "type" 
     951        //copy from current dir (type) to ABS 
     952        V_CopyHDFToWorkFolder(type,"ABS")        
     953 
     954         
     955        w_moncount = V_getMonitorCount(type)            //monitor count in "type" 
    993956        if(w_moncount == 0) 
    994957                //zero monitor counts will give divide by zero --- 
     
    998961         
    999962        //calculate scale factor 
    1000         Variable scale,trans_err 
    1001         s1 = defmon/realsread[0]                //[0] is monitor count (s1 should be 1) 
     963        s1 = defmon/w_moncount          // monitor count (s1 should be 1) 
    1002964        s2 = s_thick/w_thick 
    1003965        s3 = s_trans/w_trans 
    1004966        s4 = s_cross/s_izero 
     967        scale = s1*s2*s3*s4 
     968 
     969        trans_err = V_getSampleTransError(type)  
    1005970         
    1006971        // kappa comes in as s_izero, so be sure to use 1/kappa_err 
    1007          
    1008         data *= s1*s2*s3*s4 
    1009          
    1010         scale = s1*s2*s3*s4 
    1011         trans_err = realsRead[41] 
    1012          
    1013 //      print scale 
    1014 //      print data[0][0] 
    1015          
    1016         data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 
    1017  
    1018 //      print data_err[0][0] 
    1019          
    1020 // keep "data" in sync with linear_data  
    1021         data_copy = data 
     972 
     973        // and now loop through all of the detectors 
     974        //do the actual absolute scaling here, modifying the data in ABS 
     975        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     976                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     977                Wave data = V_getDetectorDataW("ABS",detStr) 
     978                Wave data_err = V_getDetectorDataErrW("ABS",detStr) 
     979                 
     980                data *= s1*s2*s3*s4 
     981                data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 
     982        endfor 
    1022983         
    1023984        //********* 15APR02 
    1024         // DO NOt correct for atenuators here - the COR step already does this, putting all of the data one equal 
     985        // DO NOT correct for atenuators here - the COR step already does this, putting all of the data one equal 
    1025986        // footing (zero atten) before doing the subtraction. 
    1026         // 
    1027         //Print "ABS data multiplied by  ",s1*s2*s3*s4/attenFactor 
    1028          
    1029         //update the ABS header information 
    1030         textread[1] = date() + " " + time()             //date + time stamp 
    1031987         
    1032988        Return (0) //no error 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r1022 r1027  
    20642064         
    20652065        String path = "entry:sample:transmission"        
    2066 //      String path = "QKK0037737:data:Transmission"     
    20672066        return(V_getRealValueFromHDF5(fname,path)) 
    20682067end 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf

    r1023 r1027  
    3131 
    3232 
    33 Function V_QBinAllPanels(folderStr) 
     33Function V_QBinAllPanels(folderStr,binType) 
    3434        String folderStr 
     35        Variable binType 
    3536 
    3637        // do the back, middle, and front separately 
    3738         
    3839//      figure out the binning type (where is it set?) 
    39         Variable binType,ii,delQ 
     40        Variable ii,delQ 
    4041        String detStr 
    4142 
    42         binType = V_GetBinningPopMode() 
     43//      binType = V_GetBinningPopMode() 
    4344 
    4445//// TODO: 
    45 // x- currently the "B" detector is skipped - it was skipped in  
    46 //       previous functions where q values are calculated        
     46// 
    4747//       
    4848        delQ = SetDeltaQ(folderStr,"B") 
    4949         
    5050        // dispatch based on binning type 
    51         if(binType == 1) 
     51        if(binType == 1 || binType == 2 || binType == 3) 
    5252                VC_fDoBinning_QxQy2D(folderStr, "B")            //normal binning, nothing to combine 
    5353        endif 
     
    9999End 
    100100 
    101  
    102  
    103  
    104 Proc V_Combine1DData() 
    105  
    106 // get the current display type 
    107         String type = root:Packages:NIST:VSANS:Globals:gCurDispType 
    108  
     101// concatenates and sorts the 1D data in "type" WORK folder 
     102// uses the current display if type=="" 
     103// 
     104Function V_ConcatenateForSave(type,binType) 
     105        String type 
     106        Variable binType 
     107         
     108// get the current display type, if null string passed in 
     109        SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType 
     110         
     111        if(strlen(type)==0) 
     112                type = curType 
     113        endif 
    109114 
    110115// trim the data if needed 
    111116        // remove the q=0 point from the back detector, if it's there 
     117        // does not need to know binType 
    112118        V_RemoveQ0_B(type) 
    113  
    114119 
    115120// concatenate the data sets 
     
    119124        Killwaves/Z tmp_q,tmp_i,tmp_s 
    120125        setDataFolder root: 
    121         V_1DConcatenate(type) 
     126        V_1DConcatenate(type,binType) 
    122127         
    123128// sort the data set 
    124129        V_TmpSort1D(type) 
    125130         
     131        return(0) 
     132End 
     133 
     134// 
     135// this is only called from the button on the data panel 
     136// so the type is the currently displayed type, and the binning is from the panel 
     137// 
     138Function V_SimpleSave1DData(type,saveName) 
     139        String type,saveName 
     140 
     141//  
     142// get the current display type, if null string passed in 
     143        SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType 
     144        Variable binType = V_GetBinningPopMode() 
     145         
     146        V_ConcatenateForSave(curType,binType) 
     147         
    126148// write out the data set to a file 
    127         String/G saveName="" 
    128         V_GetNameForSave("") 
     149        if(strlen(saveName)==0) 
     150                Execute "V_GetNameForSave()" 
     151                SVAR newName = root:saveName 
     152                saveName = newName 
     153        endif 
     154         
    129155        V_Write1DData(type,saveName) 
    130156 
    131157End 
     158 
    132159 
    133160Proc V_GetNameForSave(str) 
    134161        String str 
    135         String/G saveName=str 
     162        String/G root:saveName=str 
    136163End 
    137164 
     
    180207// binType = 4 = Slit Mode 
    181208// 
    182 Function V_1DConcatenate(folderStr) 
     209// if binType is passed in as -9999, get the binning mode from the popup 
     210// otherwise the value is assumed good (from a protocol) 
     211// 
     212Function V_1DConcatenate(folderStr,binType) 
    183213        String folderStr 
    184          
    185         Variable binType = V_GetBinningPopMode() 
    186          
     214        Variable binType 
     215         
     216        if(binType==-9999) 
     217                binType = V_GetBinningPopMode() 
     218        endif    
    187219         
    188220        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1025 r1027  
    4747//              NAME=string             string from set {Auto,Manual} = Automatic name generation or Manual(dialog) 
    4848// 
     49//    BINTYPE=string (VSANS binning type) "One;Two;Four;Slit Mode;" 
    4950// 
    5051//              For work.DRK usage: 
     
    533534// -- decide on the way to locate the blocked beam files. Is the enumerated text of the intent 
    534535//    sufficiently unique to locate the file? 
     536// -- can I use the Data Catalog waves to locate the files  - faster? 
     537//    (fails if the catalog has not been read in recently enough) 
     538// 
    535539// 
    536540Function/S V_PickBGDButton(ctrlName) : ButtonControl 
     
    936940        String ctrlName 
    937941         
     942//      Execute "V_GetAvgInfo_Full()" 
    938943        Execute "V_GetAvgInfo()" 
    939944         
     
    944949End 
    945950 
     951// TODO 
     952// -- this is a trimmed down version of the "full" set of averaging options 
     953//    add to this as needed to add in functionality 
     954// 
    946955//procedure called by protocol panel to ask user for average type choices 
    947956// somewhat confusing and complex, but may be as good as it gets. 
    948957// 
    949 Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) 
     958//Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) 
     959Proc V_GetAvgInfo(av_typ,autoSave,autoName,binType) 
     960        String av_typ,autoSave,AutoName,binType 
     961//      Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
     962 
     963//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 
     964        Prompt av_typ, "Type of Average",popup,"Circular;" 
     965 
     966// comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 
     967//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" 
     968        Prompt autoSave,"Save files to disk?",popup,"Yes;No" 
     969        Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" 
     970//      Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" 
     971//      Prompt side,"Include detector halves?",popup,"both;right;left" 
     972//      Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" 
     973//      Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" 
     974//      Prompt width, "Width of Rectangular average (1,128)" 
     975//      Prompt Qctr, "q-value of center of annulus" 
     976//      Prompt Qdelta,"Pixel width of annulus" 
     977        Prompt binType,"Binning Type?",popup,"One;Two;Four;Slit Mode;" 
     978 
     979        //assign results of dialog to key=value string, semicolon separated 
     980        //do only what is necessary, based on av_typ 
     981        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" 
     982 
     983        // TODO: 
     984        // hard wired value 
     985        String autoPlot = "No" 
     986         
     987                 
     988        // all averages need these values 
     989        root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" 
     990        root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" 
     991        root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" 
     992        root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" 
     993        root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "BINTYPE=" + binType + ";" 
     994         
     995//      if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
     996//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
     997//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     998//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" 
     999//      Endif 
     1000//       
     1001//      if(cmpstr(av_typ,"Rectangular")==0) 
     1002//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
     1003//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     1004//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" 
     1005//      Endif 
     1006//       
     1007//      if(cmpstr(av_typ,"Annular")==0) 
     1008//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" 
     1009//              root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" 
     1010//      Endif 
     1011End 
     1012 
     1013 
     1014// TODO 
     1015// -- this is the original(SANS) version, and needs to be updated for VSANS as the averaging options are 
     1016//    worked out 
     1017// 
     1018//procedure called by protocol panel to ask user for average type choices 
     1019// somewhat confusing and complex, but may be as good as it gets. 
     1020// 
     1021Proc V_GetAvgInfo_Full(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) 
    9501022        String av_typ,autoSave,AutoName,autoPlot,side 
    9511023        Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
     
    9901062        Endif 
    9911063End 
    992  
    9931064 
    9941065 
     
    13351406        //returns the name of the newly created (= currently in use) protocol wave through a global 
    13361407        String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtoStr 
     1408         
     1409        //reset the panel based on the protocol textwave (currently a string) 
     1410        V_ResetToSavedProtocol(newProtoStr) 
     1411         
     1412        return(0) 
    13371413End 
    13381414 
     
    15731649                Endif 
    15741650        While(0) 
     1651        // TODO 
     1652        // -- this may not be the most reliable way to pas the file name 
     1653        SVAR file_name = root:file_Name 
     1654        String sameFileLoaded = file_name               //keep a copy of the sample file loaded 
     1655         
    15751656        //always update 
    15761657        V_UpdateDisplayInformation(ActiveType) 
     
    17591840//////////////////////////////////////////////////////// 
    17601841 
    1761          
     1842// TODO: 
     1843// -- calculation works, needs proper inputs (solid angle aware) 
     1844// --   Open beam method is only a stub - fill in calculation in V_AskForAbsoluteParams_Quest() 
    17621845        Variable c2,c3,c4,c5,kappa_err 
    17631846        //do absolute scaling if desired 
     
    17841867                Endif 
    17851868                //get the sample trans and thickness from the activeType folder 
    1786                 String destStr = "root:Packages:NIST:"+activeType+":realsread" 
    1787                 Wave dest = $destStr 
    1788                 Variable c0 = dest[4]           //sample transmission 
    1789                 Variable c1 = dest[5]           //sample thickness 
     1869                Variable c0 = V_getSampleTransmission(activeType)               //sample transmission 
     1870                Variable c1 = V_getSampleThickness(activeType)          //sample thickness 
    17901871                 
    17911872                err = V_Absolute_Scale(activeType,c0,c1,c2,c3,c4,c5,kappa_err) 
    17921873                if(err) 
    17931874                        SetDataFolder root: 
    1794                         Abort "Error in Absolute_Scale(), called from executeProtocol" 
     1875                        Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" 
    17951876                endif 
    17961877                activeType = "ABS" 
     
    17981879        Endif 
    17991880 
    1800  
     1881// 
    18011882// TODO -- incomplete 
    18021883//       
     1884//mask data if desired (this is done automatically  in the average step) and is 
     1885//not done explicitly here (if no mask in MSK folder, a null mask is created and "used") 
     1886         
    18031887        //check for mask 
    18041888        //add mask if needed 
     
    18321916        else 
    18331917                //if none desired, make sure that the old mask is deleted 
    1834                 //junkStr = GetDataFolder(1) 
    1835                 //SetDataFolder root:Packages:NIST:MSK 
    1836                 KillWaves/Z root:Packages:NIST:VSANS:MSK:data 
    1837                 //SetDataFolder junkStr 
    1838         Endif 
    1839          
    1840         //mask data if desired (this is done automatically  in the average step) and is 
    1841         //not done explicitly here (if no mask in MSK folder, a null mask is created and "used") 
    1842  
    1843  
    1844          
     1918// TODO 
     1919// x- clean out the data folder 
     1920// x- note that V_KillNamedDataFolder() points to RawVSANS, and won't work 
     1921// -- what happens if the kill fails? need error handling 
     1922// 
     1923                KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
     1924        Endif 
     1925         
     1926 
     1927 
     1928 
     1929 
    18451930        // average/save data as specified 
    18461931         
     
    18641949         
    18651950        //convert the folder to linear scale before averaging, then revert by calling the window hook 
    1866         // not needed for VSANS, data is always linear scale 
    1867  
    1868          
     1951        // (not needed for VSANS, data is always linear scale) 
     1952 
     1953// TODO 
     1954// -- this switch does nothing -- fill it in 
     1955//       
    18691956        strswitch(av_type)      //dispatch to the proper routine to average to 1D data 
    18701957                case "none":             
     
    18981985                        //do nothing 
    18991986        endswitch 
     1987        // bin and plot the data 
     1988        // TODO 
     1989        // x- currently this bins and plots based on the V_1D_Data panel, NOT the selections above 
     1990        // now takes the the binType from the protocol, and uses two steps to bin and average 
     1991        String binTypeStr = StringByKey("BINTYPE",prot[5],"=",";") 
     1992        // plotting is not really necessary, and the graph may not be open - so skip for now? 
     1993        Variable binType 
     1994        strswitch(binTypeStr)   // string switch 
     1995                case "One": 
     1996                        binType = 1 
     1997                        break           // exit from switch 
     1998                case "Two": 
     1999                        binType = 2 
     2000                        break           // exit from switch 
     2001                case "Four": 
     2002                        binType = 3 
     2003                        break           // exit from switch 
     2004                case "Slit Mode": 
     2005                        binType = 4 
     2006                        break           // exit from switch 
     2007 
     2008                default:                        // optional default expression executed 
     2009                        binType = 0 
     2010                        Abort "Binning mode not found in V_QBinAllPanels() "// when no case matches 
     2011        endswitch 
     2012         
     2013        V_PlotData_Panel(binType)               //this bins and plots the *currently displayed* data 
     2014        V_QBinAllPanels(activeType,binType)             //bin the active reduction data 
     2015 
     2016// TODO: 
     2017// x- "B" detector is currently skipped - Q is not yet calculated 
     2018        String str 
     2019        sprintf str,"(\"%s\",%d)",activeType,binType 
     2020         
     2021        Execute ("V_Back_IQ_Graph"+str) 
     2022//      Print "V_Back_IQ_Graph"+str 
     2023        Execute ("V_Middle_IQ_Graph"+str) 
     2024        Execute ("V_Front_IQ_Graph"+str) 
     2025 
     2026         
    19002027///// end of averaging dispatch 
    19012028 
    1902          
     2029 
     2030// TODO 
     2031// x- how do I get the sample file name? 
     2032//     sameFileLoaded is the file name loaded (contains the extension) 
     2033//       
    19032034        //save data if desired 
    19042035        String fullpath = "", newfileName="" 
     
    19062037        If( (cmpstr(item,"Yes")==0) && (cmpstr(av_type,"none") != 0) )           
    19072038                //then save 
    1908                 //get name from textwave of the activeType dataset 
    1909                 String textStr = "root:Packages:NIST:VSANS:"+activeType+":textread" 
    1910                 Wave/T textPath = $textStr 
    1911                 String tempFilename = samStr 
    1912                 If(WaveExists(textPath) == 1) 
    1913  
    1914                         newFileName = RemoveEnding("SAMFileName.nxs.ngv",".nxs.ngv")            //NCNR data drops here, trims to 8 chars 
    1915  
    1916                 else 
    1917                         newFileName = ""                        //if the header is missing? 
    1918                         //Print "can't read the header - newfilename is null" 
    1919                 Endif 
     2039                newFileName = RemoveEnding(sameFileLoaded,".nxs.ngv") 
    19202040                 
    19212041                //pick ABS or AVE extension 
     
    19412061                //Path is catPathName, symbolic path 
    19422062                //if this doesn't exist, a dialog will be presented by setting dialog = 1 
     2063                // 
     2064                // 
    19432065                Variable dialog = 0 
    19442066                PathInfo/S catPathName 
     
    19522074                        //auto-generate name and prepend path - won't put up any dialogs since it has all it needs 
    19532075                        //use autoname if present 
    1954                         if (cmpstr(autoname,"") != 0) 
    1955                                 fullPath = S_Path + autoname + "." +exten 
    1956                         else 
    1957                                 fullPath = S_Path + newFileName+"." + exten 
    1958                         endif    
     2076//                      if (cmpstr(autoname,"") != 0) 
     2077//                              fullPath = S_Path + autoname + "." +exten 
     2078//                      else 
     2079//                              fullPath = S_Path + newFileName+"." + exten 
     2080//                      endif    
    19592081                Endif 
    19602082                // 
     
    19782100//                                      WriteWaves_W_Protocol(activeType,fullpath,dialog) 
    19792101//                              endif 
     2102// 
     2103// TODO: 
     2104// -- fill in all of the cases, default is only the "standard" I(q) 
     2105                                V_ConcatenateForSave(activeType,binType) 
     2106                                V_Write1DData(activeType,newFileName+"."+exten)         //don't pass the full path, just the name 
     2107 
    19802108                endswitch 
    19812109                 
     
    19922120//values are passed back as a global string variable (keyword=value) 
    19932121// 
    1994 Proc V_AskForAbsoluteParams(c2,c3,c4,c5,err) 
    1995         Variable c2=0.95,c3=0.1,c4=1,c5=32.0,err=0 
     2122Proc V_AskForAbsoluteParams(c2,c3,c4,c5,I_err) 
     2123        Variable c2=0.95,c3=0.1,c4=1,c5=32.0,I_err=0.32 
    19962124        Prompt c2, "Standard Transmission" 
    19972125        Prompt c3, "Standard Thickness (cm)" 
    19982126        Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" 
    19992127        Prompt c5, "Standard Cross-Section (cm-1)" 
    2000         Prompt err, "error in I(q=0) (one std dev)" 
     2128        Prompt I_err, "error in I(q=0) (one std dev)" 
    20012129         
    20022130        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="" 
     
    20062134        root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr +=  ";" + "IZERO="+num2str(c4) 
    20072135        root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr +=  ";" + "XSECT="+num2str(c5) 
    2008         root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr +=  ";" + "SDEV="+num2str(err) 
     2136        root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr +=  ";" + "SDEV="+num2str(I_err) 
    20092137         
    20102138End 
     
    20162144// 
    20172145//asks the user for absolute scaling information. the user can either 
    2018 //enter the 4 necessary values in manually (missing parameter dialog) 
     2146//enter the 5 necessary values in manually (missing parameter dialog) 
    20192147//or the user can select an empty beam file from a standard open dialog 
    20202148//if an empty beam file is selected, the "kappa" value is automatically calculated 
    20212149//in either case, the global keyword=value string is set. 
    20222150// 
    2023 //Proc AskForAbsoluteParams_Quest() 
    20242151Function V_AskForAbsoluteParams_Quest()  
    20252152         
    2026         Variable err, isNG5=0,loc,refnum 
     2153        Variable err,loc,refnum 
    20272154        //ask user if he wants to use a transmision file for absolute scaling 
    20282155        //or if he wants to enter his own information 
     
    20812208                // - obsucre bug if "ask" in ABS section of protocol clears RAW folder, then Q-axes can't be set from RAW:RealsRead 
    20822209 
    2083                 Printf "Kappa was successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 
     2210                Printf "Kappa was un-successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 
    20842211        Endif 
    20852212         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r1026 r1027  
    819819// 
    820820// -- currently just the graph, no controls 
    821 // -- this re-bins the data every time by calling V_QBinAllPanels(folderStr) 
     821// -- this re-bins the data every time by calling V_QBinAllPanels(folderStr,binType) 
    822822Function V_IvsQPanelButtonProc(ba) : ButtonControl 
    823823        STRUCT WMButtonAction &ba 
     
    827827                        // click code here 
    828828                         
    829                         V_PlotData_Panel() 
     829                        V_PlotData_Panel(-9999)         //-9999 requests a read from the popup on the panel 
    830830                         
    831831                        break 
     
    997997                        // click code here 
    998998 
    999                         Execute "V_Combine1DData()"                      
     999                        V_SimpleSave1DData("","")                
    10001000                                 
    10011001                        break 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf

    r1026 r1027  
    471471        // -- update the 1D plotting as needed. these are SANS calls (OK for now, but will need to be better) 
    472472        //do the average and plot (either the default, or what is on the panel currently) 
    473         V_PlotData_Panel() 
     473        V_PlotData_Panel(-9999)         // read the binType from the panel 
    474474         
    475475 
     
    581581//  do when they fail? I don't want them to spit up another open file dialog 
    582582// 
     583// -- problem -- if "sans1234.abs" is passed, then V_getStringFromHDF5(fname,path,num) 
     584//  will remove the extension and look for the sans1234 folder -- which may or may not be present. 
     585//  If it is present, then sans1234 validates as RAW data -- which is incorrect! 
     586// -- so I need a way to exclude everything that does not have the proper extension... 
     587// 
     588// 
    583589Function V_CheckIfRawData(fname) 
    584590        String fname 
    585591         
    586         Variable refnum,totalBytes 
    587592        String testStr="" 
    588          
    589         testStr = V_getInstrumentName(fname) 
    590  
    591         if(cmpstr(testStr,"NG3-VSANS") == 0) 
    592                 //testStr exists, ASSUMING it's a raw VSANS data file 
    593                 Return(1) 
     593 
     594// check for the proper raw data extension 
     595        if( stringmatch(fname,"*.nxs.ngv*") ) 
     596                // name appears OK, proceed 
     597                testStr = V_getInstrumentName(fname) 
     598 
     599                if(cmpstr(testStr,"NG3-VSANS") == 0) 
     600                        //testStr exists, ASSUMING it's a raw VSANS data file 
     601                        Return(1) 
     602                else 
     603                        //some other file 
     604                        Return(0) 
     605                Endif 
     606         
    594607        else 
    595                 //some other file 
    596                 Return(0) 
    597         Endif 
     608                // not a proper raw VSANS file name 
     609                return(0) 
     610                 
     611        endif    
     612         
     613 
    598614End 
    599615 
     
    890906                item = StringFromList(ii, list  ,";") 
    891907 
    892                 validName = V_FindValidFileName(item) 
    893                 if(strlen(validName) != 0)              //non-null return from FindValidFileName() 
    894                         fullName = path + validName              
    895  
    896         //method (1)                     
    897 //                      if(V_CheckIfRawData(item)) 
    898 //                              newlist += item + ";" 
    899 //                      endif 
     908//              validName = V_FindValidFileName(item) 
     909//              if(strlen(validName) != 0)              //non-null return from FindValidFileName() 
     910//                      fullName = path + validName              
    900911 
    901912        //method (2)                     
     
    905916 
    906917                         
    907                 endif 
     918//              endif 
    908919                //print "ii=",ii 
    909920        endfor 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r1024 r1027  
    8585                // I can delete these if they came along with RAW 
    8686                //   DAS_logs 
    87                 //   top-level copies of data (duplicate links) 
     87                //   top-level copies of data (duplicate links, these should not be present in a proper NICE file) 
    8888                KillDataFolder/Z $(toDF+":entry:DAS_logs") 
    8989                KillDataFolder/Z $(toDF+":entry:data") 
Note: See TracChangeset for help on using the changeset viewer.