Ejemplo n.º 1
0
            angfact = np.zeros(shape_unwrp)
            atany = np.zeros(shape_unwrp)
            atanx = np.zeros(shape_unwrp)
            org_phase = np.zeros(shape_unwrp)
            org_phase_plot = np.zeros(shape_unwrp) 
            org_unwr = np.zeros(shape_unwrp)

            #phase extraction
            angfact = delta_i[..., Un_sol[1]] - delta_i[..., Un_sol[0]]
            atany = Id_hat[..., Un_sol[0]]
            atanx = (Id_hat[..., Un_sol[1]] - np.cos(angfact) * Id_hat[..., Un_sol[0]]) / np.sin(angfact) ## sin needs to be added here for arctan2 to know the correct sign of y and x

            for k in range(len(Un_sol[0])):
                org_phase[..., k] = np.arctan2(atany[..., k], atanx[..., k])
                org_phase[..., k] = pw.filter_wrapped_phase(org_phase[..., k], k_phi[jjj])
                org_unwr[...,k] = pw.unwrap_phase_dct(org_phase[..., k], xx_alg, yy_alg, ii, jj, N, N)
                org_unwr[...,k] -= delta_i[..., Un_sol[0][k]]


            mask = [np.sqrt((xx_alg) ** 2 + (yy_alg) ** 2) >= 1]
            mask_tile = np.tile(mask, (org_phase.shape[-1],1,1)).T
            org_mask = np.ma.array(org_unwr, mask = mask_tile)
            mean_unwr = org_mask.mean(axis=(0,1))
            org_unwr -= mean_unwr
            org_med = np.median(org_unwr, axis = 2)
            org_med_flat = org_med[xy_inside]

            a_inter = np.linalg.lstsq(Zernike_2d, org_med_flat)[0]

            piston_mat[kkk, jjj], rms_mat[kkk, jjj] = opt.fmin(rms_piston, 0, args = (j_max, a_inter, N, Z_mat, orig, mask, flipint), full_output = True)[:2]
            #mins[kkk] = opt.fmin(rms_piston, 0, args = (j_max, a_inter, N, Z_mat, orig, mask, flipint))
Ejemplo n.º 2
0
    k_phi = 17  ## filtering window size
    f0 = 15
    n = 2
    butter_phase = np.zeros(org_phase.shape)
    butter_unwr = np.zeros(butter_phase.shape)
    [ny, nx] = butter_phase.shape[:2]
    res = [2**kji for kji in range(15)]
    nx_pad = np.where(res > np.tile(nx, len(res)))
    nx_pad = res[nx_pad[0][0]]
    dif_x = (nx_pad - int(nx)) / 2
    for k in range(org_phase.shape[-1]):
        org_pad = np.lib.pad(org_phase[..., k], dif_x, 'reflect')
        butter_pad = pw.butter_filter(org_pad, n, f0)
        butter_phase[..., k] = butter_pad[dif_x:nx_pad - dif_x,
                                          dif_x:nx_pad - dif_x]
        butter_unwr[..., k] = pw.unwrap_phase_dct(butter_phase[..., k], xx_alg,
                                                  yy_alg, ii, jj, N_int, N_int)
        butter_unwr[..., k] -= delta_i[..., Un_sol[0][k]]

    np.save(folder_name + "filtered_phase.npy", butter_unwr)
    np.save(folder_name + "delta_i.npy", delta_i)

    butter_mask = np.ma.array(butter_unwr, mask=mask_tile)
    mean_butt = butter_mask.mean(axis=(0, 1))
    butter_unwr -= mean_butt

    ## smoothing interferogram due to median
    but_med = np.median(butter_unwr, axis=2)
    but_med *= -1.0

    if flip_bool:
        but_med = np.fliplr(but_med)
Ejemplo n.º 3
0
##angfact = np.zeros(shape_unwrp)
##atany = np.zeros(shape_unwrp)
##atanx = np.zeros(shape_unwrp)
##org_phase = np.zeros(shape_unwrp)
##org_phase_plot = np.zeros(shape_unwrp)
org_unwr = np.zeros(shape_unwrp)
##
###phase extraction
##angfact = delta_i[..., Un_sol[1]] - delta_i[..., Un_sol[0]]
##atany = Id_hat[..., Un_sol[0]]
##atanx = (Id_hat[..., Un_sol[1]] - np.cos(angfact) * Id_hat[..., Un_sol[0]]) / np.sin(angfact) ## sin needs to be added here for arctan2 to know the correct sign of y and x

f, axarr = plt.subplots(1, org_phase.shape[-1], figsize=int_im_size)
for k in range(org_phase.shape[-1]):
    ##org_phase[..., k] = np.arctan2(atany[..., k], atanx[..., k])
    org_unwr[..., k] = pw.unwrap_phase_dct(org_phase[..., k], xx_alg, yy_alg,
                                           ii, jj, N, N)
    org_unwr[..., k] -= delta_i[..., Un_sol[0][k]]

## remove piston
mean_unwr = np.mean(org_unwr, axis=(0, 1))
org_unwr -= mean_unwr

## plot everything
for k in range(org_phase.shape[-1]):
    im = axarr[k].imshow(np.ma.array(org_unwr[..., k], mask=mask),
                         vmin=-10,
                         vmax=15)
    set_subplot_interferograms(axarr[k], i=k)
make_colorbar(f, im)
if choise == 'y':
    f.savefig(