def _add_background_windows_markers(self, windows_position): """ Plot the background windows associated with each X-ray lines. For X-ray lines, a black line links the left and right window with the average value in each window. Parameters ---------- windows_position: 2D array of float The position of the windows in energy. Each line corresponds to a X-ray lines. In a line, the two first value corresponds to the limit of the left window and the two last values corresponds to the limit of the right window. See also -------- estimate_background_windows, get_lines_intensity """ self._add_vertical_lines_groups(windows_position) ax = self.axes_manager.signal_axes[0] for bw in windows_position: # TODO: test to prevent slicing bug. To be reomved when fixed if ax.value2index(bw[0]) == ax.value2index(bw[1]): y1 = self.isig[bw[0]].data else: y1 = self.isig[bw[0]:bw[1]].mean(-1).data if ax.value2index(bw[2]) == ax.value2index(bw[3]): y2 = self.isig[bw[2]].data else: y2 = self.isig[bw[2]:bw[3]].mean(-1).data line = markers.line_segment(x1=(bw[0] + bw[1]) / 2., x2=(bw[2] + bw[3]) / 2., y1=y1, y2=y2, color='black') self.add_marker(line)
def _add_background_windows_markers(self, windows_position): """ Plot the background windows associated with each X-ray lines. For X-ray lines, a black line links the left and right window with the average value in each window. Parameters ---------- windows_position: 2D array of float The position of the windows in energy. Each line corresponds to a X-ray lines. In a line, the two first value corresponds to the limit of the left window and the two last values corresponds to the limit of the right window. See also -------- estimate_background_windows, get_lines_intensity """ self._add_vertical_lines_groups(windows_position) ax = self.axes_manager.signal_axes[0] for bw in windows_position: # TODO: test to prevent slicing bug. To be reomved when fixed if ax.value2index(bw[0]) == ax.value2index(bw[1]): y1 = self.isig[bw[0]].data else: y1 = self.isig[bw[0]:bw[1]].mean(-1).data if ax.value2index(bw[2]) == ax.value2index(bw[3]): y2 = self.isig[bw[2]].data else: y2 = self.isig[bw[2]:bw[3]].mean(-1).data line = markers.line_segment( x1=(bw[0] + bw[1]) / 2., x2=(bw[2] + bw[3]) / 2., y1=y1, y2=y2, color='black') self.add_marker(line, render_figure=False) self._render_figure(plot=['signal_plot'])