Esempio n. 1
0
    def set(self,
            x,
            y,
            image,
            horz_proj=None,
            vert_proj=None,
            pen=pg.mkPen(),
            **kwargs):
        """Set image and projection data

        TODO: more flexibility and more consistent semantics with options on
            pyqtgraph plotting commands
        Args:
            x (vector of length m): the x axis
            y (vector of length n): the y axis
            image (mxn array): the image
            horz_proj (vector of length m): horizontal projection. If None, use
                sum over y axis of image
            vert_proj (vector of length n): vertical projection. If None, use
                sum over x axis of image
            pen: passed on to the projection setData methods
            lut: passed on to image setImage method
        """
        if any([x is None, y is None, image is None]):
            return
        x = x.squeeze()
        y = y.squeeze()
        if horz_proj is None:
            horz_proj = image.sum(1)
        if vert_proj is None:
            vert_proj = image.sum(0)
        self.image.setImage(image, autoLevels=False, **kwargs)
        self.image.setRect(pg.axes_to_rect(x, y))
        self.horz_proj.setData(x, horz_proj, pen=pen)
        self.vert_proj.setData(vert_proj, y, pen=pen)
Esempio n. 2
0
 def add_buffers(self, num, pen_style=pg.QtCore.Qt.SolidLine):
     pens = [
         pg.mkPen(color=col, style=pen_style)
         for col in ['r', 'g', 'b', 'm', 'c', 'y']
     ]
     ret = []
     for i in range(num):
         self.horz_buffers.append(self.plots['horz'].plot(pen=pens[i]))
         self.vert_buffers.append(self.plots['vert'].plot(pen=pens[i]))
         ret.append(len(self.horz_buffers) - 1)
     return ret  # returns indices of buffers that were just added (to be used in set_buffer_data())
Esempio n. 3
0
    def test_arb_trans():
        ##
        ht = QDHT(64)
        R = 5
        r = ht.points(R)
        k = ht.conj_points(R)
        Er = exp(-r**2 / 2)
        Ek = ht.transform(Er, R)
        Eka = ht.transform_to_arb(Er, R, k)
        assert np.allclose(Ek, Eka)
        Eka = ht.transform_to_arb(Er, R, mathx.reshape_vec(k, -3))
        assert np.allclose(Ek, Eka.squeeze()) and Eka.shape == (64, 1, 1)

        R = ht.j_Np1**0.5
        r = ht.points(R)
        k = ht.conj_points(R)
        Er = exp(-r**2 / 2)
        Erp = -r * exp(-r**2 / 2)
        plt = pg.plot(r, Erp, pen=pg.mkPen('b', width=10))
        plt.plot(k, ht.transform_to_arb(Er, R, k, deriv=1), pen='r')
Esempio n. 4
0
 def set_image(self,
               x,
               y,
               image,
               pen=pg.mkPen('k'),
               datetimestr=None,
               **kwargs):
     """
     Args:
         kwargs: passed on to image.setImage
     """
     if any([x is None, y is None, image is None]):
         return
     horz_proj = image.sum(1)
     vert_proj = image.sum(0)
     x = x.squeeze()
     y = y.squeeze()
     self.image.setImage(image, autoLevels=False, **kwargs)
     self.image.setRect(pg.axes_to_rect(x, y))
     self.hproj.setData(x, horz_proj, pen=pen)
     self.vproj.setData(vert_proj, y, pen=pen)
     if datetimestr is not None:
         self.image_cornertext.setText(datetimestr, color='00FF00')
Esempio n. 5
0
def plot(plt,x,y,color):
    plt.plot(x.squeeze(),y.real,pen=color)
    if np.iscomplexobj(y):
        plt.plot(x.squeeze(),y.imag,pen=pg.mkPen(color,style=pg.DashLine))
Esempio n. 6
0
 def set_ref_lines(self, x, y, hData, vData):
     x = x.squeeze()
     y = y.squeeze()
     self.vproj_ref.setData(vData, y, pen=pg.mkPen('g'))
     self.hproj_ref.setData(x, hData, pen=pg.mkPen('g'))
Esempio n. 7
0
 def set_log_lines(self, x, y, hData, vData):
     x = x.squeeze()
     y = y.squeeze()
     self.vproj_log.setData(vData, y, pen=pg.mkPen('b'))
     self.hproj_log.setData(x, hData, pen=pg.mkPen('b'))