restage 0.4.0__py3-none-any.whl → 0.4.1__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.
- restage/bifrost_choppers.py +6 -5
- restage/cache.py +2 -1
- restage/energy.py +11 -6
- restage/instr.py +4 -18
- {restage-0.4.0.dist-info → restage-0.4.1.dist-info}/METADATA +1 -1
- {restage-0.4.0.dist-info → restage-0.4.1.dist-info}/RECORD +9 -9
- {restage-0.4.0.dist-info → restage-0.4.1.dist-info}/WHEEL +0 -0
- {restage-0.4.0.dist-info → restage-0.4.1.dist-info}/entry_points.txt +0 -0
- {restage-0.4.0.dist-info → restage-0.4.1.dist-info}/top_level.txt +0 -0
restage/bifrost_choppers.py
CHANGED
|
@@ -82,9 +82,7 @@ def bandwidth_chopper_speeds_phases(energy_minimum: float):
|
|
|
82
82
|
return SOURCE_FREQUENCY, phase, -SOURCE_FREQUENCY, phase
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
def calculate(order: float, time: float, energy: float, names:
|
|
86
|
-
if names is None or len(names) != 6:
|
|
87
|
-
names = ['ps1', 'ps2', 'fo1', 'fo2', 'bw1', 'bw2']
|
|
85
|
+
def calculate(order: float, time: float, energy: float, names: tuple[str, ...]):
|
|
88
86
|
a, b, c, d, e, f = names
|
|
89
87
|
s, p = 'speed', 'phase'
|
|
90
88
|
r = dict()
|
|
@@ -94,9 +92,12 @@ def calculate(order: float, time: float, energy: float, names: list[str] | None
|
|
|
94
92
|
return r
|
|
95
93
|
|
|
96
94
|
|
|
97
|
-
def main(order: float, time: float, energy: float, names:
|
|
95
|
+
def main(order: float, time: float, energy: float, names: tuple[str, ...] | None = None):
|
|
98
96
|
if names is None or len(names) != 6:
|
|
99
|
-
names =
|
|
97
|
+
# names = ('ps1', 'ps2', 'fo1', 'fo2', 'bw1', 'bw2')
|
|
98
|
+
names = ('pulse_shaping_chopper_1', 'pulse_shaping_chopper_2',
|
|
99
|
+
'frame_overlap_chopper_1', 'frame_overlap_chopper_2',
|
|
100
|
+
'bandwidth_chopper_1', 'bandwidth_chopper_2')
|
|
100
101
|
rep = calculate(order, time, energy, names)
|
|
101
102
|
print(' '.join([f'{k}={v}' for k, v in rep.items()]))
|
|
102
103
|
|
restage/cache.py
CHANGED
|
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from mccode_antlr.instr import Instr
|
|
4
4
|
from .tables import InstrEntry, SimulationTableEntry, SimulationEntry
|
|
5
|
-
from mccode_antlr.compiler.c import CBinaryTarget
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
def setup_database(named: str):
|
|
@@ -54,6 +53,8 @@ def _compile_instr(entry: InstrEntry, instr: Instr, config: dict | None = None,
|
|
|
54
53
|
generator = MCSTAS_GENERATOR
|
|
55
54
|
|
|
56
55
|
output = directory_under_module_data_path('bin')
|
|
56
|
+
# TODO consider adding `dump_source=True` _and_ putting the resulting file into
|
|
57
|
+
# the cache in order to make debugging future problems a tiny bit easier.
|
|
57
58
|
binary_path = compile_instrument(instr, target, output, generator=generator, config=config)
|
|
58
59
|
entry.mccode_version = __version__
|
|
59
60
|
entry.binary_path = str(binary_path)
|
restage/energy.py
CHANGED
|
@@ -10,13 +10,15 @@ def get_and_remove(d: dict, k: str, default=None):
|
|
|
10
10
|
return default
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def one_generic_energy_to_chopper_parameters(
|
|
13
|
+
def one_generic_energy_to_chopper_parameters(
|
|
14
|
+
calculate_choppers, chopper_names: tuple[str, ...],
|
|
15
|
+
time: float, order: int, parameters: dict):
|
|
14
16
|
if any(x in parameters for x in ('ei', 'wavelength', 'lambda', 'energy', 'e')):
|
|
15
17
|
ei = get_and_remove(parameters, 'ei', get_and_remove(parameters, 'energy', get_and_remove(parameters, 'e')))
|
|
16
18
|
if ei is None:
|
|
17
19
|
wavelength = get_and_remove(parameters, 'wavelength', get_and_remove(parameters, 'lambda'))
|
|
18
20
|
ei = _wavelength_angstrom_to_energy_mev(wavelength)
|
|
19
|
-
choppers = calculate_choppers(order, time, ei)
|
|
21
|
+
choppers = calculate_choppers(order, time, ei, names=chopper_names)
|
|
20
22
|
parameters.update(choppers)
|
|
21
23
|
return parameters
|
|
22
24
|
|
|
@@ -24,25 +26,28 @@ def one_generic_energy_to_chopper_parameters(calculate_choppers, time: float, or
|
|
|
24
26
|
def bifrost_translate_energy_to_chopper_parameters(parameters: dict):
|
|
25
27
|
from itertools import product
|
|
26
28
|
from .bifrost_choppers import calculate
|
|
27
|
-
|
|
29
|
+
choppers = tuple(f'{a}_chopper_{b}' for a, b in product(['pulse_shaping', 'frame_overlap', 'bandwidth'], [1, 2]))
|
|
30
|
+
# names = [a+b for a, b in product(('ps', 'fo', 'bw'), ('1', '2'))]
|
|
31
|
+
for name in product(choppers, ('speed', 'phase')):
|
|
28
32
|
name = ''.join(name)
|
|
29
33
|
if name not in parameters:
|
|
30
34
|
parameters[name] = 0
|
|
31
35
|
order = get_and_remove(parameters, 'order', 14)
|
|
32
36
|
time = get_and_remove(parameters, 'time', get_and_remove(parameters, 't', 170/180/(2 * 15 * 14)))
|
|
33
|
-
return one_generic_energy_to_chopper_parameters(calculate, time, order, parameters)
|
|
37
|
+
return one_generic_energy_to_chopper_parameters(calculate, choppers, time, order, parameters)
|
|
34
38
|
|
|
35
39
|
|
|
36
40
|
def cspec_translate_energy_to_chopper_parameters(parameters: dict):
|
|
37
41
|
from itertools import product
|
|
38
42
|
from .cspec_choppers import calculate
|
|
39
|
-
|
|
43
|
+
choppers = ('bw1', 'bw2', 'bw3', 's', 'p', 'm1', 'm2')
|
|
44
|
+
for name in product(choppers, ('speed', 'phase')):
|
|
40
45
|
name = ''.join(name)
|
|
41
46
|
if name not in parameters:
|
|
42
47
|
parameters[name] = 0
|
|
43
48
|
time = get_and_remove(parameters, 'time', 0.004)
|
|
44
49
|
order = get_and_remove(parameters, 'order', 16)
|
|
45
|
-
return one_generic_energy_to_chopper_parameters(calculate, time, order, parameters)
|
|
50
|
+
return one_generic_energy_to_chopper_parameters(calculate, choppers, time, order, parameters)
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
def no_op_translate_energy_to_chopper_parameters(parameters: dict):
|
restage/instr.py
CHANGED
|
@@ -6,10 +6,9 @@ from __future__ import annotations
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from typing import Union
|
|
8
8
|
from mccode_antlr.instr import Instr
|
|
9
|
-
from mccode_antlr.reader import Registry
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
def load_instr(filepath: Union[str, Path]
|
|
11
|
+
def load_instr(filepath: Union[str, Path]) -> Instr:
|
|
13
12
|
"""Loads an Instr object from a .instr file or a HDF5 file"""
|
|
14
13
|
from mccode_antlr.io import load_hdf5
|
|
15
14
|
from mccode_antlr.loader import load_mcstas_instr
|
|
@@ -19,23 +18,10 @@ def load_instr(filepath: Union[str, Path], extra_registries: list[Registry] | No
|
|
|
19
18
|
if not filepath.exists() or not filepath.is_file():
|
|
20
19
|
raise ValueError('The provided filepath does not exist or is not a file')
|
|
21
20
|
|
|
22
|
-
# FIXME this hack should be removed ASAP
|
|
23
|
-
if extra_registries is None:
|
|
24
|
-
from mccode_antlr.reader import GitHubRegistry
|
|
25
|
-
mcpl_input_once_registry = GitHubRegistry(
|
|
26
|
-
name='mcpl_input_once',
|
|
27
|
-
url='https://github.com/g5t/mccode-mcpl-input-once',
|
|
28
|
-
version='main',
|
|
29
|
-
filename='pooch-registry.txt'
|
|
30
|
-
)
|
|
31
|
-
extra_registries = [mcpl_input_once_registry]
|
|
32
|
-
|
|
33
21
|
if filepath.suffix == '.instr':
|
|
34
|
-
return load_mcstas_instr(filepath
|
|
22
|
+
return load_mcstas_instr(filepath)
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
instr.registries += tuple(extra_registries)
|
|
38
|
-
return instr
|
|
24
|
+
return load_hdf5(filepath)
|
|
39
25
|
|
|
40
26
|
|
|
41
27
|
def collect_parameter_dict(instr: Instr, kwargs: dict, strict: bool = True) -> dict:
|
|
@@ -60,7 +46,7 @@ def collect_parameter_dict(instr: Instr, kwargs: dict, strict: bool = True) -> d
|
|
|
60
46
|
for k, v in kwargs.items():
|
|
61
47
|
if k not in parameters:
|
|
62
48
|
if strict:
|
|
63
|
-
raise ValueError(f"Parameter {k} is not a valid parameter name")
|
|
49
|
+
raise ValueError(f"Parameter {k} is not a valid parameter name. Valid names are: {', '.join(parameters)}")
|
|
64
50
|
continue
|
|
65
51
|
if not isinstance(v, Value):
|
|
66
52
|
expected_type = parameters[k].data_type
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
restage/__init__.py,sha256=v0dAUYVkvzjd3j6gjFdbunV_P8U9XxsGgLFGwbxBy6E,787
|
|
2
|
-
restage/bifrost_choppers.py,sha256=
|
|
3
|
-
restage/cache.py,sha256=
|
|
2
|
+
restage/bifrost_choppers.py,sha256=xQu21g2NcTLPpZ0ZWOuvN20zh07EWoO4QVoTnoORwZI,6443
|
|
3
|
+
restage/cache.py,sha256=Ea0e_hb8cN-PKFyyVXyIDo04UbWpcL5ytihzBo34QWQ,8491
|
|
4
4
|
restage/cspec_choppers.py,sha256=ZWxyCcwYn4z9ZNqj_r6RC9ImbhVjYc1fmv-Ijm8A2Yk,206
|
|
5
5
|
restage/database.py,sha256=pblHu8hCV5u3uyE8aUrnBSsfjDLYrxy9JRtnRuOvTXQ,9152
|
|
6
6
|
restage/emulate.py,sha256=VrhfZJIbECdbDS-MHklqRuAIy9cRkjZkwPBTKQSQoe0,6164
|
|
7
|
-
restage/energy.py,sha256=
|
|
8
|
-
restage/instr.py,sha256=
|
|
7
|
+
restage/energy.py,sha256=FeWyZj6BOH0Ao4BpS39lmZm7Znz-rESk2jTLeMEJpI4,2920
|
|
8
|
+
restage/instr.py,sha256=1Yx8WVQOke_gRj7dV4BYPHXuxT1xH8xMQR7k3c7Yp9M,2490
|
|
9
9
|
restage/mcpl.py,sha256=BZYxBytughjc8slR6gUaBy3D7gzo7Yl3ACXrXhWgagI,3403
|
|
10
10
|
restage/range.py,sha256=TjOf4DSKfgoAIcrWQvv6MrtksQpnGJHdsEjVI5K-UfI,8116
|
|
11
11
|
restage/run.py,sha256=nk8d7cIyIqSt-5pyGm68Zak5H1a-fbo_z2_36eN-08E,1481
|
|
12
12
|
restage/scan.py,sha256=Yx8OQSBG6I2_64sW0LIDb0glVKwWoxUQQznASXgDZFQ,1432
|
|
13
13
|
restage/splitrun.py,sha256=dAwDFz_KShB_OWlmARxpHyCfGhBYNuEyujveuAuS74g,25800
|
|
14
14
|
restage/tables.py,sha256=oxHc9TdTVPBC6ZlQUQdoNzlo4CyvPp-pfijK81eAK28,16053
|
|
15
|
-
restage-0.4.
|
|
16
|
-
restage-0.4.
|
|
17
|
-
restage-0.4.
|
|
18
|
-
restage-0.4.
|
|
19
|
-
restage-0.4.
|
|
15
|
+
restage-0.4.1.dist-info/METADATA,sha256=7txXTXEZ9UhtEGiXmX7o6voa58v6Jn-nsRXOTJXJ63M,5112
|
|
16
|
+
restage-0.4.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
17
|
+
restage-0.4.1.dist-info/entry_points.txt,sha256=gghocSxC2gHHxUCalAibCN1mtkh3trNmAfH5Qwx0KYg,149
|
|
18
|
+
restage-0.4.1.dist-info/top_level.txt,sha256=iM_pb-taTZ0S2WMoDnt_qDMZoNMjmM19z3tTCuVm1IE,8
|
|
19
|
+
restage-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|