Skip to content

Commit b680ea9

Browse files
authored
MNT fixes #150
1 parent 16d9c9a commit b680ea9

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

apstools/synApps_ophyd/swait.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def swait_setup_random_number(swait, **kw):
187187
swait.read_attrs = ['val',]
188188

189189

190-
def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
191-
"""setup swait for noisy Gaussian"""
190+
def _setup_peak_swait_(calc, desc, swait, motor, center=0, width=1, scale=1, noise=0.05):
191+
"""internal: setup that is common to both Gaussian and Lorentzian swaits"""
192192
# consider a noisy background, as well (needs a couple calcs)
193193
assert(isinstance(motor, EpicsMotor))
194194
assert(width > 0)
@@ -200,33 +200,38 @@ def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
200200
swait.channels.C.value.put(width)
201201
swait.channels.D.value.put(scale)
202202
swait.channels.E.value.put(noise)
203-
swait.calc.put("D*(0.95+E*RNDM)/exp(((A-b)/c)^2)")
203+
swait.calc.put(calc)
204204
swait.scan.put("I/O Intr")
205-
swait.desc.put("noisy Gaussian curve")
205+
swait.desc.put(desc)
206206

207207
swait.hints = {"fields": ['val',]}
208208
swait.read_attrs = ['val',]
209209

210210

211+
def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
212+
"""setup swait for noisy Gaussian"""
213+
_setup_peak_swait_(
214+
"D*(0.95+E*RNDM)/exp(((A-b)/c)^2)",
215+
"noisy Gaussian curve",
216+
swait,
217+
motor,
218+
center=center,
219+
width=width,
220+
scale=scale,
221+
noise=noise)
222+
223+
211224
def swait_setup_lorentzian(swait, motor, center=0, width=1, scale=1, noise=0.05):
212225
"""setup swait record for noisy Lorentzian"""
213-
# consider a noisy background, as well (needs a couple calcs)
214-
assert(isinstance(motor, EpicsMotor))
215-
assert(width > 0)
216-
assert(0.0 <= noise <= 1.0)
217-
swait.reset()
218-
swait.scan.put("Passive")
219-
swait.channels.A.input_pv.put(motor.user_readback.pvname)
220-
swait.channels.B.value.put(center)
221-
swait.channels.C.value.put(width)
222-
swait.channels.D.value.put(scale)
223-
swait.channels.E.value.put(noise)
224-
swait.calc.put("D*(0.95+E*RNDM)/(1+((A-b)/c)^2)")
225-
swait.scan.put("I/O Intr")
226-
swait.desc.put("noisy Lorentzian curve")
227-
228-
swait.hints = {"fields": ['val',]}
229-
swait.read_attrs = ['val',]
226+
_setup_peak_swait_(
227+
"D*(0.95+E*RNDM)/(1+((A-b)/c)^2)",
228+
"noisy Lorentzian curve",
229+
swait,
230+
motor,
231+
center=center,
232+
width=width,
233+
scale=scale,
234+
noise=noise)
230235

231236

232237
def swait_setup_incrementer(swait, scan=None, limit=100000):

0 commit comments

Comments
 (0)