Exemplo n.º 1
0
 def evaluate_grid_dstn(self, x0, x1, y0, y1, cx, cy):
     '''
     [x0,x1): (int) X values to evaluate
     [y0,y1): (int) Y values to evaluate
     (cx,cy): (float) pixel center of the MoG
     '''
     from tractor.mix import c_gauss_2d_grid
     assert(self.D == 2)
     result = np.zeros((y1 - y0, x1 - x0))
     rtn = c_gauss_2d_grid(int(x0), int(x1), int(y0), int(y1), cx, cy,
                           self.amp, self.mean, self.var, result)
     if rtn == -1:
         raise RuntimeError('c_gauss_2d_grid failed')
     return Patch(x0, y0, result)
Exemplo n.º 2
0
            minradius = 12
        elif j == 14:
            var = np.array([[[0.5, -0.6], [-0.6, 1., ]], ])
            minradius = 4
        else:
            break

        print('args (approx1):', x0, x1, y0, y1,
              dx, dy, minval, amp, mean, var)
        rtn = c_gauss_2d_approx(x0, x1, y0, y1, dx, dy,
                                minval, amp, mean, var, result)
        if rtn == -1:
            raise RuntimeError('c_gauss_2d_approx failed')

        r2 = np.zeros((H, W))
        rtn = c_gauss_2d_grid(x0, x1, y0, y1, dx, dy, amp, mean, var, r2)
        if rtn == -1:
            raise RuntimeError('c_gauss_2d_grid failed')

        print('Max difference:', np.max(np.abs(r2 - result)))

        plt.clf()
        plt.subplot(1, 2, 1)
        plt.imshow(np.log10(np.maximum(minval * 1e-3, r2)),
                   interpolation='nearest', origin='lower')
        plt.colorbar()
        plt.title('Grid')

        plt.subplot(1, 2, 2)
        plt.imshow(np.log10(np.maximum(minval * 1e-3, result)),
                   interpolation='nearest', origin='lower')