1
2 """
3 Data file reader for NCNR NG-7 data.
4
5 """
6
7 import os, numpy
8 from reflectometry.reduction import icpformat
9 from reflectometry.reduction import refldata
10 from reflectometry.reduction import properties
11
12
13
14
15
16
17
18
19
20
21 default = properties.DatedValues()
22 default.wavelength = (4.76,'')
23
24
25
26 default.saturation = (numpy.array([[1,15000,0]]),'')
27
28
29
30 default.detector_distance = (2000., '')
31 default.psd_width = (100, '')
32 default.slit1_distance = (-75*25.4, '')
33 default.slit2_distance = (-14*25.4, '')
34 default.slit3_distance = (9*25.4, '')
35 default.slit4_distance = (42*25.4, '')
36
37
38 saturation = """
39 304 1.0 ;
40 1788 1.0074;
41 6812 1.0672;
42 13536 1.1399;
43 19426 1.2151;
44 24022 1.2944;
45 27771 1.370 ;
46 31174 1.429
47 """
48 C = numpy.matrix(saturation).A
49 C[1,:] = 1/C[1,:]
50 default.pencil_saturation = (C, '')
51
52
53 default.pencil_length = (25.4*6,'')
54 default.pencil_width = (25.4*1,'')
55
56
57 default.psd_saturation = (numpy.array([1,8000],'f'),'')
58 default.psd_minbin = (9,'')
59 default.psd_maxbin = (246,'')
60 default.psd_width = (100,'')
61 default.psd_pixels = (256,'')
62 default.monitor_timestep = (60./100,'')
63
64
65
66 -class NG7Icp(refldata.ReflData):
67
68 probe = "neutron"
69 format = "NCNR ICP"
70 instrument = "NCNR NG-7"
71
72
73
74
75 _wavelength_override = {}
116
117
119 """
120 Pencil detector on NG-7.
121 """
122 self.detector.saturation = self.default.pencil_saturation
123 self.detector.width_x = self.default.pencil_length
124 self.detector.width_y = self.default.pencil_width
125 self.detector.center_x = 0
126 self.detector.center_y = 0
127 self.detector.rotation = 0
128
130 """
131 PSD on NG-7.
132 """
133 self.detector.saturation = self.default.psd_saturation
134 width = self.default.psd_width
135 minbin,maxbin = self.default.psd_minbin,self.default.psd_maxbin
136 pixels = self.default.psd_pixels
137 self.detector.width_x = numpy.ones(pixels,'f')*(width/(maxbin-minbin))
138 self.detector.center_x = 0
139 self.detector.width_y = self.default.psd_height
140
144
146 data = icpformat.read(self.path)
147 self.detector.wavelength \
148 = data.check_wavelength(self.default.wavelength,
149 NG7Icp._wavelength_override)
150
151 if 'qz' in data:
152
153 monitor, prefactor = data.monitor,data.prefactor
154 Mon1, Exp = data.Mon1,data.Exp
155 Qz = data.column.qz
156 automonitor = prefactor*(monitor + Mon1 * abs(Qz)**Exp)
157 if data.count_type == 'NEUT':
158 self.monitor.counts = automonitor
159 elif data.count_type == 'TIME':
160 self.monitor.count_time = automonitor
161 else:
162 raise ValueError, "Expected count type 'NEUT' or 'TIME' in "+self.path
163
164 if 'monitor' in data:
165 self.monitor.counts = data.column.monitor
166 if 'time' in data:
167 self.monitor.count_time = data.column.time*60
168
169 self.monitor.base = 'counts' if self.monitor.counts is not None else 'time'
170
171 if 's1' in data: self.slit1.x = data.column.s1
172 if 's2' in data: self.slit2.x = data.column.s2
173 if 's3' in data: self.slit3.x = data.column.s3
174 if 's4' in data: self.slit4.x = data.column.s4
175 if 'qz' in data:
176 Qx = data.column.qx if 'qx' in data else 0
177 Qz = data.column.qz
178 A,B = refldata.QxQzL_to_AB(Qx,Qz,self.detector.wavelength)
179 self.sample.angle_x,self.detector.angle_x = A,B
180
181
182 self.resetQ()
183
184
185 self.detector.counts = data.counts
186