Exemple #1
0
def simulate_alignment(
    beam_a_direction, beam_b_direction, beam_a_intercept, separation,
    samples=25, calibration_file=None):
  """Return the beam construction parameters and an itop.Alignment of the
  simulated beams."""
  alignment = DataAlignment(calibration_file)
  ray_a = Ray(beam_a_direction, beam_a_intercept)
  ray_a = Ray(beam_a_direction, ray_a.sample(150))

  ray_b = Ray(beam_b_direction,
      np.array(beam_a_intercept) + np.array(separation))
  ray_b = Ray(beam_b_direction, ray_b.sample(150))
  beam_a = DataBeam()
  beam_b = DataBeam()

  for tracker_z in np.arange(125, -95, -220/samples).tolist() + [-95]:
    beam_a.add_sample(ray_a.sample(tracker_z))
    beam_b.add_sample(ray_b.sample(tracker_z))
  alignment.beams = [beam_a, beam_b]
  alignment.displacements = [
      alignment.beams[index].intercept - alignment.beams[0].intercept
      for index in range(2)]
  return alignment
Exemple #2
0
def simulate_data(
    start, stop, step, mirror_height, calibration,
    mirror_parameters=None, beam_a_parameters=None, beam_b_parameters=None):
  """Return a sample of simulated raw data on the half-open interval
  [start, stop) of mirror stage positions. Each sample is spaced by
  'step' mm. The mirror is positioned at a height 'mirror_height' with respect
  to the mirror calibration point. The mirror calibration must be specified to
  correctly position the mirror with respect to the tracker.

  By default, this function simulates perfectly parallel beams, separated by
  [-50, -5, 0] with no jitter impinging upon a R=7000mm itop mirror on a stage
  with no wobble.

  The mirror and beam parameters can be substituted by passing dictionaries to
  the appropriate keyword arguments. The content of the dictionaries for
  mirror and beam parameters must reflect the required and optional arguments
  to raytrace.ItopMirror() and raytrace.Beam() respectively. See those objects
  for available parameters.

  Beam parameters are expressed in the tracker coordinate frame.
  """
  if mirror_parameters is None:
    mirror_parameters = {
        'radius':7000,
        'dimensions':[440, 20, 20],
        }
  if beam_a_parameters is None:
    beam_a_parameters = {
        'initial_direction': [0, 0, -1],
        'initial_position': [122, 0, 150]
        }
  if beam_b_parameters is None:
    beam_b_parameters = {
        'initial_direction': [0, 0, -1],
        'initial_position': [72, -5, 150],
        }

  data = []
  mirror = ItopMirror(**mirror_parameters)
  # Move the mirror to the mirror calibration point in the tracker
  # frame (tracker_cal - mirror_cal)
  mirror.translate(array(calibration))
  mirror.translate([start - step, mirror_height, 0])
  for mirror_stage_position in np.arange(start, stop, step):
    # For a given mirror position, the mirror stage is translated in the
    # opposite direction.
    mirror.translate([step, 0, 0])
    simulated_beam_a = Beam(**beam_a_parameters)
    simulated_beam_a.propagate([mirror])
    simulated_beam_b = Beam(**beam_b_parameters)
    simulated_beam_b.propagate([mirror])
    beam_a = DataBeam()
    beam_b = DataBeam()
    for z_coordinate in np.arange(-95., 125., 220./5.).tolist() + [125.]:
      beam_a.add_sample(simulated_beam_a.ray().sample(z_coordinate))
      beam_b.add_sample(simulated_beam_b.ray().sample(z_coordinate))
    data.append(
        DataPoint(
            [mirror_stage_position, mirror_height, 0],
            [beam_a, beam_b]))
  return data