Ignore:
Timestamp:
May 18, 2017 11:34:30 AM (5 years ago)
Author:
srkline
Message:

changes to incorporate trimming and plotting of data that has been saved as individual detector I(q), as Igor .itx format. This allows the trimming parameters to be set for each detector panel, which can then be used during the reduction protocol to automatically trim and combine the panels. Next step is to incorporate this into the actual protocol definintion by expanding the current definition.

File:
1 edited

Legend:

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

    r1038 r1039  
    153153// uses the current display if type=="" 
    154154// 
    155 Function V_ConcatenateForSave(type,binType) 
    156         String type 
     155Function V_ConcatenateForSave(pathStr,type,tagStr,binType) 
     156        String pathStr,type,tagStr 
    157157        Variable binType 
    158158         
     
    172172// TODO x- figure out which binning was used (this is done in V_1DConcatenate()) 
    173173        // clear the old tmp waves first, if they still exist 
    174         SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
     174//      SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
     175        SetDataFolder $(pathStr+type) 
    175176        Killwaves/Z tmp_q,tmp_i,tmp_s 
    176177        setDataFolder root: 
    177         V_1DConcatenate(type,binType) 
     178        V_1DConcatenate(pathStr,type,tagStr,binType) 
    178179         
    179180// sort the data set 
    180         V_TmpSort1D(type) 
     181        V_TmpSort1D(pathStr,type) 
    181182         
    182183        return(0) 
     
    187188// so the type is the currently displayed type, and the binning is from the panel 
    188189// 
    189 Function V_SimpleSave1DData(type,saveName) 
    190         String type,saveName 
     190Function V_SimpleSave1DData(pathStr,type,tagStr,saveName) 
     191        String pathStr,type,tagStr,saveName 
    191192 
    192193//  
     
    195196        Variable binType = V_GetBinningPopMode() 
    196197         
    197         V_ConcatenateForSave(curType,binType) 
     198        V_ConcatenateForSave(pathStr,curType,tagStr,binType) 
    198199         
    199200// write out the data set to a file 
     
    204205        endif 
    205206         
    206         V_Write1DData(curtype,saveName) 
     207        V_Write1DData(pathStr,curtype,saveName) 
    207208 
    208209End 
     
    262263// otherwise the value is assumed good (from a protocol) 
    263264// 
    264 // 
    265 // 
    266 Function V_1DConcatenate(folderStr,binType) 
    267         String folderStr 
     265// pathStr must have the trailing colon 
     266// tagStr is normally null, but is "_trim" for data to be trimmed 
     267// 
     268Function V_1DConcatenate(pathStr,folderStr,tagStr,binType) 
     269        String pathStr,folderStr,tagStr 
    268270        Variable binType 
    269271         
     
    272274        endif    
    273275         
    274         SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     276//      SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     277        SetDataFolder $(pathStr+folderStr) 
    275278 
    276279        //kill these waves before starting, or the new concatenation will be added to the old 
     
    280283        if(binType == 1) 
    281284                // q-values 
    282                 waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 
    283                 waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 
     285                waveListStr =  "qBin_qxqy_B" + tagStr + ";" 
     286                waveListStr += "qBin_qxqy_MB" + tagStr + ";" 
     287                waveListStr += "qBin_qxqy_MT" + tagStr + ";" 
     288                waveListStr += "qBin_qxqy_ML" + tagStr + ";" 
     289                waveListStr += "qBin_qxqy_MR" + tagStr + ";" 
     290                waveListStr += "qBin_qxqy_FB" + tagStr + ";" 
     291                waveListStr += "qBin_qxqy_FT" + tagStr + ";" 
     292                waveListStr += "qBin_qxqy_FL" + tagStr + ";" 
     293                waveListStr += "qBin_qxqy_FR" + tagStr + ";" 
    284294 
    285295                Concatenate/NP/O waveListStr, tmp_q 
    286296 
    287297                //intensity 
    288                 waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
    289                 waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
     298                waveListStr =  "iBin_qxqy_B" + tagStr + ";" 
     299                waveListStr += "iBin_qxqy_MB" + tagStr + ";" 
     300                waveListStr += "iBin_qxqy_MT" + tagStr + ";" 
     301                waveListStr += "iBin_qxqy_ML" + tagStr + ";" 
     302                waveListStr += "iBin_qxqy_MR" + tagStr + ";" 
     303                waveListStr += "iBin_qxqy_FB" + tagStr + ";" 
     304                waveListStr += "iBin_qxqy_FT" + tagStr + ";" 
     305                waveListStr += "iBin_qxqy_FL" + tagStr + ";" 
     306                waveListStr += "iBin_qxqy_FR" + tagStr + ";" 
     307//              waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
     308//              waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
    290309                 
    291310                Concatenate/NP/O waveListStr, tmp_i 
    292311 
    293312                //error 
    294                 waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
    295                 waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
     313                waveListStr =  "eBin_qxqy_B" + tagStr + ";" 
     314                waveListStr += "eBin_qxqy_MB" + tagStr + ";" 
     315                waveListStr += "eBin_qxqy_MT" + tagStr + ";" 
     316                waveListStr += "eBin_qxqy_ML" + tagStr + ";" 
     317                waveListStr += "eBin_qxqy_MR" + tagStr + ";" 
     318                waveListStr += "eBin_qxqy_FB" + tagStr + ";" 
     319                waveListStr += "eBin_qxqy_FT" + tagStr + ";" 
     320                waveListStr += "eBin_qxqy_FL" + tagStr + ";" 
     321                waveListStr += "eBin_qxqy_FR" + tagStr + ";" 
     322//              waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
     323//              waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
    296324                         
    297325                Concatenate/NP/O waveListStr, tmp_s 
     
    300328        if(binType == 2)         
    301329                // q-values 
    302                 waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" 
    303                 waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" 
     330                waveListStr =  "qBin_qxqy_B" + tagStr + ";" 
     331                waveListStr += "qBin_qxqy_MTB" + tagStr + ";" 
     332                waveListStr += "qBin_qxqy_MLR" + tagStr + ";" 
     333                waveListStr += "qBin_qxqy_FTB" + tagStr + ";" 
     334                waveListStr += "qBin_qxqy_FLR" + tagStr + ";" 
     335 
     336//              waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" 
     337//              waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" 
    304338 
    305339                Concatenate/NP/O waveListStr, tmp_q 
    306340 
    307341                //intensity 
    308                 waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" 
    309                 waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" 
     342                waveListStr =  "iBin_qxqy_B" + tagStr + ";" 
     343                waveListStr += "iBin_qxqy_MTB" + tagStr + ";" 
     344                waveListStr += "iBin_qxqy_MLR" + tagStr + ";" 
     345                waveListStr += "iBin_qxqy_FTB" + tagStr + ";" 
     346                waveListStr += "iBin_qxqy_FLR" + tagStr + ";" 
     347                 
     348//              waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" 
     349//              waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" 
    310350                 
    311351                Concatenate/NP/O waveListStr, tmp_i 
    312352 
    313353                //error 
    314                 waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" 
    315                 waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" 
     354                waveListStr =  "eBin_qxqy_B" + tagStr + ";" 
     355                waveListStr += "eBin_qxqy_MTB" + tagStr + ";" 
     356                waveListStr += "eBin_qxqy_MLR" + tagStr + ";" 
     357                waveListStr += "eBin_qxqy_FTB" + tagStr + ";" 
     358                waveListStr += "eBin_qxqy_FLR" + tagStr + ";" 
     359                 
     360//              waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" 
     361//              waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" 
    316362                         
    317363                Concatenate/NP/O waveListStr, tmp_s 
     
    320366        if(binType == 3)         
    321367                // q-values 
    322                 waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" 
     368                waveListStr =  "qBin_qxqy_B" + tagStr + ";" 
     369                waveListStr += "qBin_qxqy_MLRTB" + tagStr + ";" 
     370                waveListStr += "qBin_qxqy_FLRTB" + tagStr + ";" 
     371                 
     372//              waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" 
    323373 
    324374                Concatenate/NP/O waveListStr, tmp_q 
    325375 
    326376                //intensity 
    327                 waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" 
     377                waveListStr =  "iBin_qxqy_B" + tagStr + ";" 
     378                waveListStr += "iBin_qxqy_MLRTB" + tagStr + ";" 
     379                waveListStr += "iBin_qxqy_FLRTB" + tagStr + ";" 
     380                 
     381//              waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" 
    328382                 
    329383                Concatenate/NP/O waveListStr, tmp_i 
    330384 
    331385                //error 
    332                 waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" 
     386                waveListStr =  "eBin_qxqy_B" + tagStr + ";" 
     387                waveListStr += "eBin_qxqy_MLRTB" + tagStr + ";" 
     388                waveListStr += "eBin_qxqy_FLRTB" + tagStr + ";" 
     389                 
     390//              waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" 
    333391                         
    334392                Concatenate/NP/O waveListStr, tmp_s 
     
    341399        if(binType == 4)         
    342400                // q-values 
    343                 waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 
    344                 waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 
     401                waveListStr =  "qBin_qxqy_B" + tagStr + ";" 
     402                waveListStr += "qBin_qxqy_MB" + tagStr + ";" 
     403                waveListStr += "qBin_qxqy_MT" + tagStr + ";" 
     404                waveListStr += "qBin_qxqy_ML" + tagStr + ";" 
     405                waveListStr += "qBin_qxqy_MR" + tagStr + ";" 
     406                waveListStr += "qBin_qxqy_FB" + tagStr + ";" 
     407                waveListStr += "qBin_qxqy_FT" + tagStr + ";" 
     408                waveListStr += "qBin_qxqy_FL" + tagStr + ";" 
     409                waveListStr += "qBin_qxqy_FR" + tagStr + ";" 
     410//              waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 
     411//              waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 
    345412 
    346413                Concatenate/NP/O waveListStr, tmp_q 
    347414 
    348415                //intensity 
    349                 waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
    350                 waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
     416                waveListStr =  "iBin_qxqy_B" + tagStr + ";" 
     417                waveListStr += "iBin_qxqy_MB" + tagStr + ";" 
     418                waveListStr += "iBin_qxqy_MT" + tagStr + ";" 
     419                waveListStr += "iBin_qxqy_ML" + tagStr + ";" 
     420                waveListStr += "iBin_qxqy_MR" + tagStr + ";" 
     421                waveListStr += "iBin_qxqy_FB" + tagStr + ";" 
     422                waveListStr += "iBin_qxqy_FT" + tagStr + ";" 
     423                waveListStr += "iBin_qxqy_FL" + tagStr + ";" 
     424                waveListStr += "iBin_qxqy_FR" + tagStr + ";" 
     425//              waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
     426//              waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
    351427                 
    352428                Concatenate/NP/O waveListStr, tmp_i 
    353429 
    354430                //error 
    355                 waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
    356                 waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
     431                waveListStr =  "eBin_qxqy_B" + tagStr + ";" 
     432                waveListStr += "eBin_qxqy_MB" + tagStr + ";" 
     433                waveListStr += "eBin_qxqy_MT" + tagStr + ";" 
     434                waveListStr += "eBin_qxqy_ML" + tagStr + ";" 
     435                waveListStr += "eBin_qxqy_MR" + tagStr + ";" 
     436                waveListStr += "eBin_qxqy_FB" + tagStr + ";" 
     437                waveListStr += "eBin_qxqy_FT" + tagStr + ";" 
     438                waveListStr += "eBin_qxqy_FL" + tagStr + ";" 
     439                waveListStr += "eBin_qxqy_FR" + tagStr + ";" 
     440//              waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
     441//              waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
    357442                         
    358443                Concatenate/NP/O waveListStr, tmp_s 
     
    375460// how to combine the resolution waves (they also need to be concatenated, which is currently not done) 
    376461//  
    377 Function V_TmpSort1D(folderStr) 
    378         String folderStr 
    379          
    380         SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     462Function V_TmpSort1D(pathStr,folderStr) 
     463        String pathStr,folderStr 
     464         
     465        SetDataFolder $(pathStr+folderStr) 
    381466 
    382467        Wave qw = tmp_q 
     
    395480 
    396481// TODO 
     482// (appears to be unused, in favor of the version that uses the global strings) 
    397483// needs: 
    398484// -- trim the beamstop out (based on shadow?) 
     
    642728// -- AND WILL OVERWITE DATA WITH THE SAME NAME 
    643729// 
    644 Function V_Write1DData(folderStr,saveName) 
    645         String folderStr,saveName 
     730Function V_Write1DData(pathStr,folderStr,saveName) 
     731        String pathStr,folderStr,saveName 
    646732         
    647733        String formatStr="",fullpath="" 
    648734        Variable refnum,dialog=1 
    649735 
    650         SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     736        SetDataFolder $(pathStr+folderStr) 
    651737 
    652738        Wave qw = tmp_q 
     
    702788        fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
    703789 
    704 // TODO -- make this work for 6-columns 
     790// TODO -- make this work for 6-columns (or??) 
    705791//      formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
    706792//      fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
     
    715801         
    716802//      KillWaves/Z sigQ,qbar,fs 
     803        Print "Data written to: ",fullpath 
    717804         
    718805        SetDataFolder root: 
     
    728815// 
    729816// this will bypass save dialogs 
    730 // -- AND WILL OVERWITE DATA WITH THE SAME NAME 
    731 // 
    732 Function V_Write1DData_NoConcat(folderStr,saveName,binType) 
    733         String folderStr,saveName 
     817// -- AND WILL OVERWRITE DATA WITH THE SAME NAME 
     818// 
     819Function V_Write1DData_NoConcat(pathStr,folderStr,saveName,binType) 
     820        String pathStr,folderStr,saveName 
    734821        Variable binType 
    735822         
     
    737824        Variable refnum,dialog=1 
    738825 
    739         SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     826        SetDataFolder $(pathStr+folderStr) 
    740827 
    741828 
     
    10031090 
    10041091// given strings of the number of points to remove, loop over the detectors 
     1092// 
     1093// TODO 
     1094// -- currently uses global strings or default strings 
     1095// -- if proper strings (non-null) are passed in, they are used, otherwise global, then default 
    10051096Function V_Trim1DDataStr(folderStr,binType,nBegStr,nEndStr) 
    10061097        String folderStr 
     
    10241115                return(0) 
    10251116        endif 
    1026          
    1027         //use default values if null string passed in 
     1117 
     1118         
     1119        //use global, then default values if null string passed in 
    10281120        if(strlen(nBegStr)==0) 
    1029                 nBegStr = ksBinTrimBegDefault 
    1030                 nEndStr = ksBinTrimEndDefault 
     1121                SVAR/Z gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr 
     1122                SVAR/Z gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr 
     1123         
     1124                if(!SVAR_exists(gBegPtsStr) || !SVAR_exists(gEndPtsStr) || strlen(gBegPtsStr)==0 || strlen(gEndPtsStr)==0) 
     1125                        nBegStr = ksBinTrimBegDefault 
     1126                        nEndStr = ksBinTrimEndDefault 
     1127                else 
     1128                        nBegStr = gBegPtsStr 
     1129                        nEndStr = gEndPtsStr 
     1130                endif 
    10311131        endif    
    10321132 
Note: See TracChangeset for help on using the changeset viewer.