Exemplo n.º 1
0
 def reg(imvec):
     return iu.regularizer(imvec,
                           nprior,
                           embed_mask,
                           flux,
                           im.xdim,
                           im.ydim,
                           im.psize,
                           rtype,
                           beam_size=20. * eh.RADPERUAS,
                           alpha_A=alpha_A,
                           norm_reg=True)
Exemplo n.º 2
0
                                          mask=mask)
    compare_floor = 1.0
    print(
        "Median Fractional Difference of DTFT/NFFT for chi^2 gradient of " +
        dtype,
        np.median(
            np.abs((chisq_dft_grad - chisq_nfft_grad) /
                   (np.abs(chisq_dft_grad) + compare_floor))))

# Testing the gradients of image regularization functions
prior = test_imvec * 0.0 + 1.0
prior = prior * np.sum(test_imvec) / np.sum(prior)
mask = [
    True,
] * len(test_imvec)
for reg in ['simple', 'gs', 'l1', 'tv', 'tv2']:
    dx = 1.e-12
    y0 = iu.regularizer(test_imvec, prior, mask, 1.0, im.xdim, im.ydim,
                        im.psize, reg)
    grad_exact = iu.regularizergrad(test_imvec, prior, mask, 1.0, im.xdim,
                                    im.ydim, im.psize, reg)
    grad = np.zeros(len(test_imvec))
    for j in range(len(test_imvec)):
        test_imvec2 = test_imvec.copy()
        test_imvec2[j] += dx
        y1 = iu.regularizer(test_imvec2, prior, mask, 1.0, im.xdim, im.ydim,
                            im.psize, reg)
        grad[j] = (y1 - y0) / dx
    print("Median Fractional Gradient Difference for " + reg + ":",
          np.median(np.abs((grad - grad_exact) / grad_exact)))
Exemplo n.º 3
0
nprior = nprior / np.sum(nprior)
embed_mask = mask
flux = im.total_flux() * 0.95  #not exactly equal to the total flux
alpha_A = 5000.0  #7.5

# Test the normalization of the regularizers
blur_im = im.blur_circ(20. * eh.RADPERUAS)
for rtype in iu.REGULARIZERS:
    print(
        rtype, 'norm_reg=False',
        iu.regularizer(blur_im.imvec,
                       nprior,
                       embed_mask,
                       flux,
                       im.xdim,
                       im.ydim,
                       im.psize,
                       rtype,
                       alpha_A=alpha_A,
                       beam_size=20. * eh.RADPERUAS,
                       norm_reg=False))
    print(
        rtype, 'norm_reg=True',
        iu.regularizer(blur_im.imvec,
                       nprior,
                       embed_mask,
                       flux,
                       im.xdim,
                       im.ydim,
                       im.psize,
                       rtype,