Esempio n. 1
0
 def make_absEq(cls, gl):
     plot = gl.addAlignedPlot(labels={
         'left': 'ky (rad/mm)',
         'bottom': 'kx (rad/mm)'
     },
                              title='Angular space amplitude')
     image = pg.ImageItem(lut=pg.get_colormap_lut())
     plot.addItem(image)
     scatter = pg.ScatterPlotItem(**scatter_kwargs)
     plot.addItem(scatter)
     gl.addHorizontalSpacer(10)
     gl.addColorBar(image=image, rel_row=2, label='Amplitude')
     return plot, image, scatter
Esempio n. 2
0
def make_Er_image_item(r_support, Er, rs_center=(0, 0), quantity='waves'):
    x, y, Eru = sa.unroll_r(r_support, Er, rs_center)
    if quantity == 'amplitude':
        data = abs(Eru)
        lut = pg.get_colormap_lut()
        levels = 0, data.max()
    elif quantity == 'waves':
        data = np.angle(Eru)/(2*np.pi)
        lut = pg.get_colormap_lut('bipolar')
        levels = -0.5, 0.5
    item = pg.ImageItem(data, lut=lut)
    item.setRect(pg.axes_to_rect(x*1e3, y*1e3))
    item.setLevels(levels)
    return item
Esempio n. 3
0
 def make_wavesq(cls, gl, absEq_plot):
     plot = gl.addAlignedPlot(labels={
         'left': 'ky (rad/mm)',
         'bottom': 'kx (rad/mm)'
     },
                              title='Angular space wavefront')
     image = pg.ImageItem(lut=pg.get_colormap_lut('bipolar'))
     plot.addItem(image)
     plot.setXYLink(absEq_plot)
     scatter = pg.ScatterPlotItem(**scatter_kwargs)
     plot.addItem(scatter)
     gl.addHorizontalSpacer(10)
     gl.addColorBar(image=image, rel_row=2, label='Waves')
     return plot, image, scatter
Esempio n. 4
0
 def __init__(self,
              y_label='y',
              color_bar=True,
              symmetric_phase_colormap=False,
              luts=None,
              **kwargs):
     if luts is None:
         luts = {}
     super().__init__(**kwargs)
     intensity_plot = pg.add_right_axis(self.plots.intensity, 'k', y_label)
     phase_plot = pg.add_right_axis(self.plots.phase, 'k', y_label)
     phase_plot.setYLink(intensity_plot)
     self.image_plots = self.Pair(intensity_plot, phase_plot)
     intensity_image = pg.ImageItem(np.zeros((2, 2)),
                                    lut=luts.pop('intensity',
                                                 pg.get_colormap_lut()))
     intensity_plot.addItem(intensity_image)
     phase_image = pg.ImageItem(
         np.zeros((2, 2)),
         lut=luts.pop('phase', pg.get_colormap_lut('bipolar')))
     phase_plot.addItem(phase_image)
     self.images = self.Pair(intensity_image, phase_image)
     self.symmetric_phase_colormap = symmetric_phase_colormap
     if color_bar:
         self.gl.addHorizontalSpacer(30, row=self.row + 2, col=self.col + 3)
         # labels on color bar unnecessary
         self.gl.addColorBar(image=intensity_image,
                             row=self.row + 2,
                             col=self.col + 4)  # label=intensity_label,
         self.gl.addColorBar(image=phase_image,
                             row=self.row + 7,
                             col=self.col + 4)  # label=phase_label,
     # Seems necessary for autorange at startup
     self.plots.intensity.enableAutoRange()
     self.gl.currentRow = self.row  # +8
     self.gl.currentCol = self.col + 5
     self.image_annotations = self.Pair({}, {})
