1 | """ |
---|
2 | Information relating to the CanSAS data format. These constants are used in |
---|
3 | the cansas_reader.py file to read in any version of the cansas format. |
---|
4 | """ |
---|
5 | class cansasConstants: |
---|
6 | |
---|
7 | ns = '' |
---|
8 | format = '' |
---|
9 | |
---|
10 | |
---|
11 | def __init__(self): |
---|
12 | self.ns = self.CANSAS_NS |
---|
13 | self.format = self.CANSAS_FORMAT |
---|
14 | |
---|
15 | |
---|
16 | def _iterate_namespace(self, namespace): |
---|
17 | """ |
---|
18 | Method to iterate through a cansas constants tree based on a list of |
---|
19 | names |
---|
20 | |
---|
21 | :param namespace: A list of names that match the tree structure of |
---|
22 | cansas_constants |
---|
23 | """ |
---|
24 | # The current level to look through in cansas_constants. |
---|
25 | return_me = currentLevel() |
---|
26 | return_me.current_level = self.CANSAS_FORMAT.get("SASentry") |
---|
27 | # Defaults for variable and datatype |
---|
28 | return_me.ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\"" |
---|
29 | return_me.ns_datatype = "content" |
---|
30 | return_me.ns_optional = True |
---|
31 | for name in namespace: |
---|
32 | if name != "SASentry": |
---|
33 | return_me.current_level = \ |
---|
34 | return_me.current_level.get("children").get(name, "") |
---|
35 | if return_me.current_level == "": |
---|
36 | return_me.current_level = \ |
---|
37 | return_me.current_level.get("<any>", "") |
---|
38 | cl_variable = return_me.current_level.get("variable", "") |
---|
39 | cl_datatype = return_me.current_level.get("storeas", "") |
---|
40 | cl_units_optional = \ |
---|
41 | return_me.current_level.get("units_required", "") |
---|
42 | # Where are how to store the variable for the given namespace |
---|
43 | # CANSAS_CONSTANTS tree is hierarchical, so is no value, inherit |
---|
44 | return_me.ns_variable = cl_variable if cl_variable != "" else \ |
---|
45 | return_me.ns_variable |
---|
46 | return_me.ns_datatype = cl_datatype if cl_datatype != "" else \ |
---|
47 | return_me.ns_datatype |
---|
48 | return_me.ns_optional = cl_units_optional if \ |
---|
49 | cl_units_optional != return_me.ns_optional \ |
---|
50 | else return_me.ns_optional |
---|
51 | return return_me |
---|
52 | |
---|
53 | |
---|
54 | """ |
---|
55 | CANSAS_NS holds the base namespace and the default schema file information |
---|
56 | """ |
---|
57 | CANSAS_NS = { |
---|
58 | "1.0" : { |
---|
59 | "ns" : "cansas1d/1.0", |
---|
60 | "schema" : "cansas1d_v1_0.xsd" |
---|
61 | }, |
---|
62 | "1.1" : { |
---|
63 | "ns" : "urn:cansas1d:1.1", |
---|
64 | "schema" : "cansas1d_v1_1.xsd" |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | """ |
---|
70 | The constants below hold information on where to store the CanSAS data when |
---|
71 | loaded in using sasview |
---|
72 | """ |
---|
73 | META_DATA = "{0}.meta_data[\"{2}\"] = \"{1}\"" |
---|
74 | ANY = { |
---|
75 | "variable" : "{0}.meta_data[\"{2}\"] = \'{1}\'", |
---|
76 | "storeas" : "content", |
---|
77 | } |
---|
78 | TITLE = {"variable" : "{0}.title = \"{1}\""} |
---|
79 | SASNOTE = {"variable" : "{0}.notes.append(\'{1}\')"} |
---|
80 | SASPROCESS_TERM = { |
---|
81 | "variable" : None, |
---|
82 | "attributes" : { |
---|
83 | "unit" : {"variable" : None}, |
---|
84 | "name" : {"variable" : None} |
---|
85 | } |
---|
86 | } |
---|
87 | SASPROCESS_SASPROCESSNOTE = { |
---|
88 | "variable" : None, |
---|
89 | "children" : {"<any>" : ANY} |
---|
90 | } |
---|
91 | SASPROCESS = { |
---|
92 | "variable" : None, |
---|
93 | "children" : { |
---|
94 | "name" : {"variable" : "{0}.name = \'{1}\'"}, |
---|
95 | "date" : {"variable" : "{0}.date = \'{1}\'"}, |
---|
96 | "description" : {"variable" : \ |
---|
97 | "{0}.description = \'{1}\'"}, |
---|
98 | "term" : SASPROCESS_TERM, |
---|
99 | "SASprocessnote" : SASPROCESS_SASPROCESSNOTE, |
---|
100 | "<any>" : ANY |
---|
101 | }, |
---|
102 | } |
---|
103 | RUN = { |
---|
104 | "variable" : "{0}.run.append(\"{1}\")", |
---|
105 | "attributes" : {"name" : {"variable" : \ |
---|
106 | "{0}.run_name[node_value] = \"{1}\""}} |
---|
107 | } |
---|
108 | SASDATA_IDATA_Q = { |
---|
109 | "variable" : "{0}.x = numpy.append({0}.x, {1})", |
---|
110 | "unit" : "x_unit", |
---|
111 | "attributes" : { |
---|
112 | "unit" : { |
---|
113 | "variable" : \ |
---|
114 | "{0}._xunit = \"{1}\"", |
---|
115 | "storeas" : "content" |
---|
116 | } |
---|
117 | } |
---|
118 | } |
---|
119 | SASDATA_IDATA_I = { |
---|
120 | "variable" : "{0}.y = numpy.append({0}.y, {1})", |
---|
121 | "unit" : "y_unit", |
---|
122 | "attributes" : { |
---|
123 | "unit" : { |
---|
124 | "variable" : \ |
---|
125 | "{0}._yunit = \"{1}\"", |
---|
126 | "storeas" : "content" |
---|
127 | } |
---|
128 | } |
---|
129 | } |
---|
130 | SASDATA_IDATA_IDEV = { |
---|
131 | "variable" : \ |
---|
132 | "{0}.dy = numpy.append({0}.dy, {1})", |
---|
133 | "unit" : "y_unit", |
---|
134 | "attributes" : { |
---|
135 | "unit" : { |
---|
136 | "variable" : META_DATA, |
---|
137 | "storeas" : "content" |
---|
138 | } |
---|
139 | }, |
---|
140 | } |
---|
141 | SASDATA_IDATA_QDEV = { |
---|
142 | "variable" : \ |
---|
143 | "{0}.dx = numpy.append({0}.dx, {1})", |
---|
144 | "unit" : "x_unit", |
---|
145 | "attributes" : { |
---|
146 | "unit" : { |
---|
147 | "variable" : META_DATA, |
---|
148 | "storeas" : "content" |
---|
149 | } |
---|
150 | }, |
---|
151 | } |
---|
152 | SASDATA_IDATA_DQL = { |
---|
153 | "variable" : \ |
---|
154 | "{0}.dxl = numpy.append({0}.dxl, {1})", |
---|
155 | "unit" : "x_unit", |
---|
156 | "attributes" : { |
---|
157 | "unit" : { |
---|
158 | "variable" : META_DATA, |
---|
159 | "storeas" : "content" |
---|
160 | } |
---|
161 | }, |
---|
162 | } |
---|
163 | SASDATA_IDATA_DQW = { |
---|
164 | "variable" : \ |
---|
165 | "{0}.dxw = numpy.append({0}.dxw, {1})", |
---|
166 | "unit" : "x_unit", |
---|
167 | "attributes" : { |
---|
168 | "unit" : { |
---|
169 | "variable" : META_DATA, |
---|
170 | "storeas" : "content" |
---|
171 | } |
---|
172 | }, |
---|
173 | } |
---|
174 | SASDATA_IDATA_QMEAN = { |
---|
175 | "storeas" : "content", |
---|
176 | "unit" : "x_unit", |
---|
177 | "variable" : META_DATA, |
---|
178 | "attributes" : {"unit" : {"variable" : META_DATA}}, |
---|
179 | } |
---|
180 | SASDATA_IDATA_SHADOWFACTOR = { |
---|
181 | "variable" : META_DATA, |
---|
182 | "storeas" : "content", |
---|
183 | } |
---|
184 | SASDATA_IDATA = { |
---|
185 | "storeas" : "float", |
---|
186 | "units_optional" : False, |
---|
187 | "variable" : None, |
---|
188 | "attributes" : { |
---|
189 | "name" : { |
---|
190 | "variable" : META_DATA, |
---|
191 | "storeas" : "content", |
---|
192 | }, |
---|
193 | "timestamp" : { |
---|
194 | "variable" : META_DATA, |
---|
195 | "storeas" : "content", |
---|
196 | } |
---|
197 | }, |
---|
198 | "children" : { |
---|
199 | "Q" : SASDATA_IDATA_Q, |
---|
200 | "I" : SASDATA_IDATA_I, |
---|
201 | "Idev" : SASDATA_IDATA_IDEV, |
---|
202 | "Qdev" : SASDATA_IDATA_QDEV, |
---|
203 | "dQw" : SASDATA_IDATA_DQW, |
---|
204 | "dQl" : SASDATA_IDATA_DQL, |
---|
205 | "Qmean" : SASDATA_IDATA_QMEAN, |
---|
206 | "Shadowfactor" : SASDATA_IDATA_SHADOWFACTOR, |
---|
207 | "<any>" : ANY |
---|
208 | } |
---|
209 | } |
---|
210 | SASDATA = { |
---|
211 | "attributes" : {"name" : {"variable" : META_DATA,}}, |
---|
212 | "variable" : None, |
---|
213 | "children" : { |
---|
214 | "Idata" : SASDATA_IDATA, |
---|
215 | "<any>" : ANY |
---|
216 | } |
---|
217 | } |
---|
218 | SASTRANSSPEC_TDATA_LAMDBA = { |
---|
219 | "variable" : "{0}.wavelength.append({1})", |
---|
220 | "unit" : "wavelength_unit", |
---|
221 | "attributes" : { |
---|
222 | "unit" : { |
---|
223 | "variable" : "{0}.wavelength_unit = \"{1}\"", |
---|
224 | "storeas" : "content" |
---|
225 | } |
---|
226 | } |
---|
227 | } |
---|
228 | SASTRANSSPEC_TDATA_T = { |
---|
229 | "variable" : "{0}.transmission.append({1})", |
---|
230 | "unit" : "transmission_unit", |
---|
231 | "attributes" : { |
---|
232 | "unit" : { |
---|
233 | "variable" : "{0}.transmission_unit = \"{1}\"", |
---|
234 | "storeas" : "content" |
---|
235 | } |
---|
236 | } |
---|
237 | } |
---|
238 | SASTRANSSPEC_TDATA_TDEV = { |
---|
239 | "variable" : \ |
---|
240 | "{0}.transmission_deviation.append({1})", |
---|
241 | "unit" : "transmission_deviation_unit", |
---|
242 | "attributes" : { |
---|
243 | "unit" : { |
---|
244 | "variable" : "{0}.transmission_deviation_unit = \"{1}\"", |
---|
245 | "storeas" : "content" |
---|
246 | } |
---|
247 | } |
---|
248 | } |
---|
249 | SASTRANSSPEC_TDATA = { |
---|
250 | "storeas" : "float", |
---|
251 | "variable" : None, |
---|
252 | "children" : { |
---|
253 | "Lambda" : SASTRANSSPEC_TDATA_LAMDBA, |
---|
254 | "T" : SASTRANSSPEC_TDATA_T, |
---|
255 | "Tdev" : SASTRANSSPEC_TDATA_TDEV, |
---|
256 | "<any>" : ANY, |
---|
257 | } |
---|
258 | } |
---|
259 | SASTRANSSPEC = { |
---|
260 | "variable" : None, |
---|
261 | "children" : { |
---|
262 | "Tdata" : SASTRANSSPEC_TDATA, |
---|
263 | "<any>" : ANY, |
---|
264 | }, |
---|
265 | "attributes" : {"name" : {"variable" : \ |
---|
266 | "{0}.name = \"{1}\""}, |
---|
267 | "timestamp" : {"variable" : \ |
---|
268 | "{0}.timestamp = \"{1}\""}, |
---|
269 | } |
---|
270 | } |
---|
271 | SASSAMPLE_THICK = { |
---|
272 | "variable" : "{0}.sample.thickness = {1}", |
---|
273 | "unit" : "sample.thickness_unit", |
---|
274 | "storeas" : "float", |
---|
275 | "attributes" : { |
---|
276 | "units" : { |
---|
277 | "variable" : "{0}.sample.thickness_unit = \"{1}\"", |
---|
278 | "storeas" : "content" |
---|
279 | } |
---|
280 | }, |
---|
281 | } |
---|
282 | SASSAMPLE_TRANS = { |
---|
283 | "variable" : "{0}.sample.transmission = {1}", |
---|
284 | "storeas" : "float", |
---|
285 | } |
---|
286 | SASSAMPLE_TEMP = { |
---|
287 | "variable" : "{0}.sample.temperature = {1}", |
---|
288 | "unit" : "sample.temperature_unit", |
---|
289 | "storeas" : "float", |
---|
290 | "attributes" : { |
---|
291 | "units" : { |
---|
292 | "variable" : "{0}.sample.temperature_unit = \"{1}\"", |
---|
293 | "storeas" : "content" |
---|
294 | } |
---|
295 | }, |
---|
296 | } |
---|
297 | SASSAMPLE_POS_ATTR = { |
---|
298 | "units" : { |
---|
299 | "variable" : \ |
---|
300 | "{0}.sample.position_unit = \"{1}\"", |
---|
301 | "storeas" : "content" |
---|
302 | } |
---|
303 | } |
---|
304 | SASSAMPLE_POS_X = { |
---|
305 | "variable" : "{0}.sample.position.x = {1}", |
---|
306 | "unit" : "sample.position_unit", |
---|
307 | "storeas" : "float", |
---|
308 | "attributes" : SASSAMPLE_POS_ATTR |
---|
309 | } |
---|
310 | SASSAMPLE_POS_Y = { |
---|
311 | "variable" : "{0}.sample.position.y = {1}", |
---|
312 | "unit" : "sample.position_unit", |
---|
313 | "storeas" : "float", |
---|
314 | "attributes" : SASSAMPLE_POS_ATTR |
---|
315 | } |
---|
316 | SASSAMPLE_POS_Z = { |
---|
317 | "variable" : "{0}.sample.position.z = {1}", |
---|
318 | "unit" : "sample.position_unit", |
---|
319 | "storeas" : "float", |
---|
320 | "attributes" : SASSAMPLE_POS_ATTR |
---|
321 | } |
---|
322 | SASSAMPLE_POS = { |
---|
323 | "children" : { |
---|
324 | "variable" : None, |
---|
325 | "x" : SASSAMPLE_POS_X, |
---|
326 | "y" : SASSAMPLE_POS_Y, |
---|
327 | "z" : SASSAMPLE_POS_Z, |
---|
328 | }, |
---|
329 | } |
---|
330 | SASSAMPLE_ORIENT_ATTR = { |
---|
331 | "units" : { |
---|
332 | "variable" : "{0}.sample.orientation_unit = \"{1}\"", |
---|
333 | "storeas" : "content" |
---|
334 | } |
---|
335 | } |
---|
336 | SASSAMPLE_ORIENT_ROLL = { |
---|
337 | "variable" : "{0}.sample.orientation.x = {1}", |
---|
338 | "unit" : "sample.orientation_unit", |
---|
339 | "storeas" : "float", |
---|
340 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
341 | } |
---|
342 | SASSAMPLE_ORIENT_PITCH = { |
---|
343 | "variable" : "{0}.sample.orientation.y = {1}", |
---|
344 | "unit" : "sample.orientation_unit", |
---|
345 | "storeas" : "float", |
---|
346 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
347 | } |
---|
348 | SASSAMPLE_ORIENT_YAW = { |
---|
349 | "variable" : "{0}.sample.orientation.z = {1}", |
---|
350 | "unit" : "sample.orientation_unit", |
---|
351 | "storeas" : "float", |
---|
352 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
353 | } |
---|
354 | SASSAMPLE_ORIENT = { |
---|
355 | "variable" : None, |
---|
356 | "children" : { |
---|
357 | "roll" : SASSAMPLE_ORIENT_ROLL, |
---|
358 | "pitch" : SASSAMPLE_ORIENT_PITCH, |
---|
359 | "yaw" : SASSAMPLE_ORIENT_YAW, |
---|
360 | }, |
---|
361 | } |
---|
362 | SASSAMPLE = { |
---|
363 | "attributes" : {"name" : {\ |
---|
364 | "variable" : "{0}.sample.name = \"{1}\""},}, |
---|
365 | "variable" : None, |
---|
366 | "children" : { |
---|
367 | "ID" : {"variable" : "{0}.sample.ID = \"{1}\""}, |
---|
368 | "thickness" : SASSAMPLE_THICK, |
---|
369 | "transmission" : SASSAMPLE_TRANS, |
---|
370 | "temperature" : SASSAMPLE_TEMP, |
---|
371 | "position" : SASSAMPLE_POS, |
---|
372 | "orientation" : SASSAMPLE_ORIENT, |
---|
373 | "details" : {"variable" : \ |
---|
374 | "{0}.sample.details.append(\"{1}\")"}, |
---|
375 | "<any>" : ANY |
---|
376 | }, |
---|
377 | } |
---|
378 | SASINSTR_SRC_BEAMSIZE_ATTR = { |
---|
379 | "unit" : \ |
---|
380 | "{0}.source.beam_size_unit = \"{1}\"", |
---|
381 | "storeas" : "content" |
---|
382 | } |
---|
383 | SASINSTR_SRC_BEAMSIZE_X = { |
---|
384 | "variable" : "{0}.source.beam_size.x = {1}", |
---|
385 | "unit" : "source.beam_size_unit", |
---|
386 | "storeas" : "float", |
---|
387 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
388 | } |
---|
389 | SASINSTR_SRC_BEAMSIZE_Y = { |
---|
390 | "variable" : "{0}.source.beam_size.y = {1}", |
---|
391 | "unit" : "source.beam_size_unit", |
---|
392 | "storeas" : "float", |
---|
393 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
394 | } |
---|
395 | SASINSTR_SRC_BEAMSIZE_Z = { |
---|
396 | "variable" : "{0}.source.beam_size.z = {1}", |
---|
397 | "unit" : "source.beam_size_unit", |
---|
398 | "storeas" : "float", |
---|
399 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
400 | } |
---|
401 | SASINSTR_SRC_BEAMSIZE = { |
---|
402 | "attributes" : {"name" : {"variable" : \ |
---|
403 | "{0}.source.beam_size_name = \"{1}\""}}, |
---|
404 | "variable" : None, |
---|
405 | "children" : { |
---|
406 | "x" : SASINSTR_SRC_BEAMSIZE_X, |
---|
407 | "y" : SASINSTR_SRC_BEAMSIZE_Y, |
---|
408 | "z" : SASINSTR_SRC_BEAMSIZE_Z, |
---|
409 | } |
---|
410 | } |
---|
411 | SASINSTR_SRC_WL = { |
---|
412 | "variable" : "{0}.source.wavelength = {1}", |
---|
413 | "unit" : "source.wavelength_unit", |
---|
414 | "storeas" : "float", |
---|
415 | "attributes" : { |
---|
416 | "unit" : { |
---|
417 | "variable" : "{0}.source.wavelength_unit = \"{1}\"", |
---|
418 | "storeas" : "content" |
---|
419 | }, |
---|
420 | } |
---|
421 | } |
---|
422 | SASINSTR_SRC_WL_MIN = { |
---|
423 | "variable" : "{0}.source.wavelength_min = {1}", |
---|
424 | "unit" : "source.wavelength_min_unit", |
---|
425 | "storeas" : "float", |
---|
426 | "attributes" : { |
---|
427 | "unit" : { |
---|
428 | "variable" : "{0}.source.wavelength_min_unit = \"{1}\"", |
---|
429 | "storeas" : "content" |
---|
430 | }, |
---|
431 | } |
---|
432 | } |
---|
433 | SASINSTR_SRC_WL_MAX = { |
---|
434 | "variable" : "{0}.source.wavelength_max = {1}", |
---|
435 | "unit" : "source.wavelength_max_unit", |
---|
436 | "storeas" : "float", |
---|
437 | "attributes" : { |
---|
438 | "unit" : { |
---|
439 | "variable" : "{0}.source.wavelength_max_unit = \"{1}\"", |
---|
440 | "storeas" : "content" |
---|
441 | }, |
---|
442 | } |
---|
443 | } |
---|
444 | SASINSTR_SRC_WL_SPR = { |
---|
445 | "variable" : "{0}.source.wavelength_spread = {1}", |
---|
446 | "unit" : "source.wavelength_spread_unit", |
---|
447 | "storeas" : "float", |
---|
448 | "attributes" : { |
---|
449 | "unit" : { |
---|
450 | "variable" : "{0}.source.wavelength_spread_unit = \"{1}\"", |
---|
451 | "storeas" : "content" |
---|
452 | }, |
---|
453 | } |
---|
454 | } |
---|
455 | SASINSTR_SRC = { |
---|
456 | "attributes" : {"name" : {"variable" : "{0}.source.name = \"{1}\""}}, |
---|
457 | "variable" : None, |
---|
458 | "children" : { |
---|
459 | "radiation" : {"variable" : "{0}.source.radiation = \"{1}\""}, |
---|
460 | "beam_size" : SASINSTR_SRC_BEAMSIZE, |
---|
461 | "beam_shape" : {"variable" : \ |
---|
462 | "{0}.source.beam_shape = \"{1}\""}, |
---|
463 | "wavelength" : SASINSTR_SRC_WL, |
---|
464 | "wavelength_min" : SASINSTR_SRC_WL_MIN, |
---|
465 | "wavelength_max" : SASINSTR_SRC_WL_MAX, |
---|
466 | "wavelength_spread" : SASINSTR_SRC_WL_SPR, |
---|
467 | }, |
---|
468 | } |
---|
469 | SASINSTR_COLL_APER_ATTR = { |
---|
470 | "unit" : { |
---|
471 | "variable" : "{0}.size_unit = \"{1}\"", |
---|
472 | "storeas" : "content" |
---|
473 | }, |
---|
474 | } |
---|
475 | SASINSTR_COLL_APER_X = { |
---|
476 | "variable" : "{0}.size.x = {1}", |
---|
477 | "unit" : "size_unit", |
---|
478 | "storeas" : "float", |
---|
479 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
480 | } |
---|
481 | SASINSTR_COLL_APER_Y = { |
---|
482 | "variable" : "{0}.size.y = {1}", |
---|
483 | "unit" : "size_unit", |
---|
484 | "storeas" : "float", |
---|
485 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
486 | } |
---|
487 | SASINSTR_COLL_APER_Z = { |
---|
488 | "variable" : "{0}.size.z = {1}", |
---|
489 | "unit" : "size_unit", |
---|
490 | "storeas" : "float", |
---|
491 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
492 | } |
---|
493 | SASINSTR_COLL_APER_SIZE = { |
---|
494 | "attributes" : {"unit" : {"variable" : \ |
---|
495 | "{0}.size_unit = \"{1}\""}}, |
---|
496 | "children" : { |
---|
497 | "storeas" : "float", |
---|
498 | "x" : SASINSTR_COLL_APER_X, |
---|
499 | "y" : SASINSTR_COLL_APER_Y, |
---|
500 | "z" : SASINSTR_COLL_APER_Z, |
---|
501 | } |
---|
502 | } |
---|
503 | SASINSTR_COLL_APER_DIST = { |
---|
504 | "storeas" : "float", |
---|
505 | "attributes" : { |
---|
506 | "storeas" : "content", |
---|
507 | "unit" : {"variable" : \ |
---|
508 | "{0}.distance_unit = \"{1}\""}}, |
---|
509 | "variable" : "{0}.distance = {1}", |
---|
510 | "unit" : "distance_unit", |
---|
511 | } |
---|
512 | SASINSTR_COLL_APER = { |
---|
513 | "variable" : None, |
---|
514 | "attributes" : { |
---|
515 | "name" : {"variable" : \ |
---|
516 | "{0}.name = \"{1}\""}, |
---|
517 | "type" : {"variable" : \ |
---|
518 | "{0}.type = \"{1}\""}, |
---|
519 | }, |
---|
520 | "children" : { |
---|
521 | "size" : SASINSTR_COLL_APER_SIZE, |
---|
522 | "distance" : SASINSTR_COLL_APER_DIST |
---|
523 | } |
---|
524 | } |
---|
525 | SASINSTR_COLL = { |
---|
526 | "attributes" : {"name" : {"variable" : \ |
---|
527 | "{0}.name = \"{1}\""}}, |
---|
528 | "variable" : None, |
---|
529 | "children" : { |
---|
530 | "length" : { |
---|
531 | "variable" : "{0}.length = {1}", |
---|
532 | "unit" : "length_unit", |
---|
533 | "storeas" : "float", |
---|
534 | "attributes" : { |
---|
535 | "storeas" : \ |
---|
536 | "content", |
---|
537 | "unit" : {"variable" : "{0}.length_unit = \"{1}\""} |
---|
538 | }, |
---|
539 | }, |
---|
540 | "aperture" : SASINSTR_COLL_APER, |
---|
541 | }, |
---|
542 | } |
---|
543 | SASINSTR_DET_SDD = { |
---|
544 | "variable" : "{0}.distance = {1}", |
---|
545 | "unit" : "distance_unit", |
---|
546 | "attributes" : { |
---|
547 | "unit" : { |
---|
548 | "variable" : \ |
---|
549 | "{0}.distance_unit = \"{1}\"", |
---|
550 | "storeas" : "content" |
---|
551 | } |
---|
552 | }, |
---|
553 | } |
---|
554 | SASINSTR_DET_OFF_ATTR = { |
---|
555 | "unit" : { |
---|
556 | "variable" : "{0}.offset_unit = \"{1}\"", |
---|
557 | "storeas" : "content" |
---|
558 | }, |
---|
559 | } |
---|
560 | SASINSTR_DET_OFF_X = { |
---|
561 | "variable" : "{0}.offset.x = {1}", |
---|
562 | "unit" : "offset_unit", |
---|
563 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
564 | } |
---|
565 | SASINSTR_DET_OFF_Y = { |
---|
566 | "variable" : "{0}.offset.y = {1}", |
---|
567 | "unit" : "offset_unit", |
---|
568 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
569 | } |
---|
570 | SASINSTR_DET_OFF_Z = { |
---|
571 | "variable" : "{0}.offset.z = {1}", |
---|
572 | "unit" : "offset_unit", |
---|
573 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
574 | } |
---|
575 | SASINSTR_DET_OFF = { |
---|
576 | "variable" : None, |
---|
577 | "children" : { |
---|
578 | "x" : SASINSTR_DET_OFF_X, |
---|
579 | "y" : SASINSTR_DET_OFF_Y, |
---|
580 | "z" : SASINSTR_DET_OFF_Z, |
---|
581 | } |
---|
582 | } |
---|
583 | SASINSTR_DET_OR_ATTR = { |
---|
584 | "unit" : "{0}.orientation_unit = \"{1}\"", |
---|
585 | "storeas" : "content" |
---|
586 | } |
---|
587 | SASINSTR_DET_OR_ROLL = { |
---|
588 | "variable" : "{0}.orientation.x = {1}", |
---|
589 | "unit" : "orientation_unit", |
---|
590 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
591 | } |
---|
592 | SASINSTR_DET_OR_PITCH = { |
---|
593 | "variable" : "{0}.orientation.y = {1}", |
---|
594 | "unit" : "orientation_unit", |
---|
595 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
596 | } |
---|
597 | SASINSTR_DET_OR_YAW = { |
---|
598 | "variable" : "{0}.orientation.z = {1}", |
---|
599 | "unit" : "orientation_unit", |
---|
600 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
601 | } |
---|
602 | SASINSTR_DET_OR = { |
---|
603 | "variable" : None, |
---|
604 | "children" : { |
---|
605 | "roll" : SASINSTR_DET_OR_ROLL, |
---|
606 | "pitch" : SASINSTR_DET_OR_PITCH, |
---|
607 | "yaw" : SASINSTR_DET_OR_YAW, |
---|
608 | } |
---|
609 | } |
---|
610 | SASINSTR_DET_BC_X = { |
---|
611 | "variable" : "{0}.beam_center.x = {1}", |
---|
612 | "unit" : "beam_center_unit", |
---|
613 | "attributes" : { |
---|
614 | "unit" : \ |
---|
615 | "{0}.beam_center_unit = \"{1}\"", |
---|
616 | "storeas" : "content" |
---|
617 | } |
---|
618 | } |
---|
619 | SASINSTR_DET_BC_Y = { |
---|
620 | "variable" : "{0}.beam_center.y = {1}", |
---|
621 | "unit" : "beam_center_unit", |
---|
622 | "attributes" : { |
---|
623 | "unit" : \ |
---|
624 | "{0}.beam_center_unit = \"{1}\"", |
---|
625 | "storeas" : "content" |
---|
626 | } |
---|
627 | } |
---|
628 | SASINSTR_DET_BC_Z = { |
---|
629 | "variable" : "{0}.beam_center.z = {1}", |
---|
630 | "unit" : "beam_center_unit", |
---|
631 | "attributes" : { |
---|
632 | "unit" : \ |
---|
633 | "{0}.beam_center_unit = \"{1}\"", |
---|
634 | "storeas" : "content" |
---|
635 | } |
---|
636 | } |
---|
637 | SASINSTR_DET_BC = { |
---|
638 | "variable" : None, |
---|
639 | "children" : { |
---|
640 | "x" : SASINSTR_DET_BC_X, |
---|
641 | "y" : SASINSTR_DET_BC_Y, |
---|
642 | "z" : SASINSTR_DET_BC_Z, |
---|
643 | } |
---|
644 | } |
---|
645 | SASINSTR_DET_PIXEL_X = { |
---|
646 | "variable" : "{0}.pixel_size.x = {1}", |
---|
647 | "unit" : "pixel_size_unit", |
---|
648 | "attributes" : { |
---|
649 | "unit" : "{0}.pixel_size_unit = \"{1}\"", |
---|
650 | "storeas" : "content" |
---|
651 | } |
---|
652 | } |
---|
653 | SASINSTR_DET_PIXEL_Y = { |
---|
654 | "variable" : "{0}.pixel_size.y = {1}", |
---|
655 | "unit" : "pixel_size_unit", |
---|
656 | "attributes" : { |
---|
657 | "unit" : "{0}.pixel_size_unit = \"{1}\"", |
---|
658 | "storeas" : "content" |
---|
659 | } |
---|
660 | } |
---|
661 | SASINSTR_DET_PIXEL_Z = { |
---|
662 | "variable" : "{0}.pixel_size.z = {1}", |
---|
663 | "unit" : "pixel_size_unit", |
---|
664 | "attributes" : { |
---|
665 | "unit" : "{0}.pixel_size_unit = \"{1}\"", |
---|
666 | "storeas" : "content" |
---|
667 | } |
---|
668 | } |
---|
669 | SASINSTR_DET_PIXEL = { |
---|
670 | "variable" : None, |
---|
671 | "children" : { |
---|
672 | "x" : SASINSTR_DET_PIXEL_X, |
---|
673 | "y" : SASINSTR_DET_PIXEL_Y, |
---|
674 | "z" : SASINSTR_DET_PIXEL_Z, |
---|
675 | } |
---|
676 | } |
---|
677 | SASINSTR_DET_SLIT = { |
---|
678 | "variable" : "{0}.slit_length = {1}", |
---|
679 | "unit" : "slit_length_unit", |
---|
680 | "attributes" : { |
---|
681 | "unit" : { |
---|
682 | "variable" : "{0}.slit_length_unit = \"{1}\"", |
---|
683 | "storeas" : "content" |
---|
684 | } |
---|
685 | } |
---|
686 | } |
---|
687 | SASINSTR_DET = { |
---|
688 | "storeas" : "float", |
---|
689 | "variable" : None, |
---|
690 | "attributes" : { |
---|
691 | "name" : { |
---|
692 | "storeas" : "content", |
---|
693 | "variable" : "{0}.name = \"{1}\"", |
---|
694 | } |
---|
695 | }, |
---|
696 | "children" : { |
---|
697 | "name" : { |
---|
698 | "storeas" : "content", |
---|
699 | "variable" : "{0}.name = \"{1}\"", |
---|
700 | }, |
---|
701 | "SDD" : SASINSTR_DET_SDD, |
---|
702 | "offset" : SASINSTR_DET_OFF, |
---|
703 | "orientation" : SASINSTR_DET_OR, |
---|
704 | "beam_center" : SASINSTR_DET_BC, |
---|
705 | "pixel_size" : SASINSTR_DET_PIXEL, |
---|
706 | "slit_length" : SASINSTR_DET_SLIT, |
---|
707 | } |
---|
708 | } |
---|
709 | SASINSTR = { |
---|
710 | "variable" : None, |
---|
711 | "children" : { |
---|
712 | "variable" : None, |
---|
713 | "name" : {"variable" : \ |
---|
714 | "{0}.instrument = \"{1}\""}, |
---|
715 | "SASsource" : SASINSTR_SRC, |
---|
716 | "SAScollimation" : SASINSTR_COLL, |
---|
717 | "SASdetector" : SASINSTR_DET, |
---|
718 | }, |
---|
719 | } |
---|
720 | CANSAS_FORMAT = { |
---|
721 | "SASentry" : { |
---|
722 | "units_optional" : True, |
---|
723 | "variable" : None, |
---|
724 | "storeas" : "content", |
---|
725 | "attributes" : {"name" : {"variable" : \ |
---|
726 | "{0}.run_name[node_value] = \"{1}\""}}, |
---|
727 | "children" : { |
---|
728 | "Title" : TITLE, |
---|
729 | "Run" : RUN, |
---|
730 | "SASdata" : SASDATA, |
---|
731 | "SAStransmission_spectrum" : \ |
---|
732 | SASTRANSSPEC, |
---|
733 | "SASsample" : SASSAMPLE, |
---|
734 | "SASinstrument" : SASINSTR, |
---|
735 | "SASprocess" : SASPROCESS, |
---|
736 | "SASnote" : SASNOTE, |
---|
737 | "<any>" : ANY, |
---|
738 | } |
---|
739 | } |
---|
740 | } |
---|
741 | |
---|
742 | class currentLevel: |
---|
743 | |
---|
744 | current_level = '' |
---|
745 | ns_variable = '' |
---|
746 | ns_datatype = '' |
---|
747 | ns_optional = True |
---|
748 | |
---|
749 | def __init__(self): |
---|
750 | self.current_level = '' |
---|
751 | self.ns_variable = '' |
---|
752 | self.ns_datatype = "content" |
---|
753 | self.ns_optional = True |
---|