Blacked on 3.10

This commit is contained in:
Mohacsi Istvan 2022-11-29 17:03:42 +01:00
parent 3e5c951a14
commit f3a14ab8b4
3 changed files with 21 additions and 17 deletions

View File

@ -57,7 +57,7 @@ class SpmSim(SpmBase):
# Define normalized 2D gaussian
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
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
@ -73,10 +73,10 @@ class SpmSim(SpmBase):
beam = self._simFrame()
total = np.sum(beam) - np.sum(beam[24:48, :])
rnge = np.floor(np.log10(total) - 0.0)
s1 = np.sum(beam[0:16, :]) / 10**rnge
s2 = np.sum(beam[16:24, :]) / 10**rnge
s3 = np.sum(beam[40:48, :]) / 10**rnge
s4 = np.sum(beam[48:64, :]) / 10**rnge
s1 = np.sum(beam[0:16, :]) / 10 ** rnge
s2 = np.sum(beam[16:24, :]) / 10 ** rnge
s3 = np.sum(beam[40:48, :]) / 10 ** rnge
s4 = np.sum(beam[48:64, :]) / 10 ** rnge
self.s1w.set(s1).wait()
self.s2w.set(s2).wait()

View File

@ -87,7 +87,7 @@ class XbpmSim(XbpmBase):
# define normalized 2D gaussian
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
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
@ -103,10 +103,10 @@ class XbpmSim(XbpmBase):
beam = self._simFrame()
total = np.sum(beam)
rnge = np.floor(np.log10(total) - 0.0)
s1 = np.sum(beam[32:64, 32:64]) / 10**rnge
s2 = np.sum(beam[0:32, 32:64]) / 10**rnge
s3 = np.sum(beam[32:64, 0:32]) / 10**rnge
s4 = np.sum(beam[0:32, 0:32]) / 10**rnge
s1 = np.sum(beam[32:64, 32:64]) / 10 ** rnge
s2 = np.sum(beam[0:32, 32:64]) / 10 ** rnge
s3 = np.sum(beam[32:64, 0:32]) / 10 ** rnge
s4 = np.sum(beam[0:32, 0:32]) / 10 ** rnge
self.s1w.set(s1).wait()
self.s2w.set(s2).wait()

View File

@ -17,7 +17,8 @@ from ophyd import (
PseudoPositioner,
PseudoSingle,
PVPositioner,
Device, Signal,
Device,
Signal,
Component,
DynamicDeviceComponent,
Kind,
@ -208,6 +209,7 @@ class EnergyKev(VirtualEpicsSignalRO):
class CurrentSum(Signal):
"""Adds up four current signals from the parent"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.parent.ch1.subscribe(self._emit_value)
@ -215,10 +217,15 @@ class CurrentSum(Signal):
def _emit_value(self, **kwargs):
timestamp = kwargs.pop("timestamp", time.time())
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):
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
@ -230,9 +237,7 @@ class Bpm4i(Device):
ch2 = Component(EpicsSignalRO, "S3", auto_monitor=True, kind=Kind.omitted, name="ch2")
ch3 = Component(EpicsSignalRO, "S4", auto_monitor=True, kind=Kind.omitted, name="ch3")
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__":
@ -240,4 +245,3 @@ if __name__ == "__main__":
dut.wait_for_connection()
print(dut.read())
print(dut.describe())