def save_ref_pixel_blocks(grid, half_patch_size, ifg_paths, params): """ xxxx :param grid: List of tuples (y, x) corresponding reference pixel grids :param half_patch_size: Patch size in pixels corresponding to reference pixel grids :param ifg_paths: List of interferogram paths :param params: Parameters dictionary corresponding to config file :return xxxx """ log.info('Saving ref pixel blocks') outdir = params[cf.TMPDIR] for pth in ifg_paths: ifg = Ifg(pth) ifg.open(readonly=True) ifg.nodata_value = params[cf.NO_DATA_VALUE] ifg.convert_to_nans() ifg.convert_to_mm() for y, x in grid: data = ifg.phase_data[y - half_patch_size:y + half_patch_size + 1, x - half_patch_size:x + half_patch_size + 1] data_file = join( outdir, 'ref_phase_data_{b}_{y}_{x}.npy'.format( b=os.path.basename(pth).split('.')[0], y=y, x=x)) np.save(file=data_file, arr=data) ifg.close() log.info('Saved ref pixel blocks')
def _phase_sum(ifg_paths, params): """ Save phase data and phase sum used in the reference phase estimation """ p_paths = mpiops.array_split(ifg_paths) ifg = Ifg(p_paths[0]) ifg.open(readonly=True) shape = ifg.shape phs_sum = np.zeros(shape=shape, dtype=np.float64) ifg.close() for d in p_paths: ifg = Ifg(d) ifg.open() ifg.nodata_value = params[cf.NO_DATA_VALUE] phs_sum += ifg.phase_data ifg.close() if mpiops.rank == MASTER_PROCESS: phase_sum_all = phs_sum # loop is better for memory for i in range(1, mpiops.size): # pragma: no cover phs_sum = np.zeros(shape=shape, dtype=np.float64) mpiops.comm.Recv(phs_sum, source=i, tag=i) phase_sum_all += phs_sum comp = np.isnan(phase_sum_all) # this is the same as in Matlab comp = np.ravel(comp, order='F') # this is the same as in Matlab else: # pragma: no cover comp = None mpiops.comm.Send(phs_sum, dest=0, tag=mpiops.rank) comp = mpiops.comm.bcast(comp, root=0) return comp