Ignore:
Timestamp:
May 4, 2017 3:17:32 PM (5 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.