Ignore:
Timestamp:
Apr 9, 2007 3:42:39 PM (16 years ago)
Author:
srkline
Message:

2nd pass of pulling out NCNR calls. Also cleared a lot of deadwood from the code, removing depricated functions that were mostly already commented out.

Location:
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/AvgGraphics.ipf

    r40 r76  
    845845        Wave yErrWave=$(curPath+"yErrWave") 
    846846         
    847         DoWindow/F Plot_1d 
    848 //      If(V_flag == 1)         //the graph window already exists 
    849 //              //kill the old graph and make a new one 
    850 //              //easier than adjusting the old one 
    851 //              DoWindow/K Plot_1d 
    852 //      Endif 
    853 //      Init_Plot1d() 
    854847        Variable/G root:myGlobals:Plot_1d:isPhiAve=0    //0 signifies (normal) x=qvals 
    855848        //make a completely new graph 
    856849        Draw_Plot1D(xAxisWave,yAxisWave,YErrWave) 
    857          
    858 // OLD graph creation routines   
    859 //      Display /W=(412,51,727,302)/K=1 yAxisWave vs xAxisWave 
    860 //      ModifyGraph log=1 
    861 //      ModifyGraph mode=3,marker=19,msize=1,rgb=(0,0,0) 
    862 //      ErrorBars yAxisWave Y,wave=(yErrWave,yErrWave) 
    863 //      Label left "Counts" 
    864 //      Label bottom "q\\U" 
    865 //      SVAR angst = root:myGlobals:gAngstStr 
    866 //      Label bottom "q ("+angst+"\\S-1\\M)" 
    867 //      DoWindow/C Plot_1d 
    868850         
    869851        return(0) 
     
    894876        Wave yErrWave=$(curPath+"yErrWave") 
    895877         
    896         DoWindow/F Plot_1d 
    897 //      If(V_flag == 1)         //the graph window already exists 
    898                 //kill the old graph and make a new one 
    899                 //easier than adjusting the old one 
    900 //              DoWindow/K Plot_1d 
    901 //      Endif    
    902 //      Init_Plot1d() 
    903878        Variable/G root:myGlobals:Plot_1d:isPhiAve=1    //1 signifies x=phival 
    904879        //make a completely new graph 
    905880        Draw_Plot1D(xAxisWave,yAxisWave,YErrWave) 
    906  
    907 // OLD graph creation routines 
    908 //      Display /W=(412,51,727,302)/K=1 yAxisWave vs xAxisWave 
    909 //      ModifyGraph log=0 
    910 //      ModifyGraph mode=3,marker=19,msize=1,rgb=(0,0,0) 
    911 //      ErrorBars yAxisWave Y,wave=(yErrWave,yErrWave) 
    912 //      Label left "Counts" 
    913 //      Label bottom "Angle (degrees)" 
    914 //      DoWindow/C Plot_1d 
    915881         
    916882        return(0) 
     
    11861152                        break 
    11871153                endif 
    1188                 //more ifs for each case 
     1154                //more ifs for each case as they are added 
    11891155                 
    11901156                // if selection not found, abort 
     
    12581224        ModifyGraph log(bottom)=(logBottom) 
    12591225         
    1260 //      SetDataFolder dfSav             //didn't change the data folder 
    1261 End 
    1262  
     1226End 
     1227 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Buttons.ipf

    r47 r76  
    183183End 
    184184 
    185 //sets the low cutoff of the color mapping (threshold) 
    186 //Function LowThreshSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    187 //      String ctrlName 
    188 //      Variable varNum 
    189 //      String varStr 
    190 //      String varName 
    191 //       
    192 //      ControlInfo/W=SANS_Data lowThresh 
    193 //      Variable loScale = V_Value 
    194 // 
    195 //      ControlInfo/W=SANS_Data highThresh 
    196 //      Variable hiScale = V_Value 
    197 // 
    198 //      String result = ImageInfo("SANS_Data","data",0) 
    199 //      String fullPath = StringByKey("ZWAVEDF", result, ":", ";") 
    200 //      fullpath += "data" 
    201 //      //Print fullpath 
    202 //      WaveStats/Q $fullpath 
    203 //      Variable maxData=V_max 
    204 // 
    205 //   WAVE NIHColors = $"root:myGlobals:NIHColors" 
    206 //      ScaleColorsToData((loScale*maxData),(hiScale*maxData),NIHColors) 
    207 //      ModifyImage/W=SANS_Data data cindex=NIHColors 
    208 ////    ModifyImage/W=SANS_Data vlegend cindex=NIHColors 
    209 // 
    210 //End 
    211  
    212 //sets the high cutoff of the color mapping (threshold) 
    213 //Function HighThreshSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    214 //      String ctrlName 
    215 //      Variable varNum 
    216 //      String varStr 
    217 //      String varName 
    218 // 
    219 //      ControlInfo/W=SANS_Data lowThresh 
    220 //      Variable loScale = V_Value 
    221 // 
    222 //      ControlInfo/W=SANS_Data highThresh 
    223 //      Variable hiScale = V_Value 
    224 // 
    225 //      String result = ImageInfo("SANS_Data","data",0) 
    226 //      String fullPath = StringByKey("ZWAVEDF", result, ":", ";") 
    227 //      fullpath += "data" 
    228 //      //Print fullpath 
    229 //      WaveStats/Q $fullpath 
    230 //      Variable maxData=V_max 
    231 // 
    232 //      WAVE NIHColors = $"root:myGlobals:NIHColors" 
    233 //      ScaleColorsToData((loScale*maxData),(hiScale*maxData),NIHColors) 
    234 //      ModifyImage/W=SANS_Data data cindex=NIHColors 
    235 ////    ModifyImage/W=SANS_Data vlegend cindex=NIHColors 
    236 //       
    237 //End 
    238  
    239185//button procedure to display previous RAW data file 
    240186//incremented by run number, not dependent on file prefix 
     
    328274 
    329275 
    330 //invoked by function key, (if menu declared)or the arrow button 
    331 //on Raw data display 
     276//invoked by function key, (if menu declared) 
    332277// if no window, or if display type is not RAW, do nothing 
    333278Function NextRawFile() 
     
    344289        LoadPlotAndDisplayRAW(1)                //go to next file 
    345290 
    346 //      //do the average (either the default, or what is on the panel currently 
    347 //      if(!DataFolderExists("root:myGlobals:Drawing")) 
    348 //              Execute "InitializeAveragePanel()" 
    349 //      endif 
    350 //      Panel_DoAverageButtonProc("")           //the avg panel does not need to be open, folders must exist 
    351291        return 0 
    352292end 
    353293 
    354 //invoked by function key, (if menu declared)or the arrow button 
    355 //on Raw data display 
     294//invoked by function key, (if menu declared) 
    356295// if no window, or if display type is not RAW, do nothing 
    357296Function PreviousRawFile() 
     
    368307        LoadPlotAndDisplayRAW(-1)               //go to previous file 
    369308 
    370 //      //do the average (either the default, or what is on the panel currently 
    371 //      if(!DataFolderExists("root:myGlobals:Drawing")) 
    372 //              Execute "InitializeAveragePanel()" 
    373 //      endif 
    374 //      Panel_DoAverageButtonProc("")           //the avg panel does not need to be open, folders must exist 
    375309        return 0 
    376310end 
    377  
    378311 
    379312//test function invoked by F5 
     
    388321        endif 
    389322        GetSelection table,CatVSTable,3 
    390 //      Print V_startRow 
    391323         
    392324        Wave/T fWave = $"root:myGlobals:CatVSHeaderInfo:Filenames" 
     
    400332        fRawWindowHook() 
    401333 
    402         //do the average (either the default, or what is on the panel currently 
     334        // if you want a plot, too 
     335        //do the average and plot (either the default, or what is on the panel currently 
    403336        if(!DataFolderExists("root:myGlobals:Drawing")) 
    404337                Execute "InitializeAveragePanel()" 
    405338        endif 
    406339        Panel_DoAverageButtonProc("")           //the avg panel does not need to be open, folders must exist 
     340         
    407341        return(0) 
    408342End 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/CatVSTable.ipf

    r74 r76  
    22#pragma version=5.0 
    33#pragma IgorVersion=4.0 
    4  
    54 
    65// 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/CircSectAve.ipf

    r47 r76  
    329329        DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
    330330         
    331         //print fileStr 
    332 //      do 
    333 //        if(strsearch(fileStr, "NG5", 0) != -1) 
    334 //          //string was found, it's an NG5 file 
    335 //          DDet = 1.0 
    336 //          break 
    337 //        Endif 
    338 //        if(strsearch(fileStr, "NG3", 0) != -1) 
    339 //          //string was found, it's an NG3 file 
    340 //          DDet = 0.5 
    341 //          break 
    342 //        Endif 
    343 //        if(strsearch(fileStr, "NG7", 0) != -1) 
    344 //          //string was found, it's an NG7 file 
    345 //          DDet = 0.5 
    346 //          break 
    347 //        Endif 
    348 //      while(0) 
    349  
    350331        //Width of annulus used for the average is gotten from the 
    351332        //input dialog before.  This also must be passed to the resolution 
     
    356337 
    357338        ii=0 
    358 //      String res_string="root:myGlobals:Res_vals" 
    359 //      Make/O/D/N=3 $res_string 
    360 //      Wave res_wave=$res_string 
     339 
    361340        Variable ret1,ret2,ret3 
    362341        do 
    363342                getResolution(qval[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,ddr,ret1,ret2,ret3) 
    364                 sigmaq[ii] = ret1       //res_wave[0] 
    365                 qbar[ii] = ret2         //res_wave[1] 
    366                 fsubs[ii] = ret3                //res_wave[2] 
     343                sigmaq[ii] = ret1        
     344                qbar[ii] = ret2  
     345                fsubs[ii] = ret3         
    367346                ii+=1 
    368347        while(ii<nq) 
     
    374353        //Plot the data in the Plot_1d window 
    375354        Avg_1D_Graph(aveint,qval,sigave) 
    376 //      DoWindow/F Plot_1d 
    377 //      If(V_flag == 1)         //the graph window already exists 
    378 //              //kill the old graph and make a new one 
    379 //              //easier than adjusting the old one 
    380 //              DoWindow/K Plot_1d 
    381 //      Endif 
    382 //      //make a completely new graph 
    383 //      Display /W=(412,51,727,302)/K=1 aveint vs qval 
    384 //      ModifyGraph log=1 
    385 //      ModifyGraph mode=3,marker=19,msize=1,rgb=(0,0,0) 
    386 //      ErrorBars aveint Y,wave=(sigave,sigave) 
    387 //      Label left "Counts";DelayUpdate 
    388 //      Label bottom "q\\U" 
    389 //      SVAR angst = root:myGlobals:gAngstStr 
    390 //      Label bottom "q ("+angst+"\\S-1\\M)" 
    391 //      DoWindow/C Plot_1d 
    392          
     355 
    393356        //get rid of the default mask, if one was created (it is in the current folder) 
    394357        //don't just kill "mask" since it might be pointing to the one in the MSK folder 
     
    493456                //rename the button to reflect "isLin" - the displayed name must have been isLog 
    494457                Button bisLog,title="isLin",rename=bisLin 
    495                  
    496458        Endif 
    497459 
     
    522484        Return 0 
    523485End 
    524 //above is unused function 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Correct.ipf

    r47 r76  
    3131//******************************** 
    3232 
    33  
    3433//unused test procedure for Correct() function 
    3534//must be updated to include "mode" parameter before re-use 
     
    5756End 
    5857 
    59 //mode describes the type of subtraction that is to be done 
    60 //1 = both emp and bgd subtraction 
    61 //2 = only bgd subtraction 
    62 //3 = only emp subtraction 
    63 //4 = no subtraction (handled by ExecuteProtocol(), but implemented here as well) 
    64 // 
    65 // + 10 indicates that WORK.DRK is to be used 
    66 //**********unused*********** 
    67 //**worse yet, only partially converted to use DRK files!*********** 
    68 // 
    69 Function OLD_Correct(mode) 
    70         Variable mode 
    71          
    72         //Print "mode = ",mode 
    73         if(mode==4) 
    74                 Print "no subtraction required - Correct(mode) should not have been called" 
    75                 return(1)               //error - correct should not have been called 
    76         Endif 
    77          
    78         // always check for existence of data in SAM 
    79         // if the desired workfile doesn't exist, let the user know, and abort 
    80         String destPath 
    81         String type = "SAM" 
    82         //check for SAM 
    83         destPath = "root:"+Type + ":data" 
    84         if(WaveExists($destpath) == 0) 
    85                 Print "There is no work file in "+type+"--Aborting" 
    86                 Return(1)               //error condition 
    87         else 
    88                 //check for log-scaling of the "SAM" data and adjust if necessary 
    89                 ConvertFolderToLinearScale(type) 
    90                 Wave sam_data = $"root:SAM:data" 
    91         Endif 
    92          
    93         //check for BGD if mode = 1 or 2 or 11 or 12 
    94         if( (mode ==1) || (mode==2) || (mode==11) || (mode==12) ) 
    95                 type = "BGD" 
    96                 destPath =  "root:"+Type + ":data" 
    97                 if(WaveExists($destpath) == 0) 
    98                         Print "There is no work file in "+type+"--Aborting" 
    99                         Return(1)               //error condition 
    100                 else 
    101                         //check for log-scaling of the "BGD" data and adjust if necessary 
    102                         ConvertFolderToLinearScale(type) 
    103                         Wave bgd_data = $"root:BGD:data" 
    104                 Endif 
    105         Endif 
    106          
    107         // check for EMP data if type 3 or 1 or 13 or 11 
    108         if( (mode==1) || (mode==3) || (mode==11) || (mode==13) ) 
    109                 type = "EMP" 
    110                 destPath =  "root:"+Type + ":data" 
    111                 if(WaveExists($destpath) == 0) 
    112                         Print "There is no work file in "+type+"--Aborting" 
    113                         Return(1)               //error condition 
    114                 else 
    115                         //check for log-scaling of the "EMP" data and adjust if necessary 
    116                         ConvertFolderToLinearScale(type) 
    117                         Wave emp_data = $"root:EMP:data" 
    118                 Endif 
    119         Endif 
    120          
    121         // check for DRK data if type 11,12,13, or 14 
    122         if( (mode==11) || (mode==12) || (mode==13) || (mode==14) ) 
    123                 type = "DRK" 
    124                 destPath =  "root:"+Type + ":data" 
    125                 if(WaveExists($destpath) == 0) 
    126                         Print "There is no work file in "+type+"--Aborting" 
    127                         Return(1)               //error condition 
    128                 else 
    129                         //check for log-scaling of the "EMP" data and adjust if necessary 
    130                         ConvertFolderToLinearScale(type) 
    131                         Wave drk_data = $"root:DRK:data" 
    132                 Endif 
    133         Endif 
    134          
    135         //necessary files exist, proceed 
    136  
    137         //make needed wave references to other folders 
    138         //NOTE that these references MAY NOT EXIST, depending on the mode 
    139         WAVE sam_reals = $"root:SAM:realsread" 
    140         WAVE sam_ints = $"root:SAM:integersread" 
    141         WAVE/T sam_text = $"root:SAM:textread" 
    142         WAVE/Z emp_reals = $"root:EMP:realsread" 
    143         WAVE/Z emp_ints = $"root:EMP:integersread" 
    144         WAVE/T/Z emp_text = $"root:EMP:textread" 
    145         WAVE/Z bgd_reals = $"root:BGD:realsread" 
    146         WAVE/Z bgd_ints = $"root:BGD:integersread" 
    147         WAVE/T/Z bgd_text = $"root:BGD:textread" 
    148          
    149         //find the attenuation of the sample (if any) 
    150         Variable SamAttenFactor,lambda,attenNo,err=0 
    151         String samfileStr="" 
    152         samfileStr = sam_text[3] 
    153         lambda = sam_reals[26] 
    154         attenNo = sam_reals[3] 
    155         SamAttenFactor = AttenuationFactor(samFileStr,lambda,AttenNo) 
    156         //if sample trans is zero, do only SAM-BGD subtraction (notify the user) 
    157         Variable sam_trans = sam_reals[4] 
    158          
    159         //copy SAM information to COR, wiping out the old contents of the COR folder first 
    160         err = CopyWorkContents("SAM","COR")      
    161         if(err==1) 
    162                 Abort "No data in SAM, abort from Correct()" 
    163         endif 
    164          
    165         //now switch to COR folder 
    166         DestPath="root:COR" 
    167         //make appropriate wave references 
    168         WAVE data=$(destPath + ":data")                                 // these wave references point to the SAM data in COR 
    169         WAVE/T textread=$(destPath + ":textread")                       //that are to be directly operated on 
    170         WAVE integersread=$(destPath + ":integersread") 
    171         WAVE realsread=$(destPath + ":realsRead") 
    172  
    173         NVAR pixelsX = root:myGlobals:gNPixelsX 
    174         NVAR pixelsY = root:myGlobals:gNPixelsY 
    175          
    176         //Print "done copying data, starting the correct calculations" 
    177          
    178         // Start the actual "correct" step here 
    179         Variable wcen=0.001,numsam,tmonsam,tsam,rsam,csam,fsam 
    180         Variable tmonbgd,fbgd,xshift,yshift,rbgd,cbgd,sh_sum,ii,jj,trans,tmonemp,temp,femp 
    181         Variable cemp,remp 
    182         //make temporary waves to hold the intermediate results and the shifted arrays 
    183         Duplicate/O data cor1,cor2 
    184         cor1 = 0                //initialize to zero 
    185         cor2 = 0 
    186          
    187         //make needed wave references to other folders 
    188         Wave sam_reals = $"root:SAM:realsread" 
    189         Wave bgd_reals = $"root:BGD:realsread" 
    190         Wave emp_reals = $"root:EMP:realsread" 
    191          
    192         //get counts, trans, etc. from file headers 
    193         numsam = sam_ints[3]            //number of runs in SAM file 
    194         tmonsam = sam_reals[0]          //monitor count in SAM 
    195         tsam = sam_reals[4]             //SAM transmission 
    196         csam = sam_reals[16]            //x center 
    197         rsam = sam_reals[17]            //beam (x,y) define center of corrected field 
    198         //Print "rsam,csam = ",rsam,csam 
    199          
    200         // 
    201         //do sam-bgd subtraction if mode (1) or (2) 
    202         //else (mode 3), set cor1 = sam_data 
    203         if( (mode==1) || (mode==2) ) 
    204                 fsam = 1 
    205                 tmonbgd = bgd_reals[0]          //monitor count in BGD 
    206                 fbgd = tmonsam/tmonbgd  //this should be ==1 since normalized files 
    207          
    208                 //set up  center shift, relative to SAM 
    209                 cbgd = bgd_reals[16] 
    210                 rbgd = bgd_reals[17] 
    211                 //Print "rbgd,cbgd = ",rbgd,cbgd 
    212                 xshift = cbgd-csam 
    213                 yshift = rbgd-rsam 
    214                 if(abs(xshift) <= wcen) 
    215                         xshift = 0 
    216                 Endif 
    217                 if(abs(yshift) <= wcen) 
    218                         yshift = 0 
    219                 Endif 
    220                  
    221                 If((xshift != 0) || (yshift != 0)) 
    222                         DoAlert 1,"Do you want to ignore the beam center mismatch?" 
    223                         if(V_flag==1)           //yes -> just go on 
    224                                 xshift=0 
    225                                 yshift=0 
    226                         endif 
    227                 endif 
    228                 //do the sam-bgd subtraction,  deposit result in cor1[][] 
    229                 If((xshift == 0) && (yshift == 0)) 
    230                         //great, no shift required 
    231                         cor1 = fsam*sam_data - fbgd*bgd_data*SamAttenFactor 
    232                 else 
    233                         //shift required, very time-consuming 
    234                         Print "sam-bgd shift x,y = ",xshift,yshift 
    235                         Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
    236                         ii=0 
    237                         do 
    238                                 jj=0 
    239                                 do 
    240                                         //get the contribution of shifted data 
    241                                         sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 
    242                                         if(noadd[0]) 
    243                                                 cor1[ii][jj]=0 
    244                                         else 
    245                                                 //add the sam_data + shifted sum  
    246                                                 cor1[ii][jj] = fsam*sam_data[ii][jj] - fbgd*sh_sum*SamAttenFactor 
    247                                         Endif 
    248                                         jj+=1 
    249                                 while(jj<pixelsY) 
    250                                 ii+=1 
    251                         while(ii<pixelsX) 
    252                 Endif 
    253         else                    //switch on mode 
    254                 cor1 = sam_data         //setup for just EMP subtraction 
    255         Endif 
    256          
    257         //Print "sam-bgd done" 
    258          
    259         if(mode == 2)           //just a BGD subtraction 
    260                 //we're done, get out w/no error 
    261                 //set the COR data to the result 
    262                 data = cor1 
    263                 //update COR header 
    264                 textread[1] = date() + " " + time()             //date + time stamp 
    265                 SetDataFolder root: 
    266                 KillWaves/Z cor1,cor2 
    267                 Return(0) 
    268         Endif 
    269          
    270         //if mode ==1 (ONLY choice left) do the empty-background subtraction 
    271         //else mode = 3, set cor2 to emp_data 
    272         if(mode==1)             //full subtraction 
    273                 trans = emp_reals[4]            //EMP transmission 
    274                 if(trans == 0) 
    275                         trans = 1 
    276                         DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 
    277                 endif 
    278                 tmonemp = emp_reals[0] 
    279                 femp = tmonsam/tmonemp 
    280                 temp = trans 
    281          
    282                 //set up center shift, relative to EMP 
    283                 cemp = emp_reals[16] 
    284                 remp = emp_reals[17] 
    285                 //Print "remp,cemp ",remp,cemp 
    286                 xshift = cbgd - cemp 
    287                 yshift = rbgd - remp 
    288                 if(abs(xshift) <= wcen ) 
    289                         xshift = 0 
    290                 endif 
    291                 if(abs(yshift) <= wcen) 
    292                         yshift = 0 
    293                 endif 
    294                  
    295                 If((xshift != 0) || (yshift != 0)) 
    296                         DoAlert 1,"Do you want to ignore the beam center mismatch?" 
    297                         if(V_flag==1) 
    298                                 xshift=0 
    299                                 yshift=0 
    300                         endif 
    301                 endif 
    302                 //do the emp-bgd subtraction,  deposit result in cor2[][] 
    303                 If((xshift == 0) && (yshift == 0)) 
    304                         //great, no shift required, DON'T scale this by the attenuation gfactor 
    305                         cor2 = femp*emp_data - fbgd*bgd_data 
    306                 else 
    307                         //shift required, very time-consuming 
    308                         Print "emp-bgd shift x,y = ",xshift,yshift 
    309                         Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
    310                         ii=0 
    311                         do 
    312                                 jj=0 
    313                                 do 
    314                                         //get the contribution of shifted data 
    315                                         sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 
    316                                         if(noadd[0]) 
    317                                                 cor2[ii][jj]=0 
    318                                         else 
    319                                                 //add the sam_data + shifted sum  
    320                                                 cor2[ii][jj] = femp*emp_data[ii][jj] - fbgd*sh_sum 
    321                                         Endif 
    322                                         jj+=1 
    323                                 while(jj<pixelsY) 
    324                                 ii+=1 
    325                         while(ii<pixelsX) 
    326                 Endif 
    327         else            //switch on mode==1 for full subtraction 
    328                 cor2 = emp_data 
    329                 //be sure to set the empty center location... for the shift 
    330                 trans = emp_reals[4]            //EMP transmission 
    331                 if(trans == 0) 
    332                         trans = 1 
    333                         DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 
    334                 endif 
    335                 tmonemp = emp_reals[0] 
    336                 femp = tmonsam/tmonemp 
    337                 temp = trans 
    338          
    339                 //set up center shift, relative to EMP 
    340                 cemp = emp_reals[16] 
    341                 remp = emp_reals[17] 
    342         Endif 
    343          
    344         //Print "emp-bgd done" 
    345          
    346         //mode 2 exited, either 1 or 3 apply from here, and are setup properly. 
    347          
    348         //set up for final step, data(COR) = cor1 - Tsam/Temp*cor2 
    349         //set up shift, relative to SAM 
    350         xshift = cemp - csam 
    351         yshift = remp - rsam 
    352         if(abs(xshift) <= wcen ) 
    353                 xshift = 0 
    354         endif 
    355         if(abs(yshift) <= wcen) 
    356                 yshift = 0 
    357         endif 
    358          
    359         If((xshift != 0) || (yshift != 0)) 
    360                 DoAlert 1,"Do you want to ignore the beam center mismatch?" 
    361                 if(V_flag==1) 
    362                         xshift=0 
    363                         yshift=0 
    364                 endif 
    365         endif 
    366         //do the cor1-a*cor2 subtraction,  deposit result in data[][] (in the COR folder) 
    367         If((xshift == 0) && (yshift == 0)) 
    368                 //great, no shift required 
    369                 data = cor1 - (tsam/temp)*cor2*SamAttenFactor 
    370         else 
    371                 //shift required, very time-consuming 
    372                 Print "sam-emp shift x,y = ",xshift,yshift 
    373                 Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
    374                 ii=0 
    375                 do 
    376                         jj=0 
    377                         do 
    378                                 //get the contribution of shifted data 
    379                                 sh_sum = ShiftSum(cor2,ii,jj,xshift,yshift,noadd) 
    380                                 if(noadd[0]) 
    381                                         data[ii][jj]=0 
    382                                 else 
    383                                         //add the sam_data + shifted sum  
    384                                         data[ii][jj] = cor1[ii][jj] - (tsam/temp)*sh_sum*SamAttenFactor 
    385                                 Endif 
    386                                 jj+=1 
    387                         while(jj<pixelsY) 
    388                         ii+=1 
    389                 while(ii<pixelsX) 
    390         Endif 
    391          
    392         //Print "all done" 
    393          
    394         //update COR header 
    395         textread[1] = date() + " " + time()             //date + time stamp 
    396          
    397         //clean up 
    398         SetDataFolder root:COR 
    399         SetDataFolder root: 
    400         KillWaves/Z cor1,cor2,noadd 
    401  
    402         Return(0)               //all is ok, if you made it to this point 
    403 End 
    40458 
    40559//mode describes the type of subtraction that is to be done 
     
    13851039 
    13861040////////////////////////// 
     1041//**********unused*********** 
     1042//mode describes the type of subtraction that is to be done 
     1043//1 = both emp and bgd subtraction 
     1044//2 = only bgd subtraction 
     1045//3 = only emp subtraction 
     1046//4 = no subtraction (handled by ExecuteProtocol(), but implemented here as well) 
     1047// 
     1048// + 10 indicates that WORK.DRK is to be used 
     1049//**********unused*********** 
     1050//**worse yet, only partially converted to use DRK files!*********** 
     1051// 
     1052Function OLD_Correct(mode) 
     1053        Variable mode 
     1054         
     1055        //Print "mode = ",mode 
     1056        if(mode==4) 
     1057                Print "no subtraction required - Correct(mode) should not have been called" 
     1058                return(1)               //error - correct should not have been called 
     1059        Endif 
     1060         
     1061        // always check for existence of data in SAM 
     1062        // if the desired workfile doesn't exist, let the user know, and abort 
     1063        String destPath 
     1064        String type = "SAM" 
     1065        //check for SAM 
     1066        destPath = "root:"+Type + ":data" 
     1067        if(WaveExists($destpath) == 0) 
     1068                Print "There is no work file in "+type+"--Aborting" 
     1069                Return(1)               //error condition 
     1070        else 
     1071                //check for log-scaling of the "SAM" data and adjust if necessary 
     1072                ConvertFolderToLinearScale(type) 
     1073                Wave sam_data = $"root:SAM:data" 
     1074        Endif 
     1075         
     1076        //check for BGD if mode = 1 or 2 or 11 or 12 
     1077        if( (mode ==1) || (mode==2) || (mode==11) || (mode==12) ) 
     1078                type = "BGD" 
     1079                destPath =  "root:"+Type + ":data" 
     1080                if(WaveExists($destpath) == 0) 
     1081                        Print "There is no work file in "+type+"--Aborting" 
     1082                        Return(1)               //error condition 
     1083                else 
     1084                        //check for log-scaling of the "BGD" data and adjust if necessary 
     1085                        ConvertFolderToLinearScale(type) 
     1086                        Wave bgd_data = $"root:BGD:data" 
     1087                Endif 
     1088        Endif 
     1089         
     1090        // check for EMP data if type 3 or 1 or 13 or 11 
     1091        if( (mode==1) || (mode==3) || (mode==11) || (mode==13) ) 
     1092                type = "EMP" 
     1093                destPath =  "root:"+Type + ":data" 
     1094                if(WaveExists($destpath) == 0) 
     1095                        Print "There is no work file in "+type+"--Aborting" 
     1096                        Return(1)               //error condition 
     1097                else 
     1098                        //check for log-scaling of the "EMP" data and adjust if necessary 
     1099                        ConvertFolderToLinearScale(type) 
     1100                        Wave emp_data = $"root:EMP:data" 
     1101                Endif 
     1102        Endif 
     1103         
     1104        // check for DRK data if type 11,12,13, or 14 
     1105        if( (mode==11) || (mode==12) || (mode==13) || (mode==14) ) 
     1106                type = "DRK" 
     1107                destPath =  "root:"+Type + ":data" 
     1108                if(WaveExists($destpath) == 0) 
     1109                        Print "There is no work file in "+type+"--Aborting" 
     1110                        Return(1)               //error condition 
     1111                else 
     1112                        //check for log-scaling of the "EMP" data and adjust if necessary 
     1113                        ConvertFolderToLinearScale(type) 
     1114                        Wave drk_data = $"root:DRK:data" 
     1115                Endif 
     1116        Endif 
     1117         
     1118        //necessary files exist, proceed 
     1119 
     1120        //make needed wave references to other folders 
     1121        //NOTE that these references MAY NOT EXIST, depending on the mode 
     1122        WAVE sam_reals = $"root:SAM:realsread" 
     1123        WAVE sam_ints = $"root:SAM:integersread" 
     1124        WAVE/T sam_text = $"root:SAM:textread" 
     1125        WAVE/Z emp_reals = $"root:EMP:realsread" 
     1126        WAVE/Z emp_ints = $"root:EMP:integersread" 
     1127        WAVE/T/Z emp_text = $"root:EMP:textread" 
     1128        WAVE/Z bgd_reals = $"root:BGD:realsread" 
     1129        WAVE/Z bgd_ints = $"root:BGD:integersread" 
     1130        WAVE/T/Z bgd_text = $"root:BGD:textread" 
     1131         
     1132        //find the attenuation of the sample (if any) 
     1133        Variable SamAttenFactor,lambda,attenNo,err=0 
     1134        String samfileStr="" 
     1135        samfileStr = sam_text[3] 
     1136        lambda = sam_reals[26] 
     1137        attenNo = sam_reals[3] 
     1138        SamAttenFactor = AttenuationFactor(samFileStr,lambda,AttenNo) 
     1139        //if sample trans is zero, do only SAM-BGD subtraction (notify the user) 
     1140        Variable sam_trans = sam_reals[4] 
     1141         
     1142        //copy SAM information to COR, wiping out the old contents of the COR folder first 
     1143        err = CopyWorkContents("SAM","COR")      
     1144        if(err==1) 
     1145                Abort "No data in SAM, abort from Correct()" 
     1146        endif 
     1147         
     1148        //now switch to COR folder 
     1149        DestPath="root:COR" 
     1150        //make appropriate wave references 
     1151        WAVE data=$(destPath + ":data")                                 // these wave references point to the SAM data in COR 
     1152        WAVE/T textread=$(destPath + ":textread")                       //that are to be directly operated on 
     1153        WAVE integersread=$(destPath + ":integersread") 
     1154        WAVE realsread=$(destPath + ":realsRead") 
     1155 
     1156        NVAR pixelsX = root:myGlobals:gNPixelsX 
     1157        NVAR pixelsY = root:myGlobals:gNPixelsY 
     1158         
     1159        //Print "done copying data, starting the correct calculations" 
     1160         
     1161        // Start the actual "correct" step here 
     1162        Variable wcen=0.001,numsam,tmonsam,tsam,rsam,csam,fsam 
     1163        Variable tmonbgd,fbgd,xshift,yshift,rbgd,cbgd,sh_sum,ii,jj,trans,tmonemp,temp,femp 
     1164        Variable cemp,remp 
     1165        //make temporary waves to hold the intermediate results and the shifted arrays 
     1166        Duplicate/O data cor1,cor2 
     1167        cor1 = 0                //initialize to zero 
     1168        cor2 = 0 
     1169         
     1170        //make needed wave references to other folders 
     1171        Wave sam_reals = $"root:SAM:realsread" 
     1172        Wave bgd_reals = $"root:BGD:realsread" 
     1173        Wave emp_reals = $"root:EMP:realsread" 
     1174         
     1175        //get counts, trans, etc. from file headers 
     1176        numsam = sam_ints[3]            //number of runs in SAM file 
     1177        tmonsam = sam_reals[0]          //monitor count in SAM 
     1178        tsam = sam_reals[4]             //SAM transmission 
     1179        csam = sam_reals[16]            //x center 
     1180        rsam = sam_reals[17]            //beam (x,y) define center of corrected field 
     1181        //Print "rsam,csam = ",rsam,csam 
     1182         
     1183        // 
     1184        //do sam-bgd subtraction if mode (1) or (2) 
     1185        //else (mode 3), set cor1 = sam_data 
     1186        if( (mode==1) || (mode==2) ) 
     1187                fsam = 1 
     1188                tmonbgd = bgd_reals[0]          //monitor count in BGD 
     1189                fbgd = tmonsam/tmonbgd  //this should be ==1 since normalized files 
     1190         
     1191                //set up  center shift, relative to SAM 
     1192                cbgd = bgd_reals[16] 
     1193                rbgd = bgd_reals[17] 
     1194                //Print "rbgd,cbgd = ",rbgd,cbgd 
     1195                xshift = cbgd-csam 
     1196                yshift = rbgd-rsam 
     1197                if(abs(xshift) <= wcen) 
     1198                        xshift = 0 
     1199                Endif 
     1200                if(abs(yshift) <= wcen) 
     1201                        yshift = 0 
     1202                Endif 
     1203                 
     1204                If((xshift != 0) || (yshift != 0)) 
     1205                        DoAlert 1,"Do you want to ignore the beam center mismatch?" 
     1206                        if(V_flag==1)           //yes -> just go on 
     1207                                xshift=0 
     1208                                yshift=0 
     1209                        endif 
     1210                endif 
     1211                //do the sam-bgd subtraction,  deposit result in cor1[][] 
     1212                If((xshift == 0) && (yshift == 0)) 
     1213                        //great, no shift required 
     1214                        cor1 = fsam*sam_data - fbgd*bgd_data*SamAttenFactor 
     1215                else 
     1216                        //shift required, very time-consuming 
     1217                        Print "sam-bgd shift x,y = ",xshift,yshift 
     1218                        Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
     1219                        ii=0 
     1220                        do 
     1221                                jj=0 
     1222                                do 
     1223                                        //get the contribution of shifted data 
     1224                                        sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 
     1225                                        if(noadd[0]) 
     1226                                                cor1[ii][jj]=0 
     1227                                        else 
     1228                                                //add the sam_data + shifted sum  
     1229                                                cor1[ii][jj] = fsam*sam_data[ii][jj] - fbgd*sh_sum*SamAttenFactor 
     1230                                        Endif 
     1231                                        jj+=1 
     1232                                while(jj<pixelsY) 
     1233                                ii+=1 
     1234                        while(ii<pixelsX) 
     1235                Endif 
     1236        else                    //switch on mode 
     1237                cor1 = sam_data         //setup for just EMP subtraction 
     1238        Endif 
     1239         
     1240        //Print "sam-bgd done" 
     1241         
     1242        if(mode == 2)           //just a BGD subtraction 
     1243                //we're done, get out w/no error 
     1244                //set the COR data to the result 
     1245                data = cor1 
     1246                //update COR header 
     1247                textread[1] = date() + " " + time()             //date + time stamp 
     1248                SetDataFolder root: 
     1249                KillWaves/Z cor1,cor2 
     1250                Return(0) 
     1251        Endif 
     1252         
     1253        //if mode ==1 (ONLY choice left) do the empty-background subtraction 
     1254        //else mode = 3, set cor2 to emp_data 
     1255        if(mode==1)             //full subtraction 
     1256                trans = emp_reals[4]            //EMP transmission 
     1257                if(trans == 0) 
     1258                        trans = 1 
     1259                        DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 
     1260                endif 
     1261                tmonemp = emp_reals[0] 
     1262                femp = tmonsam/tmonemp 
     1263                temp = trans 
     1264         
     1265                //set up center shift, relative to EMP 
     1266                cemp = emp_reals[16] 
     1267                remp = emp_reals[17] 
     1268                //Print "remp,cemp ",remp,cemp 
     1269                xshift = cbgd - cemp 
     1270                yshift = rbgd - remp 
     1271                if(abs(xshift) <= wcen ) 
     1272                        xshift = 0 
     1273                endif 
     1274                if(abs(yshift) <= wcen) 
     1275                        yshift = 0 
     1276                endif 
     1277                 
     1278                If((xshift != 0) || (yshift != 0)) 
     1279                        DoAlert 1,"Do you want to ignore the beam center mismatch?" 
     1280                        if(V_flag==1) 
     1281                                xshift=0 
     1282                                yshift=0 
     1283                        endif 
     1284                endif 
     1285                //do the emp-bgd subtraction,  deposit result in cor2[][] 
     1286                If((xshift == 0) && (yshift == 0)) 
     1287                        //great, no shift required, DON'T scale this by the attenuation gfactor 
     1288                        cor2 = femp*emp_data - fbgd*bgd_data 
     1289                else 
     1290                        //shift required, very time-consuming 
     1291                        Print "emp-bgd shift x,y = ",xshift,yshift 
     1292                        Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
     1293                        ii=0 
     1294                        do 
     1295                                jj=0 
     1296                                do 
     1297                                        //get the contribution of shifted data 
     1298                                        sh_sum = ShiftSum(bgd_data,ii,jj,xshift,yshift,noadd) 
     1299                                        if(noadd[0]) 
     1300                                                cor2[ii][jj]=0 
     1301                                        else 
     1302                                                //add the sam_data + shifted sum  
     1303                                                cor2[ii][jj] = femp*emp_data[ii][jj] - fbgd*sh_sum 
     1304                                        Endif 
     1305                                        jj+=1 
     1306                                while(jj<pixelsY) 
     1307                                ii+=1 
     1308                        while(ii<pixelsX) 
     1309                Endif 
     1310        else            //switch on mode==1 for full subtraction 
     1311                cor2 = emp_data 
     1312                //be sure to set the empty center location... for the shift 
     1313                trans = emp_reals[4]            //EMP transmission 
     1314                if(trans == 0) 
     1315                        trans = 1 
     1316                        DoAlert 0,"Empty cell transmission was zero. It has been reset to one for the calculation" 
     1317                endif 
     1318                tmonemp = emp_reals[0] 
     1319                femp = tmonsam/tmonemp 
     1320                temp = trans 
     1321         
     1322                //set up center shift, relative to EMP 
     1323                cemp = emp_reals[16] 
     1324                remp = emp_reals[17] 
     1325        Endif 
     1326         
     1327        //Print "emp-bgd done" 
     1328         
     1329        //mode 2 exited, either 1 or 3 apply from here, and are setup properly. 
     1330         
     1331        //set up for final step, data(COR) = cor1 - Tsam/Temp*cor2 
     1332        //set up shift, relative to SAM 
     1333        xshift = cemp - csam 
     1334        yshift = remp - rsam 
     1335        if(abs(xshift) <= wcen ) 
     1336                xshift = 0 
     1337        endif 
     1338        if(abs(yshift) <= wcen) 
     1339                yshift = 0 
     1340        endif 
     1341         
     1342        If((xshift != 0) || (yshift != 0)) 
     1343                DoAlert 1,"Do you want to ignore the beam center mismatch?" 
     1344                if(V_flag==1) 
     1345                        xshift=0 
     1346                        yshift=0 
     1347                endif 
     1348        endif 
     1349        //do the cor1-a*cor2 subtraction,  deposit result in data[][] (in the COR folder) 
     1350        If((xshift == 0) && (yshift == 0)) 
     1351                //great, no shift required 
     1352                data = cor1 - (tsam/temp)*cor2*SamAttenFactor 
     1353        else 
     1354                //shift required, very time-consuming 
     1355                Print "sam-emp shift x,y = ",xshift,yshift 
     1356                Make/O/N=1 noadd                //needed to get noadd condition back from ShiftSum() 
     1357                ii=0 
     1358                do 
     1359                        jj=0 
     1360                        do 
     1361                                //get the contribution of shifted data 
     1362                                sh_sum = ShiftSum(cor2,ii,jj,xshift,yshift,noadd) 
     1363                                if(noadd[0]) 
     1364                                        data[ii][jj]=0 
     1365                                else 
     1366                                        //add the sam_data + shifted sum  
     1367                                        data[ii][jj] = cor1[ii][jj] - (tsam/temp)*sh_sum*SamAttenFactor 
     1368                                Endif 
     1369                                jj+=1 
     1370                        while(jj<pixelsY) 
     1371                        ii+=1 
     1372                while(ii<pixelsX) 
     1373        Endif 
     1374         
     1375        //Print "all done" 
     1376         
     1377        //update COR header 
     1378        textread[1] = date() + " " + time()             //date + time stamp 
     1379         
     1380        //clean up 
     1381        SetDataFolder root:COR 
     1382        SetDataFolder root: 
     1383        KillWaves/Z cor1,cor2,noadd 
     1384 
     1385        Return(0)               //all is ok, if you made it to this point 
     1386End 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/FIT_Ops.ipf

    r70 r76  
    732732End 
    733733 
    734 //function returning a string (list) of semicolon separated filenames 
    735 //that are not version numbers, and not raw data files 
    736 //(can't really pare out other files any better - trying to just get ascii I vs. q) 
    737 //works in folder specified by catPathName, (abort if it doesn't exist) 
    738 // 
    739 //** not used anymore - simpler file filter is used instead 
    740 // 
    741 //Function/S GetValidFITRPAPopupList() 
    742 // 
    743 //      String list = "none;something;" 
    744 //       
    745 //      PathInfo catPathName 
    746 //      String path = S_path 
    747 //      if(V_flag == 0) 
    748 //              Abort "path does not exist - use Pick Path button" 
    749 //      Endif 
    750 //       
    751 //      list = IndexedFile(catPathName,-1,"????")               //get all files in folder 
    752 //       
    753 //      //trim version numbers from list 
    754 //      Variable num = ItemsInList(list,";") 
    755 //      Variable ii,isRAW 
    756 //      String item = "",listCopy = "", fullName = "",partialName = "" 
    757 //       
    758 //      ii=1 
    759 //      do 
    760 //              item = num2str(ii) 
    761 //              list = RemoveFromList(item,list,";") 
    762 //              ii+=1 
    763 //      while (ii<12) 
    764 //       
    765 //      //trim raw data files from list 
    766 //      listCopy = list                                 //scan through items in copy, change list 
    767 //      num = ItemsInList(listCopy,";")         //get the new number of items in the list 
    768 //      ii=0 
    769 //      do 
    770 //              //build valid fileName 
    771 //              item = StringFromList(ii,listCopy,";") 
    772 //              if (strlen(item) !=0 ) 
    773 //                      partialName  = FindValidFileName(item) 
    774 //                      if(strlen(partialName) !=0)             //non-null return from FindValidFileName() 
    775 //                              fullName = path + partialName 
    776 //                              //check if RAW, if so, remove from list 
    777 //                              isRAW = CheckIfRAWData(fullName) 
    778 //                              if(isRAW) 
    779 //                                      list = RemoveFromList(item,list,";") 
    780 //                              Endif 
    781 //                      Endif 
    782 //              Endif 
    783 //              ii+=1 
    784 //      While(ii<num) 
    785 //       
    786 //      return list 
    787 //End 
     734 
    788735 
    789736// window recreation macro to draw the fit/rpa panel 
     
    11071054        qrgh = x*sqrt(nh*ap2/6) 
    11081055        qrgd = x*sqrt(nd*ap2/6) 
    1109         iabs_rpa = kn/(1/(ch*dbf(qrgh)) + 1/(cd*dbf(qrgd)) - chiv) 
     1056        iabs_rpa = kn/(1/(ch*FIT_dbf(qrgh)) + 1/(cd*FIT_dbf(qrgd)) - chiv) 
    11101057        iabs = corr*iabs_rpa + inc 
    11111058         
     
    11331080        qrgh = x*sqrt(nh*ap2/6) 
    11341081        qrgd = x*sqrt(nd*ap2/6) 
    1135         iabs_rpa = kn/(1/(ch*dbf(qrgh)) + 1/(cd*dbf(qrgd)) - chiv) 
     1082        iabs_rpa = kn/(1/(ch*FIT_dbf(qrgh)) + 1/(cd*FIT_dbf(qrgd)) - chiv) 
    11361083        iabs = corr*iabs_rpa + inc 
    11371084         
     
    11591106//The following lines were commented out in the fortran function 
    11601107        //qrgd = x*sqrt(nd*ap2/6) 
    1161         //iabs_rpa = kn/(1/(ch*dbf(qrgh)) + 1/(cd*dbf(qrgd)) - chiv) 
    1162  
    1163         iabs_rpa = kn*dbf(qrgh) 
     1108        //iabs_rpa = kn/(1/(ch*FIT_dbf(qrgh)) + 1/(cd*FIT_dbf(qrgd)) - chiv) 
     1109 
     1110        iabs_rpa = kn*FIT_dbf(qrgh) 
    11641111        iabs = iabs_rpa + inc 
    11651112         
     
    11701117 
    11711118//Debye Function used for polymer standards 
    1172 Function dbf(rgq) 
     1119Function FIT_dbf(rgq) 
    11731120        Variable rgq 
    11741121        Variable x 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/MainPanel.ipf

    r41 r76  
    361361//************* OLD version of Main Panel ************* 
    362362//Window Main_Panel() 
    363 Window Main_Panel_OLD() 
     363Window OLD_Main_Panel() 
    364364        PauseUpdate; Silent 1           // building window... 
    365365        NewPanel /K=2 /W=(630,75,938,408) as "SANS Reduction Controls" 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Marquee.ipf

    r75 r76  
    7979                return(1) 
    8080        endif 
    81                 //printf "marquee left in bottom axis terms: %g\r",round(V_left) 
    82                 //printf "marquee right in bottom axis terms: %g\r",round(V_right) 
    83                 //printf "marquee top in left axis terms: %g\r",round(V_top) 
    84                 //printf "marquee bottom in left axis terms: %g\r",round(V_bottom) 
     81        //printf "marquee left in bottom axis terms: %g\r",round(V_left) 
     82        //printf "marquee right in bottom axis terms: %g\r",round(V_right) 
     83        //printf "marquee top in left axis terms: %g\r",round(V_top) 
     84        //printf "marquee bottom in left axis terms: %g\r",round(V_bottom) 
    8585        Variable x1,x2,y1,y2 
    8686        x1 = round(V_left) 
     
    145145        WriteXYBoxToHeader(filename,x1,x2,y1,y2) 
    146146         
    147         //ReWriteReal() takes care of open/close on its own 
    148147        Print counts, " counts in XY box" 
    149148        WriteBoxCountsToHeader(filename,counts) 
     
    361360        return(0) 
    362361End 
     362 
     363// 
    363364// promts the user for a range of file numbers to perform the sum over 
    364365// list must be comma delimited numbers (or dashes) just as in the BuildProtocol panel 
     
    418419 
    419420//testing function, not used 
    420 Function testKeep(x1,x2,y1,y2) 
     421Function testKeepInBounds(x1,x2,y1,y2) 
    421422        Variable x1,x2,y1,y2 
    422423         
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/MaskUtils.ipf

    r47 r76  
    3939        maskButtonProc("maskButton") 
    4040//      OverlayMask(1) 
    41  
    42  
    43 //      Display/W=(10,50,400,400); AppendImage $waveStr 
    4441 
    4542        //back to root folder (redundant) 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/MultipleReduce.ipf

    r41 r76  
    1515//************************** 
    1616 
     17//panel to allow reduction of a series of files using a selected  protocol 
     18// 
     19//main entry procedure to open the panel, initializing if necessary 
     20Proc ReduceMultipleFiles() 
     21         
     22        DoWindow/F Multiple_Reduce_Panel 
     23        If(V_flag == 0) 
     24                InitializeMultReducePanel() 
     25                //draw panel 
     26                Multiple_Reduce_Panel() 
     27                //pop the protocol list 
     28                MRProtoPopMenuProc("",1,"") 
     29        Endif 
     30End 
     31 
     32//create the global variables needed to run the MReduce Panel 
     33//all are kept in root:myGlobals:MRED 
     34// 
     35Proc InitializeMultReducePanel() 
     36 
     37        If(DataFolderExists("root:myGlobals:MRED")) 
     38                //ok, do nothing 
     39        else 
     40                //no, create the folder and the globals 
     41                NewDataFolder/O root:myGlobals:MRED 
     42//              String/G root:myGlobals:MRED:gMRedMatchStr = "*" 
     43                PathInfo catPathName 
     44                If(V_flag==1) 
     45                        String dum = S_path 
     46                        String/G root:myGlobals:MRED:gCatPathStr = dum 
     47                else 
     48                        String/G root:myGlobals:MRED:gCatPathStr = "no path selected" 
     49                endif 
     50                String/G root:myGlobals:MRED:gMRedList = "none" 
     51                String/G root:myGlobals:MRED:gMRProtoList = "none" 
     52                String/G root:myGlobals:MRED:gFileNumList="" 
     53//              String/G root:myGlobals:MRED:gMRS1 = "no file selected" 
     54//              String/G root:myGlobals:MRED:gMRS2 = "no file selected" 
     55//              String/G root:myGlobals:MRED:gMRS3 = "no box selected" 
     56//              Variable/G root:myGlobals:MRED:gMRV1 =0 
     57//              Variable/G root:myGlobals:MRED:gMRV2 = 999 
     58        Endif  
     59End 
     60 
     61//panel recreation macro for the MRED panel 
     62// 
     63Window Multiple_Reduce_Panel() 
     64        PauseUpdate; Silent 1           // building window... 
     65        NewPanel /W=(535,72,951,228) /K=1 as "Multiple File Reduction" 
     66        ModifyPanel cbRGB=(65535,49151,29490) 
     67        ModifyPanel fixedSize=1 
     68        SetDrawLayer UserBack 
     69        DrawLine 7,30,422,30 
     70        SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" 
     71        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"} 
     72        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gCatPathStr 
     73        Button PathButton,pos={3,3},size={70,20},proc=PickMRPathButton,title="Pick Path" 
     74        Button PathButton,help={"Select the folder containing the raw SANS data files"} 
     75        Button helpButton,pos={385,3},size={25,20},proc=ShowMRHelp,title="?" 
     76        Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} 
     77        PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=MRedPopMenuProc,title="File(s) to Reduce" 
     78        PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} 
     79        PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRedList" 
     80        SetVariable MRList,pos={3,48},size={350,13},proc=FileNumberListProc,title="File number list: " 
     81        SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
     82        SetVariable MRList,limits={-Inf,Inf,1},value= root:myGlobals:MRED:gFileNumList 
     83        Button ReduceAllButton,pos={3,128},size={180,20},proc=ReduceAllPopupFiles,title="Reduce All Files in Popup" 
     84        Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} 
     85        Button DoneButton,pos={292,128},size={110,20},proc=MRDoneButtonProc,title="Done Reducing" 
     86        Button DoneButton,help={"When done reducing files, this will close this control panel."} 
     87        Button cat_short,pos={310,72},size={90,20},proc=DoCatShort,title="File Catalog" 
     88        Button cat_short,help={"Use this button to generate a table with file header information. Very useful for identifying files."} 
     89        Button show_cat_short,pos={280,98},size={120,20},proc=ShowCatShort_MRED,title="Show File Catalog" 
     90        Button show_cat_short,help={"Use this button to bring the File Catalog window to the front."} 
     91        PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=MRProtoPopMenuProc,title="Protocol " 
     92        PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
     93        PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRProtoList" 
     94EndMacro 
    1795 
    1896//simple procedure to bring the CAT TABLE to the front if it is present 
     
    107185End 
    108186 
    109  
    110 //panel to allow reduction of a series of files using a selected  protocol 
    111 // 
    112 //main entry procedure to open the panel, initializing if necessary 
    113 Proc ReduceMultipleFiles() 
    114          
    115         DoWindow/F Multiple_Reduce_Panel 
    116         If(V_flag == 0) 
    117                 InitializeMultReducePanel() 
    118                 //draw panel 
    119                 Multiple_Reduce_Panel() 
    120                 //pop the protocol list 
    121                 MRProtoPopMenuProc("",1,"") 
    122         Endif 
    123 End 
    124  
    125 //create the global variables needed to run the MReduce Panel 
    126 //all are kept in root:myGlobals:MRED 
    127 // 
    128 Proc InitializeMultReducePanel() 
    129  
    130         If(DataFolderExists("root:myGlobals:MRED")) 
    131                 //ok, do nothing 
    132         else 
    133                 //no, create the folder and the globals 
    134                 NewDataFolder/O root:myGlobals:MRED 
    135 //              String/G root:myGlobals:MRED:gMRedMatchStr = "*" 
    136                 PathInfo catPathName 
    137                 If(V_flag==1) 
    138                         String dum = S_path 
    139                         String/G root:myGlobals:MRED:gCatPathStr = dum 
    140                 else 
    141                         String/G root:myGlobals:MRED:gCatPathStr = "no path selected" 
    142                 endif 
    143                 String/G root:myGlobals:MRED:gMRedList = "none" 
    144                 String/G root:myGlobals:MRED:gMRProtoList = "none" 
    145                 String/G root:myGlobals:MRED:gFileNumList="" 
    146 //              String/G root:myGlobals:MRED:gMRS1 = "no file selected" 
    147 //              String/G root:myGlobals:MRED:gMRS2 = "no file selected" 
    148 //              String/G root:myGlobals:MRED:gMRS3 = "no box selected" 
    149 //              Variable/G root:myGlobals:MRED:gMRV1 =0 
    150 //              Variable/G root:myGlobals:MRED:gMRV2 = 999 
    151         Endif  
    152 End 
    153  
    154 //panel recreation macro for the MRED panel 
    155 // 
    156 Window Multiple_Reduce_Panel() 
    157         PauseUpdate; Silent 1           // building window... 
    158         NewPanel /W=(535,72,951,228) /K=1 as "Multiple File Reduction" 
    159         ModifyPanel cbRGB=(65535,49151,29490) 
    160         ModifyPanel fixedSize=1 
    161         SetDrawLayer UserBack 
    162         DrawLine 7,30,422,30 
    163         SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" 
    164         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"} 
    165         SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gCatPathStr 
    166         Button PathButton,pos={3,3},size={70,20},proc=PickMRPathButton,title="Pick Path" 
    167         Button PathButton,help={"Select the folder containing the raw SANS data files"} 
    168         Button helpButton,pos={385,3},size={25,20},proc=ShowMRHelp,title="?" 
    169         Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} 
    170         PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=MRedPopMenuProc,title="File(s) to Reduce" 
    171         PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} 
    172         PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRedList" 
    173         SetVariable MRList,pos={3,48},size={350,13},proc=FileNumberListProc,title="File number list: " 
    174         SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} 
    175         SetVariable MRList,limits={-Inf,Inf,1},value= root:myGlobals:MRED:gFileNumList 
    176 //      SetVariable MRLow,pos={3,72},size={150,13},proc=SetLowFileNumProc,title="File range: " 
    177 //      SetVariable MRLow,help={"Enter the first file number to reduce. Files must be consecutively numbered."} 
    178 //      SetVariable MRLow,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gMRV1 
    179         Button ReduceAllButton,pos={3,128},size={180,20},proc=ReduceAllPopupFiles,title="Reduce All Files in Popup" 
    180         Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} 
    181         Button DoneButton,pos={292,128},size={110,20},proc=MRDoneButtonProc,title="Done Reducing" 
    182         Button DoneButton,help={"When done reducing files, this will close this control panel."} 
    183         Button cat_short,pos={310,72},size={90,20},proc=DoCatShort,title="File Catalog" 
    184         Button cat_short,help={"Use this button to generate a table with file header information. Very useful for identifying files."} 
    185         Button show_cat_short,pos={280,98},size={120,20},proc=ShowCatShort_MRED,title="Show File Catalog" 
    186         Button show_cat_short,help={"Use this button to bring the File Catalog window to the front."} 
    187 //      SetVariable MRHigh,pos={160,73},size={90,13},proc=SetHighFileNumProc,title=" to: " 
    188 //      SetVariable MRHigh,help={"Enter the last file number to reduce. Files must be consecutively numbered."} 
    189 //      SetVariable MRHigh,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gMRV2 
    190         PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=MRProtoPopMenuProc,title="Protocol " 
    191         PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} 
    192         PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRProtoList" 
    193 EndMacro 
    194  
    195187//executed when a list of filenumbers is entered in the box 
    196188//responds as if the file popup was hit, to update the popup list contents 
     
    219211        ShowCATWindow() 
    220212End 
    221  
    222 //obsolete procedure - unused 
    223 // 
    224 //procedure for setVar box to set the low file number (forced to be >=0) 
    225 //sets the global variable, then forces an update of the popup 
    226 // 
    227 //Function SetLowFileNumProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    228 //      String ctrlName 
    229 //      Variable varNum 
    230 //      String varStr 
    231 //      String varName 
    232 //       
    233 //      ControlInfo MRLow 
    234 //      //low value must be >=0 
    235 //      Variable test = v_value 
    236 //      if (test < 0 ) 
    237 //              test = 0 
    238 //      Endif 
    239 //      Variable/G root:myGlobals:MRED:gMRV1 = test 
    240 //      //then update the popup list 
    241 //      MRedPopMenuProc("MRFilesPopup",1,"") 
    242 // 
    243 //End 
    244  
    245 //obsolete procedure - unused 
    246 // 
    247 //procedure for setVar box to set the high file number (forced to be <=999) 
    248 //sets the global variable, then forces an update of the popup 
    249 // 
    250 //Function SetHighFileNumProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    251 //      String ctrlName 
    252 //      Variable varNum 
    253 //      String varStr 
    254 //      String varName 
    255 // 
    256 //      ControlInfo MRHigh 
    257 //      //high value must be <=999 
    258 //      Variable test = V_value 
    259 //      if(test > 999) 
    260 //              test = 999 
    261 //      Endif 
    262 //      Variable/G root:myGlobals:MRED:gMRV2 = test 
    263 //      //then update the popup list 
    264 //      MRedPopMenuProc("MRFilesPopup",1,"") 
    265 //End 
    266213 
    267214//allows the user to set the path to the local folder that contains the SANS data 
     
    294241// range of file numbers entered in the text box 
    295242// 
    296 Function MRedPopMenuProc(MRFilesPopup,popNum,popStr) : PopupMenuControl 
     243Function MREDPopMenuProc(MRFilesPopup,popNum,popStr) : PopupMenuControl 
    297244        String MRFilesPopup 
    298245        Variable popNum 
     
    300247 
    301248        String list = GetValidMRedPopupList() 
    302 //      Wave/T redList = redList 
    303 //      String list = Wave2SemiList(redWave) 
    304249//       
    305250        String/G root:myGlobals:MRED:gMredList = list 
     
    330275        semiList = SortList(semiList,";",0) 
    331276        return(semiList) 
    332          
    333 //      //make sure that path exists 
    334 //      PathInfo catPathName 
    335 //      String path = S_path 
    336 //      if (V_flag == 0) 
    337 //              Abort "folder path does not exist - use Pick Path button" 
    338 //      Endif 
    339 //      String list="" 
    340 //       
    341 //      list = IndexedFile(catPathName,-1,"????")       //get all files in folder 
    342 //       
    343 //      NVAR  lownum = root:myGlobals:MRED:gMRV1 
    344 //      NVAR  highnum = root:myGlobals:MRED:gMRV2 
    345 //       
    346 //      //trim list to include only selected files that are RAW SANS files 
    347 //      //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be reduced) 
    348 //      Variable ii,isRAW,num,runNum=-1 
    349 //      String item="",newList = "",fullName = "",partialName="" 
    350 //       
    351 //      //get rid of version numbers first (up to 11) 
    352 //      list =  RemoveVersNumsFromList(list) 
    353 //       
    354 //      //then filter out only the raw data files within the range lownum to highnum 
    355 //      num = ItemsInList(list,";")             //get the new number of items in the list 
    356 //      ii=0 
    357 //      do 
    358 //              //parse through the list in this order: 
    359 //              // 1 - get the run number from the file (AAAAANNN.SAn_asdfasdfasdf) by finding the "dot" 
    360 //              // 2 - exclude by lownum/highnum 
    361 //              // 3 - exclude by isRaw? (to minimize disk access) 
    362 //              item = StringFromList(ii, list  ,";" ) 
    363 //              if(strlen(item) != 0) 
    364 //                      //find the run number, if it exists 
    365 //                      runNum = GetRunNumFromFile(item) 
    366 //                      //is the runNum in the selected range? 
    367 //                      if( (runNum >= lowNum) && (runNum <= highnum) ) 
    368 //                              //valid number, continue 
    369 //                              //build valid filename 
    370 //                              partialName = FindValidFileName(item) 
    371 //                              if(strlen(partialName) != 0)            //non-null return from FindValidFileName() 
    372 //                                      fullName = path + partialName 
    373 //                                      //check if RAW, if so, add original item to newList 
    374 //                                      isRAW = CheckIfRawData(fullName) 
    375 //                                      if(isRaw) 
    376 //                                              newList += item + ";" 
    377 //                                      Endif 
    378 //                              Endif 
    379 //                      Endif 
    380 //              Endif 
    381 //              ii+=1 
    382 //      while(ii<num)           //process all items in list 
    383 // 
    384 //      Return(newList) 
    385277End 
    386278 
     
    463355        Return 0 
    464356End 
    465  
    466  
    467 //************************************* 
    468 //under construction MRED function 
    469  
    470 //testing - unused 
    471 //Macro Init_NEW_MRED() 
    472 //      Make/O/T/N=1 fileWave,redWave 
    473 //      Make/O/N=1 selWave 
    474 //End 
    475  
    476 //testing - unused 
    477 // 
    478 //returns a list of raw data files from catPathName 
    479 //Function/S RawDataList() 
    480 //      //make sure that path exists 
    481 //      PathInfo catPathName 
    482 //      String path = S_path 
    483 //      if (V_flag == 0) 
    484 //              Abort "folder path does not exist - use Pick Path button" 
    485 //      Endif 
    486 //      String list=IndexedFile(catPathName,-1,"????")  //get all files in folder 
    487 //       
    488 //      //trim list to include only selected files that are RAW SANS files 
    489 //      //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be reduced) 
    490 //      Variable ii,isRAW,num,runNum=-1 
    491 //      String item="",newList = "",fullName = "",partialName="" 
    492 //       
    493 //      //get rid of version numbers first (up to 11) 
    494 //      list =  RemoveVersNumsFromList(list) 
    495 //       
    496 //      //then filter out only the raw data files within the range lownum to highnum 
    497 //      num = ItemsInList(list,";")             //get the new number of items in the list 
    498 //      ii=0 
    499 //      do 
    500 //              //  exclude by isRaw? (to minimize disk access) 
    501 //              item = StringFromList(ii, list  ,";" ) 
    502 //              if(strlen(item) != 0) 
    503 //                              partialName = FindValidFileName(item) 
    504 //                              if(strlen(partialName) != 0)            //non-null return from FindValidFileName() 
    505 //                                      fullName = path + partialName 
    506 //                                      //check if RAW, if so, add original item to newList 
    507 //                                      isRAW = CheckIfRawData(fullName) 
    508 //                                      if(isRaw) 
    509 //                                              newList += item + ";" 
    510 //                                      Endif 
    511 //                              Endif 
    512 //              Endif 
    513 //              ii+=1 
    514 //      while(ii<num)           //process all items in list 
    515 // 
    516 //      Return(newList) 
    517 //End 
    518  
    519 //testing - unused 
    520 // 
    521 //Function/S RunNumList2FileNameList(NumList) 
    522 //      String numList          //text list of run numbers 
    523 // 
    524 //      //find a valid file name if possible, return null otherwise 
    525 //      String retList = "",str="" 
    526 //      Variable numRuns,ii,r_index 
    527 //      numRuns = ItemsInList(numList,";") 
    528 //      for(ii=0;ii<numRuns;ii+=1) 
    529 //              r_index = str2num(StringFromList(ii,numList,";")) 
    530 //              str= FindFileFromRunNumber(r_index) 
    531 //              if(cmpstr(str,"")!=0) 
    532 //                      retList += str + ";" 
    533 //              Endif 
    534 //      EndFor 
    535 //      return(retList) 
    536 //End 
    537  
    538 //testing - unused 
    539 // 
    540 //Window panel0() : Panel 
    541 //      PauseUpdate; Silent 1           // building window... 
    542 //      NewPanel /W=(501,97,929,307) /K=1 
    543 //      ListBox fileList,pos={0,0},size={179,146},listWave=root:fileWave 
    544 //      ListBox fileList,selWave=root:selWave,mode= 4 
    545 //      ListBox redList,pos={219,0},size={179,146},listWave=root:redWave,mode= 1 
    546 //      ListBox redList,selRow= -1 
    547 //      Button button0,pos={114,148},size={50,20},proc=AddButtonProc,title="Add" 
    548 //      Button button1,pos={219,148},size={50,20},proc=ClearButtonProc,title="Clear" 
    549 //      Button button2,pos={337,148},size={50,20},proc=PopButtonProc,title="Pop" 
    550 //      Button button3,pos={4,148},size={50,20},proc=NewListButtonProc 
    551 //      Button button4,pos={279,148},size={50,20},proc=DelButtonProc,title="Del" 
    552 //EndMacro 
    553  
    554 //testing - unused 
    555 // 
    556 //Function DelButtonProc(ctrlName) : ButtonControl 
    557 //      String ctrlName 
    558 //       
    559 //      ControlInfo redList 
    560 //      Variable selRow=V_Value 
    561 //      Wave lw=$S_Value 
    562 //      DeletePoints selRow,1,lw 
    563 //       
    564 //End 
    565  
    566 //testing - unused 
    567 // 
    568 //Function NewListButtonProc(ctrlName) : ButtonControl 
    569 //      String ctrlName 
    570 //       
    571 //      String list=IndexedFile(catPathName,-1,"????") 
    572 //      String newList="",item="" 
    573 //      Variable num=ItemsInList(list,";"),ii 
    574 //      for(ii=0;ii<num;ii+=1) 
    575 //              item = StringFromList(ii, list  ,";") 
    576 //              if( stringmatch(item,"*.sa1*") ) 
    577 //                      newlist += item + ";" 
    578 //              endif 
    579 //              if( stringmatch(item,"*.sa2*") ) 
    580 //                      newlist += item + ";" 
    581 //              endif 
    582 //              if( stringmatch(item,"*.sa3*") ) 
    583 //                      newlist += item + ";" 
    584 //              endif 
    585 //              //print "ii=",ii 
    586 //      endfor 
    587 //      newList = SortList(newList,";",0) 
    588 //      num=ItemsInList(newlist,";") 
    589 //      Make/O/T/N=(num) fileWave 
    590 //      Make/O/N=(num) selWave 
    591 //      fileWave = StringFromList(p,newlist,";") 
    592 //      Sort filewave,filewave 
    593 //End 
    594  
    595 //testing - unused 
    596 // 
    597 //Function AddButtonProc(ctrlName) : ButtonControl 
    598 //      String ctrlName 
    599 // 
    600 //      Wave/T fileWave=fileWave 
    601 //      Wave/T redWave=redWave 
    602 //      Wave sel=selWave 
    603 //       
    604 //      Variable num=numpnts(sel),ii=0 
    605 //      variable lastPt=numpnts(redwave) 
    606 //      do 
    607 //              if(sel[ii] == 1) 
    608 //                      InsertPoints lastPt,1, redWave 
    609 //                      redWave[lastPt]=filewave[ii] 
    610 //                      lastPt +=1 
    611 //              endif 
    612 //              ii+=1 
    613 //      while(ii<num) 
    614 //      return(0) 
    615 //End 
    616  
    617 //testing - unused 
    618 // 
    619 //Function ClearButtonProc(ctrlName) : ButtonControl 
    620 //      String ctrlName 
    621 //      Make/O/T/N=1 redWave 
    622 //End 
    623  
    624 //testing - unused 
    625 // 
    626 //Function PopButtonProc(ctrlName) : ButtonControl 
    627 //      String ctrlName          
    628 //      MRedPopMenuProc("MRFilesPopup",0,"") 
    629 //End 
    630357 
    631358 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/NCNR_Utils.ipf

    r74 r76  
    10411041        return newlist 
    10421042End 
     1043 
     1044// returns a list of raw data files in the catPathName directory on disk 
     1045// - list is SEMICOLON-delimited 
     1046// 
     1047// does it the "cheap" way, simply finding the ".SAn" in the file name 
     1048// = does not check for proper byte length. 
     1049Function/S GetRawDataFileList() 
     1050         
     1051        //make sure that path exists 
     1052        PathInfo catPathName 
     1053        if (V_flag == 0) 
     1054                Abort "Folder path does not exist - use Pick Path button on Main Panel" 
     1055        Endif 
     1056         
     1057        String list=IndexedFile(catPathName,-1,"????") 
     1058        String newList="",item="" 
     1059        Variable num=ItemsInList(list,";"),ii 
     1060        for(ii=0;ii<num;ii+=1) 
     1061                item = StringFromList(ii, list  ,";") 
     1062                if( stringmatch(item,"*.sa1*") ) 
     1063                        newlist += item + ";" 
     1064                endif 
     1065                if( stringmatch(item,"*.sa2*") ) 
     1066                        newlist += item + ";" 
     1067                endif 
     1068                if( stringmatch(item,"*.sa3*") ) 
     1069                        newlist += item + ";" 
     1070                endif 
     1071                //print "ii=",ii 
     1072        endfor 
     1073        newList = SortList(newList,";",0) 
     1074        return(newList) 
     1075End 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/NSORT.ipf

    r74 r76  
    345345End 
    346346 
    347 //unused tesing procedure 
    348 // 
    349 Proc AskToStripPoints(nb,ne) 
    350         Variable nb=7,ne=0 
    351         Prompt nb,"Points to strip from beginning of file" 
    352         Prompt ne,"Points to strip from end of file" 
    353          
    354         gBegPts = nb 
    355         gEndPts = ne 
    356          
    357 End 
    358  
    359347//gets the scaling constant to make (best) overlap of the specified datasets 
    360348//the scaling value is an average value of the individual scaling values for  
     
    380368                ii+=1 
    381369        while(ii<=num2) 
    382         Variable norm 
    383         norm = ratio/(num2+1)           // +1 counts for point zero 
    384         //Print "norm = ",norm 
    385  
    386         Return norm 
     370        Variable val 
     371        val = ratio/(num2+1)            // +1 counts for point zero 
     372        //Print "val = ",val 
     373 
     374        Return val 
    387375End 
    388376 
     
    593581//when a value is entered, the global value is set, and the corresponding dataset 
    594582//is updated on the plot, showing the new result of removing this number of points 
     583// 
     584//      SetVar boxes are named beg_N and end_N (so 4th element is the number) 
     585// 
     586// 1 == LowQ 
     587// 2 == MedQ 
     588// 3 == HighQ 
     589// 
    595590//"Plot_1" is the low-q button name 
    596591//"Plot_2" is the med-q button name 
    597592//"Plot_3" is the high-q button name 
     593// 
    598594//calling plot_0_Button() responds as if that named button were pressed 
     595// and gets the proper number to trim directly from the SetVar 
    599596// 
    600597Function SetBegOrEnd(ctrlName,varNum,varStr,varName) : SetVariableControl 
     
    609606        DoWindow/F NSORT_Panel 
    610607End 
    611  
    612 //Function SetEnd_1(ctrlName,varNum,varStr,varName) : SetVariableControl 
    613 //      String ctrlName 
    614 //      Variable varNum 
    615 //      String varStr 
    616 //      String varName 
    617 //       
    618 //      //Variable/G root:myGlobals:NSORT:gPtsEnd1 = varNum 
    619 //      print str2num(ctrlName[4]),ctrlName,varNum,varStr,varName 
    620 //      Plot_0_Button("Plot_1") 
    621 //      DoWindow/F NSORT_Panel 
    622 //End 
    623 // 
    624 ////see comments on SetEnd_1() 
    625 //// 
    626 //Function SetEnd_2(ctrlName,varNum,varStr,varName) : SetVariableControl 
    627 //      String ctrlName 
    628 //      Variable varNum 
    629 //      String varStr 
    630 //      String varName 
    631 //       
    632 //      Variable/G root:myGlobals:NSORT:gPtsEnd2 = varNum 
    633 //      Plot_0_Button("Plot_2") 
    634 //      DoWindow/F NSORT_Panel 
    635 //End 
    636 // 
    637 ////see comments on SetEnd_1() 
    638 //// 
    639 //Function SetEnd_3(ctrlName,varNum,varStr,varName) : SetVariableControl 
    640 //      String ctrlName 
    641 //      Variable varNum 
    642 //      String varStr 
    643 //      String varName 
    644 //       
    645 //      Variable/G root:myGlobals:NSORT:gPtsEnd3 = varNum 
    646 //      Plot_0_Button("Plot_3") 
    647 //      DoWindow/F NSORT_Panel 
    648 //End 
    649 // 
    650 ////see comments on SetEnd_1() 
    651 //// 
    652 //Function SetBeg_1(ctrlName,varNum,varStr,varName) : SetVariableControl 
    653 //      String ctrlName 
    654 //      Variable varNum 
    655 //      String varStr 
    656 //      String varName 
    657 //       
    658 //      Variable/G root:myGlobals:NSORT:gPtsBeg1 = varNum 
    659 //      Plot_0_Button("Plot_1") 
    660 //      DoWindow/F NSORT_Panel 
    661 //End 
    662 // 
    663 ////see comments on SetEnd_1() 
    664 //// 
    665 //Function SetBeg_2(ctrlName,varNum,varStr,varName) : SetVariableControl 
    666 //      String ctrlName 
    667 //      Variable varNum 
    668 //      String varStr 
    669 //      String varName 
    670 // 
    671 //      Variable/G root:myGlobals:NSORT:gPtsBeg2 = varNum 
    672 //      Plot_0_Button("Plot_2") 
    673 //      DoWindow/F NSORT_Panel 
    674 //End 
    675 // 
    676 ////see comments on SetEnd_1() 
    677 //// 
    678 //Function SetBeg_3(ctrlName,varNum,varStr,varName) : SetVariableControl 
    679 //      String ctrlName 
    680 //      Variable varNum 
    681 //      String varStr 
    682 //      String varName 
    683 // 
    684 //      Variable/G root:myGlobals:NSORT:gPtsBeg3 = varNum 
    685 //      Plot_0_Button("Plot_3") 
    686 //      DoWindow/F NSORT_Panel 
    687 //End 
    688  
    689 ////obsolete button control 
    690 //Function ManualScaleButton(ctrlName) : ButtonControl 
    691 //      String ctrlName 
    692 // 
    693 //      Execute "ManualScalePrompt()" 
    694 //       
    695 //End 
    696 // 
    697 ////obsolete missing param dialog 
    698 //Proc ManualScalePrompt(s12,s23) 
    699 //      Variable s12 = 1 
    700 //      Variable s23 = 1 
    701 //      Prompt s12,"enter the multiplier for medium q set" 
    702 //      Prompt s23,"enter the multiplier for high q set" 
    703 //       
    704 //      Variable/G root:myGlobals:NSORT:gScale1_2 = s12 
    705 //      Variable/G root:myGlobals:NSORT:gScale2_3 = s23 
    706 //End 
    707608 
    708609//this will--- 
     
    781682        return(0) 
    782683End 
    783  
    784684 
    785685//window recreation macro for NSORT Panel 
     
    869769        CheckBox AutoCheck,pos={14,310},size={100,20},title="Auto Scale",value=1 
    870770        CheckBox AutoCheck,help={"If checked, the scale factor will be automatically determined, if not checked, the current values in the fields will be used"} 
    871 //      CheckBox check_0,pos={282,91},size={80,20},title="Update ?",value=1 
    872 //      CheckBox check_0,help={"If checked, the list of data files will be updated from disk, unchecked (faster) will not refresh the list"} 
    873 //      CheckBox check_1,pos={282,174},size={80,20},title="Update ?",value=1 
    874 //      CheckBox check_1,help={"If checked, the list of data files will be updated from disk, unchecked (faster) will not refresh the list"} 
    875 //      CheckBox check_2,pos={282,257},size={80,20},title="Update ?",value=1 
    876 //      CheckBox check_2,help={"If checked, the list of data files will be updated from disk, unchecked (faster) will not refresh the list"} 
    877771EndMacro 
    878772 
     
    941835 
    942836//when menu is popped, it gets a valid list to display and updates the control 
    943 //**for speed, refreshes list only if checkbox is checked 
    944837// 
    945838// 2002- always refreshes, as new (fast) filter is used 
     
    949842        String popStr 
    950843 
    951         //only update the popup if the "update" checkbox is checked 
    952         //to improve speed 
    953 //      Variable checked = 0 
    954 //      ControlInfo check_0 
    955 //      checked = V_value 
    956          
    957 //      If(checked) 
    958                 String/G root:myGlobals:NSORT:gDataPopList = ReducedDataFileList("") 
    959                 ControlUpdate popup_1 
    960 //      Endif 
    961          
     844        String/G root:myGlobals:NSORT:gDataPopList = ReducedDataFileList("") 
     845        ControlUpdate popup_1 
     846 
     847        return(0) 
    962848End 
    963849 
    964850//when menu is popped, it gets a valid list to display and updates the control 
    965 //**for speed, refreshes list only if checkbox is checked 
    966851// 
    967852Function MedQPopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl 
     
    969854        Variable popNum 
    970855        String popStr 
    971          
    972         //only update the popup if the "update" checkbox is checked 
    973         //to improve speed 
    974 //      Variable checked = 0 
    975 //      ControlInfo check_1 
    976 //      checked = V_value 
    977          
    978 //      If(checked)              
    979                 String/G root:myGlobals:NSORT:gDataPopList_3 = "none;" +  ReducedDataFileList("") 
    980                 ControlUpdate popup_2 
    981                 if(cmpstr(popStr,"none")==0) 
    982                         PopupMenu popup_3,mode=1        //force "none" (item #1) to be the selection 
    983                         CheckBox AutoCheck,value=0      //un-check the auto-scale checkbox 
    984                         DoAlert 0,"You have only one data set. Auto Scaling has been unchecked and Mult Factor 1-2 will be applied to your data. Remember to re-check this as needed"// remind the user of this fact 
    985                         RemoveFromGraph/Z MedQSet_i,TrimMedQSet_i,HighQSet_i,TrimHighQSet_i             //remove the data from the graph 
    986                 Endif    
    987 //endif 
     856                 
     857        String/G root:myGlobals:NSORT:gDataPopList_3 = "none;" +  ReducedDataFileList("") 
     858        ControlUpdate popup_2 
     859        if(cmpstr(popStr,"none")==0) 
     860                PopupMenu popup_3,mode=1        //force "none" (item #1) to be the selection 
     861                CheckBox AutoCheck,value=0      //un-check the auto-scale checkbox 
     862                DoAlert 0,"You have only one data set. Auto Scaling has been unchecked and Mult Factor 1-2 will be applied to your data. Remember to re-check this as needed"// remind the user of this fact 
     863                RemoveFromGraph/Z MedQSet_i,TrimMedQSet_i,HighQSet_i,TrimHighQSet_i             //remove the data from the graph 
     864        Endif    
     865        return(0) 
    988866End 
    989867 
     
    991869// - will be different, since set 3 can also be "none" if only 2 sets 
    992870//are to be NSORTed 
    993 //**for speed, refreshes list only if checkbox is checked 
    994871// 
    995872Function HighQPopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl 
     
    998875        String popStr 
    999876 
    1000         //only update the popup if the "update" checkbox is checked 
    1001         //to improve speed 
    1002 //      Variable checked = 0 
    1003 //      ControlInfo check_2 
    1004 //      checked = V_value 
    1005  
    1006 //      If(checked) 
    1007                 //add the option "none" to the file list (which should already end with a semicolon) 
    1008                 String/G root:myGlobals:NSORT:gDataPopList_3 = "none;" +  ReducedDataFileList("") 
    1009  
    1010                 ControlUpdate popup_3 
    1011                 if(cmpstr(popStr,"none")==0) 
    1012                         RemoveFromGraph/Z HighQSet_i,TrimHighQSet_i             //remove the data from the graph 
    1013                 Endif    
    1014                 ControlInfo popup_2 
    1015                 if(cmpstr(S_Value,"none")==0) 
    1016                         PopupMenu popup_3,mode=1        //force "none" (item #1) to be the selection if medium is none 
    1017                 endif 
    1018 //      Endif 
    1019          
    1020 End 
    1021  
    1022 ////function returning a string (list) of semicolon separated filenames 
    1023 ////that are not version numbers, and not raw data files 
    1024 ////(can't really pare out other files any better - trying to just get ascii I vs. q) 
    1025 ////works in folder specified by catPathName, (abort if it doesn't exist) 
    1026 //// 
    1027 ////***** UNUSED ******** - simpler fileFilter is used to simply filter out the raw data 
    1028 //// 
    1029 //Function/S GetValidNSORTPopupList() 
    1030 // 
    1031 //      String list = "none;something;" 
    1032 //       
    1033 //      PathInfo catPathName 
    1034 //      String path = S_path 
    1035 //      if(V_flag == 0) 
    1036 //              Abort "path does not exist - use Pick Path button" 
    1037 //      Endif 
    1038 //       
    1039 //      list = IndexedFile(catPathName,-1,"????")               //get all files in folder 
    1040 //       
    1041 //      //trim version numbers from list 
    1042 //      Variable num = ItemsInList(list,";") 
    1043 //      Variable ii,isRAW 
    1044 //      String item = "",listCopy = "", fullName = "",partialName = "" 
    1045 //       
    1046 //      ii=1 
    1047 //      do 
    1048 //              item = num2str(ii) 
    1049 //              list = RemoveFromList(item,list,";") 
    1050 //              ii+=1 
    1051 //      while (ii<12) 
    1052 //       
    1053 //      //trim raw data files from list 
    1054 //      listCopy = list                                 //scan through items in copy, change list 
    1055 //      num = ItemsInList(listCopy,";")         //get the new number of items in the list 
    1056 //      ii=0 
    1057 //      do 
    1058 //              //build valid fileName 
    1059 //              item = StringFromList(ii,listCopy,";") 
    1060 //              if (strlen(item) !=0 ) 
    1061 //                      partialName  = FindValidFileName(item) 
    1062 //                      if(strlen(partialName) !=0)             //non-null return from FindValidFileName() 
    1063 //                              fullName = path + partialName 
    1064 //                              //check if RAW, if so, remove from list 
    1065 //                              isRAW = CheckIfRAWData(fullName) 
    1066 //                              if(isRAW) 
    1067 //                                      list = RemoveFromList(item,list,";") 
    1068 //                              Endif 
    1069 //                      Endif 
    1070 //              Endif 
    1071 //              ii+=1 
    1072 //      While(ii<num) 
    1073 //       
    1074 //      return list 
    1075 //End 
     877        //add the option "none" to the file list (which should already end with a semicolon) 
     878        String/G root:myGlobals:NSORT:gDataPopList_3 = "none;" +  ReducedDataFileList("") 
     879 
     880        ControlUpdate popup_3 
     881        if(cmpstr(popStr,"none")==0) 
     882                RemoveFromGraph/Z HighQSet_i,TrimHighQSet_i             //remove the data from the graph 
     883        Endif    
     884        ControlInfo popup_2 
     885        if(cmpstr(S_Value,"none")==0) 
     886                PopupMenu popup_3,mode=1        //force "none" (item #1) to be the selection if medium is none 
     887        endif 
     888        return(0)        
     889End 
     890 
    1076891 
    1077892//be sure to use the "Trim.." datasets that have had the bad points removed 
     
    12711086                Sort q123, q123,i123,sig123 
    12721087                ///////////////// 
    1273                  
    1274                 //old method 
    1275                         //first point of overlap region (from set 3) 
    1276                         //FindLevel/P/Q q123,(highq[0]) 
    1277                         //Variable firstOverlapPt = V_levelX 
    1278                         //last point of overlap region (from set 12) 
    1279                         //FindLevel/P/Q q123,(q12[n12-1]) 
    1280                         //Variable lastOverlapPt = V_levelX 
    1281                 //end old method, not used 
    12821088                 
    12831089                //find the maximum point number of set 2  in the overlap region 
     
    14761282                ///////////////// 
    14771283                 
    1478                 //old method 
    1479                         //first point of overlap region (from set 3) 
    1480                         //FindLevel/P/Q q123,(highq[0]) 
    1481                         //Variable firstOverlapPt = V_levelX 
    1482                         //last point of overlap region (from set 12) 
    1483                         //FindLevel/P/Q q123,(q12[n12-1]) 
    1484                         //Variable lastOverlapPt = V_levelX 
    1485                 //end old method, not used 
    1486                  
    14871284                //find the maximum point number of set 2  in the overlap region 
    14881285                FindLevel/P/Q highq,(q12[n12-1]) 
     
    15531350 
    15541351///////////////////////////////////////////////////////////// 
    1555 //testing, may speed up NSORT 
     1352// testing, may speed up NSORT, NCNR-specific naming scheme of  
     1353// run numbers and a run prefix 
    15561354Proc Set3NSORTFiles(low,med,hi,pref) 
    15571355        Variable low=1,med=2,hi=3 
     
    15791377End 
    15801378 
     1379//make a three character string of the run number 
    15811380Function/S ThreeDigitString(num) 
    15821381        Variable num 
    15831382         
    1584         //make a three character string of the run number 
    15851383        String numStr="" 
    15861384        if(num<10) 
     
    18661664 
    18671665 
    1868  
    1869  
    18701666// Commentized lines here are incomplete - and NON-FUNCTIONING 
    18711667// 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/PatchFiles.ipf

    r75 r76  
    121121                Abort "folder path does not exist - use Pick Path button" 
    122122        Endif 
    123         String list 
    124         list = IndexedFile(catPathName,-1,"????")       //get all files in folder 
     123         
     124        String newList = "" 
     125 
     126        newList = GetRawDataFileList() 
     127 
    125128        //trim list to include only selected files 
    126129        SVAR match = root:myGlobals:Patch:gPatchMatchStr 
    127         list = MyMatchList(match,list,";") 
    128         //further trim list to include only RAW SANS files 
    129         //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched) 
    130         Variable num = ItemsInList(list,";") 
    131         Variable ii,isRAW 
    132         String item="",newList = "",fullName = "",partialName="" 
    133          
    134         //get rid of version numbers first (up to 11) 
    135         ii=1 
    136         do 
    137                 item = num2str(ii) 
    138                 list = RemoveFromList(item, list ,";" ) 
    139                 ii+=1 
    140         while(ii<12) 
    141          
    142         //then filter out only the raw data files 
    143         num = ItemsInList(list,";")        //get the new number of items in the list 
    144         ii=0 
    145         do 
    146                 //build valid filename 
    147                 item = StringFromList(ii, list  ,";" ) 
    148                 if(strlen(item) != 0) 
    149                    partialName = FindValidFileName(item) 
    150                    if(strlen(partialName) != 0)      //non-null return from FindValidFileName() 
    151                       fullName = path + partialName 
    152                       //check if RAW, if so, add original item to newList 
    153                       isRAW = CheckIfRawData(fullName) 
    154                       if(isRaw) 
    155                          newList += item + ";" 
    156                       Endif 
    157                    Endif 
    158                 Endif 
    159                 ii+=1 
    160         while(ii<num)      //process all items in list 
    161  
     130        newlist = MyMatchList(match,newlist,";") 
     131         
    162132        newList = SortList(newList,";",0) 
    163133        Return(newList) 
     
    664634        //just reset the global variables that are on the patch panel 
    665635         
    666 //      Variable refNum,integer,realval 
    667 //      String textstr="" 
    668 //      Variable countTime 
    669 //       
    670 //      //full filename with path is passed in 
    671 //      //actually open the file 
    672 //      Open/R refNum as fname 
    673 //       
    674 //      // read the sample.label text field 
    675 //      FSetPos refNum,98          //will start reading at byte 99 
    676 //      FReadLine/N=60 refNum,textstr 
    677 //      FSetPos refNum,31 
    678 //      FBinRead/B=3/F=3 refnum,countTime 
    679 //       
    680 //      Close refNum 
    681 //       
    682 //      //Print "countTime = ",countTime 
    683 //       
    684 //      //now get all of the reals 
    685 //      // 
    686 //      //Do all the GBLoadWaves at the end 
    687 //      // 
    688 //      //FBinRead Cannot handle 32 bit VAX floating point 
    689 //      //GBLoadWave, however, can properly read it 
    690 //      String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
    691 //      String strToExecute 
    692 //      //append "/S=offset/U=numofreals" to control the read 
    693 //      // then append fname to give the full file path 
    694 //      // then execute 
    695 //       
    696 //      // NEW reads 
    697 //      Variable moncnt,savmon,detcnt,atten,trans,thick,temp,field 
    698 //      Variable dis,ang,bstop,ap1,ap2,ap12dis,lmda,dlmda,beamx,beamy,trnscnt 
    699 //       
    700 //      strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 
    701 //      Execute strToExecute 
    702 //      Wave w=$"tempGBWave0" 
    703 //      moncnt = w[0] 
    704 //      savmon = w[1] 
    705 //      detcnt = w[2] 
    706 //      atten = w[3] 
    707 //      //printf "moncnt = %g,savmon = %g,detcnt = %g,atten = %g\r",moncnt,savmon,detcnt,atten 
    708 //       
    709 //      strToExecute = GBLoadStr + "/S=158/U=2" + "\"" + fname + "\"" 
    710 //      Execute strToExecute 
    711 //      trans = w[0] 
    712 //      thick = w[1] 
    713 //      //printf "trans = %g, thick = %g\r",trans,thick 
    714 //       
    715 //      strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 
    716 //      Execute strToExecute 
    717 //      temp = w[0] 
    718 //      field = w[1] 
    719 //      //printf "temp = %g, field = %g\r",temp,field 
    720 //       
    721 //      strToExecute = GBLoadStr + "/S=252/U=12" + "\"" + fname + "\"" 
    722 //      Execute strToExecute 
    723 //      beamx = w[0] 
    724 //      beamy = w[1] 
    725 //      dis = w[2] 
    726 //      ang = w[3] 
    727 //      // w[4] det size 
    728 //      bstop = w[5] 
    729 //      // w[6] blank 
    730 //      ap1 = w[7] 
    731 //      ap2 = w[8] 
    732 //      ap12dis = w[9] 
    733 //      lmda = w[10] 
    734 //      dlmda = w[11] 
    735 //      //printf "beamx = %g, beamy = %g\r",beamx,beamy 
    736 //      //printf "dis = %g,ang = %g, bstop = %g,ap1= %g,ap2 = %g\r",dis,ang,bstop,ap1,ap2 
    737 //      //printf "ap12dis = %g, lmda = %g, dlmda = %g\r",ap12dis,lmda,dlmda 
    738 //       
    739 //      strToExecute = GBLoadStr + "/S=388/U=1" + "\"" + fname + "\"" 
    740 //      Execute strToExecute 
    741 //      trnscnt = w[0] 
    742 //      //printf "trnscnt = %g\r",trnscnt 
    743 //       
    744 //      //assign to the globals for display in the panel 
    745 //      String/G root:myGlobals:Patch:gPS1= textstr 
    746 //      Variable/G root:myGlobals:Patch:gPV1 = trans 
    747 //      Variable/G root:myGlobals:Patch:gPV2 = thick 
    748 //      Variable/G root:myGlobals:Patch:gPV3 = beamx 
    749 //      Variable/G root:myGlobals:Patch:gPV4 = beamy 
    750 //      Variable/G root:myGlobals:Patch:gPV5 = atten 
    751 //      Variable/G root:myGlobals:Patch:gPV6 = countTime 
    752 //      Variable/G root:myGlobals:Patch:gPV7 = moncnt 
    753 //      Variable/G root:myGlobals:Patch:gPV8 = detcnt 
    754 //      Variable/G root:myGlobals:Patch:gPV9 = trnscnt 
    755 //      Variable/G root:myGlobals:Patch:gPV10 = lmda 
    756 //      Variable/G root:myGlobals:Patch:gPV11 = dlmda 
    757 //      Variable/G root:myGlobals:Patch:gPV12 = temp 
    758 //      Variable/G root:myGlobals:Patch:gPV13 = field 
    759 //      Variable/G root:myGlobals:Patch:gPV14 = ap1 
    760 //      Variable/G root:myGlobals:Patch:gPV15 = ap2 
    761 //      Variable/G root:myGlobals:Patch:gPV16 = ap12dis 
    762 //      Variable/G root:myGlobals:Patch:gPV17 = ang 
    763 //      Variable/G root:myGlobals:Patch:gPV18 = bstop 
    764 //      Variable/G root:myGlobals:Patch:gPV19 = dis 
    765 //       
    766 //      //clean up - get rid of w = $"tempGBWave0" 
    767 //      KillWaves/Z w 
    768          
    769636        // each "get" is an individual call to GBLoadWave... 
    770637        // test for acceptable speed over a network... 
     
    879746 
    880747//simple action for button to close the panel 
    881 //closes all file that may accidently be open at this point 
    882 //(but none are open) 
    883 // 
    884748Function DoneButtonProc(ctrlName) : ButtonControl 
    885749        String ctrlName 
    886  
    887         // this button will make sure all files are closed  
    888         //and close the panel 
    889          
    890         Close/A 
     750         
    891751        DoWindow/K Patch_Panel 
    892752         
     
    903763         
    904764        //reset the global variable to the entered text so that it can be relayed to the  
    905         //write() routine. Only the TEXT SetVariable control needs to be handles this way 
     765        //write() routine. Only the TEXT SetVariable control needs to be handled this way 
    906766         
    907767        String/G root:myGlobals:Patch:gPS1 = varStr 
    908768 
    909769End 
    910  
    911  
    912 //button action function to set the XY box for the empty beam file (or reset it) 
    913 //this function is called by the button on the Patch Panel to set the XY box 
    914 //panel, but is nearly identical. This function resets the string used in the Patch 
    915 //panel to list the current empty beam file 
    916 // 
    917 //depends on the user slecting and setting the box with the marquee (see marquee.ipf) 
    918 //then reads the set coordinates from the global keyword string 
    919 //  
    920 //**********UNUSED****************** 
    921 //Function SetXYBoxButton(ctrlName) : ButtonControl 
    922 //      String ctrlName 
    923 // 
    924 //      String msgStr = "Select the Empty Beam FIle" 
    925 //      String filename,shortName 
    926 //       
    927 //      //get the filename, then read it in 
    928 //      filename = PromptForPath(msgStr) 
    929 //      //check for cancel from dialog 
    930 //      if(strlen(filename)==0) 
    931 //              //user cancelled, abort 
    932 //              SetDataFolder root: 
    933 //              Abort "No file selected, action aborted" 
    934 //      Endif 
    935 //      shortName = GetFileNameFromPathKeepSemi(filename) 
    936 //      String/G root:myGlobals:Patch:gPS2 = filename      //(reset the string for the patch panel) 
    937 //       
    938 //      ReadHeaderAndData(filename) 
    939 //      //data is displayed here (go htrough the normal display steps, so all is created properly 
    940 //      String/G root:myGlobals:gDataDisplayType="RAW" 
    941 //      fRawWindowHook() 
    942 //       
    943 //      // check the empty beam file for previously selected coordinates 
    944 //      //if they exist, set the xy string , save the normalized counts somewhere 
    945 //      //the value was written to an unused r*4 header analysis.factor (@b494) 
    946 //      Variable refnum,x1,x2,y1,y2,err 
    947 //      Open/R refnum as filename 
    948 //      FSetPos refnum,478 
    949 //      FBinRead/F=3/B=3 refnum, x1 
    950 //      FBinRead/F=3/B=3 refnum, x2 
    951 //      FBinRead/F=3/B=3 refnum, y1 
    952 //      FBinRead/F=3/B=3 refnum, y2 
    953 //      Close refnum 
    954 //      //read the real count value 
    955 //      String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
    956 //      String strToExecute 
    957 //      strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + filename + "\"" 
    958 //      Execute strToExecute 
    959 //      Wave w=$"tempGBWave0" 
    960 //      Variable/G root:myGlobals:Patch:gTransCts = w[0] 
    961 //      // 
    962 //      if( ((x1-x2)==0) || ((y1-y2)==0) )         //zero width marquee in either direction 
    963 //              //no region selected 
    964 //               
    965 //              //add the empty beam file to work.SAM 
    966 //              err = Raw_to_work("SAM") 
    967 //       
    968 //              //the calling macro must change the display type 
    969 //              String/G root:myGlobals:gDataDisplayType="SAM"      //displayed data type is sam 
    970 //       
    971 //              //data is displayed here 
    972 //              fRawWindowHook() 
    973 //       
    974 //              //prompt user to select box w/marquee 
    975 //              DoAlert 0,"Select the region to sum with the Marquee" 
    976 //       
    977 //              //from here the Marquee menu selection must handle the task of setting the box 
    978 //              //and updating the information in the file header 
    979 //      else 
    980 //              // region already selected, just put up the values from the file header 
    981 //              //allow user the option of overriding the current box region 
    982 //              msgStr = "X1="+num2str(x1)+";" 
    983 //              msgStr += "X2="+num2str(x2)+";" 
    984 //              msgStr += "Y1="+num2str(y1)+";" 
    985 //              msgStr += "Y2="+num2str(y2)+";" 
    986 //              String textStr 
    987 //              textStr = "Override current box  "+msgStr+" ?" 
    988 //              DoAlert 1,textStr 
    989 //              If((V_flag)==1) 
    990 //                 //get new box coordinates, same procedure as above 
    991 //                 //add the empty beam file to work.SAM 
    992 //                 err = Raw_to_work("SAM") 
    993 //       
    994 //                 //the calling macro must change the display type 
    995 //                 String/G root:myGlobals:gDataDisplayType="SAM"      //displayed data type is sam 
    996 //       
    997 //                 //data is displayed here 
    998 //                 fRawWindowHook() 
    999 //       
    1000 //                 //prompt user to select box w/marquee 
    1001 //                 DoAlert 0,"Select the region to sum with the Marquee" 
    1002 //       
    1003 //                 //from here the Marquee menu selection must handle the task of setting the box 
    1004 //                 //and updating the information in the file header 
    1005 //              else 
    1006 //                 String/G root:myGlobals:Patch:gPS3 = msgStr 
    1007 //              Endif 
    1008 //      Endif 
    1009 //       
    1010 //      KillWaves/Z w 
    1011 //      Return (0) 
    1012 //End 
    1013  
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/PlotUtils.ipf

    r70 r76  
    483483        PM_doAppend(S_Value) 
    484484         
    485        DoWindow/F Plot_Manager 
     485        DoWindow/F Plot_Manager 
    486486End 
    487487 
     
    520520        Endif 
    521521        PM_doNewGraph(S_Value) 
    522        DoWindow/F Plot_Manager 
     522        DoWindow/F Plot_Manager 
    523523End 
    524524 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/ProtocolAsPanel.ipf

    r72 r76  
    8080        String waveStr="tempProtocol" 
    8181        SetDataFolder root:myGlobals:Protocols 
    82         Make/O/T/N=(nsteps) $"root:myGlobals:Protocols:tempProtocol" 
    83         do 
    84                 $"root:myGlobals:Protocols:tempProtocol"[ii] = "" 
    85                 ii+=1 
    86         while(ii<nsteps) 
     82        Make/O/T/N=(nsteps) $"root:myGlobals:Protocols:tempProtocol" = "" 
     83 
    8784        String/G root:myGlobals:Protocols:gSAM="ask" 
    8885        String/G root:myGlobals:Protocols:gBGD="ask" 
     
    203200                checked = 0 
    204201        Endif 
    205 //      numItems = ItemsInList(list,comma) 
    206 //      nameList = "" 
    207 //      ii=0 
    208 //      checked = 1 
    209 //      do 
    210 //              fullPath = StringFromList(ii,list,comma) 
    211 //              PathStr = GetPathStrFromFullName(fullPath) 
    212 //              item = GetFileNameFromPathKeepSemi(fullPath) 
    213 //              nameList += item+comma 
    214 //              If(cmpstr(item,"none") ==0) 
    215 //                      nameList = item 
    216 //                      checked = 0 
    217 //                      break 
    218 //              Endif 
    219 //              If(cmpstr(item,"ask") ==0) 
    220 //                      nameList = item 
    221 //                      checked = 1 
    222 //                      break 
    223 //              Endif 
    224 //              if((cmpstr(pathStr,catPathStr) != 0) %& !(specialProtocol)) 
    225 //                      Print "pathstr = ",pathStr 
    226 //                      Print "catPathStr = ",catPathStr 
    227 //                      Abort "saved protocol path and CAT path do not match - reset CAT/SHORT to pathStr" 
    228 //              Endif 
    229 //              ii+=1 
    230 //      while(ii<numItems) 
     202 
    231203        //set the global string to display and checkbox 
    232204        String/G root:myGlobals:Protocols:gBGD = nameList 
     
    239211                checked = 0 
    240212        Endif 
    241 //      numItems = ItemsInList(list,comma) 
    242 //      nameList = "" 
    243 //      ii=0 
    244 //      checked = 1 
    245 //      do 
    246 //              fullPath = StringFromList(ii,list,comma) 
    247 //              PathStr = GetPathStrFromFullName(fullPath) 
    248 //              item = GetFileNameFromPathKeepSemi(fullPath) 
    249 //              nameList += item+comma 
    250 //              If(cmpstr(item,"none") ==0) 
    251 //                      nameList = item 
    252 //                      checked = 0 
    253 //                      break 
    254 //              Endif 
    255 //              If(cmpstr(item,"ask") ==0) 
    256 //                      nameList = item 
    257 //                      checked = 1 
    258 //                      break 
    259 //              Endif 
    260 //              if((cmpstr(pathStr,catPathStr) != 0) %& !(specialProtocol)) 
    261 //                      Print "pathstr = ",pathStr 
    262 //                      Print "catPathStr = ",catPathStr 
    263 //                      Abort "saved protocol path and CAT path do not match" 
    264 //              Endif 
    265 //              ii+=1 
    266 //      while(ii<numItems) 
     213 
    267214        //set the global string to display and checkbox 
    268215        String/G root:myGlobals:Protocols:gEMP = nameList 
     
    275222                checked = 0 
    276223        Endif 
    277 //      list = w[2] 
    278 //      numItems = ItemsInList(list,comma) 
    279 //      nameList = "" 
    280 //      ii=0 
    281 //      checked = 1 
    282 //      do 
    283 //              fullPath = StringFromList(ii,list,comma) 
    284 //              PathStr = GetPathStrFromFullName(fullPath) 
    285 //              item = GetFileNameFromPathKeepSemi(fullPath) 
    286 //              nameList += item+comma 
    287 //              If(cmpstr(item,"none") ==0) 
    288 //                      nameList = item 
    289 //                      checked = 0 
    290 //                      break 
    291 //              Endif 
    292 //              If(cmpstr(item,"ask") ==0) 
    293 //                      nameList = item 
    294 //                      checked = 1 
    295 //                      break 
    296 //              Endif 
    297 //              if((cmpstr(pathStr,catPathStr) != 0) %& !(specialProtocol)) 
    298 //                      Print "pathstr = ",pathStr 
    299 //                      Print "catPathStr = ",catPathStr 
    300 //                      Abort "saved protocol path and CAT path do not match" 
    301 //              Endif 
    302 //              ii+=1 
    303 //      while(ii<numItems) 
     224 
    304225        //set the global string to display and checkbox 
    305226        String/G root:myGlobals:Protocols:gDIV = nameList 
     
    312233                checked = 0 
    313234        Endif 
    314 //      list = w[3] 
    315 //      numItems = ItemsInList(list,comma) 
    316 //      nameList = "" 
    317 //      ii=0 
    318 //      checked = 1 
    319 //      do 
    320 //              fullPath = StringFromList(ii,list,comma) 
    321 //              PathStr = GetPathStrFromFullName(fullPath) 
    322 //              item = GetFileNameFromPathKeepSemi(fullPath) 
    323 //              nameList += item+comma 
    324 //              If(cmpstr(item,"none") ==0) 
    325 //                      nameList = item 
    326 //                      checked = 0 
    327 //                      break 
    328 //              Endif 
    329 //              If(cmpstr(item,"ask") ==0) 
    330 //                      nameList = item 
    331 //                      checked = 1 
    332 //                      break 
    333 //              Endif 
    334 //              if((cmpstr(pathStr,catPathStr) != 0) %& !(specialProtocol)) 
    335 //                      Print "pathstr = ",pathStr 
    336 //                      Print "catPathStr = ",catPathStr 
    337 //                      Abort "saved protocol path and CAT path do not match" 
    338 //              Endif 
    339 //              ii+=1 
    340 //      while(ii<numItems) 
     235 
    341236        //set the global string to display and checkbox 
    342237        String/G root:myGlobals:Protocols:gMASK = nameList 
     
    606501         
    607502        return(0) 
    608 End 
    609  
    610 //********UNUSED************ 
    611 //7/2001 - plan to modify this function to parse the comma-delimited list, (possibly just run numbers) 
    612 //and return a valid comma-delimited list of full filenames (no paths) 
    613 // 
    614 //function that takes a comma separated list of filenames (without path or version) 
    615 //and returns a full list of path;name;vers (comma delimited)  
    616 //that is needed for the protocol, which is expecting the full path 
    617 //to directly open the file(s) in the list 
    618 //this function checks for the existence of files before adding to the list 
    619 //pathStr (input) is the path (as returned by pathInfo) 
    620 // 
    621 Function/S BuildList(list,pathstr) 
    622         String list,pathstr 
    623          
    624         //input list is probably just filename, no version number 
    625         //COMMA separated lists, since file names will (MAY) include semicolon version numbers 
    626         //find the file and version number - so that full path:file;vers for each item 
    627         //trailing comma OK at end of list, ExecuteProtocol() treats all as lists 
    628          
    629         String newList="",separator=",",tempstr="",partialName="" 
    630         Variable ii=0,numitems 
    631          
    632         numitems = ItemsInList(list,separator) 
    633         do 
    634                 tempstr = StringFromList(ii,list,separator) 
    635                 if(cmpstr(tempstr,"ask")==0) 
    636                                 newList = tempstr                                       //don't prepend path to "ask" option, no comma 
    637                                 break                                                           //get out - don't add anything else to list 
    638                 endif 
    639                 if(strlen(tempStr)!=0)          //skip any null items 
    640                         //add version number (if needed) and make sure the filename is valid 
    641                         partialName = FindValidFilename(tempStr) 
    642                         //can't check for RAW here - may be dealing with mask, div ... or other filetypes 
    643                         newList += pathstr+partialName+separator 
    644                 endif 
    645                 ii+=1 
    646         while(ii<numitems) 
    647          
    648         Return(newlist) 
    649          
    650503End 
    651504 
     
    1098951End 
    1099952 
    1100 //procedure called by protocol panel to ask user for agerage type choices 
     953//procedure called by protocol panel to ask user for average type choices 
    1101954// somewhat confusing and complex, but may be as good as it gets. 
    1102955// 
     
    11751028// Procedure files for creating and executing a data reduction protocol 
    11761029// 
    1177 //**** ONLY invoked from the MAIN PANEL**** 
     1030//**** ONLY invoked from the MAIN PANEL**** NOT REALLY EVER USED ****** 
    11781031//Procedure for reducing a sample file (multiple added files) with a specified 
    11791032//protocol. User may create a new protocol, and will be prompted 
     
    12091062        //samStr is set at top to "ask", since this is the action always desired from "ReduceAFile" 
    12101063         
    1211         ////// 
    1212         //PathInfo catPathName                  //this is where the files came from 
    1213         //String pathstr=S_path,samStr 
    1214         //samStr = BuildList(tempStr,pathStr)           //ExecuteProtocol() needs full path for SAM files 
    1215         ///// 
    1216          
    12171064        ExecuteProtocol(waveStr,samStr) 
    12181065         
     
    12561103        return(list) 
    12571104End 
    1258 //missing paramater dialog to solicit user for a waveStr for the protocal  
     1105 
     1106//missing paramater dialog to solicit user for a waveStr for the protocol  
    12591107//about to be created 
    12601108//name is passed back as a global string and calling procedure is responsible for 
     
    12721120//ensures that a valid protocol name was chosen, then fills out each "item" 
    12731121//(6 total) needed for reduction 
    1274 //it the user cancels at nay point, the partial protocol will be deleted 
     1122//it the user cancels at any point, the partial protocol will be deleted 
    12751123// 
    12761124Function ProtocolQuestionnare() 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/RawWindowHook.ipf

    r41 r76  
    3434        String/G root:myGlobals:gCurDispFile = "default string" 
    3535        String/G root:myGlobals:gCurTitle = "" 
    36 //      Variable/G root:myGlobals:gMapLow=0. 
    37 //      Variable/G root:myGlobals:gMapHigh=1 
    3836        Make/O/N=2 root:myGlobals:q_x_axis,root:myGlobals:q_y_axis 
    3937         
     
    9492                Button Print_status,pos={170,23},size={50,20},proc=StatusButton,title="Status" 
    9593                Button Print_status,help={"Print out information about the currently displayed file into the history window"} 
    96 //              SetVariable lowThresh,pos={170,55},size={110,17},proc=LowThreshSetVarProc,title="Map low" 
    97 //              SetVariable lowThresh,limits={0,1,0.01},value= root:myGlobals:gMapLow 
    98 //              SetVariable lowThresh,help={"Low limit of threshold as a fraction of maximum data value"} 
    99 //              SetVariable highThresh,pos={285,55},size={120,17},proc=HighThreshSetVarProc,title="Map high" 
    100 //              SetVariable highThresh,limits={0,1,0.01},value= root:myGlobals:gMapHigh 
    101 //              SetVariable highThresh,help={"High limit of threshold as a fraction of maximum data value"} 
    10294                Button maskButton size={84,20}, pos={170,53}, proc=maskButtonProc,title="Show Mask" 
    10395                Button maskButton help={"If a mask has been loaded this will overlay it on the current plot"} 
     
    235227                xaxval= AxisValFromPixel("","bottom",xpix) 
    236228                yaxval= AxisValFromPixel("","left",ypix) 
    237                 //xint = trunc(xaxval) 
    238                 //yint = trunc(yaxval) 
    239229                xint = round(xaxval) 
    240230                yint = round(yaxval) 
     
    352342// - needs the location of the currently displayed data to get the header information 
    353343// to be able to calculate q-values at the edges of the detector 
    354 //** assumes a linear correcpondence between pixel->q-values (which should bea a really 
     344//** assumes a linear correspondence between pixel->q-values (which should bea a really 
    355345// safe bet, since we're using the small -angle approximation...) 
    356346// 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/RectAnnulAvg.ipf

    r47 r76  
    5959         
    6060        // center of detector, for non-linear corrections 
    61         xcenter = 64.5 
    62         ycenter = 64.5 
     61        NVAR pixelsX = root:myGlobals:gNPixelsX 
     62        NVAR pixelsY = root:myGlobals:gNPixelsY 
     63         
     64        xcenter = pixelsX/2 + 0.5               // == 64.5 for 128x128 Ordela 
     65        ycenter = pixelsY/2 + 0.5               // == 64.5 for 128x128 Ordela 
    6366         
    6467        // beam center, in pixels 
     
    325328        Variable DDet, apOff=0.0 
    326329        DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
    327 //      do  
    328 //        if(strsearch(fileStr, "NG5", 0) != -1) 
    329 //          //string was found, it's an NG5 file 
    330 //          DDet = 1.0 
    331 //          break 
    332 //        Endif 
    333 //        if(strsearch(fileStr, "NG3", 0) != -1) 
    334 //          //string was found, it's an NG3 file 
    335 //          DDet = 1.0 
    336 //          break 
    337 //        Endif 
    338 //        if(strsearch(fileStr, "NG7", 0) != -1) 
    339 //          //string was found, it's an NG7 file 
    340 //          DDet = 0.5 
    341 //          break 
    342 //        Endif 
    343 //      while(0) 
     330 
    344331 
    345332        //Width of annulus used for the average is gotten from the  
     
    351338 
    352339        ii=0 
    353 //      String res_string="root:myGlobals:Res_vals" 
    354 //      Make/O/D/N=3 $res_string 
    355 //      Wave res_wave=$res_string 
     340 
    356341        Variable ret1,ret2,ret3 
    357342        do 
    358343                getResolution(qval[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,ddr,ret1,ret2,ret3) 
    359                 sigmaq[ii] = ret1       //res_wave[0] 
    360                 qbar[ii] = ret2         //res_wave[1] 
    361                 fsubs[ii] = ret3                //res_wave[2] 
     344                sigmaq[ii] = ret1 
     345                qbar[ii] = ret2  
     346                fsubs[ii] = ret3 
    362347                ii+=1 
    363348        while(ii<nq) 
     
    372357 
    373358        Avg_1D_Graph(aveint,qval,sigave) 
    374 //      DoWindow/F Plot_1d 
    375 //      If(V_flag == 1)         //the graph window already exists 
    376 //              //kill the old graph and make a new one 
    377 //              //easier than adjusting the old one 
    378 //              DoWindow/K Plot_1d 
    379 //      Endif    
    380 //      Display /W=(412,51,727,302)/K=1 aveint vs qval 
    381 //      ModifyGraph log=1 
    382 //      ModifyGraph mode=3,marker=19,msize=1,rgb=(0,0,0) 
    383 //      ErrorBars aveint Y,wave=(sigave,sigave) 
    384 //      Label left "Counts";DelayUpdate 
    385 //      Label bottom "q\\U" 
    386 //      SVAR angst = root:myGlobals:gAngstStr 
    387 //      Label bottom "q ("+angst+"\\S-1\\M)" 
    388 //      DoWindow/C Plot_1d 
    389          
     359 
    390360        //get rid of the default mask, if one was created (it is in the current folder) 
    391361        //don't just kill "mask" since it might be pointing to the one in the MSK folder 
     
    490460        Wave reals = $(destPath + ":RealsRead") 
    491461 
     462        // center of detector, for non-linear corrections 
    492463        NVAR pixelsX = root:myGlobals:gNPixelsX 
    493464        NVAR pixelsY = root:myGlobals:gNPixelsY 
    494465         
    495         // center of detector, for non-linear corrections 
    496         xcenter = 64.5 
    497         ycenter = 64.5 
     466        xcenter = pixelsX/2 + 0.5               // == 64.5 for 128x128 Ordela 
     467        ycenter = pixelsY/2 + 0.5               // == 64.5 for 128x128 Ordela 
    498468         
    499469        // beam center, in pixels 
     
    517487        nphi = numPhiSteps              //number of anular sectors is set by users 
    518488         
    519         rcentr = 150            //pixels within rcentr of beam center are broken into 9 parts 
    520489        rc = 2*dtdist*asin(qc*lambda/4/Pi)              //in mm 
    521490        delr = nw*sx/2 
     
    673642        //angle dependent transmission correction is not done in phiave 
    674643        Ann_1D_Graph(aveint,phival,sigave) 
    675 //      DoWindow/F Plot_1d 
    676 //      If(V_flag == 1)         //the graph window already exists 
    677 //              //kill the old graph and make a new one 
    678 //              //easier than adjusting the old one 
    679 //              DoWindow/K Plot_1d 
    680 //      Endif    
    681 //      Display /W=(412,51,727,302)/K=1 aveint vs phival 
    682 //      ModifyGraph log=0 
    683 //      ModifyGraph mode=3,marker=19,msize=1,rgb=(0,0,0) 
    684 //      ErrorBars aveint Y,wave=(sigave,sigave) 
    685 //      Label left "Counts";DelayUpdate 
    686 //      Label bottom "Angle (degrees)" 
    687 //      DoWindow/C Plot_1d 
    688644         
    689645        //get rid of the default mask, if one was created (it is in the current folder) 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Schematic.ipf

    r70 r76  
    102102        text2 = "Using Protocol: "+protocolName 
    103103        text3 = "Sample file: "+ root:SAM:fileList 
    104         text5 = "T\\BSAM\\M = " + GetTrans("SAM")       //trans and thickness of the sample 
    105         text5 += "   d\\BSAM\\M = " + GetThick("SAM") + " cm" 
    106         text7 = "T\\BEMP\\M = " + GetTrans("EMP")       //transmission of the empty cell 
     104        text5 = "T\\BSAM\\M = " + getTransStrFromReals("SAM")   //trans and thickness of the sample 
     105        text5 += "   d\\BSAM\\M = " + getThickStrFromReals("SAM") + " cm" 
     106        text7 = "T\\BEMP\\M = " + getTransStrFromReals("EMP")   //transmission of the empty cell 
    107107        //attenuators used in sample measurement 
    108108 
    109         text23 = "SAM Attenuator = "+GetAttenNum("SAM") 
     109        text23 = "SAM Attenuator = "+GetAttenNumStrFromReals("SAM") 
    110110         
    111111        text11 = "Final 1-D Dataset" 
     
    433433        text2 = "Using Protocol: "+protocolName 
    434434        text3 = "Sample file: "+ root:SAM:fileList 
    435         text5 = "T\\BSAM\\M = " + GetTrans("SAM")       //trans and thickness of the sample 
    436         text5 += "   d\\BSAM\\M = " + GetThick("SAM") + " cm" 
    437         text7 = "T\\BEMP\\M = " + GetTrans("EMP")       //transmission of the empty cell 
     435        text5 = "T\\BSAM\\M = " + getTransStrFromReals("SAM")   //trans and thickness of the sample 
     436        text5 += "   d\\BSAM\\M = " + getThickStrFromReals("SAM") + " cm" 
     437        text7 = "T\\BEMP\\M = " + getTransStrFromReals("EMP")   //transmission of the empty cell 
    438438        //attenuators used in sample measurement 
    439439 
    440         text23 = "SAM Attenuator = "+GetAttenNum("SAM") 
     440        text23 = "SAM Attenuator = "+GetAttenNumStrFromReals("SAM") 
    441441         
    442442        text11 = "Final 1-D Dataset" 
     
    623623//returns "none" if the value (in RealsRead) cannot be found 
    624624// 
    625 Function/S GetTrans(type) 
     625Function/S getTransStrFromReals(type) 
    626626        String type 
    627627         
     
    639639//returns "none" if the value (in RealsRead) cannot be found 
    640640// 
    641 Function/S GetThick(type) 
     641Function/S getThickStrFromReals(type) 
    642642        String type 
    643643         
     
    655655//returns "none" if the value (in RealsRead) cannot be found 
    656656// 
    657 Function/S GetAttenNum(type) 
     657Function/S GetAttenNumStrFromReals(type) 
    658658        String type 
    659659         
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Tile_2D.ipf

    r41 r76  
    328328        Endif 
    329329         
    330         String list=IndexedFile(catPathName,-1,"????") 
    331         String newList="",item="" 
    332         Variable num=ItemsInList(list,";"),ii 
    333         for(ii=0;ii<num;ii+=1) 
    334                 item = StringFromList(ii, list  ,";") 
    335                 if( stringmatch(item,"*.sa1*") ) 
    336                         newlist += item + ";" 
    337                 endif 
    338                 if( stringmatch(item,"*.sa2*") ) 
    339                         newlist += item + ";" 
    340                 endif 
    341                 if( stringmatch(item,"*.sa3*") ) 
    342                         newlist += item + ";" 
    343                 endif 
    344                 //print "ii=",ii 
    345         endfor 
    346         newList = SortList(newList,";",0) 
     330        String newList="" 
     331        Variable num 
     332 
     333        newList = GetRawDataFileList() 
     334         
    347335        num=ItemsInList(newlist,";") 
    348336        WAVE/T fileWave=$"root:myGlobals:Tile_2D:fileWave" 
     
    528516        Endif 
    529517         
    530         String list=IndexedFile(catPathName,-1,"????") 
    531         String newList="",item="" 
    532         Variable num=ItemsInList(list,";"),ii 
    533         for(ii=0;ii<num;ii+=1) 
    534                 item = StringFromList(ii, list  ,";") 
    535                 if( stringmatch(item,"*.sa1*") ) 
    536                         newlist += item + ";" 
    537                 endif 
    538                 if( stringmatch(item,"*.sa2*") ) 
    539                         newlist += item + ";" 
    540                 endif 
    541                 if( stringmatch(item,"*.sa3*") ) 
    542                         newlist += item + ";" 
    543                 endif 
    544                 //print "ii=",ii 
    545         endfor 
    546         newList = SortList(newList,";",0) 
     518        Variable num 
     519        String newList = GetRawDataFileList() 
     520         
    547521        num=ItemsInList(newlist,";") 
    548522        WAVE/T fileWave=$"root:myGlobals:RAW2ASCII:fileWave" 
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/WriteQIS.ipf

    r69 r76  
    653653End 
    654654 
    655  
    656 ////***this function is not used - WriteWaves_W_Protocol() is used instead 
    657 //// 
    658 ////for writing out data (q-i-s) from the "type" folder 
    659 ////if fullpath is a complete HD path:filename, no dialog will be presented 
    660 ////if fullpath is just a filename, the save dialog will be presented (forced if dialog =1) 
    661 ////writes ONLY the standard header information (no protocol information) 
    662 //// 
    663 //Function WriteWaves(type,fullpath,dialog) 
    664 //      String type,fullpath 
    665 //      Variable dialog         //=1 will present dialog for name 
    666 //       
    667 //      String destStr="" 
    668 //      destStr = "root:"+type 
    669 //       
    670 //      Variable refNum 
    671 //      String formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 
    672 //      String fname,ave="C",headerFormat = "%10.4g %8.2g %8.2g %8.2g %8.3g %8.3g %8s %5.0g\r\n" 
    673 //      Variable step=1 
    674 //       
    675 //      //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
    676 //      WAVE intw=$(destStr + ":integersRead") 
    677 //      WAVE rw=$(destStr + ":realsRead") 
    678 //      WAVE/T textw=$(destStr + ":textRead") 
    679 //      WAVE qvals =$(destStr + ":qval") 
    680 //      WAVE inten=$(destStr + ":aveint") 
    681 //      WAVE sig=$(destStr + ":sigave") 
    682 //      WAVE qbar = $(destStr + ":QBar") 
    683 //      WAVE sigmaq = $(destStr + ":SigmaQ") 
    684 //      WAVE fsubs = $(destStr + ":fSubS") 
    685 // 
    686 //      //check each wave 
    687 //      If(!(WaveExists(intw))) 
    688 //              Abort "intw DNExist BinaryWrite()" 
    689 //      Endif 
    690 //      If(!(WaveExists(rw))) 
    691 //              Abort "rw DNExist BinaryWrite()" 
    692 //      Endif 
    693 //      If(!(WaveExists(textw))) 
    694 //              Abort "textw DNExist BinaryWrite()" 
    695 //      Endif 
    696 //      If(!(WaveExists(qvals))) 
    697 //              Abort "qvals DNExist BinaryWrite()" 
    698 //      Endif 
    699 //      If(!(WaveExists(inten))) 
    700 //              Abort "inten DNExist BinaryWrite()" 
    701 //      Endif 
    702 //      If(!(WaveExists(sig))) 
    703 //              Abort "sig DNExist BinaryWrite()" 
    704 //      Endif 
    705 //      If(!(WaveExists(qbar))) 
    706 //              Abort "qbar DNExist BinaryWrite()" 
    707 //      Endif 
    708 //      If(!(WaveExists(sigmaq))) 
    709 //              Abort "sigmaq DNExist BinaryWrite()" 
    710 //      Endif 
    711 //      If(!(WaveExists(fsubs))) 
    712 //              Abort "fsubs DNExist BinaryWrite()" 
    713 //      Endif 
    714 //               
    715 //      if(dialog) 
    716 //              PathInfo/S catPathName 
    717 //              fullPath = DoSaveFileDialog("Save data as") 
    718 //              If(cmpstr(fullPath,"")==0) 
    719 //                      //user cancel, don't write out a file 
    720 //                      Close/A 
    721 //                      Abort "no data file was written" 
    722 //              Endif 
    723 //              //Print "dialog fullpath = ",fullpath 
    724 //      Endif 
    725 //       
    726 //      //actually open the file 
    727 //      Open refNum as fullpath 
    728 //       
    729 //      fprintf refnum,"FILE: %s\t\t CREATED: %s\r\n",textw[0],textw[1] 
    730 //      fprintf refnum,"LABEL: %s\r\n",textw[6] 
    731 //      fprintf refnum,"MON CNT   LAMBDA   DET ANG   DET DIST   TRANS   THICK   AVE   STEP\r\n" 
    732 //      fprintf refnum,headerFormat,rw[0],rw[26],rw[19],rw[18],rw[4],rw[5],ave,step 
    733 //      wfprintf refnum, formatStr, qvals,inten,sig,sigmaq,qbar,fsubs 
    734 //       
    735 //      Close refnum 
    736 //       
    737 //      SetDataFolder root:             //(redundant) 
    738 //       
    739 //      Return(0) 
    740 //End 
Note: See TracChangeset for help on using the changeset viewer.