Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pyaml/lattice/abstract_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class BPMScalarAggregator(ScalarAggregator):
"""

def __init__(self, ring:at.Lattice):
self.__lattice = ring
self.__refpts = []
self.lattice = ring
self.refpts = []

def add_elem(self,elem:at.Element):
self.__refpts.append(self.__lattice.index(elem))
self.refpts.append(self.lattice.index(elem))

def set(self, value: NDArray[np.float64]):
pass
Expand All @@ -171,7 +171,7 @@ def set_and_wait(self, value: NDArray[np.float64]):
pass

def get(self) -> np.array:
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
return orbit[:, [0, 2]].flatten()

def readback(self) -> np.array:
Expand All @@ -182,24 +182,24 @@ def unit(self) -> str:

#------------------------------------------------------------------------------

class BPMVScalarAggregator(BPMScalarAggregator):
class BPMHScalarAggregator(BPMScalarAggregator):
"""
Vertical BPM simulator aggregator
"""

def get(self) -> np.array:
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
return orbit[:, 0]

#------------------------------------------------------------------------------

class BPMHScalarAggregator(BPMScalarAggregator):
class BPMVScalarAggregator(BPMScalarAggregator):
"""
Horizontal BPM simulator aggregator
"""

def get(self) -> np.array:
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
return orbit[:, 2]

#------------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion tests/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ def test_arrays(install_test_package):

# Test BPMs array

# Using aggragtor
# Using aggregator
pos = sr.design.get_bpms("BPMS").positions.get()
assert(np.abs(pos[0][0] + 7.21154171490481e-05)<1e-10)
assert(np.abs(pos[0][1] - 3.3988843436571406e-05)<1e-10)
assert(np.abs(pos[1][0] - 1.1681211772781844e-04)<1e-10)
assert(np.abs(pos[1][1] - 7.072972488250373e-06)<1e-10)

# Using aggregator (h and v)
pos_h = sr.design.get_bpms("BPMS").h.get()
pos_v = sr.design.get_bpms("BPMS").v.get()
assert np.all(np.isclose(pos[:, 0], pos_h, rtol=1e-15, atol=1e-15))
assert np.all(np.isclose(pos[:, 1], pos_v, rtol=1e-15, atol=1e-15))

# No aggregator
bpms = []
for b in sr.design.get_bpms("BPMS"):
Expand Down
Loading