Skip to content

Commit ab35f1d

Browse files
committed
Merge branch 'dev' of https://github.com/ocelot-collab/ocelot into dev
2 parents c7ec550 + a33e817 commit ab35f1d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ocelot/adaptors/tfs.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414

1515
def tfs_to_cell_and_optics(tfs_path):
16-
converter = MADXLatticeConverter(tfs_path)
17-
cell = converter.convert()
18-
optics = optics_from_tfs(converter.tfs)
16+
tfs_table = tfs.read(tfs_path)
17+
18+
cell = convert_tfs_lattice(tfs_table)
19+
optics = optics_from_tfs(tfs_table)
1920
return cell, optics
2021

2122
def optics_from_tfs(tfs_table):
@@ -53,9 +54,16 @@ def optics_from_tfs(tfs_table):
5354

5455
class UnsupportedMADXElementType(RuntimeError): pass
5556

57+
def convert_tfs_lattice(tfs_table, converter=None):
58+
if converter is None:
59+
converter = MADXLatticeConverter()
60+
61+
for row in tfs_table.itertuples():
62+
yield converter.dispatch(row)
63+
5664

5765
class MADXLatticeConverter:
58-
def _dispatch(self, row):
66+
def dispatch(self, row):
5967
etype = row.KEYWORD
6068
etypelow = etype.lower()
6169
try:

0 commit comments

Comments
 (0)