Blacked on 3.10
This commit is contained in:
parent
3e5c951a14
commit
f3a14ab8b4
@ -57,7 +57,7 @@ class SpmSim(SpmBase):
|
|||||||
# Define normalized 2D gaussian
|
# Define normalized 2D gaussian
|
||||||
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
||||||
return np.exp(
|
return np.exp(
|
||||||
-((x - mx) ** 2.0 / (2.0 * sx**2.0) + (y - my) ** 2.0 / (2.0 * sy**2.0))
|
-((x - mx) ** 2.0 / (2.0 * sx ** 2.0) + (y - my) ** 2.0 / (2.0 * sy ** 2.0))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generator for dynamic values
|
# Generator for dynamic values
|
||||||
@ -73,10 +73,10 @@ class SpmSim(SpmBase):
|
|||||||
beam = self._simFrame()
|
beam = self._simFrame()
|
||||||
total = np.sum(beam) - np.sum(beam[24:48, :])
|
total = np.sum(beam) - np.sum(beam[24:48, :])
|
||||||
rnge = np.floor(np.log10(total) - 0.0)
|
rnge = np.floor(np.log10(total) - 0.0)
|
||||||
s1 = np.sum(beam[0:16, :]) / 10**rnge
|
s1 = np.sum(beam[0:16, :]) / 10 ** rnge
|
||||||
s2 = np.sum(beam[16:24, :]) / 10**rnge
|
s2 = np.sum(beam[16:24, :]) / 10 ** rnge
|
||||||
s3 = np.sum(beam[40:48, :]) / 10**rnge
|
s3 = np.sum(beam[40:48, :]) / 10 ** rnge
|
||||||
s4 = np.sum(beam[48:64, :]) / 10**rnge
|
s4 = np.sum(beam[48:64, :]) / 10 ** rnge
|
||||||
|
|
||||||
self.s1w.set(s1).wait()
|
self.s1w.set(s1).wait()
|
||||||
self.s2w.set(s2).wait()
|
self.s2w.set(s2).wait()
|
||||||
|
@ -87,7 +87,7 @@ class XbpmSim(XbpmBase):
|
|||||||
# define normalized 2D gaussian
|
# define normalized 2D gaussian
|
||||||
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
||||||
return np.exp(
|
return np.exp(
|
||||||
-((x - mx) ** 2.0 / (2.0 * sx**2.0) + (y - my) ** 2.0 / (2.0 * sy**2.0))
|
-((x - mx) ** 2.0 / (2.0 * sx ** 2.0) + (y - my) ** 2.0 / (2.0 * sy ** 2.0))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generator for dynamic values
|
# Generator for dynamic values
|
||||||
@ -103,10 +103,10 @@ class XbpmSim(XbpmBase):
|
|||||||
beam = self._simFrame()
|
beam = self._simFrame()
|
||||||
total = np.sum(beam)
|
total = np.sum(beam)
|
||||||
rnge = np.floor(np.log10(total) - 0.0)
|
rnge = np.floor(np.log10(total) - 0.0)
|
||||||
s1 = np.sum(beam[32:64, 32:64]) / 10**rnge
|
s1 = np.sum(beam[32:64, 32:64]) / 10 ** rnge
|
||||||
s2 = np.sum(beam[0:32, 32:64]) / 10**rnge
|
s2 = np.sum(beam[0:32, 32:64]) / 10 ** rnge
|
||||||
s3 = np.sum(beam[32:64, 0:32]) / 10**rnge
|
s3 = np.sum(beam[32:64, 0:32]) / 10 ** rnge
|
||||||
s4 = np.sum(beam[0:32, 0:32]) / 10**rnge
|
s4 = np.sum(beam[0:32, 0:32]) / 10 ** rnge
|
||||||
|
|
||||||
self.s1w.set(s1).wait()
|
self.s1w.set(s1).wait()
|
||||||
self.s2w.set(s2).wait()
|
self.s2w.set(s2).wait()
|
||||||
|
@ -17,7 +17,8 @@ from ophyd import (
|
|||||||
PseudoPositioner,
|
PseudoPositioner,
|
||||||
PseudoSingle,
|
PseudoSingle,
|
||||||
PVPositioner,
|
PVPositioner,
|
||||||
Device, Signal,
|
Device,
|
||||||
|
Signal,
|
||||||
Component,
|
Component,
|
||||||
DynamicDeviceComponent,
|
DynamicDeviceComponent,
|
||||||
Kind,
|
Kind,
|
||||||
@ -208,6 +209,7 @@ class EnergyKev(VirtualEpicsSignalRO):
|
|||||||
|
|
||||||
class CurrentSum(Signal):
|
class CurrentSum(Signal):
|
||||||
"""Adds up four current signals from the parent"""
|
"""Adds up four current signals from the parent"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.parent.ch1.subscribe(self._emit_value)
|
self.parent.ch1.subscribe(self._emit_value)
|
||||||
@ -215,10 +217,15 @@ class CurrentSum(Signal):
|
|||||||
def _emit_value(self, **kwargs):
|
def _emit_value(self, **kwargs):
|
||||||
timestamp = kwargs.pop("timestamp", time.time())
|
timestamp = kwargs.pop("timestamp", time.time())
|
||||||
self.wait_for_connection()
|
self.wait_for_connection()
|
||||||
self._run_subs(sub_type='value', timestamp=timestamp, obj=self)
|
self._run_subs(sub_type="value", timestamp=timestamp, obj=self)
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
total = self.parent.ch1.get() + self.parent.ch2.get() + self.parent.ch3.get() + self.parent.ch4.get()
|
total = (
|
||||||
|
self.parent.ch1.get()
|
||||||
|
+ self.parent.ch2.get()
|
||||||
|
+ self.parent.ch3.get()
|
||||||
|
+ self.parent.ch4.get()
|
||||||
|
)
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
|
||||||
@ -230,9 +237,7 @@ class Bpm4i(Device):
|
|||||||
ch2 = Component(EpicsSignalRO, "S3", auto_monitor=True, kind=Kind.omitted, name="ch2")
|
ch2 = Component(EpicsSignalRO, "S3", auto_monitor=True, kind=Kind.omitted, name="ch2")
|
||||||
ch3 = Component(EpicsSignalRO, "S4", auto_monitor=True, kind=Kind.omitted, name="ch3")
|
ch3 = Component(EpicsSignalRO, "S4", auto_monitor=True, kind=Kind.omitted, name="ch3")
|
||||||
ch4 = Component(EpicsSignalRO, "S5", auto_monitor=True, kind=Kind.omitted, name="ch4")
|
ch4 = Component(EpicsSignalRO, "S5", auto_monitor=True, kind=Kind.omitted, name="ch4")
|
||||||
sum = Component(CurrentSum, kind=Kind.hinted, name="sum", )
|
sum = Component(CurrentSum, kind=Kind.hinted, name="sum",)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -240,4 +245,3 @@ if __name__ == "__main__":
|
|||||||
dut.wait_for_connection()
|
dut.wait_for_connection()
|
||||||
print(dut.read())
|
print(dut.read())
|
||||||
print(dut.describe())
|
print(dut.describe())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user