Skip to content

Commit 83505e9

Browse files
committed
allow to specify use (=mat_key) for loading the lattice from the .mat file
1 parent 6fe0828 commit 83505e9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pySC/configuration/generation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ def generate_SC(yaml_filepath: str, seed: int = 1, scale_errors: Optional[int] =
3737
else:
3838
no_6d = False
3939

40+
if 'use' in config_dict['lattice']:
41+
use = config_dict['lattice']['use']
42+
else:
43+
use = 'RING'
44+
4045
print(f'Loading AT lattice from {lattice_file}')
41-
lattice = ATLattice(lattice_file=lattice_file, no_6d=no_6d)
46+
lattice = ATLattice(lattice_file=lattice_file, no_6d=no_6d, use=use)
4247
else:
4348
raise NotImplementedError(f"Simulator {config_dict['lattice']['simulator']} is not implemented.")
4449

pySC/core/lattice.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ class ATLattice(Lattice):
5151
# fake field so that pydantic can distinguish
5252
# the different machine types
5353
at_simulator: None = None
54+
use: str = 'RING'
5455
_ring: at.Lattice = PrivateAttr(default=None)
5556
_design: at.Lattice = PrivateAttr(default=None)
5657

5758
@model_validator(mode="after")
5859
def load_lattice(self):
59-
self._ring = at.load_mat(self.lattice_file)
60-
self._design = at.load_mat(self.lattice_file)
60+
self._ring = at.load_mat(self.lattice_file, use=self.use)
61+
self._design = at.load_mat(self.lattice_file, use=self.use)
6162

6263
if not self.no_6d:
6364
self._ring.enable_6d()

0 commit comments

Comments
 (0)