def radii_with_params(data, alignment, mirror_index, lab_index=N_AIR): """Return a list of the radii between beam_1 and beam_2 in the given data as a tuple (s, r) where s is the absolute separation distance in x and r is the radius. Any additional keyword arguments are passed on to the mirror normal reconstruction. """ matrix = rotation_matrix(alignment.beams[0].direction) input_directions = [-i.transform(matrix).direction for i in alignment.beams] beam_indexes = range(len(data[0].beams)) if alignment.front_reflections is None else [0] mirror_radii = [[] for i in beam_indexes] for item_1, data_1 in enumerate(data[:-1]): input_1 = alignment.input_positions(data_1.mirror_position) for data_2 in data[item_1 + 1:]: input_2 = alignment.input_positions(data_2.mirror_position) for beam_id in beam_indexes: if all([d.beams[beam_id] is not None for d in (data_1, data_2)]): mirror_radii[beam_id].append( (radius(data_1.beams[beam_id], input_1[beam_id], data_2.beams[beam_id], input_2[beam_id], input_directions[beam_id], mirror_index, lab_index, alignment.mirror_normal), _radius_parameters_list(data_1.beams[beam_id], input_1[beam_id], data_2.beams[beam_id], input_2[beam_id], input_directions[beam_id], mirror_index, lab_index, alignment.mirror_normal))) return mirror_radii
def realign(self, alignment): """Applies an alignment to the data point trajectories.""" offset = alignment.tracker_origin() - self.mirror_position matrix = rotation_matrix(-alignment.beams[0].direction) new_beams = [] for beam in self.beams: if beam is None: new_beams.append(None) else: new_beams.append((beam.translate(offset)).transform(matrix)) return DataPoint(self.mirror_position, new_beams)
def _generate_reflectance_plot(data, alignment, mirror_index, lab_index=N_AIR, normal_vector=None): """Plot the reflectance of the mirror as a function of beam input position. """ reflectivities = {} number_of_beams = 2 if alignment.front_reflections is None else 1 calibrated_input_beams = [ beam.transform(rotation_matrix(alignment.beams[0].direction)) for beam in alignment.beams] for index in range(number_of_beams): reflectivities[index] = {'i':[], 'r':[], 'e':[]} for sample in data: input_positions = alignment.input_positions( sample.mirror_position) for beam_index, reflected_beam in enumerate(sample.beams): if reflected_beam is None: continue r_value, r_error = reflectance( reflected_beam, calibrated_input_beams[beam_index], alignment, mirror_index, lab_index, normal_vector) reflectivities[beam_index]['i'].append(input_positions[beam_index][0]) reflectivities[beam_index]['r'].append(r_value) reflectivities[beam_index]['e'].append(max(r_error)) for index in reflectivities.keys(): plt.errorbar( reflectivities[index]['i'], reflectivities[index]['r'], reflectivities[index]['e'], marker='o', ls='None', color=BEAM_COLORS[index], label='Beam {}'.format(index)) plt.title('Reflectance') plt.legend(loc='best', numpoints=1) plt.ylabel("Reflectance") plt.xlabel("Input Position [mm]")
def _rotate_about_origin(self, angle, axis): """Rotate the surface by angle about an axis at the origin.""" matrix = rotation_matrix(angle, axis) self._center = matrix.dot(self._center)
def _rotate_about_origin(self, angle, axis): """Rotate the surface by angle about an axis at the origin.""" matrix = rotation_matrix(angle, axis) self._normal = matrix.dot(self._normal) self._position = matrix.dot(self._position)