Ignore:
Timestamp:
May 20, 2016 4:28:56 PM (6 years ago)
Author:
srkline
Message:

changes to a few analysis models to make these Igor 7-ready

adding mask editing utilities

many changes to event mode for easier processing of split lists

updated event mode help file

+ lots more!

File:
1 edited

Legend:

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

    r984 r999  
    1010// -- fill in all of the details... 
    1111// 
     12 
     13 
     14// 
     15// see the VCALC BinAllMiddlePanels() for an example of this 
     16// see the binning routines in VC_DetectorBinning_Utils.ipf for the details 
     17// 
     18// TODO  
     19// x- detector "B" is currently skipped since the calibration waves are not faked 
     20//    when the raw data is loaded. Then the qxqyqz waves are not generated. 
     21// 
     22// -- REDO the logic here. It's a mess, and will get the calculation wrong  
     23// 
     24// -- figure out the binning type (where is it set for VSANS?) 
     25// -- don't know, so currently VSANS binning type is HARD-WIRED 
     26// -- figure out when this needs to be called to (force) re-calculate I vs Q 
     27// 
     28Function V_QBinAllPanels(folderStr) 
     29        String folderStr 
     30 
     31        // do the back, middle, and front separately 
     32         
     33//      figure out the binning type (where is it set?) 
     34        Variable binType,ii,delQ 
     35        String detStr 
     36        binType = 1 
     37         
     38         
     39 
     40//// TODO: 
     41// x- currently the "B" detector is skipped - it was skipped in  
     42//       previous functions where q values are calculated        
     43//       
     44        delQ = SetDeltaQ(folderStr,"B") 
     45         
     46        // dispatch based on binning type 
     47        if(binType == 1) 
     48                VC_fDoBinning_QxQy2D(folderStr, "B")            //normal binning, nothing to combine 
     49        endif 
     50 
     51// TODO -- this is only a temporary fix for slit mode    
     52        if(binType == 4) 
     53                /// this is for a tall, narrow slit mode         
     54                VC_fBinDetector_byRows(folderStr,"B") 
     55        endif    
     56 
     57 
     58 
     59// these are the binning types where detectors are not combined 
     60// other combined binning is below the loop 
     61        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     62                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     63                 
     64                // set delta Q for binning 
     65                delQ = SetDeltaQ(folderStr,detStr) 
     66                 
     67                // dispatch based on binning type 
     68                if(binType==1) 
     69                        VC_fDoBinning_QxQy2D(folderStr,detStr) 
     70                endif 
     71                 
     72                // TODO -- this is only a temporary fix for slit mode    
     73                if(binType == 4) 
     74                        /// this is for a tall, narrow slit mode         
     75                        VC_fBinDetector_byRows(folderStr,detStr) 
     76                endif    
     77                 
     78        endfor 
     79         
     80        // bin in pairs 
     81        if(binType == 2) 
     82                VC_fDoBinning_QxQy2D(folderStr,"MLR") 
     83                VC_fDoBinning_QxQy2D(folderStr,"MTB") 
     84                VC_fDoBinning_QxQy2D(folderStr,"FLR") 
     85                VC_fDoBinning_QxQy2D(folderStr,"FTB")    
     86        endif 
     87         
     88        // bin everything on front or middle together 
     89        if(binType == 3) 
     90                VC_fDoBinning_QxQy2D(folderStr,"MLRTB") 
     91                VC_fDoBinning_QxQy2D(folderStr,"FLRTB") 
     92        endif 
     93 
     94        return(0) 
     95End 
     96 
     97 
     98 
     99 
     100 
    12101Macro V_Combine1DData() 
    13102 
     
    26115         
    27116// write out the data set to a file 
    28  
    29  
    30 End 
    31  
    32  
    33  
     117        String/G saveName="" 
     118        V_GetNameForSave("") 
     119        V_Write1DData(type,saveName) 
     120 
     121End 
     122 
     123Proc V_GetNameForSave(str) 
     124        String str 
     125        String/G saveName=str 
     126End 
    34127 
    35128 
     
    122215 
    123216// TODO: 
     217// -- resolution waves are ignored 
     218// -- only a sort is done, no rescaling of data sets 
     219//    (it's too late now anyways, since the data was concatenated 
     220// 
    124221// see Auto_Sort() in the SANS Automation ipf for the rest of the details of 
    125 // how to combine the resolution waves (they also need to be concatenated, which is currently not done. 
    126 // 
     222// how to combine the resolution waves (they also need to be concatenated, which is currently not done) 
     223//  
    127224Function V_TmpSort1D(folderStr) 
    128225        String folderStr 
     
    197294 
    198295 
     296 
    199297// TODO: 
    200298// -- this is a temporary solution before a real writer is created 
    201299// -- resolution is not handled here (and it shouldn't be) since resolution is not known yet. 
    202300// 
    203 // 
    204301// this will bypass save dialogs 
    205302// -- AND WILL OVERWITE DATA WITH THE SAME NAME 
    206303// 
    207 Function V_Write1DData(folderStr,delim,term) 
    208         String folderStr,delim,term 
     304Function V_Write1DData(folderStr,saveName) 
     305        String folderStr,saveName 
    209306         
    210307        String formatStr="",fullpath="" 
    211308        Variable refnum,dialog=1 
     309 
     310        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     311 
     312        Wave qw = tmp_q 
     313        Wave iw = tmp_i 
     314        Wave sw = tmp_s 
    212315         
    213316        String dataSetFolderParent,basestr 
    214317         
    215         //Abuse ParseFilePath to get path without folder name 
    216         dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 
    217         //Abuse ParseFilePath to get basestr 
    218         basestr = ParseFilePath(0,folderStr,":",1,0) 
     318        // ParseFilePath to get path without folder name 
     319//      dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 
     320        // ParseFilePath to get basestr 
     321//      basestr = ParseFilePath(0,folderStr,":",1,0) 
    219322         
    220323        //make sure the waves exist 
    221         SetDataFolder $(dataSetFolderParent+basestr) 
    222         WAVE/Z qw = $(baseStr+"_q") 
    223         WAVE/Z iw = $(baseStr+"_i") 
    224         WAVE/Z sw = $(baseStr+"_s") 
    225         WAVE/Z resw = $(baseStr+"_res") 
    226324         
    227325        if(WaveExists(qw) == 0) 
     
    234332                Abort "s is missing" 
    235333        endif 
    236         if(WaveExists(resw) == 0) 
    237                 Abort "Resolution information is missing." 
    238         endif 
    239          
    240         Duplicate/O qw qbar,sigQ,fs 
    241         if(dimsize(resW,1) > 4) 
    242                 //it's USANS put -dQv back in the last 3 columns 
    243                 NVAR/Z dQv = USANS_dQv 
    244                 if(NVAR_Exists(dQv) == 0) 
    245                         SetDataFolder root: 
    246                         Abort "It's USANS data, and I don't know what the slit height is." 
    247                 endif 
    248                 sigQ = -dQv 
    249                 qbar = -dQv 
    250                 fs = -dQv 
    251         else 
    252                 //it's SANS 
    253                 sigQ = resw[p][0] 
    254                 qbar = resw[p][1] 
    255                 fs = resw[p][2] 
    256         endif 
    257          
     334//      if(WaveExists(resw) == 0) 
     335//              Abort "Resolution information is missing." 
     336//      endif 
     337         
     338//      Duplicate/O qw qbar,sigQ,fs 
     339//      if(dimsize(resW,1) > 4) 
     340//              //it's USANS put -dQv back in the last 3 columns 
     341//              NVAR/Z dQv = USANS_dQv 
     342//              if(NVAR_Exists(dQv) == 0) 
     343//                      SetDataFolder root: 
     344//                      Abort "It's USANS data, and I don't know what the slit height is." 
     345//              endif 
     346//              sigQ = -dQv 
     347//              qbar = -dQv 
     348//              fs = -dQv 
     349//      else 
     350//              //it's SANS 
     351//              sigQ = resw[p][0] 
     352//              qbar = resw[p][1] 
     353//              fs = resw[p][2] 
     354//      endif 
     355//       
     356 
    258357        PathInfo catPathName 
    259         fullPath = S_Path + folderStr 
     358        fullPath = S_Path + saveName 
    260359 
    261360        Open refnum as fullpath 
    262361 
    263362        fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
    264         formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
    265         fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
    266  
    267         wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
     363 
     364// TODO -- make this work for 6-columns 
     365//      formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
     366//      fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
     367//      wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
     368 
     369        //currently, only three columns 
     370        formatStr = "%15.4g %15.4g %15.4g\r\n"   
     371        fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     372 
     373        wfprintf refnum,formatStr,qw,iw,sw 
    268374        Close refnum 
    269375         
    270         KillWaves/Z sigQ,qbar,fs 
     376//      KillWaves/Z sigQ,qbar,fs 
    271377         
    272378        SetDataFolder root: 
Note: See TracChangeset for help on using the changeset viewer.