Changeset 1036 for sans/Dev/trunk


Ignore:
Timestamp:
May 4, 2017 3:17:32 PM (6 years ago)
Author:
srkline
Message:

added utilities to allow saving of I(q) data sets either individual or concatenated. At this point, it simply trims a nominal number of points from the beginning and end of each set before concatenation (and then sorting).

These operations will need to be augmented in the future.

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

Legend:

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

    r1035 r1036  
    2727/////////////////// 
    2828 
    29 Strconstant ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;" 
    3029 
    3130 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf

    r1035 r1036  
    3333 
    3434 
     35 
     36Strconstant ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;" 
     37 
    3538Strconstant ksBinTypeStr = "One;Two;Four;Slit Mode;" 
     39Strconstant ksBinType1 = "B;FT;FB;FL;FR;MT;MB;ML;MR;"           //these are the "active" extensions 
     40Strconstant ksBinType2 = "B;FTB;FLR;MTB;MLR;" 
     41Strconstant ksBinType3 = "B;FLRTB;MLRTB;" 
     42Strconstant ksBinType4 = "B;FT;FB;FL;FR;MT;MB;ML;MR;" 
     43 
    3644 
    3745// NOTE 
     
    229237// TODO: 
    230238// x- this currently ignores the binning type (one, two, etc. ) 
     239// x- change the Concatenate call to use the waveList, to eliminate the need to declare all of the waves 
    231240// -- this currently assumes that all of the waves exist 
    232241// -- need robust error checking for wave existence 
     
    249258// otherwise the value is assumed good (from a protocol) 
    250259// 
     260// 
     261// 
    251262Function V_1DConcatenate(folderStr,binType) 
    252263        String folderStr 
     
    262273        KillWaves/Z tmp_q,tmp_i,tmp_s 
    263274         
     275        String waveListStr="" 
     276        if(binType == 1) 
     277                // q-values 
     278                waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 
     279                waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 
     280 
     281                Concatenate/NP/O waveListStr, tmp_q 
     282 
     283                //intensity 
     284                waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
     285                waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
     286                 
     287                Concatenate/NP/O waveListStr, tmp_i 
     288 
     289                //error 
     290                waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
     291                waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
     292                         
     293                Concatenate/NP/O waveListStr, tmp_s 
     294        endif 
     295 
     296        if(binType == 2)         
     297                // q-values 
     298                waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" 
     299                waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" 
     300 
     301                Concatenate/NP/O waveListStr, tmp_q 
     302 
     303                //intensity 
     304                waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" 
     305                waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" 
     306                 
     307                Concatenate/NP/O waveListStr, tmp_i 
     308 
     309                //error 
     310                waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" 
     311                waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" 
     312                         
     313                Concatenate/NP/O waveListStr, tmp_s 
     314        endif 
     315 
     316        if(binType == 3)         
     317                // q-values 
     318                waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" 
     319 
     320                Concatenate/NP/O waveListStr, tmp_q 
     321 
     322                //intensity 
     323                waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" 
     324                 
     325                Concatenate/NP/O waveListStr, tmp_i 
     326 
     327                //error 
     328                waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" 
     329                         
     330                Concatenate/NP/O waveListStr, tmp_s 
     331        endif 
     332 
     333// TODO - This is the identical set of waves as for the case of binType = 1. 
     334// they have the same names, but are averaged differently since it's slit mode. 
     335// I have separated this, since in practice the TB panels are probably best to ignore 
     336// and NOT include in the averaging since the Qy range is so limited. 
     337        if(binType == 4)         
     338                // q-values 
     339                waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 
     340                waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 
     341 
     342                Concatenate/NP/O waveListStr, tmp_q 
     343 
     344                //intensity 
     345                waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 
     346                waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 
     347                 
     348                Concatenate/NP/O waveListStr, tmp_i 
     349 
     350                //error 
     351                waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 
     352                waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 
     353                         
     354                Concatenate/NP/O waveListStr, tmp_s 
     355        endif 
     356 
     357// Can't kill here, since they are still needed to sort and write out! 
     358//      KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3        
     359         
     360        SetDataFolder root: 
     361         
     362        return(0)                
     363End 
     364 
     365// TODO: 
     366// -- resolution waves are ignored, since they don't exist (yet) 
     367// -- only a sort is done, no rescaling of data sets 
     368//    (it's too late now anyways, since the data was concatenated) 
     369// 
     370// see Auto_Sort() in the SANS Automation ipf for the rest of the details of 
     371// how to combine the resolution waves (they also need to be concatenated, which is currently not done) 
     372//  
     373Function V_TmpSort1D(folderStr) 
     374        String folderStr 
     375         
     376        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     377 
     378        Wave qw = tmp_q 
     379        Wave iw = tmp_i 
     380        Wave sw = tmp_s 
     381         
     382//      Sort qw, qw,iw,sw,res0,res1,res2,res3 
     383 
     384        Sort qw, qw,iw,sw 
     385 
     386 
     387        SetDataFolder root: 
     388        return(0) 
     389End 
     390 
     391 
     392// TODO 
     393// needs: 
     394// -- trim the beamstop out (based on shadow?) 
     395// -- trim out zero q from the file (bad actor in analysis functions) 
     396// -- trim num from the highQ end or lowQ end? 
     397// -- splits the res wave into individual waves in anticipation of concatenation 
     398//   -- or -- deal with the res wave after? 
     399// 
     400// -- make a copy of the waves? 
     401// -- then, what is the concatenate function looking for?? 
     402// 
     403Function V_Trim1DData(dataFolder,binType,nBeg,nEnd) 
     404        String dataFolder 
     405        Variable binType,nBeg,nEnd 
     406 
     407        Variable npt,ii 
     408   SetDataFolder $("root:Packages:NIST:VSANS:"+dataFolder) 
     409 
     410        Printf "%d points removed from beginning, %d points from the end (of each set) before concatenating\r",nbeg,nend 
     411         
     412// for each binType block: 
     413// declare the waves 
     414// make a copy of the waves?? 
     415//      //Break out resolution wave into separate waves 
     416// delete the beginning points from everything 
     417        // trim off the last nEnd points from everything 
     418//      DeletePoints num-nEnd,nEnd, qw,iw,sw 
     419//      // delete all points where the shadow is < 0.98 
     420////Put resolution contents back??? 
     421 
    264422        if(binType == 1)         
    265423                Wave/Z q_fb = qBin_qxqy_FB 
     
    273431                Wave/Z q_b = qBin_qxqy_B 
    274432         
    275                 Concatenate/NP {q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b}, tmp_q 
    276                  
    277433                Wave/Z i_fb = iBin_qxqy_FB 
    278434                Wave/Z i_ft = iBin_qxqy_FT 
     
    285441                Wave/Z i_b = iBin_qxqy_B 
    286442                 
    287                 Concatenate/NP {i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b}, tmp_i 
    288          
    289443                Wave/Z s_fb = eBin_qxqy_FB 
    290444                Wave/Z s_ft = eBin_qxqy_FT 
     
    296450                Wave/Z s_mr = eBin_qxqy_MR 
    297451                Wave/Z s_b = eBin_qxqy_B 
    298                  
    299                 Concatenate/NP {s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b}, tmp_s 
     452                                 
     453                DeletePoints 0,nBeg, q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b 
     454                DeletePoints 0,nBeg, i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b 
     455                DeletePoints 0,nBeg, s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b 
     456                //since each set may have a different number of points 
     457                npt = numpnts(q_fb)  
     458                DeletePoints npt-nEnd,nEnd, q_fb,i_fb,s_fb 
     459 
     460                npt = numpnts(q_ft)  
     461                DeletePoints npt-nEnd,nEnd, q_ft,i_ft,s_ft 
     462 
     463                npt = numpnts(q_fl)  
     464                DeletePoints npt-nEnd,nEnd, q_fl,i_fl,s_fl 
     465 
     466                npt = numpnts(q_fr)  
     467                DeletePoints npt-nEnd,nEnd, q_fr,i_fr,s_fr 
     468 
     469                npt = numpnts(q_mb)  
     470                DeletePoints npt-nEnd,nEnd, q_mb,i_mb,s_mb 
     471 
     472                npt = numpnts(q_mt)  
     473                DeletePoints npt-nEnd,nEnd, q_mt,i_mt,s_mt 
     474 
     475                npt = numpnts(q_ml)  
     476                DeletePoints npt-nEnd,nEnd, q_ml,i_ml,s_ml 
     477 
     478                npt = numpnts(q_mr)  
     479                DeletePoints npt-nEnd,nEnd, q_mr,i_mr,s_mr 
     480 
     481                npt = numpnts(q_b)  
     482                DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b 
     483                 
    300484        endif 
    301485 
     
    306490                Wave/Z q_mlr = qBin_qxqy_MLR 
    307491                Wave/Z q_b = qBin_qxqy_B 
    308          
    309                 Concatenate/NP {q_ftb,q_flr,q_mtb,q_mlr,q_b}, tmp_q 
    310492                 
    311493                Wave/Z i_ftb = iBin_qxqy_FTB 
     
    314496                Wave/Z i_mlr = iBin_qxqy_MLR 
    315497                Wave/Z i_b = iBin_qxqy_B 
    316                  
    317                 Concatenate/NP {i_ftb,i_flr,i_mtb,i_mlr,i_b}, tmp_i 
    318          
     498                                 
    319499                Wave/Z s_ftb = eBin_qxqy_FTB 
    320500                Wave/Z s_flr = eBin_qxqy_FLR 
     
    323503                Wave/Z s_b = eBin_qxqy_B 
    324504                 
    325                 Concatenate/NP {s_ftb,s_flr,s_mtb,s_mlr,s_b}, tmp_s 
     505 
     506                DeletePoints 0,nBeg, q_ftb,q_flr,q_mtb,q_mlr,q_b 
     507                DeletePoints 0,nBeg, i_ftb,i_flr,i_mtb,i_mlr,i_b 
     508                DeletePoints 0,nBeg, s_ftb,s_flr,s_mtb,s_mlr,s_b 
     509                //since each set may have a different number of points 
     510                npt = numpnts(q_ftb)  
     511                DeletePoints npt-nEnd,nEnd, q_ftb,i_ftb,s_ftb            
     512                 
     513                npt = numpnts(q_flr)  
     514                DeletePoints npt-nEnd,nEnd, q_flr,i_flr,s_flr            
     515                 
     516                npt = numpnts(q_mtb)  
     517                DeletePoints npt-nEnd,nEnd, q_mtb,i_mtb,s_mtb            
     518                 
     519                npt = numpnts(q_mlr)  
     520                DeletePoints npt-nEnd,nEnd, q_mlr,i_mlr,s_mlr            
     521                 
     522                npt = numpnts(q_b)  
     523                DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b          
     524                 
     525 
    326526        endif 
    327527 
     
    330530                Wave/Z q_mlrtb = qBin_qxqy_MLRTB 
    331531                Wave/Z q_b = qBin_qxqy_B 
    332          
    333                 Concatenate/NP {q_flrtb,q_mlrtb,q_b}, tmp_q 
    334532                 
    335533                Wave/Z i_flrtb = iBin_qxqy_FLRTB 
    336534                Wave/Z i_mlrtb = iBin_qxqy_MLRTB 
    337                 Wave/Z i_b = iBin_qxqy_B 
    338                  
    339                 Concatenate/NP {i_flrtb,i_mlrtb,i_b}, tmp_i 
    340          
     535                Wave/Z i_b = iBin_qxqy_B         
     536                 
    341537                Wave/Z s_flrtb = eBin_qxqy_FLRTB 
    342538                Wave/Z s_mlrtb = eBin_qxqy_MLRTB 
    343539                Wave/Z s_b = eBin_qxqy_B 
    344540                 
    345                 Concatenate/NP {s_flrtb,s_mlrtb,s_b}, tmp_s 
     541                DeletePoints 0,nBeg, q_flrtb,q_mlrtb,q_b 
     542                DeletePoints 0,nBeg, i_flrtb,i_mlrtb,i_b 
     543                DeletePoints 0,nBeg, s_flrtb,s_mlrtb,s_b 
     544                //since each set may have a different number of points 
     545                npt = numpnts(q_flrtb)  
     546                DeletePoints npt-nEnd,nEnd, q_flrtb,i_flrtb,s_flrtb              
     547                 
     548                npt = numpnts(q_mlrtb)  
     549                DeletePoints npt-nEnd,nEnd, q_mlrtb,i_mlrtb,s_mlrtb              
     550                 
     551                npt = numpnts(q_b)  
     552                DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b          
     553 
    346554        endif 
    347555 
     
    361569                Wave/Z q_b = qBin_qxqy_B 
    362570         
    363                 Concatenate/NP {q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b}, tmp_q 
    364                  
    365571                Wave/Z i_fb = iBin_qxqy_FB 
    366572                Wave/Z i_ft = iBin_qxqy_FT 
     
    373579                Wave/Z i_b = iBin_qxqy_B 
    374580                 
    375                 Concatenate/NP {i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b}, tmp_i 
    376          
    377581                Wave/Z s_fb = eBin_qxqy_FB 
    378582                Wave/Z s_ft = eBin_qxqy_FT 
     
    384588                Wave/Z s_mr = eBin_qxqy_MR 
    385589                Wave/Z s_b = eBin_qxqy_B 
    386                  
    387                 Concatenate/NP {s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b}, tmp_s 
    388         endif 
    389  
    390  
    391  
    392  
    393 // Can't kill here, since they are still needed to sort and write out! 
    394 //      KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3        
    395          
    396         SetDataFolder root: 
    397          
    398         return(0)                
    399 End 
    400  
    401 // TODO: 
    402 // -- resolution waves are ignored, since they don't exist (yet) 
    403 // -- only a sort is done, no rescaling of data sets 
    404 //    (it's too late now anyways, since the data was concatenated) 
    405 // 
    406 // see Auto_Sort() in the SANS Automation ipf for the rest of the details of 
    407 // how to combine the resolution waves (they also need to be concatenated, which is currently not done) 
    408 //  
    409 Function V_TmpSort1D(folderStr) 
    410         String folderStr 
    411          
    412         SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
    413  
    414         Wave qw = tmp_q 
    415         Wave iw = tmp_i 
    416         Wave sw = tmp_s 
    417          
    418 //      Sort qw, qw,iw,sw,res0,res1,res2,res3 
    419  
    420         Sort qw, qw,iw,sw 
    421  
    422  
    423         SetDataFolder root: 
    424         return(0) 
    425 End 
    426  
    427  
    428 // TODO 
    429 // -- currently, this function is NOT called by anything 
    430 // needs: 
    431 // -- trim the beamstop out (based on shadow) 
    432 // -- trim out zero q from the file (bad actor in analysis functions) 
    433 // -- trim num from the highQ end or lowQ end? 
    434 // -- splits the res wave into individual waves in anticipation of concatenation 
    435 //   -- or -- deal with the res wave after? 
    436 // 
    437 // 
    438 // 
    439 Function V_Trim1DData(folderStr,nEnd) 
    440         String folderStr 
    441         Variable nEnd 
    442  
    443         if(DataFolderExists("root:"+folderStr)  == 0) 
    444                 return(0) 
    445         endif 
    446                  
    447         SetDataFolder $("root:"+folderStr) 
    448          
    449         Wave qw = $(folderStr + "_q") 
    450         Wave iw = $(folderStr + "_i") 
    451         Wave sw = $(folderStr + "_s") 
    452         Wave res = $(folderStr + "_res") 
    453          
    454         variable num,ii 
    455          
    456         num=numpnts(qw) 
    457         //Break out resolution wave into separate waves 
    458         Make/O/D/N=(num) res0 = res[p][0]               // sigQ 
    459         Make/O/D/N=(num) res1 = res[p][1]               // qBar 
    460         Make/O/D/N=(num) res2 = res[p][2]               // fshad 
    461         Make/O/D/N=(num) res3 = res[p][3]               // qvals 
    462          
    463         // trim off the last nEnd points from everything 
    464         DeletePoints num-nEnd,nEnd, qw,iw,sw,res0,res1,res2,res3 
    465          
    466         // delete all points where the shadow is < 0.98 
    467         num=numpnts(qw) 
    468         for(ii=0;ii<num;ii+=1) 
    469                 if(res2[ii] < 0.98) 
    470                         DeletePoints ii,1, qw,iw,sw,res0,res1,res2,res3 
    471                         num -= 1 
    472                         ii -= 1 
    473                 endif 
    474         endfor 
    475          
    476 ////Put resolution contents back??? 
    477 //              reswave[][0] = res0[p] 
    478 //              reswave[][1] = res1[p] 
    479 //              reswave[][2] = res2[p] 
    480 //              reswave[][3] = res3[p] 
    481 //               
     590                                 
     591                DeletePoints 0,nBeg, q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b 
     592                DeletePoints 0,nBeg, i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b 
     593                DeletePoints 0,nBeg, s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b 
     594                //since each set may have a different number of points 
     595                npt = numpnts(q_fb)  
     596                DeletePoints npt-nEnd,nEnd, q_fb,i_fb,s_fb 
     597 
     598                npt = numpnts(q_ft)  
     599                DeletePoints npt-nEnd,nEnd, q_ft,i_ft,s_ft 
     600 
     601                npt = numpnts(q_fl)  
     602                DeletePoints npt-nEnd,nEnd, q_fl,i_fl,s_fl 
     603 
     604                npt = numpnts(q_fr)  
     605                DeletePoints npt-nEnd,nEnd, q_fr,i_fr,s_fr 
     606 
     607                npt = numpnts(q_mb)  
     608                DeletePoints npt-nEnd,nEnd, q_mb,i_mb,s_mb 
     609 
     610                npt = numpnts(q_mt)  
     611                DeletePoints npt-nEnd,nEnd, q_mt,i_mt,s_mt 
     612 
     613                npt = numpnts(q_ml)  
     614                DeletePoints npt-nEnd,nEnd, q_ml,i_ml,s_ml 
     615 
     616                npt = numpnts(q_mr)  
     617                DeletePoints npt-nEnd,nEnd, q_mr,i_mr,s_mr 
     618 
     619                npt = numpnts(q_b)  
     620                DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b 
     621                 
     622        endif 
    482623                         
    483624        SetDataFolder root: 
     
    489630// TODO: 
    490631// -- this is a temporary solution before a real writer is created 
    491 // -- resolution is not handled here (and it shouldn't be) since resolution is not known yet. 
     632// -- resolution is not generated here (and it shouldn't be) since resolution is not known yet. 
     633// -- but a real writer will need to be aware of resolution, and there may be different forms 
    492634// 
    493635// this will bypass save dialogs 
     
    571713        return(0) 
    572714End 
     715 
     716 
     717 
     718// TODO: 
     719// -- this is a temporary solution before a real writer is created 
     720// -- resolution is not generated here (and it shouldn't be) since resolution is not known yet. 
     721// -- but a real writer will need to be aware of resolution, and there may be different forms 
     722// 
     723// this will bypass save dialogs 
     724// -- AND WILL OVERWITE DATA WITH THE SAME NAME 
     725// 
     726Function V_Write1DData_NoConcat(folderStr,saveName,binType) 
     727        String folderStr,saveName 
     728        Variable binType 
     729         
     730        String formatStr="",fullpath="" 
     731        Variable refnum,dialog=1 
     732 
     733        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
     734 
     735 
     736        //TODO 
     737        //-- make sure the waves exist 
     738         
     739//      if(WaveExists(qw) == 0) 
     740//              Abort "q is missing" 
     741//      endif 
     742//      if(WaveExists(iw) == 0) 
     743//              Abort "i is missing" 
     744//      endif 
     745//      if(WaveExists(sw) == 0) 
     746//              Abort "s is missing" 
     747//      endif 
     748//      if(WaveExists(resw) == 0) 
     749//              Abort "Resolution information is missing." 
     750//      endif 
     751         
     752//      Duplicate/O qw qbar,sigQ,fs 
     753//      if(dimsize(resW,1) > 4) 
     754//              //it's USANS put -dQv back in the last 3 columns 
     755//              NVAR/Z dQv = USANS_dQv 
     756//              if(NVAR_Exists(dQv) == 0) 
     757//                      SetDataFolder root: 
     758//                      Abort "It's USANS data, and I don't know what the slit height is." 
     759//              endif 
     760//              sigQ = -dQv 
     761//              qbar = -dQv 
     762//              fs = -dQv 
     763//      else 
     764//              //it's SANS 
     765//              sigQ = resw[p][0] 
     766//              qbar = resw[p][1] 
     767//              fs = resw[p][2] 
     768//      endif 
     769//       
     770 
     771 
     772 
     773        // TODO: 
     774        // -- currently I'm using the Save comand and the /B flag 
     775        //    to save the data as Igor Text format, since otherwise the command string would be 
     776        //    too long. Need to come up with an Igor-demo friendly save here 
     777        // 
     778        // -- need a reader/plotter capable of handling this data. The regular data loader won't handle 
     779        //    all the different number of columns present, or the ITX format. See V_DataPlotting and duplicate these routines 
     780        //    Most of these routines take "winNameStr" as an argument, so I may be able to use them 
     781        // 
     782        // -- do I want to add the /O flag to force an overwrite if there is a name conflict? 
     783 
     784        PathInfo catPathName 
     785        fullPath = S_Path + saveName + ".itx" 
     786 
     787//      Open refnum as fullpath 
     788//      fprintf refnum,"Individual data sets written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
     789 
     790        String waveStr="" 
     791        // can be a multiple number of columns 
     792                 
     793        switch(binType) 
     794                case 1:         // 9 sets = 27 waves! 
     795                        waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
     796                        waveStr += "qBin_qxqy_ML;iBin_qxqy_ML;eBin_qxqy_ML;" 
     797                        waveStr += "qBin_qxqy_MR;iBin_qxqy_MR;eBin_qxqy_MR;" 
     798                        waveStr += "qBin_qxqy_MT;iBin_qxqy_MT;eBin_qxqy_MT;" 
     799                        waveStr += "qBin_qxqy_MB;iBin_qxqy_MB;eBin_qxqy_MB;" 
     800                        waveStr += "qBin_qxqy_FL;iBin_qxqy_FL;eBin_qxqy_FL;" 
     801                        waveStr += "qBin_qxqy_FR;iBin_qxqy_FR;eBin_qxqy_FR;" 
     802                        waveStr += "qBin_qxqy_FT;iBin_qxqy_FT;eBin_qxqy_FT;" 
     803                        waveStr += "qBin_qxqy_FB;iBin_qxqy_FB;eBin_qxqy_FB;" 
     804                         
     805                         
     806                        Save/T/M="\r\n"/B waveStr as fullPath 
     807 
     808                                                 
     809//                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
     810//                       
     811//                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     812//       
     813//                      wfprintf refnum,formatStr,qw,iw,sw 
     814                        break 
     815                case 2:         // 5 sets 
     816 
     817                        waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
     818                        waveStr += "qBin_qxqy_MLR;iBin_qxqy_MLR;eBin_qxqy_MLR;qBin_qxqy_MTB;iBin_qxqy_MTB;eBin_qxqy_MTB;" 
     819                        waveStr += "qBin_qxqy_FLR;iBin_qxqy_FLR;eBin_qxqy_FLR;qBin_qxqy_FTB;iBin_qxqy_FTB;eBin_qxqy_FTB;" 
     820 
     821                        Save/T/M="\r\n"/B waveStr as fullPath 
     822                         
     823//                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
     824//                       
     825//                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     826//       
     827//                      wfprintf refnum,formatStr,qw,iw,sw 
     828                        break 
     829                case 3:         // 3 sets 
     830//                      WAVE q1 = qBin_qxqy_B 
     831//                      WAVE i1 = iBin_qxqy_B 
     832//                      WAVE s1 = eBin_qxqy_B 
     833//                      WAVE q2 = qBin_qxqy_MLRTB 
     834//                      WAVE i2 = iBin_qxqy_MLRTB 
     835//                      WAVE s2 = eBin_qxqy_MLRTB 
     836//                      WAVE q3 = qBin_qxqy_FLRTB 
     837//                      WAVE i3 = iBin_qxqy_FLRTB 
     838//                      WAVE s3 = eBin_qxqy_FLRTB 
     839// 
     840//                               
     841//                      Save/T/M="\r\n" q1,i1,s1,q2,i2,s2,q3,i3,s3 as fullPath 
     842                         
     843                        waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
     844                        waveStr += "qBin_qxqy_MLRTB;iBin_qxqy_MLRTB;eBin_qxqy_MLRTB;qBin_qxqy_FLRTB;iBin_qxqy_FLRTB;eBin_qxqy_FLRTB;" 
     845 
     846                        Save/T/M="\r\n"/B waveStr as fullPath                    
     847                         
     848                         
     849//                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
     850//                       
     851//                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     852//       
     853//                      wfprintf refnum,formatStr,qw,iw,sw 
     854                        break 
     855                case 4:         // 9 sets 
     856                        waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
     857                        waveStr += "qBin_qxqy_ML;iBin_qxqy_ML;eBin_qxqy_ML;" 
     858                        waveStr += "qBin_qxqy_MR;iBin_qxqy_MR;eBin_qxqy_MR;" 
     859                        waveStr += "qBin_qxqy_MT;iBin_qxqy_MT;eBin_qxqy_MT;" 
     860                        waveStr += "qBin_qxqy_MB;iBin_qxqy_MB;eBin_qxqy_MB;" 
     861                        waveStr += "qBin_qxqy_FL;iBin_qxqy_FL;eBin_qxqy_FL;" 
     862                        waveStr += "qBin_qxqy_FR;iBin_qxqy_FR;eBin_qxqy_FR;" 
     863                        waveStr += "qBin_qxqy_FT;iBin_qxqy_FT;eBin_qxqy_FT;" 
     864                        waveStr += "qBin_qxqy_FB;iBin_qxqy_FB;eBin_qxqy_FB;" 
     865                         
     866                         
     867                        Save/T/M="\r\n"/B waveStr as fullPath 
     868 
     869//                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
     870//                       
     871//                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
     872//       
     873//                      wfprintf refnum,formatStr,qw,iw,sw 
     874                        break 
     875                                         
     876                default: 
     877                // do nothing, just close 
     878 
     879        endswitch 
     880 
     881//      Close refnum 
     882 
     883// TODO 
     884// -- clean up any waves on exit?        Only if I generate extra waves 
     885//      KillWaves/Z sigQ,qbar,fs 
     886         
     887        SetDataFolder root: 
     888        return(0) 
     889End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1035 r1036  
    44 
    55//************************ 
    6 //      Vers. 1.2 092101 
    7 // 
    8 //7/2001 converted protocols to simply use the filenames, rather than the path:filename 
    9 //this should allow portability of the protocols between machines 
    10 //**ALL** protocols now depend on the path "catPathName" 
    11 // 
    12 //procedure files for construction of protocols interactively, 
    13 //selecting files from the CAT/VSHORT table, rather than picking blindly 
    14 //from a dialog - the process of selecting/setting files is not as  
    15 //transparent as it could be for new users 
     6 
    167// 
    178//************************* 
     
    4435//              QDELTA=value            total width of annulus centered at QCENTER 
    4536//              PLOT=string             string from set {Yes,No} = truth of generating plot of averaged data 
    46 //              SAVE=string             string from set {Yes,No} = truth of saving averaged data to disk 
     37//              SAVE=string             string from set {Yes,No} = truth of saving averaged data to disk, now with "Concatenate"  or "Individual" 
    4738//              NAME=string             string from set {Auto,Manual} = Automatic name generation or Manual(dialog) 
    4839// 
    49 //    BINTYPE=string (VSANS binning type) "One;Two;Four;Slit Mode;", defined by ksBinTypeStr 
     40// 
     41//    BINTYPE=string (VSANS binning type) "One;Two;Four;Slit Mode;", as defined by ksBinTypeStr 
     42// 
    5043// 
    5144//              For work.DRK usage: 
    52 //              **the list is COMMA delimited, soparator is = 
     45//              **the list is COMMA delimited, separator is = 
    5346//              DRK=none,DRKMODE=0, 
    5447//              DRK=name                        is the name of the file, must be a full name, expected to be raw data 
     
    8982        String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK="ask" 
    9083        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="ask" 
    91         String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE="AVTYPE=Circular;SAVE=Yes;NAME=Auto;PLOT=Yes;" 
     84        String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE="AVTYPE=Circular;SAVE=Yes - Concatenate;NAME=Auto;PLOT=Yes;" 
    9285        String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK="DRK=none,DRKMODE=0," 
    9386         
     
    528521//              newList = list 
    529522//      endif 
     523 
     524 
     525Function/S V_GetSAMList() 
     526 
     527        String match="SAMPLE" 
     528        String list = V_getFileIntentList(match,0) 
     529 
     530//      Printf "SAM files = %s\r",list   
     531        return(list) 
     532end 
    530533 
    531534 
     
    739742 
    740743 
     744// 
     745Function/S V_PickEMPBeamButton(ctrlName) : ButtonControl 
     746        String ctrlName 
     747        String list="",item="",fname,newList,intent 
     748        Variable ii,num 
     749         
     750        PathInfo catPathName 
     751        String path = S_path 
     752 
     753        String match="EMPTY BEAM" 
     754 
     755// get the list from the file catalog (=0.0007s) 
     756//       
     757        WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames 
     758        WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent 
     759         
     760        Variable np = numpnts(intentW) 
     761        for(ii=0;ii<np;ii+=1) 
     762                if(cmpstr(intentW[ii],match)==0) 
     763                        list += fileNameW[ii] + ";" 
     764                endif            
     765        endfor 
     766         
     767        List = SortList(List,";",0) 
     768        Printf "EMP Beam files = %s\r",list      
     769 
     770 
     771 
     772         
     773        return(list) 
     774End 
     775 
    741776Function/S V_GetDIVList() 
    742777 
     
    10021037        Button button_quest,pos={20,2},size={150,20},proc=V_ProtocolQuestionnaire,title="Questions" 
    10031038        Button button_quest,help={"Run through the questionnaire for setting up a reduction protocol"} 
    1004          
     1039 
     1040        PopupMenu popup_sam,pos={85,28},size={51,23},proc=SAMFilePopMenuProc 
     1041        PopupMenu popup_sam,mode=1,value= #"V_getSAMList()"      
    10051042        PopupMenu popup_bkg,pos={85,76},size={51,23},proc=BKGFilePopMenuProc 
    10061043        PopupMenu popup_bkg,mode=1,value= #"V_getBGDList()" 
     
    11061143 
    11071144EndMacro 
     1145 
     1146Function SAMFilePopMenuProc(pa) : PopupMenuControl 
     1147        STRUCT WMPopupAction &pa 
     1148 
     1149        switch( pa.eventCode ) 
     1150                case 2: // mouse up 
     1151                        Variable popNum = pa.popNum 
     1152                        String popStr = pa.popStr 
     1153                        SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gSAM 
     1154                        tempStr = popStr 
     1155                        break 
     1156                case -1: // control being killed 
     1157                        break 
     1158        endswitch 
     1159 
     1160        return 0 
     1161End 
     1162 
    11081163 
    11091164Function BKGFilePopMenuProc(pa) : PopupMenuControl 
     
    12351290// TODO 
    12361291// -- this is a trimmed down version of the "full" set of averaging options 
    1237 //    add to this as needed to add in functionality 
     1292//    add to this as needed as I figure out what functionality is appropriate 
    12381293// 
    12391294//procedure called by protocol panel to ask user for average type choices 
     
    12501305// comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 
    12511306//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" 
    1252         Prompt autoSave,"Save files to disk?",popup,"Yes;No" 
     1307        Prompt autoSave,"Save files to disk?",popup,"Yes - Concatenate;Yes - Individual;No" 
    12531308        Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" 
    12541309//      Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" 
     
    18501905// x- this is no longer done after the COR step, and CAL is not produced as output of DIV        
    18511906// x- needs to be aware of the file name passed in 
    1852 // -- PromptForPath does not exist in VSANS. Need a better (automated) way to find the file. 
     1907// x- PromptForPath does not exist in VSANS. Need a better (automated) way to find the file. 
    18531908 
    18541909//check for work.div file (prot[2]) 
    18551910//load in if needed 
    1856 // no math is done here, DIV is applied as files are converted to WORK 
    1857 // no need to display DIV, or update any data display 
    1858 // 
    1859 //              DoAlert 0,"DIV step incomplete" 
     1911// no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) 
     1912// 
     1913        String divFileName = "" 
    18601914 
    18611915        If(cmpstr("none",prot[2])!=0)           // if !0, then there's a file requested 
     
    18631917                        //ask user for file 
    18641918//                       junkStr = PromptForPath("Select the detector sensitivity file") 
    1865                         junkStr="" 
    1866                         If(strlen(junkStr)==0) 
     1919                        Prompt divFileName,"DIV File",popup,V_PickDIVButton("") 
     1920                        DoPrompt "Select File",divFileName 
     1921 
     1922                        If(strlen(divFileName)==0) 
    18671923                                SetDataFolder root: 
    18681924                                Abort "No file selected, data reduction aborted" 
    18691925                        Endif 
    1870                         V_LoadHDF5Data(junkStr,"DIV") 
     1926                        V_LoadHDF5Data(divFileName,"DIV") 
    18711927                else 
    18721928                        //assume it's a path, and that the first (and only) item is the path:file 
     
    18791935 
    18801936 
    1881  
    1882  
    18831937// TODO: 
    1884 // -- currently does not allow adding RAW data files together 
     1938// -- currently does not allow adding RAW data files together, so no parsing is done 
    18851939//       
    1886  
     1940// 
    18871941        //prompt for sam data => read raw data, add to sam folder 
    18881942        //or parse file(s) from the input paramter string 
     
    19361990        While(0) 
    19371991        // TODO 
    1938         // -- this may not be the most reliable way to pas the file name 
     1992        // -- this may not be the most reliable way to pass the file name (for naming of the saved file later) 
    19391993        SVAR file_name = root:file_Name 
    1940         String sameFileLoaded = file_name               //keep a copy of the sample file loaded 
     1994        String samFileLoaded = file_name                //keep a copy of the sample file loaded 
    19411995         
    19421996        //always update 
     
    21282182// TODO: 
    21292183// -- calculation works, needs proper inputs (solid angle aware) 
    2130 // --   Open beam method is only a stub - fill in calculation in V_AskForAbsoluteParams_Quest() 
     2184// --   Open beam method needs to be verified in V_AskForAbsoluteParams_Quest() 
    21312185        Variable c2,c3,c4,c5,kappa_err 
    21322186        //do absolute scaling if desired 
    2133                 DoAlert 0,"Abs step incomplete" 
     2187//              DoAlert 0,"Abs step incomplete" 
    21342188 
    21352189        if(cmpstr("none",prot[4])!=0) 
     
    21662220 
    21672221// 
    2168 // TODO -- incomplete 
    2169 //              -- fill in the "ask" step 
     2222// TODO 
     2223//              x- fill in the "ask" step 
    21702224//  -- none is OK, except if the kill fails for any reason 
    2171 // -- the regular case of the file name specified by the protocol works correctly 
    2172 // -- don't create a null mask if not used, it will handle the error and print out that the mask is missing 
    2173  
    2174 //mask data if desired (this is done automatically in the average step) and is 
     2225// x- the regular case of the file name specified by the protocol works correctly 
     2226// x- don't create a null mask if not used, it will handle the error and print out that the mask is missing 
     2227 
     2228//mask data if desired (this is done automatically when the data is binned to I(q)) and is 
    21752229//not done explicitly here 
    21762230         
    21772231        //check for mask 
    2178         //add mask if needed 
    2179         // can't properly check the filename - so for now always add 
    21802232        //doesn't change the activeType 
     2233        String mskFileName="" 
     2234         
    21812235        if(cmpstr("none",prot[3])!=0) 
    21822236                If(cmpstr("ask",prot[3])==0) 
    21832237                        //get file from user 
    2184                         // TODO -- fill in the get file prompt, and handle the result 
    2185 //                      junkStr = PromptForPath("Select Mask file") 
    2186                         DoAlert 0,"Mask step incomplete" 
    2187  
    2188                         If(strlen(junkStr)==0) 
     2238                        // TODO 
     2239                        // x- fill in the get file prompt, and handle the result 
     2240                        Prompt mskFileName,"MASK File",popup,V_PickMASKButton("") 
     2241                        DoPrompt "Select File",mskFileName 
     2242//                      if (V_Flag) 
     2243//                              return 0                                                                        // user cancelled 
     2244//                      endif 
     2245 
     2246                        If(strlen(mskFileName)==0)              //use cancelled 
    21892247                                //if none desired, make sure that the old mask is deleted 
    2190                                 //junkStr = GetDataFolder(1) 
    2191                                 //SetDataFolder root:Packages:NIST:MSK 
    21922248                                KillDataFolder/Z root:Packages:NIST:VSANS:MSK: 
    21932249                                NewDataFolder/O root:Packages:NIST:VSANS:MSK 
    2194                                 //SetDataFolder junkStr 
     2250                                 
    21952251                                DoAlert 0,"No Mask file selected, data not masked" 
    21962252                        else 
    2197                                 //read in the file from the dialog 
    2198                                 V_LoadHDF5Data(junkStr,"MSK") 
     2253                                //read in the file from the selection 
     2254                                V_LoadHDF5Data(mskFileName,"MSK") 
    21992255                        Endif 
    22002256                else 
    22012257                        //just read it in from the protocol 
    22022258                        //list processing is necessary to remove any final comma 
    2203                         junkStr = pathStr + StringFromList(0, prot[3],"," ) 
    2204                         V_LoadHDF5Data(junkStr,"MSK") 
     2259                        mskFileName = pathStr + StringFromList(0, prot[3],"," ) 
     2260                        V_LoadHDF5Data(mskFileName,"MSK") 
    22052261                Endif 
     2262                 
    22062263        else 
    22072264                //if none desired, make sure that the old mask is deleted 
     
    22172274         
    22182275 
    2219  
    2220  
    2221  
    22222276        // average/save data as specified 
    2223          
    22242277        //Parse the keyword=<Value> string as needed, based on AVTYPE 
    22252278         
     
    22282281        If(cmpstr(av_type,"none") != 0) 
    22292282                If (cmpstr(av_type,"")==0)              //if the key could not be found... (if "ask" the string) 
    2230                         //get the averaging parameters from the user, as if the set button was hit 
    2231                         //in the panel 
     2283                        //get the averaging parameters from the user, as if the set button was hit in the panel 
    22322284                        V_SetAverageParamsButtonProc("dummy")           //from "ProtocolAsPanel" 
    22332285                        SVAR tempAveStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr 
     
    22442296 
    22452297        // bin and plot the data 
     2298         
    22462299        // TODO 
    2247         // x- currently this bins and plots based on the V_1D_Data panel, NOT the selections above 
    2248         // now takes the the binType from the protocol, and uses two steps to bin and average 
     2300// -- this switch does nothing -- fill it in 
     2301//       x- need to convert BINTYPE keyword into a numerical value to pass 
     2302// 
     2303 
    22492304        String binTypeStr = StringByKey("BINTYPE",prot[5],"=",";") 
    22502305        // plotting is not really necessary, and the graph may not be open - so skip for now? 
     
    22562311 
    22572312 
    2258  
    2259 // TODO 
    2260 // -- this switch does nothing -- fill it in 
    2261 //       -- need to convert BINTYPE keyword into a numerical value to pass 
    2262 //    ?? define a global string and use WhichListItem() to get a number back? 
    2263 // 
    2264          
    22652313        strswitch(av_type)      //dispatch to the proper routine to average to 1D data 
    22662314                case "none":             
     
    22962344        endswitch 
    22972345 
    2298 // TODO -- this call will bin the active type, then the next call bins the active type 
    2299 // -- then later, I dispatch to bin the active type...   
    2300 // -- !!!need to split out the panel draw and the binning calls from V_PlotData_Panel 
     2346// TODO 
     2347// x- this call will bin the active type, then the next call bins the active type 
     2348// x- then later, I dispatch to bin the active type...   
     2349// x- !!!need to split out the panel draw and the binning calls from V_PlotData_Panel 
    23012350// 
    23022351        V_PlotData_Panel()              //this brings the plot window to the front, or draws it (ONLY) 
     
    23082357// TODO 
    23092358// x- how do I get the sample file name? 
    2310 //     sameFileLoaded is the file name loaded (contains the extension) 
     2359//    local variable samFileLoaded is the file name loaded (contains the extension) 
    23112360//       
    23122361        //save data if desired 
    23132362        String fullpath = "", newfileName="" 
    2314         String item = StringByKey("SAVE",prot[5],"=",";")               //does user want to save data? 
    2315         If( (cmpstr(item,"Yes")==0) && (cmpstr(av_type,"none") != 0) )           
     2363        String saveType = StringByKey("SAVE",prot[5],"=",";")           //does user want to save data? 
     2364        If( (cmpstr(saveType[0,2],"Yes")==0) && (cmpstr(av_type,"none") != 0) )          
    23162365                //then save 
    2317                 newFileName = RemoveEnding(sameFileLoaded,".nxs.ngv") 
     2366                newFileName = RemoveEnding(samFileLoaded,".nxs.ngv") 
    23182367                 
    23192368                //pick ABS or AVE extension 
     
    23422391                // 
    23432392                Variable dialog = 0 
     2393 
     2394// TODO 
     2395// -- need to define nBeg and nEnd somewhere 
     2396// -- currently hard-wired 
     2397// --do I need to define these "per-panel"?              
     2398                Variable nBeg = 3, nEnd = 10 
     2399                 
    23442400                PathInfo/S catPathName 
    2345                 item = StringByKey("NAME",prot[5],"=",";")              //Auto or Manual naming 
     2401                String item = StringByKey("NAME",prot[5],"=",";")               //Auto or Manual naming 
    23462402                String autoname = StringByKey("AUTONAME",prot[5],"=",";")               //autoname -  will get empty string if not present 
    23472403                If((cmpstr(item,"Manual")==0) || (cmpstr(newFileName,"") == 0)) 
     
    23812437// TODO: 
    23822438// -- fill in all of the cases, default is only the "standard" I(q) 
    2383                                 V_ConcatenateForSave(activeType,binType) 
    2384                                 V_Write1DData(activeType,newFileName+"."+exten)         //don't pass the full path, just the name 
     2439 
     2440                                if(cmpstr(saveType,"Yes - Concatenate")==0) 
     2441                                        V_Trim1DData(activeType,binType,nBeg,nEnd) 
     2442                                        V_ConcatenateForSave(activeType,binType)                // this removes q=0 point, concatenates, sorts 
     2443                                        V_Write1DData(activeType,newFileName+"."+exten)         //don't pass the full path, just the name 
     2444                                else 
     2445                                        // remove the q=0 point from the back detector, if it's there 
     2446                                        // does not need to know binType 
     2447                                        // does not trim any of the data 
     2448                                        V_RemoveQ0_B(activeType) 
     2449                                        V_Write1DData_NoConcat(activeType,newFileName,binType) 
     2450                                endif 
    23852451 
    23862452                endswitch 
     
    23922458        Return(0) 
    23932459End 
     2460 
     2461 
     2462 
    23942463 
    23952464 
     
    24202489// TODO 
    24212490// -- fill in all of the functionality for calculation from direct beam 
     2491//  and verify that the calculations are numerically correct 
    24222492// 
    24232493//asks the user for absolute scaling information. the user can either 
    2424 //enter the 5 necessary values in manually (missing parameter dialog) 
     2494//enter the necessary values in manually (missing parameter dialog) 
    24252495//or the user can select an empty beam file from a standard open dialog 
    24262496//if an empty beam file is selected, the "kappa" value is automatically calculated 
     
    24402510                //empty beam flux file selected, prompt for file, and use this to calculate KAPPA 
    24412511                Variable kappa=1 
     2512                Variable kappa_err 
    24422513                         
    24432514                //get the necessary variables for the calculation of kappa 
    2444                 Variable detCnt,countTime,attenTrans,monCnt,sdd,pixel 
    2445                 String detStr 
    2446  
    2447                                  
    2448                 //lookup table for transmission factor 
    2449                 //determine which instrument the measurement was done on from acctStr 
    2450                 Variable lambda, attenNo,atten_err 
    2451                  
    2452                 //get the XY box, if needed 
    2453                 Variable x1,x2,y1,y2,ct_err 
    2454                 String filename,tempStr                 //02JUL13 
    2455  
    2456 //              err = GetXYBoxFromFile(tempName,x1,x2,y1,y2)            //xy's are passed/returned by reference 
    2457 //              Printf "Using Box X(%d,%d),Y(%d,%d)\r",x1,x2,y1,y2 
    2458  
    2459                  
     2515                Variable countTime,monCnt,sdd,pixel 
     2516                String detStr,junkStr,errStr 
     2517 
     2518                Variable empAttenFactor,        emp_atten_err 
     2519                 
     2520                //get the XY box and files 
     2521                Variable x1,x2,y1,y2,emptyCts,empty_ct_err 
     2522                String emptyFileName,tempStr,divFileName 
     2523                 
     2524                // TODO 
     2525                // x- need an empty beam file name 
     2526                // 
     2527                Prompt emptyFileName,"Empty Beam File",popup,V_PickEMPBeamButton("") 
     2528                DoPrompt "Select File",emptyFileName 
     2529                if (V_Flag) 
     2530                        return 0                                                                        // user canceled 
     2531                endif 
     2532 
    24602533                //need the detector sensitivity file - make a guess, allow to override 
    2461  
    2462  
    2463                 //toggle SANS_Data to linear display if needed, so that we're working with linear scaled data 
    2464 //              Wave divData = $"root:Packages:NIST:div:Data" 
    2465 //              Wave data = $"root:Packages:NIST:raw:data"              //this will be the linear data 
    2466                 // correct by detector sensitivity 
    2467 //              data /= divData 
    2468                  
    2469                 // now do the sum, only in the box       
    2470 //              detCnt = SumCountsInBox(x1,x2,y1,y2,ct_err,"RAW") 
    2471  
    2472                 //               
     2534                Prompt divFileName,"DIV File",popup,V_PickDIVButton("") 
     2535                DoPrompt "Select File",divFileName 
     2536                if (V_Flag) 
     2537                        return 0                                                                        // user canceled 
     2538                endif 
     2539                V_LoadHDF5Data(divFileName,"DIV") 
     2540 
     2541 
     2542                WAVE xyBoxW = V_getBoxCoordinates(emptyFileName) 
     2543                // TODO 
     2544                // -- need to get the panel string for the sum. 
     2545                // -- the detector string is currently hard-wired 
     2546                detStr = "B" 
     2547 
     2548                 
     2549                // load in the data, and use all of the corrections, especially DIV 
     2550                // (be sure the corrections are actually set to "on", don't assume that they are) 
     2551                // save preferences for file loading 
     2552                Variable savDivPref,savSAPref 
     2553                NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor 
     2554                savDivPref = gDoDIVCor 
     2555                NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor 
     2556                savSAPref = gDoSolidAngleCor 
     2557                 
     2558                // set local preferences 
     2559                gDoDIVCor = 1 
     2560                gDoSolidAngleCor = 1 
     2561                 
     2562                V_LoadAndPlotRAW_wName(emptyFileName) 
     2563                // convert raw->SAM 
     2564                V_Raw_to_work("SAM") 
     2565                V_UpdateDisplayInformation("SAM")        
     2566                 
     2567                // and determine box sum and error 
     2568                // store these locally 
     2569                emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"SAM",detStr) 
     2570 
     2571                Print "empty counts = ",emptyCts 
     2572                Print "empty err/counts = ",empty_ct_err/emptyCts 
     2573 
     2574                //              TODO 
     2575                // -- get all of the proper values for the calculation 
     2576                // -- verify the calculation (no solid angle needed) 
     2577                 
     2578                // get the attenuation factor for the empty beam 
     2579                empAttenFactor = V_getAttenuator_transmission(emptyFileName) 
     2580                emp_atten_err = V_getAttenuator_trans_err(emptyFileName) 
     2581                 
     2582                countTime = V_getCount_time(emptyFileName) 
     2583                 
     2584                // TODO 
     2585                // -- not sure if this is the correct monitor count to use, but I do know to use "SAM" 
     2586                //   rather than the file. 
     2587                monCnt = V_getBeamMonNormData("SAM") 
     2588                 
     2589                 
     2590                 
    24732591//              kappa = detCnt/countTime/attenTrans*1.0e8/(monCnt/countTime)*(pixel/sdd)^2 
    2474                  
    2475                 Variable kappa_err 
    2476 //              kappa_err = (ct_err/detCnt)^2 + (atten_err/attenTrans)^2 
    2477 //              kappa_err = sqrt(kappa_err) * kappa 
    2478                  
    2479                 // set the parameters in the global string 
    2480 //              Execute "V_AskForAbsoluteParams(1,1,"+junkStr+",1,"+errStr+")"          //no missing parameters, no dialog 
    2481                  
    2482                 //should wipe out the data in the RAW folder, since it's not really RAW now 
    2483 //              DoWindow/K SANS_Data 
    2484  
    2485                 // SRK JUL 2006 don't clear the contents - just kill the window to force new data to be loaded 
    2486                 // - obsucre bug if "ask" in ABS section of protocol clears RAW folder, then Q-axes can't be set from RAW:RealsRead 
    2487  
    2488                 Printf "Kappa was un-successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 
     2592                kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime) 
     2593                 
     2594                kappa_err = (empty_ct_err/emptyCts)^2 + (emp_atten_err/empAttenFactor)^2 
     2595                kappa_err = sqrt(kappa_err) * kappa 
     2596                 
     2597                // TODO 
     2598                // -- set the parameters in the global string 
     2599                junkStr = num2str(kappa) 
     2600                errStr = num2Str(kappa_err) 
     2601                Execute "V_AskForAbsoluteParams(1,1,"+junkStr+",1,"+errStr+")"          //no missing parameters, no dialog 
     2602                 
     2603 
     2604                Printf "Kappa was (maybe) successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 
     2605         
     2606                // restore preferences on exit 
     2607                gDoDIVCor = savDivPref 
     2608                gDoSolidAngleCor = savSAPref 
     2609 
    24892610        Endif 
    24902611         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Transmission.ipf

    r1033 r1036  
    3535        PopupMenu popup_2,mode=1,value= V_getFileIntentList("EMPTY BEAM",0) 
    3636        Button button_0,pos={22.00,397.00},size={100.00,20.00},proc=V_CalcTransmButtonProc,title="Calculate" 
    37         Button button_1,pos={23.00,491.00},size={100.00,20.00},proc=V_WriteTransmButtonProc,title="Write" 
     37//      Button button_1,pos={23.00,491.00},size={100.00,20.00},proc=V_WriteTransmButtonProc,title="Write" 
    3838        Button button_2,pos={349.00,13.00},size={30.00,20.00},proc=V_HelpTransmButtonProc,title="?" 
    3939        Button button_3,pos={410.00,13.00},size={50.00,20.00},proc=V_DoneTransmButtonProc,title="Done" 
     
    8484                        WAVE groupIDW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID 
    8585                        WAVE transmW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission 
    86                                  
     86                         
     87                        // TODO 
     88                        // I don't have a wave for the transmission error value, so it's not displayed here 
     89                        // -- do I read it in, or just ignore it...      
    8790                        np = numpnts(labelW)            //fileNameW is LONGER - so don't use numpnts(fileWave) 
    8891                        for(ii=0;ii<np;ii+=1) 
Note: See TracChangeset for help on using the changeset viewer.