Skip to content

Commit

Permalink
Fix #79: add scan_from_param and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Vogelgesang committed Oct 3, 2013
1 parent c2c803d commit 7d2870b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions concert/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ def scan(param, feedback, minimum=None, maximum=None, intervals=64,
return (xss, yss)


def scan_from_param(scan_param, feedback_param,
minimum=None, maximum=None, intervals=64,
convert=lambda x: x):
"""Convenience function to scan one parameter and measure another.
Scan the *scan_param* object and measure *feedback_param* at each of the
*intervals* steps between *minimum* and *maximum*.
Returns a tuple *(x, y)* with scanned parameter and measured values.
"""
def feedback():
return feedback_param.get().result()

return scan(scan_param, feedback, minimum, maximum, intervals, convert)


def ascan(param_list, n_intervals, handler, initial_values=None):
"""
For each of the *n_intervals* and for each of the *(parameter, start,
Expand Down
7 changes: 6 additions & 1 deletion concert/tests/integration/processes/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from concert.tests import assert_almost_equal
from concert.devices.motors.dummy import Motor as DummyMotor
from concert.devices.cameras.dummy import Camera
from concert.processes import scan, ascan, dscan
from concert.processes import scan, ascan, dscan, scan_from_param
from concert.tests import slow
from concert.tests.base import ConcertTest

Expand Down Expand Up @@ -49,3 +49,8 @@ def feedback():
x, y = scan(self.motor['position'], feedback,
1 * q.mm, 10 * q.mm, 10).result()
compare_sequences(x, y, self.assertEqual)

def test_scan_from_param(self):
p = self.motor['position']
x, y = scan_from_param(p, p, 1 * q.mm, 10 * q.mm, 10).result()
compare_sequences(x, y, self.assertEqual)

2 comments on commit 7d2870b

@tfarago
Copy link
Contributor

@tfarago tfarago commented on 7d2870b Oct 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, how about scan_param_feedback? The "from" is a bit confusing for me. How is this so hard to come up with?! Let's call it foo... :-)

@matze
Copy link
Contributor

@matze matze commented on 7d2870b Oct 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, I'll update that. And a good question: probably because we are not in a creative business ;-)

Please sign in to comment.