syned 1.0.48__py3-none-any.whl → 1.0.49__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syned/beamline/__init__.py +1 -1
- syned/beamline/beamline.py +155 -155
- syned/beamline/beamline_element.py +76 -76
- syned/beamline/element_coordinates.py +199 -199
- syned/beamline/optical_element.py +47 -47
- syned/beamline/optical_element_with_surface_shape.py +126 -126
- syned/beamline/optical_elements/__init__.py +1 -1
- syned/beamline/optical_elements/absorbers/absorber.py +21 -21
- syned/beamline/optical_elements/absorbers/beam_stopper.py +63 -63
- syned/beamline/optical_elements/absorbers/filter.py +61 -61
- syned/beamline/optical_elements/absorbers/holed_filter.py +67 -67
- syned/beamline/optical_elements/absorbers/slit.py +80 -80
- syned/beamline/optical_elements/crystals/__init__.py +1 -1
- syned/beamline/optical_elements/crystals/crystal.py +70 -70
- syned/beamline/optical_elements/gratings/__init__.py +1 -1
- syned/beamline/optical_elements/gratings/grating.py +279 -279
- syned/beamline/optical_elements/ideal_elements/__init__.py +1 -1
- syned/beamline/optical_elements/ideal_elements/ideal_element.py +15 -15
- syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +183 -183
- syned/beamline/optical_elements/ideal_elements/ideal_lens.py +54 -54
- syned/beamline/optical_elements/ideal_elements/screen.py +15 -15
- syned/beamline/optical_elements/mirrors/__init__.py +1 -1
- syned/beamline/optical_elements/mirrors/mirror.py +39 -39
- syned/beamline/optical_elements/multilayers/__init__.py +46 -46
- syned/beamline/optical_elements/multilayers/multilayer.py +45 -45
- syned/beamline/optical_elements/refractors/__init__.py +1 -1
- syned/beamline/optical_elements/refractors/crl.py +79 -79
- syned/beamline/optical_elements/refractors/interface.py +60 -60
- syned/beamline/optical_elements/refractors/lens.py +105 -105
- syned/beamline/shape.py +2884 -2803
- syned/storage_ring/__init__.py +1 -1
- syned/storage_ring/electron_beam.py +804 -804
- syned/storage_ring/empty_light_source.py +40 -40
- syned/storage_ring/light_source.py +90 -90
- syned/storage_ring/magnetic_structure.py +8 -8
- syned/storage_ring/magnetic_structures/__init__.py +1 -1
- syned/storage_ring/magnetic_structures/bending_magnet.py +329 -329
- syned/storage_ring/magnetic_structures/insertion_device.py +169 -169
- syned/storage_ring/magnetic_structures/undulator.py +413 -413
- syned/storage_ring/magnetic_structures/wiggler.py +27 -27
- syned/syned_object.py +273 -275
- syned/util/__init__.py +21 -21
- syned/util/json_tools.py +196 -198
- syned/widget/widget_decorator.py +66 -66
- {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/METADATA +88 -87
- syned-1.0.49.dist-info/RECORD +52 -0
- {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/WHEEL +1 -1
- {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/licenses/LICENSE +20 -20
- syned/__test/__init__.py +0 -46
- syned/__test/test.py +0 -28
- syned-1.0.48.dist-info/RECORD +0 -54
- {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/top_level.txt +0 -0
syned/util/json_tools.py
CHANGED
|
@@ -1,198 +1,196 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Functions to read/write syned objects in json files.
|
|
3
|
-
|
|
4
|
-
Notes
|
|
5
|
-
-----
|
|
6
|
-
The elements that are not explicitely imported in the code that follows, but they MUST be imported
|
|
7
|
-
to define the objects at run time.
|
|
8
|
-
To import more elements, yoy can use the exec_command keyword.
|
|
9
|
-
|
|
10
|
-
"""
|
|
11
|
-
from syned.storage_ring.electron_beam import ElectronBeam
|
|
12
|
-
from syned.storage_ring.magnetic_structures.undulator import Undulator
|
|
13
|
-
from syned.storage_ring.magnetic_structures.wiggler import Wiggler
|
|
14
|
-
from syned.storage_ring.magnetic_structures.bending_magnet import BendingMagnet
|
|
15
|
-
from syned.storage_ring.magnetic_structure import MagneticStructure
|
|
16
|
-
from syned.beamline.optical_elements.ideal_elements.screen import Screen
|
|
17
|
-
from syned.beamline.optical_elements.ideal_elements.ideal_lens import IdealLens
|
|
18
|
-
from syned.beamline.optical_elements.absorbers.filter import Filter
|
|
19
|
-
from syned.beamline.optical_elements.absorbers.slit import Slit
|
|
20
|
-
from syned.beamline.optical_elements.absorbers.beam_stopper import BeamStopper
|
|
21
|
-
from syned.beamline.optical_elements.absorbers.holed_filter import HoledFilter
|
|
22
|
-
from syned.beamline.optical_elements.mirrors.mirror import Mirror
|
|
23
|
-
from syned.beamline.optical_elements.crystals.crystal import Crystal
|
|
24
|
-
from syned.beamline.optical_elements.gratings.grating import Grating
|
|
25
|
-
from syned.beamline.optical_elements.gratings.grating import GratingVLS
|
|
26
|
-
from syned.beamline.optical_elements.gratings.grating import GratingBlaze
|
|
27
|
-
from syned.beamline.optical_elements.gratings.grating import GratingLamellar
|
|
28
|
-
|
|
29
|
-
from syned.beamline.shape import BoundaryShape
|
|
30
|
-
from syned.beamline.shape import Rectangle, Ellipse, Circle
|
|
31
|
-
from syned.beamline.shape import MultiplePatch
|
|
32
|
-
from syned.beamline.shape import DoubleRectangle, DoubleEllipse, DoubleCircle
|
|
33
|
-
|
|
34
|
-
from syned.beamline.shape import SurfaceShape
|
|
35
|
-
from syned.beamline.shape import Conic, Plane, Sphere, SphericalCylinder
|
|
36
|
-
from syned.beamline.shape import Ellipsoid, EllipticalCylinder
|
|
37
|
-
from syned.beamline.shape import Paraboloid, ParabolicCylinder
|
|
38
|
-
from syned.beamline.shape import Hyperboloid, HyperbolicCylinder
|
|
39
|
-
from syned.beamline.shape import Toroid
|
|
40
|
-
|
|
41
|
-
from syned.storage_ring.light_source import LightSource
|
|
42
|
-
from syned.storage_ring.empty_light_source import EmptyLightSource
|
|
43
|
-
|
|
44
|
-
from syned.beamline.beamline import Beamline
|
|
45
|
-
from syned.beamline.beamline_element import BeamlineElement
|
|
46
|
-
from syned.beamline.element_coordinates import ElementCoordinates
|
|
47
|
-
|
|
48
|
-
from collections import OrderedDict
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
The file
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
f
|
|
73
|
-
text =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
The
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
The
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if verbose: print("
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if verbose: print("
|
|
169
|
-
tmp3
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
#
|
|
197
|
-
# syned_obj = load_from_json_file(file_url)
|
|
198
|
-
# print(syned_obj.info())
|
|
1
|
+
"""
|
|
2
|
+
Functions to read/write syned objects in json files.
|
|
3
|
+
|
|
4
|
+
Notes
|
|
5
|
+
-----
|
|
6
|
+
The elements that are not explicitely imported in the code that follows, but they MUST be imported
|
|
7
|
+
to define the objects at run time.
|
|
8
|
+
To import more elements, yoy can use the exec_command keyword.
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
from syned.storage_ring.electron_beam import ElectronBeam
|
|
12
|
+
from syned.storage_ring.magnetic_structures.undulator import Undulator
|
|
13
|
+
from syned.storage_ring.magnetic_structures.wiggler import Wiggler
|
|
14
|
+
from syned.storage_ring.magnetic_structures.bending_magnet import BendingMagnet
|
|
15
|
+
from syned.storage_ring.magnetic_structure import MagneticStructure
|
|
16
|
+
from syned.beamline.optical_elements.ideal_elements.screen import Screen
|
|
17
|
+
from syned.beamline.optical_elements.ideal_elements.ideal_lens import IdealLens
|
|
18
|
+
from syned.beamline.optical_elements.absorbers.filter import Filter
|
|
19
|
+
from syned.beamline.optical_elements.absorbers.slit import Slit
|
|
20
|
+
from syned.beamline.optical_elements.absorbers.beam_stopper import BeamStopper
|
|
21
|
+
from syned.beamline.optical_elements.absorbers.holed_filter import HoledFilter
|
|
22
|
+
from syned.beamline.optical_elements.mirrors.mirror import Mirror
|
|
23
|
+
from syned.beamline.optical_elements.crystals.crystal import Crystal
|
|
24
|
+
from syned.beamline.optical_elements.gratings.grating import Grating
|
|
25
|
+
from syned.beamline.optical_elements.gratings.grating import GratingVLS
|
|
26
|
+
from syned.beamline.optical_elements.gratings.grating import GratingBlaze
|
|
27
|
+
from syned.beamline.optical_elements.gratings.grating import GratingLamellar
|
|
28
|
+
|
|
29
|
+
from syned.beamline.shape import BoundaryShape
|
|
30
|
+
from syned.beamline.shape import Rectangle, Ellipse, Circle
|
|
31
|
+
from syned.beamline.shape import MultiplePatch
|
|
32
|
+
from syned.beamline.shape import DoubleRectangle, DoubleEllipse, DoubleCircle
|
|
33
|
+
|
|
34
|
+
from syned.beamline.shape import SurfaceShape
|
|
35
|
+
from syned.beamline.shape import Conic, Plane, Sphere, SphericalCylinder
|
|
36
|
+
from syned.beamline.shape import Ellipsoid, EllipticalCylinder
|
|
37
|
+
from syned.beamline.shape import Paraboloid, ParabolicCylinder
|
|
38
|
+
from syned.beamline.shape import Hyperboloid, HyperbolicCylinder
|
|
39
|
+
from syned.beamline.shape import Toroid
|
|
40
|
+
|
|
41
|
+
from syned.storage_ring.light_source import LightSource
|
|
42
|
+
from syned.storage_ring.empty_light_source import EmptyLightSource
|
|
43
|
+
|
|
44
|
+
from syned.beamline.beamline import Beamline
|
|
45
|
+
from syned.beamline.beamline_element import BeamlineElement
|
|
46
|
+
from syned.beamline.element_coordinates import ElementCoordinates
|
|
47
|
+
|
|
48
|
+
from collections import OrderedDict
|
|
49
|
+
|
|
50
|
+
import json_tricks # to save numpy arrays
|
|
51
|
+
|
|
52
|
+
from urllib.request import urlopen
|
|
53
|
+
|
|
54
|
+
def load_from_json_file(file_name, exec_commands=None):
|
|
55
|
+
"""
|
|
56
|
+
Function to load a syned object from a json file.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
file_name : str
|
|
61
|
+
The file name.
|
|
62
|
+
exec_commands : str
|
|
63
|
+
The commands (typically import...) to be executed before accesing the file.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
instance of SynedObject
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
f = open(file_name)
|
|
71
|
+
text = f.read()
|
|
72
|
+
f.close()
|
|
73
|
+
return load_from_json_text(text, exec_commands=exec_commands)
|
|
74
|
+
|
|
75
|
+
def load_from_json_url(file_url, exec_commands=None):
|
|
76
|
+
"""
|
|
77
|
+
Function to load a syned object from a remote json file.
|
|
78
|
+
|
|
79
|
+
Parameters
|
|
80
|
+
----------
|
|
81
|
+
file_url : str
|
|
82
|
+
The URL with the file name.
|
|
83
|
+
exec_commands : str
|
|
84
|
+
The commands (typically import...) to be executed before accesing the file.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
instance of SynedObject
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
u = urlopen(file_url)
|
|
92
|
+
ur = u.read()
|
|
93
|
+
url = ur.decode(encoding='UTF-8')
|
|
94
|
+
return load_from_json_text(url, exec_commands=exec_commands)
|
|
95
|
+
|
|
96
|
+
def load_from_json_text(text, exec_commands=None):
|
|
97
|
+
"""
|
|
98
|
+
Function to load a syned object from a json txt.
|
|
99
|
+
|
|
100
|
+
Parameters
|
|
101
|
+
----------
|
|
102
|
+
text : str
|
|
103
|
+
The text with the corresponding info.
|
|
104
|
+
exec_commands : str
|
|
105
|
+
The commands (typically import...) to be executed before accesing the file.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
instance of SynedObject
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
return load_from_json_dictionary_recurrent(json_tricks.loads(text), exec_commands=exec_commands)
|
|
113
|
+
|
|
114
|
+
def load_from_json_dictionary_recurrent(jsn, verbose=False, exec_commands=None):
|
|
115
|
+
"""
|
|
116
|
+
Function to convert a dictionary (got from json file) into a syned object.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
jsn : dict
|
|
121
|
+
The dictionary with json file information.
|
|
122
|
+
verbose : boolean, optional
|
|
123
|
+
Define or not verbose output.
|
|
124
|
+
exec_commands : str
|
|
125
|
+
The commands (typically import...) to be executed before accesing the file.
|
|
126
|
+
|
|
127
|
+
Returns
|
|
128
|
+
-------
|
|
129
|
+
instance of SynedObject
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
if isinstance(exec_commands, list):
|
|
133
|
+
for command in exec_commands:
|
|
134
|
+
if verbose: print(">>>>",command)
|
|
135
|
+
exec(command)
|
|
136
|
+
elif isinstance(exec_commands, str):
|
|
137
|
+
if verbose: print(">>>>", exec_commands)
|
|
138
|
+
exec(exec_commands)
|
|
139
|
+
|
|
140
|
+
if verbose: print(jsn.keys())
|
|
141
|
+
if "CLASS_NAME" in jsn.keys():
|
|
142
|
+
if verbose: print("FOUND CLASS NAME: ",jsn["CLASS_NAME"])
|
|
143
|
+
if verbose: print(">>>>eval: ", jsn["CLASS_NAME"])
|
|
144
|
+
try:
|
|
145
|
+
tmp1 = eval(jsn["CLASS_NAME"]+"()")
|
|
146
|
+
except:
|
|
147
|
+
raise RuntimeError("Error evaluating: "+jsn["CLASS_NAME"]+"() ** you could use the exec_command keyword to import it at run time **")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
if tmp1.keys() is not None:
|
|
151
|
+
NOT_FOUND = "--------NOT-FOUND--------"
|
|
152
|
+
for key in tmp1.keys():
|
|
153
|
+
stored_value = jsn.get(key, NOT_FOUND)
|
|
154
|
+
if str(stored_value) != NOT_FOUND:
|
|
155
|
+
if verbose: print(">>>>processing",key ,type(jsn[key]))
|
|
156
|
+
if isinstance(jsn[key],dict):
|
|
157
|
+
if verbose: print(">>>>>>>>dictionary found, starting recurrency",key ,type(jsn[key]))
|
|
158
|
+
tmp2 = load_from_json_dictionary_recurrent(jsn[key],exec_commands=exec_commands)
|
|
159
|
+
if verbose: print(">>>>2",key,type(tmp2))
|
|
160
|
+
tmp1.set_value_from_key_name(key,tmp2)
|
|
161
|
+
elif isinstance(jsn[key], list):
|
|
162
|
+
if verbose: print(">>>>>>>>LIST found, starting recurrency",key ,type(jsn[key]))
|
|
163
|
+
out_list_of_objects = []
|
|
164
|
+
for element in jsn[key]:
|
|
165
|
+
if isinstance(element, dict):
|
|
166
|
+
if verbose: print(">>>>>>>>LIST found, starting recurrency",key ,type(element))
|
|
167
|
+
tmp3 = load_from_json_dictionary_recurrent(element, exec_commands=exec_commands)
|
|
168
|
+
if verbose: print(">>>>3",type(tmp3))
|
|
169
|
+
out_list_of_objects.append(tmp3)
|
|
170
|
+
else:
|
|
171
|
+
print("***** Failed to load", element)
|
|
172
|
+
if verbose: print("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk",out_list_of_objects)
|
|
173
|
+
tmp1.set_value_from_key_name(key,out_list_of_objects)
|
|
174
|
+
# tmp1.set_value_from_key_name(key,tmp2)
|
|
175
|
+
else:
|
|
176
|
+
if verbose: print(">>>>>>> setting value for key: ",key," to: ",repr(jsn[key]))
|
|
177
|
+
tmp1.set_value_from_key_name(key,jsn[key])
|
|
178
|
+
|
|
179
|
+
return tmp1
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if __name__ == "__main__":
|
|
183
|
+
|
|
184
|
+
file_url = "http://ftp.esrf.fr/pub/scisoft/syned/lightsources/ESRF_ID01_EBS_PPU35_22.json"
|
|
185
|
+
syned_obj = load_from_json_url(file_url)
|
|
186
|
+
print(syned_obj.info())
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
#
|
|
190
|
+
# file_url = "/home/manuel/Oasys/ALSU-IR-BM.json"
|
|
191
|
+
# syned_obj = load_from_json_file(file_url)
|
|
192
|
+
# print(syned_obj.info())
|
|
193
|
+
|
|
194
|
+
# file_url = "/home/manuel/Oasys/bl.json"
|
|
195
|
+
# syned_obj = load_from_json_file(file_url)
|
|
196
|
+
# print(syned_obj.info())
|
syned/widget/widget_decorator.py
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
from syned.beamline.beamline import Beamline
|
|
3
|
-
|
|
4
|
-
class WidgetDecorator(object):
|
|
5
|
-
"""
|
|
6
|
-
Definition of a widget decorator (to be used by widget implementations).
|
|
7
|
-
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
@classmethod
|
|
11
|
-
def syned_input_data(cls, multi_input=False):
|
|
12
|
-
"""
|
|
13
|
-
A string to help defining SYNED data in OASYS.
|
|
14
|
-
|
|
15
|
-
Returns
|
|
16
|
-
-------
|
|
17
|
-
list
|
|
18
|
-
[("SynedData", Beamline, "receive_syned_data")]
|
|
19
|
-
|
|
20
|
-
"""
|
|
21
|
-
try: # OASYS2
|
|
22
|
-
import oasys2
|
|
23
|
-
|
|
24
|
-
if not multi_input:
|
|
25
|
-
from orangewidget.widget import Input
|
|
26
|
-
|
|
27
|
-
return Input(name="Syned Data",
|
|
28
|
-
type=Beamline,
|
|
29
|
-
id="SynedData",
|
|
30
|
-
default=True, auto_summary=False)
|
|
31
|
-
else:
|
|
32
|
-
from orangewidget.widget import MultiInput
|
|
33
|
-
|
|
34
|
-
return MultiInput(name="Syned Data",
|
|
35
|
-
type=Beamline,
|
|
36
|
-
id="SynedData",
|
|
37
|
-
default=True, auto_summary=False)
|
|
38
|
-
except:
|
|
39
|
-
return [("SynedData", Beamline, "receive_syned_data")]
|
|
40
|
-
|
|
41
|
-
@classmethod
|
|
42
|
-
def append_syned_input_data(cls, inputs):
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
Parameters
|
|
46
|
-
----------
|
|
47
|
-
inputs
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"""
|
|
51
|
-
for input in WidgetDecorator.syned_input_data():
|
|
52
|
-
inputs.append(input)
|
|
53
|
-
|
|
54
|
-
def receive_syned_data(self, data):
|
|
55
|
-
"""
|
|
56
|
-
To be implemented in the main object.
|
|
57
|
-
|
|
58
|
-
Parameters
|
|
59
|
-
----------
|
|
60
|
-
data
|
|
61
|
-
|
|
62
|
-
Raises
|
|
63
|
-
------
|
|
64
|
-
NotImplementedError
|
|
65
|
-
|
|
66
|
-
"""
|
|
1
|
+
|
|
2
|
+
from syned.beamline.beamline import Beamline
|
|
3
|
+
|
|
4
|
+
class WidgetDecorator(object):
|
|
5
|
+
"""
|
|
6
|
+
Definition of a widget decorator (to be used by widget implementations).
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def syned_input_data(cls, multi_input=False):
|
|
12
|
+
"""
|
|
13
|
+
A string to help defining SYNED data in OASYS.
|
|
14
|
+
|
|
15
|
+
Returns
|
|
16
|
+
-------
|
|
17
|
+
list
|
|
18
|
+
[("SynedData", Beamline, "receive_syned_data")]
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
try: # OASYS2
|
|
22
|
+
import oasys2
|
|
23
|
+
|
|
24
|
+
if not multi_input:
|
|
25
|
+
from orangewidget.widget import Input
|
|
26
|
+
|
|
27
|
+
return Input(name="Syned Data",
|
|
28
|
+
type=Beamline,
|
|
29
|
+
id="SynedData",
|
|
30
|
+
default=True, auto_summary=False)
|
|
31
|
+
else:
|
|
32
|
+
from orangewidget.widget import MultiInput
|
|
33
|
+
|
|
34
|
+
return MultiInput(name="Syned Data",
|
|
35
|
+
type=Beamline,
|
|
36
|
+
id="SynedData",
|
|
37
|
+
default=True, auto_summary=False)
|
|
38
|
+
except:
|
|
39
|
+
return [("SynedData", Beamline, "receive_syned_data")]
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def append_syned_input_data(cls, inputs):
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
inputs
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
for input in WidgetDecorator.syned_input_data():
|
|
52
|
+
inputs.append(input)
|
|
53
|
+
|
|
54
|
+
def receive_syned_data(self, data):
|
|
55
|
+
"""
|
|
56
|
+
To be implemented in the main object.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
data
|
|
61
|
+
|
|
62
|
+
Raises
|
|
63
|
+
------
|
|
64
|
+
NotImplementedError
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
67
|
raise NotImplementedError("Should be implemented")
|