source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/WriteModelData_v40.ipf @ 472

Last change on this file since 472 was 472, checked in by srkline, 14 years ago

A large number of changes and fixes:

--168/169/170: panels and windows are now at least on-screen for all packages. Tested
with 1024x768 resolution.
-- closed ticket 176 which was a question about resampling data to generate error estimates
on fitted parameters. Useful for reflectometry, not needed for SANS.
--157: bug of low Q power law extrapolation in Invariant fixed by avoiding q==0
--178/180: Tr/Tw? notification in USANS. log/lin checkbox for display.
--167: saveData checkbox for USANS not behaving well. turns off/on better now.
--197: changed all (?) 1D writing routines to enforce 26 characters as the maximum length
to make sure that file loading will never exceed 31 characters

-- lots of changes to MonteCarlo? and SASCALC

  • SASCALC now enforces *exact* lens conditions, rather than a close approximation
  • improved MonteCarlo? interface panel
  • added writer for simlulated VAX binary data file
  • can save 2D as ABS or raw counts
  • can freeze w/no offset
File size: 2.2 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion = 6.0
3
4Proc WriteModelData(xwave,ywave,delim,term)
5        String xwave,ywave,delim,term
6        Prompt xwave,"X data",popup,PossibleModelWaves("x*")
7        Prompt ywave,"Y data",popup,PossibleModelWaves("y*")
8        Prompt delim,"delimeter",popup,"tab;space;"
9        Prompt term,"line termination",popup,"CR;LF;CRLF;"
10       
11        //Print xwave, ywave, delim, term
12       
13        fWriteModelData($xwave,$ywave,delim,term)
14       
15End
16
17Function/S PossibleModelWaves(filterStr)
18        String filterStr
19       
20        String list,tmplist,DF,newList=""
21        Variable ii,num
22       
23        //waves in root
24        list = WaveList(filterStr,";","")
25       
26        //add possble smeared models that are housed in data folders
27        ControlInfo/W=WrapperPanel popup_0
28        if(V_flag==0 || cmpstr(S_Value,"No data loaded")==0)
29                return(list)
30        else
31                DF="root:"+S_Value
32                SetDataFolder $DF
33                if(cmpstr(filterStr,"x*")==0)
34                        tmplist = WaveList("*_q",";","")
35                        tmpList += WaveList("GFitX_*",";","")
36                else
37                        tmplist = WaveList("smea*",";","")
38                        tmpList += WaveList("GFit_*",";","")
39                endif
40                //prepend these list items with the folder
41                num=itemsinlist(tmplist)
42                if(num > 0)
43                        ii=0
44                        do
45                                newList += DF+":"+StringFromList(ii, tmpList, ";") + ";"
46                                ii+=1
47                        while(ii<num)
48                       
49                        //then add to the list
50                        list += newList
51                endif
52        endif
53       
54        SetDataFolder root:
55        return(list)
56end
57
58// always asks for a file name
59Function fWriteModelData(xwave,ywave,delim,term)
60        Wave xwave,ywave
61        String delim,term
62       
63        String formatStr="",fullpath=""
64        Variable refnum,dialog=1
65       
66        //setup delimeter and terminator choices
67        If(cmpstr(delim,"tab")==0)
68                //tab-delimeted
69                formatStr="%15.4g\t%15.4g"
70        else
71                //use 3 spaces
72                formatStr="%15.4g   %15.4g"
73        Endif
74        If(cmpstr(term,"CR")==0)
75                formatStr += "\r"
76        Endif
77        If(cmpstr(term,"LF")==0)
78                formatStr += "\n"
79        Endif
80        If(cmpstr(term,"CRLF")==0)
81                formatStr += "\r\n"
82        Endif
83       
84        if(dialog)
85                PathInfo/S catPathName
86                fullPath = DoSaveFileDialog("Save data as",fname=NameofWave(ywave)+".txt")
87                If(cmpstr(fullPath,"")==0)
88                        //user cancel, don't write out a file
89                        Close/A
90                        Abort "no data file was written"
91                Endif
92                //Print "dialog fullpath = ",fullpath
93        Endif
94       
95        Open refnum as fullpath
96       
97        fprintf refnum,"Model data created %s\r\n",(date()+" "+time())
98        wfprintf refnum,formatStr,xwave,ywave
99        Close refnum
100        return(0)
101End
Note: See TracBrowser for help on using the repository browser.