随机矩阵放大的方式 生成相位数据集,用于相位展开
import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import zoom
import gc
from tqdm import tqdm
from zernike import RZerndef wrap_phase(phase):"""将相位包裹到[-π, π]区间"""return np.angle(np.exp(1j * phase))def clean_nan_values(arr):"""清理数组中的NaN值"""arr_copy = arr.copy()if np.any(np.isnan(arr_copy)):arr_copy = np.nan_to_num(arr_copy, nan=0.0)return arr_copydef fit_zernike_coefficients(phase, mask, n_coef=37):"""使用RZern对相位进行Zernike多项式拟合参数:phase: 相位图mask: 掩码n_coef: Zernike系