Пример #1
0
    def close_scan(self):
        # go smoothly to start position
        if self._back_to_zero:
            print('\nGoing back to 0 V on scanners...')
            move_smooth(self._scanner_axes, targets=[0, 0])

        print(
            '\nSCAN COMPLETED\n' +
            'X from {:.2f} V to {:.2f} V with step size {:.2f} V (nb of steps: {})\n'
            .format(self.xPositions[0], self.xPositions[-1], self.xStep,
                    self.xNbOfSteps) +
            'Y from {:.2f} V to {:.2f} V with step size {:.2f} V (nb of steps: {})\n'
            .format(self.yPositions[0], self.yPositions[-1], self.yStep,
                    self.yNbOfSteps) +
            'Total number of steps: {}'.format(self.totalNbOfSteps))

        self.close_instruments()
Пример #2
0
    def initialize_scan(self):
        self.init_detectors(self._detectors)
        self.init_scanners(self._scanner_axes)

        print('Total number of steps: {}\n'.format(self.totalNbOfSteps) +
              'X number of steps:     {}\n'.format(self.xNbOfSteps) +
              'Y number of steps:     {}'.format(self.yNbOfSteps))

        self._start_time = 0
        self._first_point = True
        self._idx = 0
        self._id_x = 0
        self._id_y = 0
        self._firstInRow = True

        move_smooth(self._scanner_axes,
                    targets=[self.xPositions[0], self.yPositions[0]])

        print('\nScanners are at start position. Waiting for acquisition.\n')
        print('step \tx (V)\ty (V)')
Пример #3
0
    def run_scan(self,
                 close_instruments=True,
                 silence_errors=True,
                 do_move_smooth=True):

        try:
            self.init_detectors(self._detectors)
            self.init_scanners(self._scanner_axes)

            print('Total number of steps: {}\n'.format(self.totalNbOfSteps) +
                  'X number of steps:     {}\n'.format(self.xNbOfSteps) +
                  'Y number of steps:     {}'.format(self.yNbOfSteps))

            start_time = 0
            first_point = True
            idx = 0

            if do_move_smooth:
                move_smooth(self._scanner_axes,
                            targets=[self.xPositions[0], self.yPositions[0]])

            print(
                '\nScanners are at start position. Waiting for acquisition.\n')
            print('step \tx (V)\ty (V)')

            for id_y, y in enumerate(self.yPositions):
                firstInRow = True

                for id_x, x in enumerate(self.xPositions):
                    idx += 1

                    self._scanner_axes[0].move(x)
                    try:
                        self._scanner_axes[1].move(y)
                    except IndexError:
                        pass

                    # display update
                    print('{}/{} \t{:.1f} \t{:.1f}'.format(
                        idx, self.totalNbOfSteps, x, y))

                    # For first point may wait for a reaction
                    # (when acquisition is launched in WinSpec and the old Acton spectrometers)
                    if first_point:
                        self.wait_first_point(self._detectors)
                        start_time = time.time()
                        first_point = False
                    else:
                        if idx % 10 == 0:
                            self.print_elapsed_time(
                                start_time=start_time,
                                current_index=idx,
                                total_nb_of_steps=self.totalNbOfSteps)

                        # delay between rows
                        if firstInRow:
                            time.sleep(self.delayBetweenRows)
                            firstInRow = False

                        # delay between points
                        time.sleep(self.delayBetweenPoints)

                    # trigger exposure / detector measurement
                    if self._detectors is not None:
                        for i, detector in enumerate(self._detectors):
                            getattr(self, 'detector_readout_' +
                                    str(i))[id_x, id_y] = detector.readout()

                    time.sleep(
                        self.max_delay_after_readout
                    )  # some old devices will not react immediately to say they are integrating

                    # wait for detector to say it finished
                    self.wait_for_ready(self._detectors)

                # move back to first point of row smoothly
                if y != self.yPositions[-1]:
                    self._scanner_axes[0].move_smooth(
                        target=self.xPositions[0])

            # go smoothly to start position
            if do_move_smooth:
                if self._back_to_zero:
                    print('\nGoing back to 0 V on scanners...')
                    move_smooth(self._scanner_axes, targets=[0, 0])

            print(
                '\nSCAN COMPLETED\n' +
                'X from {:.2f} V to {:.2f} V with step size {:.2f} V (nb of steps: {})\n'
                .format(self.xPositions[0], self.xPositions[-1], self.xStep,
                        self.xNbOfSteps) +
                'Y from {:.2f} V to {:.2f} V with step size {:.2f} V (nb of steps: {})\n'
                .format(self.yPositions[0], self.yPositions[-1], self.yStep,
                        self.yNbOfSteps) +
                'Total number of steps: {}'.format(self.totalNbOfSteps))

        except KeyboardInterrupt:
            print('\n####  Program interrupted by user.  ####')
            close_instruments = True
        except:
            close_instruments = True
            if not silence_errors:
                raise
        finally:
            if close_instruments:
                print("Closing all instruments.")
                self.close_instruments()