source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_UtilityProcedures.ipf @ 935

Last change on this file since 935 was 935, checked in by srkline, 9 years ago

Adding a directory with the beginning procedures for "VCALC" -- the VSANS version of SASCALC.

Including the VSANS_Includes file is all that is needed - no other SANS procedures are used.

File size: 5.8 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4// a bunch of utility procedures to get information from the VCALC panel and to access
5// constants based in which of the detectors I'm trying to work with. Saves a lot of repetitive switches
6//
7// start the function names with VCALC_ to avoid the eventual conflicts with the file loading utilities
8// for reduction of real VSANS data
9
10
11///  Values from the VCALC panel
12
13
14// returns the nominal SDD from the panel -- value is METERS
15// Does NOT include the set back (offset) of the T/B panels. This is a separate value
16Function VCALC_getSDD(type)
17        String type
18       
19        Variable sdd
20       
21        strswitch(type)
22                case "FL":
23                case "FR":             
24                        ControlInfo/W=VCALC VCALCCtrl_2d
25                        SDD = V_Value
26                        break
27                case "FT":
28                case "FB":             
29                        ControlInfo/W=VCALC VCALCCtrl_2d
30                        SDD = V_Value   
31                        break
32
33                case "ML":
34                case "MR":             
35                        ControlInfo/W=VCALC VCALCCtrl_3d
36                        SDD = V_Value
37                        break
38                case "MT":
39                case "MB":
40                        ControlInfo/W=VCALC VCALCCtrl_3d
41                        SDD = V_Value
42                        break   
43                                               
44                case "B":               
45                        ControlInfo/W=VCALC VCALCCtrl_4b
46                        SDD = V_Value
47                        break
48                       
49                default:
50                        Print "Error -- type not found in        V_getSDD(type)"                                       
51                        sdd = NaN               //no match for type             
52        endswitch
53       
54        return(sdd)
55end
56
57// returns the panel separation [mm]
58Function VCALC_getPanelSeparation(type)
59        String type
60       
61        Variable sep
62       
63        strswitch(type)
64                case "FL":
65                case "FR":
66                case "FLR":             
67                        ControlInfo/W=VCALC VCALCCtrl_2a
68                        sep = V_Value
69                        break
70                case "FT":
71                case "FB":
72                case "FTB":             
73                        ControlInfo/W=VCALC VCALCCtrl_2b
74                        sep = V_Value   
75                        break
76
77                case "ML":
78                case "MR":
79                case "MLR":             
80                        ControlInfo/W=VCALC VCALCCtrl_3a
81                        sep = V_Value
82                        break
83                case "MT":
84                case "MB":
85                case "MTB":
86                        ControlInfo/W=VCALC VCALCCtrl_3b
87                        sep = V_Value
88                        break   
89                                               
90                case "B":               
91                        sep = 0
92                        break
93                       
94                default:
95                        Print "Error -- type not found in        VCALC_getPanelSeparation(type)"                                       
96                        sep = NaN               //no match for type             
97        endswitch
98       
99        return(sep)
100end
101
102// returns the lateral panel offset [mm]
103Function VCALC_getLateralOffset(type)
104        String type
105       
106        Variable offset
107       
108        strswitch(type)
109                case "FL":
110                case "FR":
111                case "FLR":
112                case "FT":
113                case "FB":
114                case "FTB":             
115                        ControlInfo/W=VCALC VCALCCtrl_2c
116                        offset = V_Value       
117                        break
118
119                case "ML":
120                case "MR":
121                case "MLR":
122                case "MT":
123                case "MB":
124                case "MTB":
125                        ControlInfo/W=VCALC VCALCCtrl_3c
126                        offset = V_Value
127                        break   
128                                               
129                case "B":               
130                        ControlInfo/W=VCALC VCALCCtrl_4a
131                        offset = V_Value
132                        break
133                       
134                default:
135                        Print "Error -- type not found in        VCALC_getLateralOffset(type)"                                 
136                        offset = NaN            //no match for type             
137        endswitch
138       
139        return(offset)
140end
141
142// returns the (mean) wavelength from the panel -- value is angstroms
143Function VCALC_getWavelength()
144       
145        ControlInfo/W=VCALC VCALCCtrl_0b
146
147        return(V_Value)
148end
149
150// returns the number of neutrons on the sample
151Function VCALC_getImon()
152       
153        ControlInfo/W=VCALC VCALCCtrl_5a
154
155        return(V_Value)
156end
157
158// returns the model function to use
159Function/S VCALC_getModelFunctionStr()
160       
161        ControlInfo/W=VCALC VCALCCtrl_5b
162
163        return(S_Value)
164end
165
166
167
168/// NVARs set in VCALC space (not necessarily matching the true instrument values)
169// -- these all set to the proper data folder, then BACK TO ROOT:
170
171
172// return the pixel X size, in [cm]
173Function VCALC_getPixSizeX(type)
174        String type
175
176        SetDataFolder root:Packages:NIST:VSANS:VCALC
177                       
178        strswitch(type)
179                case "FL":
180                        NVAR pixSizeX = front_L_pixelX
181                        break
182                case "FR":             
183                        NVAR pixSizeX = front_R_pixelX
184                        break
185                case "FT":
186                        NVAR pixSizeX = front_T_pixelX
187                        break   
188                case "FB":             
189                        NVAR pixSizeX = front_B_pixelX
190                        break
191                       
192                case "ML":
193                        NVAR pixSizeX = middle_L_pixelX
194                        break
195                case "MR":             
196                        NVAR pixSizeX = middle_R_pixelX
197                        break
198                case "MT":
199                        NVAR pixSizeX = middle_T_pixelX
200                        break   
201                case "MB":             
202                        NVAR pixSizeX = middle_B_pixelX
203                        break
204                                               
205                case "B":               
206                        NVAR pixSizeX = Back_pixelX
207                        break
208                       
209                default:                                                       
210                        Print "Detector type mismatch in        V_getPixSizeX(type)"
211                        return(NaN)
212        endswitch
213
214        setDataFolder root:
215               
216        return(pixSizeX)
217end
218
219// return the pixel Y size, in [cm]
220Function VCALC_getPixSizeY(type)
221        String type
222
223        SetDataFolder root:Packages:NIST:VSANS:VCALC
224                       
225        strswitch(type)
226                case "FL":
227                        NVAR pixSizeY = front_L_pixelY
228                        break
229                case "FR":             
230                        NVAR pixSizeY = front_R_pixelY
231                        break
232                case "FT":
233                        NVAR pixSizeY = front_T_pixelY
234                        break   
235                case "FB":             
236                        NVAR pixSizeY = front_B_pixelY
237                        break
238                       
239                case "ML":
240                        NVAR pixSizeY = middle_L_pixelY
241                        break
242                case "MR":             
243                        NVAR pixSizeY = middle_R_pixelY
244                        break
245                case "MT":
246                        NVAR pixSizeY = middle_T_pixelY
247                        break   
248                case "MB":             
249                        NVAR pixSizeY = middle_B_pixelY
250                        break
251                                               
252                case "B":               
253                        NVAR pixSizeY = Back_pixelY
254                        break
255                       
256                default:                                                       
257                        Print "Detector type mismatch in        V_getPixSizeY(type)"
258                        return(NaN)
259        endswitch
260
261        setDatafolder root:
262               
263        return(pixSizeY)
264end
265
266// SDD offset of the top/bottom panels
267// value returned is in mm (so beware)
268//
269Function VSANS_getTopBottomSDDOffset(type)
270        String type
271
272        SetDataFolder root:Packages:NIST:VSANS:VCALC
273       
274        strswitch(type)
275                case "FL":
276                case "FR":
277                        return(0)               
278                        break           //already zero, do nothing
279                case "FT":
280                case "FB":             
281                        NVAR sdd_offset = front_SDDOffset       //T/B are 300 mm farther back
282                        break
283                       
284                case "ML":
285                case "MR":
286                        return(0)
287                        break           //already zero, do nothing
288                case "MT":
289                case "MB":
290                        NVAR sdd_offset = Middle_SDDOffset      //T/B are 30 cm farther back
291                        break   
292                                               
293                case "B":
294                        return(0)
295                        break           //already zero, do nothing
296                       
297                default:
298                        Print "Error -- type not found in        VSANS_getTopBottomSDDOffset(type)"                                     
299                        sdd_offset = NaN                //no match for type             
300        endswitch
301
302        SetDataFolder root:
303               
304        return(sdd_offset)     
305End
306
307
308/////////// procedure to concatenate I(q) files into a single file
309//
310// currently, no rescaling is done, just simple concatentate and sort
311//
Note: See TracBrowser for help on using the repository browser.