def rep_scan_1d( self, motor="", start=0.0, end=0.0, data_points=0, dwell_time=0.0, relative=True, counters=[], repetitions=1 ): """Perform a repeated 1D scan of motor in [start, end] of data_points :param motor: Motor to scan :param start: Relative scan starting position for motor1 :param end: Relative scan ending position for motor1 :param data_points: Number of data points to acquire :param dwell_time: Seconds at each point :param dwell_time: Seconds at each point """ try: motor = AliasedPV(motor) start = util.check_float(start) end = util.check_float(end) data_points = util.check_int(data_points) dwell_time = util.check_float(dwell_time) relative = util.check_bool(relative) repetitions = util.check_int(repetitions) except Exception as ex: print("Scan argument check failed: %s" % (ex,)) return False if relative: scan_type = "repdscan" else: scan_type = "repascan" m_name = self.core.get_aliased_name(motor) command = ( "%(scan_type)s %(m_name)s %(start)g %(end)g %(data_points)d %(dwell_time)g %(repetitions)d" % locals() ) pos0 = ECLIPositioner(motor, label=m_name) start_pos = pos0.current() pos0.array = np.linspace(start, end, data_points) if relative: pos0.array += start_pos pos0.array = np.array(list(pos0.array) * repetitions) print("Scan: %s from %g to %g (%d data points, %d repetitions)" % (motor, start, end, data_points, repetitions)) positioners = [pos0] counters = list(counters) counters.insert(0, pos0.get_counter()) return self.scan_run( positioners, dwell_time, command=command, counters=counters, detectors=[], dimensions=(data_points * repetitions,), )
def scan_2d( self, motor1="", start1=0.0, end1=0.0, points1=0, motor2="", start2=0.0, end2=0.0, points2=0, dwell_time=0.0, relative=True, ): """Perform a 2D scan of dimension (points1, points2): motor1 in [start1, end1], with points1 data points (inner loop, fast) motor2 in [start2, end2], with points2 data points (outer loop, slow) Scan relative to the starting position (dmesh) or utilizing absolute positions (amesh):: for motor2 = start2 to end2, step (end2-start2) / points2: for motor1 = start1 to end1, step (end1-start1) / points1: wait for [time] secs take data point :param motor1: Motor to scan :param start1: Relative scan starting position for motor1 :param end1: Relative scan ending position for motor1 :param points1: Number of data points for motor1 :param motor2: Motor 2 to scan :param start2: Relative scan starting position for motor2 :param points2: Number of data points for motor2 :param end2: Relative scan ending position for motor2 :param data_points: Number of data points to acquire :param dwell_time: Seconds at each point :returns: the scan instance """ # TODO merge this into scan_nd try: motor1 = AliasedPV(motor1) start1 = util.check_float(start1) end1 = util.check_float(end1) points1 = util.check_int(points1) motor2 = AliasedPV(motor2) start2 = util.check_float(start2) end2 = util.check_float(end2) points2 = util.check_int(points2) dwell_time = util.check_float(dwell_time) relative = util.check_bool(relative) except Exception as ex: print("Scan argument check failed: %s" % (ex,)) return False if relative: scan_type = "dmesh" else: scan_type = "amesh" m1_name = self.core.get_aliased_name(motor1) m2_name = self.core.get_aliased_name(motor2) command = ( "%(scan_type)s %(m1_name)s %(start1)g %(end1)g %(points1)d %(m2_name)s %(start2)g %(end2)g %(points2)d %(dwell_time)g" % locals() ) # Positioner 1 - 'fast' inner loop pos1 = ECLIPositioner(motor1, label=m1_name) pos1.array = np.array(points2 * [np.linspace(start1, end1, points1)]).flatten() if relative: pos1.array += pos1.current() # Positioner 2 - 'slow' outer loop pos2 = ECLIPositioner(motor2, label=m2_name) pos2.array = np.array([[i] * points1 for i in np.linspace(start2, end2, points2)]).flatten() if relative: pos2.array += pos2.current() dimensions = (points1, points2) print("Inner: %s from %g to %g (%d data points)" % (motor1, start1, end1, points1)) print("Outer: %s from %g to %g (%d data points)" % (motor2, start2, end2, points2)) print("Dimensions: %s (total points=%d)" % (dimensions, points1 * points2)) positioners = (pos1, pos2) counters = [pos.get_counter() for pos in positioners] return self.scan_run( positioners, dwell_time, command=command, counters=counters, detectors=[], dimensions=dimensions )