def test_small_test_data_ref_chipsize_15(self): refx, refy = run_pyrate.ref_pixel_calc(self.ifg_paths, self.params_chipsize_15) self.assertEqual(refx, 7) self.assertEqual(refy, 7) self.assertAlmostEqual(0.5, self.params_alt_ref_frac[cf.REF_MIN_FRAC])
def test_more_small_test_data_ref_pixel(self): refx, refy = run_pyrate.ref_pixel_calc(self.ifg_paths, self.params_alt_ref_frac) self.assertEqual(refx, 38) self.assertEqual(refy, 58) self.assertAlmostEqual(0.5, self.params_alt_ref_frac[cf.REF_MIN_FRAC])
def setUpClass(cls): params = cf.get_config_params(common.TEST_CONF_ROIPAC) cls.temp_out_dir = tempfile.mkdtemp() sys.argv = ['run_prepifg.py', common.TEST_CONF_ROIPAC] params[cf.OUT_DIR] = cls.temp_out_dir run_prepifg.main(params) params[cf.REF_EST_METHOD] = 2 xlks, ylks, crop = cf.transform_params(params) base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST]) dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks) # start run_pyrate copy ifgs = shared.pre_prepare_ifgs(dest_paths, params) mst_grid = common.mst_calculation(dest_paths, params) refx, refy = run_pyrate.ref_pixel_calc(dest_paths, params) # Estimate and remove orbit errors pyrate.orbital.remove_orbital_error(ifgs, params) ifgs = common.prepare_ifgs_without_phase(dest_paths, params) _, ifgs = rpe.estimate_ref_phase(ifgs, params, refx, refy) maxvar = [vcm.cvd(i, params)[0] for i in ifgs] vcmt = vcm.get_vcmt(ifgs, maxvar) params[cf.TIME_SERIES_METHOD] = 1 params[cf.PARALLEL] = 0 # Calculate time series cls.tsincr_0, cls.tscum_0, _ = common.calculate_time_series( ifgs, params, vcmt, mst=mst_grid) params[cf.PARALLEL] = 1 cls.tsincr_1, cls.tscum_1, cls.tsvel_1 = \ common.calculate_time_series(ifgs, params, vcmt, mst=mst_grid) params[cf.PARALLEL] = 2 cls.tsincr_2, cls.tscum_2, cls.tsvel_2 = \ common.calculate_time_series(ifgs, params, vcmt, mst=mst_grid) # load the matlab data ts_dir = os.path.join(common.SML_TEST_DIR, 'matlab_time_series') tsincr_path = os.path.join(ts_dir, 'ts_incr_interp0_method1.csv') ts_incr = np.genfromtxt(tsincr_path) # the matlab tsvel return is a bit pointless and not tested here # tserror is not returned # tserr_path = os.path.join(SML_TIME_SERIES_DIR, # 'ts_error_interp0_method1.csv') # ts_err = np.genfromtxt(tserr_path, delimiter=',') tscum_path = os.path.join(ts_dir, 'ts_cum_interp0_method1.csv') ts_cum = np.genfromtxt(tscum_path) cls.ts_incr = np.reshape(ts_incr, newshape=cls.tsincr_0.shape, order='F') cls.ts_cum = np.reshape(ts_cum, newshape=cls.tscum_0.shape, order='F')
def test_small_test_data_ref_all_1(self): refx, refy = run_pyrate.ref_pixel_calc(self.ifg_paths, self.params_all_1s) self.assertAlmostEqual(0.7, self.params_all_1s[cf.REF_MIN_FRAC]) self.assertEqual(1, self.params_all_1s[cf.REFNX]) self.assertEqual(1, self.params_all_1s[cf.REFNY]) self.assertEqual(refx, 2) self.assertEqual(refy, 2)
def setUpClass(cls): params = cf.get_config_params(TEST_CONF_ROIPAC) cls.temp_out_dir = tempfile.mkdtemp() sys.argv = ['run_prepifg.py', TEST_CONF_ROIPAC] params[cf.OUT_DIR] = cls.temp_out_dir params[cf.REF_EST_METHOD] = 2 run_prepifg.main(params) xlks, ylks, crop = cf.transform_params(params) base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST]) dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks) ifgs = shared.pre_prepare_ifgs(dest_paths, params) refx, refy = run_pyrate.ref_pixel_calc(dest_paths, params) pyrate.orbital.remove_orbital_error(ifgs, params) ifgs = prepare_ifgs_without_phase(dest_paths, params) _, ifgs = rpe.estimate_ref_phase(ifgs, params, refx, refy) # Calculate interferogram noise cls.maxvar = [cvd(i, params)[0] for i in ifgs] cls.vcmt = get_vcmt(ifgs, cls.maxvar)
def setUpClass(cls): params = cf.get_config_params(common.TEST_CONF_ROIPAC) cls.temp_out_dir = tempfile.mkdtemp() sys.argv = ['run_prepifg.py', common.TEST_CONF_ROIPAC] params[cf.OUT_DIR] = cls.temp_out_dir run_prepifg.main(params) params[cf.OUT_DIR] = cls.temp_out_dir params[cf.REF_EST_METHOD] = 2 params[cf.PARALLEL] = False xlks, ylks, crop = cf.transform_params(params) base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST]) dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks) # start run_pyrate copy ifgs = shared.pre_prepare_ifgs(dest_paths, params) mst_grid = tests.common.mst_calculation(dest_paths, params) # Estimate reference pixel location refx, refy = run_pyrate.ref_pixel_calc(dest_paths, params) # Estimate and remove orbit errors pyrate.orbital.remove_orbital_error(ifgs, params) for i in ifgs: i.close() ifgs = shared.pre_prepare_ifgs(dest_paths, params) cls.ref_phs, cls.ifgs = estimate_ref_phase(ifgs, params, refx, refy) # end run_pyrate copy for i in ifgs: i.close()
def test_vcm_matlab_vs_mpi(mpisync, tempdir, get_config): from tests.common import SML_TEST_DIR, TEST_CONF_ROIPAC params_dict = get_config(TEST_CONF_ROIPAC) MATLAB_VCM_DIR = os.path.join(SML_TEST_DIR, 'matlab_vcm') matlab_vcm = np.genfromtxt(os.path.join(MATLAB_VCM_DIR, 'matlab_vcmt.csv'), delimiter=',') if mpiops.rank == 0: outdir = tempdir() else: outdir = None outdir = mpiops.comm.bcast(outdir, root=0) params_dict[cf.OUT_DIR] = outdir params_dict[cf.PARALLEL] = False xlks, ylks, crop = cf.transform_params(params_dict) base_unw_paths = cf.original_ifg_paths(params_dict[cf.IFG_FILE_LIST]) # dest_paths are tifs that have been geotif converted and multilooked dest_paths = cf.get_dest_paths(base_unw_paths, crop, params_dict, xlks) # run prepifg, create the dest_paths files if mpiops.rank == 0: run_prepifg.roipac_prepifg(base_unw_paths, params_dict) mpiops.comm.barrier() tiles = run_pyrate.get_tiles(dest_paths[0], rows=1, cols=1) preread_ifgs = run_pyrate.create_ifg_dict(dest_paths, params=params_dict, tiles=tiles) refpx, refpy = run_pyrate.ref_pixel_calc(dest_paths, params_dict) run_pyrate.orb_fit_calc(dest_paths, params_dict) run_pyrate.ref_phase_estimation(dest_paths, params_dict, refpx, refpy) maxvar, vcmt = run_pyrate.maxvar_vcm_calc(dest_paths, params_dict, preread_ifgs) np.testing.assert_array_almost_equal(maxvar, matlab_maxvar, decimal=4) np.testing.assert_array_almost_equal(matlab_vcm, vcmt, decimal=3) if mpiops.rank == 0: shutil.rmtree(outdir)
def setUpClass(cls): params = cf.get_config_params(TEST_CONF_ROIPAC) cls.temp_out_dir = tempfile.mkdtemp() sys.argv = ['run_prepifg.py', TEST_CONF_ROIPAC] params[cf.OUT_DIR] = cls.temp_out_dir params[cf.TMPDIR] = os.path.join(params[cf.OUT_DIR], cf.TMPDIR) shared.mkdir_p(params[cf.TMPDIR]) run_prepifg.main(params) params[cf.REF_EST_METHOD] = 2 xlks, _, crop = cf.transform_params(params) base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST]) dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks) # start run_pyrate copy ifgs = shared.pre_prepare_ifgs(dest_paths, params) mst_grid = tests.common.mst_calculation(dest_paths, params) refx, refy = run_pyrate.ref_pixel_calc(dest_paths, params) # Estimate and remove orbit errors pyrate.orbital.remove_orbital_error(ifgs, params) ifgs = prepare_ifgs_without_phase(dest_paths, params) _, ifgs = rpe.estimate_ref_phase(ifgs, params, refx, refy) maxvar = [vcm_module.cvd(i, params)[0] for i in ifgs] vcmt = vcm_module.get_vcmt(ifgs, maxvar) # Calculate linear rate map params[cf.PARALLEL] = 1 cls.rate, cls.error, cls.samples = tests.common.calculate_linear_rate( ifgs, params, vcmt, mst_mat=mst_grid) params[cf.PARALLEL] = 2 cls.rate_2, cls.error_2, cls.samples_2 = \ tests.common.calculate_linear_rate(ifgs, params, vcmt, mst_mat=mst_grid) params[cf.PARALLEL] = 0 # Calculate linear rate map cls.rate_s, cls.error_s, cls.samples_s = \ tests.common.calculate_linear_rate(ifgs, params, vcmt, mst_mat=mst_grid) matlab_linrate_dir = os.path.join(SML_TEST_DIR, 'matlab_linrate') cls.rate_matlab = np.genfromtxt(os.path.join(matlab_linrate_dir, 'stackmap.csv'), delimiter=',') cls.error_matlab = np.genfromtxt(os.path.join(matlab_linrate_dir, 'errormap.csv'), delimiter=',') cls.samples_matlab = np.genfromtxt(os.path.join( matlab_linrate_dir, 'coh_sta.csv'), delimiter=',')