Changeset 497


Ignore:
Timestamp:
May 1, 2009 4:33:09 PM (13 years ago)
Author:
srkline
Message:

Added feature to re-save 1-d data from its data folder, presumably after someone has modified it by say, manually subtracting background or rescaling. (Danilo, ticket #156). There is now a SANS Models menu item for this, rather clumsily na,ed. Changes were put into WriteModelData_v40.ipf.

Currently only handles 6-column datasets. Logic for others would be straightforward if needed.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Analysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/SA_includes_v400.ipf

    r495 r497  
    3333        "Freeze Model" 
    3434        "Write Model Data" 
     35        "ReWrite Experimental Data",ReWrite1DData() 
    3536        "-" 
    3637        Submenu "Packages" 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/WriteModelData_v40.ipf

    r474 r497  
    101101End 
    102102 
     103 
     104///////////// 
     105Proc ReWrite1DData(folderStr,delim,term) 
     106        String folderStr,delim,term 
     107        Prompt folderStr,"Data Set",popup,W_DataSetPopupList() 
     108        Prompt delim,"delimeter",popup,"tab;space;" 
     109        Prompt term,"line termination",popup,"CR;LF;CRLF;" 
     110                 
     111        fReWrite1DData(folderStr,delim,term) 
     112         
     113End 
     114 
     115 
     116// always asks for a file name 
     117// - and right now, always expect 6-column data! 
     118Function fReWrite1DData(folderStr,delim,term) 
     119        String folderStr,delim,term 
     120         
     121        String formatStr="",fullpath="" 
     122        Variable refnum,dialog=1 
     123         
     124        //setup delimeter and terminator choices 
     125        If(cmpstr(delim,"tab")==0) 
     126                //tab-delimeted 
     127                formatStr="%15.4g\t%15.4g\t%15.4g\t%15.4g\t%15.4g\t%15.4g" 
     128        else 
     129                //use 3 spaces 
     130                formatStr="%15.4g   %15.4g   %15.4g   %15.4g   %15.4g   %15.4g" 
     131        Endif 
     132        If(cmpstr(term,"CR")==0) 
     133                formatStr += "\r" 
     134        Endif 
     135        If(cmpstr(term,"LF")==0) 
     136                formatStr += "\n" 
     137        Endif 
     138        If(cmpstr(term,"CRLF")==0) 
     139                formatStr += "\r\n" 
     140        Endif 
     141         
     142        //make sure the waves exist 
     143        SetDataFolder $("root:"+folderStr) 
     144        WAVE/Z qw = $(folderStr+"_q") 
     145        WAVE/Z iw = $(folderStr+"_i") 
     146        WAVE/Z sw = $(folderStr+"_s") 
     147        WAVE/Z resw = $(folderStr+"_res") 
     148         
     149        if(WaveExists(qw) == 0) 
     150                Abort "q is missing" 
     151        endif 
     152        if(WaveExists(iw) == 0) 
     153                Abort "i is missing" 
     154        endif 
     155        if(WaveExists(sw) == 0) 
     156                Abort "s is missing" 
     157        endif 
     158        if(WaveExists(resw) == 0) 
     159                Abort "Resolution information is missing." 
     160        endif 
     161         
     162        Duplicate/O qw qbar,sigQ,fs 
     163        sigQ = resw[p][0] 
     164        qbar = resw[p][1] 
     165        fs = resw[p][2] 
     166         
     167        if(dialog) 
     168                PathInfo/S catPathName 
     169                fullPath = DoSaveFileDialog("Save data as",fname=folderStr+".txt") 
     170                If(cmpstr(fullPath,"")==0) 
     171                        //user cancel, don't write out a file 
     172                        Close/A 
     173                        Abort "no data file was written" 
     174                Endif 
     175                //Print "dialog fullpath = ",fullpath 
     176        Endif 
     177         
     178        Open refnum as fullpath 
     179         
     180        fprintf refnum,"Modified data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
     181        wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
     182        Close refnum 
     183         
     184        KillWaves/Z sigQ,qbar,fs 
     185         
     186        SetDataFolder root: 
     187        return(0) 
     188End 
Note: See TracChangeset for help on using the changeset viewer.