Ejemplo n.º 1
0
 def _measure_tilt(self, tracker, mirror):
   """Establish the input face normal of a tilted mirror."""
   if mirror is None:
     raise AlignmentError('Mirror argument must be provided.')
   else:
     print 'Measuring mirror tilt.'
   # FIXME: The mirror should reliably place where the CCD cannot
   #     see the main reflection.
   mirror.position(self.beams[0].intercept[0]-50, wait=True)
   tracker.power_index = 1
   #TODO: Catch errors and remind user to reset CCD settings.
   raw_input("Set CCD shutter to >1ms with gain 1. Press Enter when ready.")
   self.front_reflections = []
   start_point = [tracker.axes[0].limits.upper,
                  self.beams[0].last_sample()[1],
                  tracker.axes[2].limits.lower]
   expose_single_beam(
       tracker.devices['driver'], 0, self.beam_count())
   self.front_reflections.append(
       tracker.find_beam_trajectory(
           start_point, -1, 1, z_samples=25))
   self.mirror_normal = optics.reflection_normal(
       self.front_reflections[0].direction, -self.beams[0].direction)
   tracker.power_index = None
   raw_input("Set CCD shutter to default setting 0.216ms with gain 1. Press Enter when ready.")
Ejemplo n.º 2
0
  def sample_position(self, mirror_x, start_point=None,
      x_scan_direction=1):
    """Returns the reflected beam trajectories with the mirror at the given
    mirror stage position.

    Takes the optional keyword arguments.
      start_point (None):
        Start the scan at a position given by the coordinates in the form
        [x, y, z]. By default, the start point is determined from the
        stage limits.

      x_scan_direction (1):
        The direction to scan for the beam in x.

    """
    self.mirror.position(mirror_x, wait=True)
    tracked_beams = []
    if start_point is None:
      start_point, x_scan_direction = self._find_start_point(mirror_x)
    for beam_index, in_range in enumerate(
        tuple(self._beams_in_range(mirror_x))):
      if not in_range:
        print('Skipping Beam {}'.format(beam_index))
        tracked_beams.append(None)
        continue
      expose_single_beam(self.tracker.devices['driver'],
          beam_index,
          self.alignment.beam_count())
      time.sleep(0.25)
      tracked_beams.append(
          self.tracker.find_beam_trajectory(
              start_point,
              x_scan_direction,
              scan_direction_z=(1 if start_point[2] < 0 else -1),
              measure_power=True
              ))
      if tracked_beams[-1] is None:
        print('Failed to find beam {}.'.format(beam_index))
      start_point = self.tracker.position().array()
    self.data.append(
        DataPoint([self.mirror.position().value, self.input_y, 0],
                  tracked_beams))
    return self.data[-1]
Ejemplo n.º 3
0
  def align(self, tracker, home=False, tilted=False, mirror=None):
    """Establishes the alignment between the given tracker and the beams.

    Takes an optional keyword argument
    home (False): Recalibrates the rotation stage to it's home switch.

    """
    if tilted and mirror is None:
      raise AlignmentError(
          'Mirror axis must given as keyword argument to measure tilt.')

    print 'Measuring tracker alignment. This will take some time.'
    self.beams = []
    self.displacements = []
    tracker.devices['r_stage'].power_on()
    if home:
      tracker.devices['r_stage'].go_to_home(wait=True)
    tracker.rotate(180, wait=True)
    start_point = [tracker.axes[0].limits.upper,
                   tracker.axes[1].limits.upper - 8,
                   tracker.axes[2].limits.upper]
    z_direction = -1
    for beam_index in self.beam_indexes():
      if tilted and beam_index > 0:
        self.beams.append(self.beams[0])
        continue
      expose_single_beam(
          tracker.devices['driver'], beam_index, self.beam_count())
      self.beams.append(
          tracker.find_beam_trajectory(
            start_point, -1, z_direction, z_samples=25,
            measure_power=True))
      start_point = self.beams[-1].last_sample() + [-180, 0, 0]
      z_direction = -1 * z_direction
      self.displacements.append(
          self.beams[beam_index].intercept - self.beams[0].intercept)
    tracker.rotate(0, wait=True)
    if tilted:
      self._measure_tilt(tracker, mirror)
    self.date = datetime.datetime.now().isoformat()