def _linrate_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): """ MPI wrapper for linrate calculation """ process_tiles = mpiops.array_split(tiles) log.info('Calculating linear rate map') output_dir = params[cf.TMPDIR] for t in process_tiles: log.info('Calculating linear rate of tile {}'.format(t.index)) ifg_parts = [shared.IfgPart(p, t, preread_ifgs) for p in ifg_paths] mst_grid_n = np.load(os.path.join(output_dir, 'mst_mat_{}.npy'.format(t.index))) rate, error, samples = linrate.linear_rate(ifg_parts, params, vcmt, mst_grid_n) # declare file names np.save(file=os.path.join(output_dir, 'linrate_{}.npy'.format(t.index)), arr=rate) np.save(file=os.path.join(output_dir, 'linerror_{}.npy'.format(t.index)), arr=error) np.save(file=os.path.join(output_dir, 'linsamples_{}.npy'.format(t.index)), arr=samples) mpiops.comm.barrier()
def linrate_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): """ MPI capable linrate calculation. :param ifg_paths: List of interferogram paths :param params: Parameters dictionary corresponding to config file :param vcmt: vcmt array :param tiles: List of all tiles used during MPI processes :param preread_ifgs: Dictionary containing interferogram characteristics for efficient computing :return xxxx """ process_tiles = mpiops.array_split(tiles) log.info('Calculating linear rate') output_dir = params[cf.TMPDIR] for t in process_tiles: log.info('calculating lin rate of tile {}'.format(t.index)) ifg_parts = [shared.IfgPart(p, t, preread_ifgs) for p in ifg_paths] mst_grid_n = np.load( os.path.join(output_dir, 'mst_mat_{}.npy'.format(t.index))) rate, error, samples = linrate.linear_rate(ifg_parts, params, vcmt, mst_grid_n) # declare file names np.save(file=os.path.join(output_dir, 'linrate_{}.npy'.format(t.index)), arr=rate) np.save(file=os.path.join(output_dir, 'linerror_{}.npy'.format(t.index)), arr=error) np.save(file=os.path.join(output_dir, 'linsamples_{}.npy'.format(t.index)), arr=samples) mpiops.comm.barrier()
def calculate_linear_rate(ifgs, params, vcmt, mst_mat=None): # log.info('Calculating linear rate') res = linrate.linear_rate(ifgs, params, vcmt, mst_mat) for r in res: if r is None: raise ValueError('TODO: bad value') rate, error, samples = res write_linrate_tifs(ifgs, params, res) # log.info('Linear rate calculated') return rate, error, samples
def test_linear_rate(self): # Simple test with one pixel and equal weighting exprate = array([[5.0]]) experr = array([[0.836242010007091]]) # from Matlab Pirate expsamp = array([[5]]) vcmt = eye(6, 6) mst = ones((6, 1, 1)) mst[4] = 0 params = default_params() rate, error, samples = linear_rate(self.ifgs, params, vcmt, mst) assert_array_almost_equal(rate, exprate) assert_array_almost_equal(error, experr) assert_array_almost_equal(samples, expsamp)