Esempio n. 5
0
"""
Check out how ImageItem behaves with nan values and how to make a mask e.g. to
grey out undefined phase values.
More investigation than testing.
"""
import numpy as np
import pyqtgraph_extended as pg
##
x=np.arange(100)
y=np.arange(120)[:,None]
f=np.exp(-((x-50)**2+(y-60)**2)/200)
fp=f.copy()
fp[0,0]=float('nan')
fp[f<0.2]=float('nan')
plt=pg.plot()
im=pg.ImageItem(fp)
im.setRect(pg.axes_to_rect(x,y))
im.setLookupTable(pg.get_colormap_lut())
im.setLevels((0,1))
plt.addItem(im)
##
f3=pg.makeARGB(f,pg.get_colormap_lut(),levels=(0,1),useRGBA=True)[0]#[:,:,[1,2,3,0]]
f3[f<0.1]=[128,128,128,128]
plt=pg.plot()
im=pg.ImageItem(f3)
im.setRect(pg.axes_to_rect(x,y))
#im.setLookupTable(pg.get_colormap_lut())
plt.addItem(im)
Esempio n. 6
0
    def __init__(self, parent=None):
        ProfileWidget.__init__(self, parent)

        combo_box = QtWidgets.QComboBox()
        self.field_combo_box = combo_box
        combo_box.addItem('true')
        combo_box.addItem('approximate planar')
        combo_box.addItem('approximate planar flattened')
        combo_box.currentIndexChanged.connect(self._update)

        check_box = QtWidgets.QCheckBox('Remove tilt')
        self.remove_tilt_check_box = check_box
        check_box.setChecked(True)
        check_box.stateChanged.connect(self._update)

        check_box = QtWidgets.QCheckBox('Remove constant')
        self.remove_constant_check_box = check_box
        check_box.setChecked(True)
        check_box.stateChanged.connect(self._update)

        glw = pg.GraphicsLayoutWidget()
        self.label = glw.addLabel()
        glw.nextRow()
        gl = glw.addLayout()
        absEr_plot, absEr_image, absEr_scatter = self.make_absEr(gl)
        gl.addHorizontalSpacer(10)
        wavesr_plot, wavesr_image, wavesr_scatter = self.make_wavesr(
            gl, absEr_plot)
        gl.addHorizontalSpacer(10)
        self.dz_plot = gl.addAlignedPlot(labels={
            'left': 'y (mm)',
            'bottom': 'x (mm)'
        })
        self.dz_image = pg.ImageItem(lut=pg.get_colormap_lut())
        self.dz_plot.addItem(self.dz_image)
        self.dz_plot.setXYLink(wavesr_plot)
        gl.addHorizontalSpacer(10)
        gl.addColorBar(image=self.dz_image, rel_row=2, label='Relative z (mm)')

        glw.nextRows()
        gl = glw.addLayout()
        absEq_plot, absEq_image, absEq_scatter = self.make_absEq(gl)
        gl.addHorizontalSpacer(10)
        wavesq_plot, wavesq_image, wavesq_scatter = self.make_wavesr(
            gl, absEq_plot)

        self.plots = sa.RQ(sa.AbsPhase(absEr_plot, wavesr_plot),
                           sa.AbsPhase(absEq_plot, wavesq_plot))
        self.images = sa.RQ(sa.AbsPhase(absEr_image, wavesr_image),
                            sa.AbsPhase(absEq_image, wavesq_image))
        self.scatters = sa.RQ(sa.AbsPhase(absEr_scatter, wavesr_scatter),
                              sa.AbsPhase(absEq_scatter, wavesq_scatter))

        # Place widgets.
        vbox = QtWidgets.QVBoxLayout()
        self.setLayout(vbox)
        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        hbox.addWidget(QtWidgets.QLabel('Mode:'))
        hbox.addWidget(self.field_combo_box)
        hbox.addWidget(QtWidgets.QLabel('Phase:'))
        hbox.addWidget(self.remove_tilt_check_box)
        hbox.addWidget(self.remove_constant_check_box)
        hbox.setAlignment(Qt.Qt.AlignLeft)
        vbox.addWidget(glw)