moreniius 0.2.1__tar.gz → 0.2.3__tar.gz
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.
- {moreniius-0.2.1/src/moreniius.egg-info → moreniius-0.2.3}/PKG-INFO +5 -5
- {moreniius-0.2.1 → moreniius-0.2.3}/pyproject.toml +4 -4
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/instr.py +2 -1
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/orientation.py +21 -7
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/utils.py +8 -1
- {moreniius-0.2.1 → moreniius-0.2.3/src/moreniius.egg-info}/PKG-INFO +5 -5
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius.egg-info/SOURCES.txt +1 -0
- moreniius-0.2.3/src/moreniius.egg-info/requires.txt +7 -0
- moreniius-0.2.3/tests/test_motorized_positions.py +24 -0
- moreniius-0.2.1/src/moreniius.egg-info/requires.txt +0 -7
- {moreniius-0.2.1 → moreniius-0.2.3}/.github/workflows/pip.yml +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/.github/workflows/wheels.yml +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/.gitignore +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/README.md +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/setup.cfg +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/__init__.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/additions.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/__init__.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/comp.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/instance.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/mccode/mccode.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/moreniius.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/nexus_structure.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/nxoff.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius/writer.py +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius.egg-info/dependency_links.txt +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius.egg-info/entry_points.txt +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/src/moreniius.egg-info/top_level.txt +0 -0
- {moreniius-0.2.1 → moreniius-0.2.3}/tests/test_nexus_structure.py +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: moreniius
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
Classifier: License :: OSI Approved :: BSD License
|
|
6
6
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: zenlog
|
|
9
|
-
Requires-Dist: platformdirs
|
|
8
|
+
Requires-Dist: zenlog>=1.1
|
|
9
|
+
Requires-Dist: platformdirs>=3.11
|
|
10
10
|
Requires-Dist: importlib_metadata; python_version < "3.8"
|
|
11
|
-
Requires-Dist: mccode-antlr[hdf5]
|
|
12
|
-
Requires-Dist: nexusformat
|
|
11
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.7.1
|
|
12
|
+
Requires-Dist: nexusformat>=1.0.6
|
|
13
13
|
|
|
14
14
|
# moreniius
|
|
15
15
|
A project to contain custom components required to use `eniius` to produce `NeXus Structure` `JSON` from `mccode-antlr` simulated instruments.
|
|
@@ -5,11 +5,11 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "moreniius"
|
|
7
7
|
dependencies = [
|
|
8
|
-
'zenlog
|
|
9
|
-
'platformdirs
|
|
8
|
+
'zenlog>=1.1',
|
|
9
|
+
'platformdirs>=3.11',
|
|
10
10
|
"importlib_metadata; python_version<'3.8'",
|
|
11
|
-
'mccode-antlr[hdf5]
|
|
12
|
-
'nexusformat
|
|
11
|
+
'mccode-antlr[hdf5]>=0.7.1',
|
|
12
|
+
'nexusformat>=1.0.6'
|
|
13
13
|
]
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
authors = [
|
|
@@ -83,7 +83,8 @@ class NXInstr:
|
|
|
83
83
|
'expression' in nx_args[0]:
|
|
84
84
|
not_expr = [x for x in nx_args[0] if x != 'expression']
|
|
85
85
|
if len(not_expr) == 1:
|
|
86
|
-
return
|
|
86
|
+
# TODO make this return an nx_class once we're sure that nx_kwargs is parseable (no mccode_antlr.Expr)
|
|
87
|
+
return nx_class(nx_args[0][not_expr[0]], **nx_kwargs)
|
|
87
88
|
else:
|
|
88
89
|
raise RuntimeError('Not sure what I should do here')
|
|
89
90
|
return nx_class(*nx_args, **nx_kwargs)
|
|
@@ -17,14 +17,28 @@ class NXPart:
|
|
|
17
17
|
def make_nx(self, nx_class, *args, **kwargs):
|
|
18
18
|
return self.instr.make_nx(nx_class, *args, **kwargs)
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def make_translation(self, norm, vec, dep):
|
|
21
|
+
return self.make_nx(NXfield, norm, vector=vec, depends_on=dep, transformation_type='translation', units='m')
|
|
22
|
+
|
|
23
|
+
def translations(self, dep: str, name: str) -> list[tuple[str, NXfield]]:
|
|
21
24
|
from mccode_antlr.instr import RotationPart
|
|
25
|
+
from mccode_antlr.common import Expr, Value
|
|
22
26
|
if isinstance(self.o, RotationPart):
|
|
23
27
|
raise RuntimeError('Part is a rotation!')
|
|
24
28
|
pos = self.o.position()
|
|
29
|
+
if any(isinstance(c, (Expr, Value)) for c in (pos.x, pos.y, pos.z)):
|
|
30
|
+
translations = []
|
|
31
|
+
print(f'{pos.x=} {pos.y=} {pos.z=}')
|
|
32
|
+
for n, c, v in (('x', pos.x, [1, 0, 0]), ('y', pos.y, [0, 1, 0]), ('z', pos.z, [0, 0, 1])):
|
|
33
|
+
if c != Expr.parse('0'):
|
|
34
|
+
next_name = f'{name}_{n}'
|
|
35
|
+
translations.append((next_name, self.make_translation(c, v, dep)))
|
|
36
|
+
dep = next_name
|
|
37
|
+
return translations
|
|
38
|
+
# vector is all constants, hopefully
|
|
25
39
|
norm = pos.length()
|
|
26
|
-
vec = pos if norm.is_zero else pos
|
|
27
|
-
return self.
|
|
40
|
+
vec = pos if norm.is_zero else pos/norm
|
|
41
|
+
return [(name, self.make_translation(norm, vec, dep))]
|
|
28
42
|
|
|
29
43
|
def rotation(self, dep: str) -> NXfield:
|
|
30
44
|
from mccode_antlr.instr import TranslationPart
|
|
@@ -43,11 +57,11 @@ class NXPart:
|
|
|
43
57
|
|
|
44
58
|
def transformations(self, name: str, dep: str | None = None) -> list[tuple[str, NXfield]]:
|
|
45
59
|
if self.o.is_translation and self.o.is_rotation:
|
|
46
|
-
|
|
47
|
-
rot = self.rotation(
|
|
48
|
-
return [
|
|
60
|
+
ops = self.translations(dep, name)
|
|
61
|
+
rot = self.rotation(ops[-1][0])
|
|
62
|
+
return [*ops, (f'{name}_r', rot)]
|
|
49
63
|
elif self.o.is_translation:
|
|
50
|
-
return
|
|
64
|
+
return self.translations(dep, name)
|
|
51
65
|
elif self.o.is_rotation:
|
|
52
66
|
return [(name, self.rotation(dep))]
|
|
53
67
|
else:
|
|
@@ -32,7 +32,14 @@ def outer_transform_dependency(transformations):
|
|
|
32
32
|
names = list(transformations)
|
|
33
33
|
if len(names) == 1:
|
|
34
34
|
return names[0]
|
|
35
|
-
|
|
35
|
+
def depends_on_per(name):
|
|
36
|
+
obj = getattr(transformations, name)
|
|
37
|
+
if not hasattr(obj, 'depends_on'):
|
|
38
|
+
raise ValueError(f'{name} in {names} dependency chain missing "depends_on" attribute')
|
|
39
|
+
return obj.depends_on
|
|
40
|
+
|
|
41
|
+
# depends = {name: getattr(transformations, name).depends_on for name in names}
|
|
42
|
+
depends = {name: depends_on_per(name) for name in names}
|
|
36
43
|
externals = [v for k, v in depends.items() if v not in depends]
|
|
37
44
|
if len(externals) != 1:
|
|
38
45
|
raise RuntimeError(f"Dependency chain {depends} should have one absolute dependency, found {externals} instead")
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: moreniius
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
Classifier: License :: OSI Approved :: BSD License
|
|
6
6
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: zenlog
|
|
9
|
-
Requires-Dist: platformdirs
|
|
8
|
+
Requires-Dist: zenlog>=1.1
|
|
9
|
+
Requires-Dist: platformdirs>=3.11
|
|
10
10
|
Requires-Dist: importlib_metadata; python_version < "3.8"
|
|
11
|
-
Requires-Dist: mccode-antlr[hdf5]
|
|
12
|
-
Requires-Dist: nexusformat
|
|
11
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.7.1
|
|
12
|
+
Requires-Dist: nexusformat>=1.0.6
|
|
13
13
|
|
|
14
14
|
# moreniius
|
|
15
15
|
A project to contain custom components required to use `eniius` to produce `NeXus Structure` `JSON` from `mccode-antlr` simulated instruments.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
def make_motorized_instrument():
|
|
3
|
+
from mccode_antlr.assembler import Assembler
|
|
4
|
+
from mccode_antlr.reader import MCSTAS_REGISTRY, LocalRegistry
|
|
5
|
+
from mccode_to_kafka.writer import da00_dataarray_config, da00_variable_config
|
|
6
|
+
|
|
7
|
+
inst = Assembler('inst', registries=[MCSTAS_REGISTRY])
|
|
8
|
+
inst.parameter('double ex/"m"=0')
|
|
9
|
+
inst.parameter('double phi/"degree"=0')
|
|
10
|
+
|
|
11
|
+
inst.component('origin', 'Arm', at=(0, 0, 0))
|
|
12
|
+
inst.component('source', 'Source_simple', at=[(0, 0, 0), 'origin'])
|
|
13
|
+
inst.component('xpos', 'Arm', at=[('ex', 0, 0), 'source'])
|
|
14
|
+
inst.component('zrot', 'Arm', at=[(0, 0, 0), 'xpos'], rotate=[(0, 0, 'phi'), 'xpos'])
|
|
15
|
+
|
|
16
|
+
return inst.instrument
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_motorized_instrument():
|
|
20
|
+
import moreniius
|
|
21
|
+
motorized = make_motorized_instrument()
|
|
22
|
+
nx = moreniius.MorEniius.from_mccode(motorized, origin='origin', only_nx=False, absolute_depends_on=True)
|
|
23
|
+
assert nx is not None
|
|
24
|
+
#TODO add actual tests for the contents of, e.g., the dumped NeXus Structure
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|