Exemple #1
0
    def setUpClass(cls):

        params = Configuration(TEST_CONF_ROIPAC).__dict__
        cls.temp_out_dir = tempfile.mkdtemp()
        sys.argv = ['prepifg.py', TEST_CONF_ROIPAC]
        params[cf.OUT_DIR] = cls.temp_out_dir
        params[cf.TMPDIR] = os.path.join(cls.temp_out_dir, cf.TMPDIR)
        shared.mkdir_p(params[cf.TMPDIR])
        params[cf.REF_EST_METHOD] = 2
        conv2tif.main(params)
        prepifg.main(params)
        cls.params = params
        xlks, ylks, crop = cf.transform_params(params)
        base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST],
                                               params[cf.OBS_DIR])
        dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks)
        ifgs = common.pre_prepare_ifgs(dest_paths, params)
        refx, refy = process._ref_pixel_calc(dest_paths, params)
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        _, cls.ifgs = process._ref_phase_estimation(dest_paths, params, refx, refy)
        ifgs[0].open()
        r_dist = RDist(ifgs[0])()
        ifgs[0].close()
        # Calculate interferogram noise
        cls.maxvar = [cvd(i, params, r_dist, calc_alpha=True,
                          save_acg=True, write_vals=True)[0] for i in dest_paths]
        cls.vcmt = get_vcmt(ifgs, cls.maxvar)
        for ifg in ifgs:
            ifg.close()
Exemple #2
0
    def setup_class(cls):
        params = Configuration(common.TEST_CONF_ROIPAC).__dict__
        params[cf.TEMP_MLOOKED_DIR] = os.path.join(params[cf.OUT_DIR], cf.TEMP_MLOOKED_DIR)
        conv2tif.main(params)
        prepifg.main(params)

        params[cf.REF_EST_METHOD] = 2

        xlks, _, crop = cf.transform_params(params)

        dest_paths, headers = common.repair_params_for_correct_tests(params[cf.OUT_DIR], params)
        correct._copy_mlooked(params)
        copied_dest_paths = [os.path.join(params[cf.TEMP_MLOOKED_DIR], os.path.basename(d)) for d in dest_paths]
        del dest_paths
        # start run_pyrate copy
        ifgs = pre_prepare_ifgs(copied_dest_paths, params)
        mst_grid = tests.common.mst_calculation(copied_dest_paths, params)

        refx, refy = pyrate.core.refpixel.ref_pixel_calc_wrapper(params)

        params[cf.REFX] = refx
        params[cf.REFY] = refy
        params[cf.ORBFIT_OFFSET] = True

        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = prepare_ifgs_without_phase(copied_dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        correct._update_params_with_tiles(params)
        _, ifgs = pyrate.core.ref_phs_est.ref_phase_est_wrapper(params)
        ifgs[0].open()
        r_dist = vcm_module.RDist(ifgs[0])()
        ifgs[0].close()
        maxvar = [vcm_module.cvd(i, params, r_dist)[0] for i in copied_dest_paths]
        for ifg in ifgs:
            ifg.open()
        vcmt = vcm_module.get_vcmt(ifgs, maxvar)    
        for ifg in ifgs:
            ifg.close()     
            ifg.open()
        
        # Calculate stacked rate map
        params[cf.PARALLEL] = 1
        cls.rate, cls.error, cls.samples = tests.common.calculate_stack_rate(ifgs, params, vcmt, mst_mat=mst_grid)

        # Calculate stacked rate map
        params[cf.PARALLEL] = 0
        cls.rate_s, cls.error_s, cls.samples_s = tests.common.calculate_stack_rate(ifgs, params, vcmt, mst_mat=mst_grid)

        stackrate_dir = os.path.join(SML_TEST_DIR, 'stackrate')

        cls.rate_container = np.genfromtxt(os.path.join(stackrate_dir, 'stackmap.csv'), delimiter=',')
        cls.error_container = np.genfromtxt(os.path.join(stackrate_dir, 'errormap.csv'), delimiter=',')
        cls.samples_container = np.genfromtxt(os.path.join(stackrate_dir, 'coh_sta.csv'), delimiter=',')
    
        for ifg in ifgs:
            ifg.close()

        cls.params = params
Exemple #3
0
    def setUpClass(cls):
        params = Configuration(common.TEST_CONF_ROIPAC).__dict__
        cls.temp_out_dir = tempfile.mkdtemp()
        sys.argv = ['prepifg.py', common.TEST_CONF_ROIPAC]
        params[cf.OUT_DIR] = cls.temp_out_dir
        conv2tif.main(params)
        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],
                                               params[cf.OBS_DIR])

        dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks)
        # start run_pyrate copy
        ifgs = common.pre_prepare_ifgs(dest_paths, params)
        mst_grid = common.mst_calculation(dest_paths, params)
        refx, refy = process._ref_pixel_calc(dest_paths, params)
        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = common.prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        _, ifgs = process._ref_phase_estimation(dest_paths, params, refx, refy)
        ifgs[0].open()
        r_dist = covariance.RDist(ifgs[0])()
        ifgs[0].close()
        maxvar = [covariance.cvd(i, params, r_dist)[0] for i in dest_paths]
        for ifg in ifgs:
            ifg.open()
        vcmt = covariance.get_vcmt(ifgs, maxvar)

        for ifg in ifgs:
            ifg.close()
            ifg.open()
            ifg.nodata_value = 0.0

        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)

        # load the legacy data
        ts_dir = os.path.join(common.SML_TEST_DIR, 'time_series')
        tsincr_path = os.path.join(ts_dir, 'ts_incr_interp0_method1.csv')
        ts_incr = np.genfromtxt(tsincr_path)

        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 setUpClass(cls):
     cls.ifgs = common.small_data_setup()
     cls.params = default_params()
     cls.mstmat = mst.mst_boolean_array(cls.ifgs)
     r_dist = covariance.RDist(cls.ifgs[0])()
     cls.maxvar = [covariance.cvd(i, cls.params, r_dist)[0]
                   for i in cls.ifgs]
     cls.vcmt = covariance.get_vcmt(cls.ifgs, cls.maxvar)
Exemple #5
0
    def setup_class(cls):
        roipac_params = Configuration(TEST_CONF_ROIPAC).__dict__
        from copy import deepcopy
        params = deepcopy(roipac_params)
        shared.mkdir_p(params[C.TMPDIR])
        params[C.REF_EST_METHOD] = 2
        conv2tif.main(params)
        params = deepcopy(roipac_params)
        prepifg.main(params)
        params = deepcopy(roipac_params)
        base_ifg_paths = [
            c.unwrapped_path for c in params[C.INTERFEROGRAM_FILES]
        ]
        dest_paths = [c.converted_path for c in params[C.INTERFEROGRAM_FILES]]
        params[C.INTERFEROGRAM_FILES] = [
            MultiplePaths(d, params) for d in dest_paths
        ]
        for p in params[C.INTERFEROGRAM_FILES]:  # hack
            p.sampled_path = p.converted_path

        for i in dest_paths:
            Path(i).chmod(
                0o664
            )  # assign write permission as conv2tif output is readonly
        ifgs = common.pre_prepare_ifgs(dest_paths, params)
        correct._copy_mlooked(params)
        correct._update_params_with_tiles(params)
        correct._create_ifg_dict(params)
        pyrate.core.refpixel.ref_pixel_calc_wrapper(params)
        params[C.ORBFIT_OFFSET] = True
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()

        for p in params[C.INTERFEROGRAM_FILES]:  # hack
            p.tmp_sampled_path = p.sampled_path
        _, cls.ifgs = pyrate.core.ref_phs_est.ref_phase_est_wrapper(params)
        ifgs[0].open()
        r_dist = RDist(ifgs[0])()
        ifgs[0].close()
        # Calculate interferogram noise
        cls.maxvar = [
            cvd(i,
                params,
                r_dist,
                calc_alpha=True,
                save_acg=True,
                write_vals=True)[0] for i in dest_paths
        ]
        cls.vcmt = get_vcmt(ifgs, cls.maxvar)
        for ifg in ifgs:
            ifg.close()
        cls.params = params
Exemple #6
0
    def test_vcm_basic(self):
        ifgs = small5_mock_ifgs(5, 9)
        maxvar = [8.486, 12.925, 6.313, 0.788, 0.649]

        exp = array([[8.486, 5.2364, 0.0, 0.0, 0.0],
            [5.2364, 12.925,  4.5165,  1.5957,  0.0],
            [0.0, 4.5165, 6.313, 1.1152, 0.0],
            [0.0, 1.5957, 1.1152, 0.788, -0.3576],
            [0.0, 0.0, 0.0, -0.3576, 0.649]])

        act = get_vcmt(ifgs, maxvar)
        assert_array_almost_equal(act, exp, decimal=3)
Exemple #7
0
    def test_vcm_17ifgs(self):
        # TODO: maxvar should be calculated by vcm.cvd
        maxvar = [2.879, 4.729, 22.891, 4.604, 3.290, 6.923, 2.519, 13.177,
                  7.548, 6.190, 12.565, 9.822, 18.484, 7.776, 2.734, 6.411,
                  4.754]

        exp = array([
            [2.879, 0.0, -4.059, -1.820, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            [0.0, 4.729, 0.0, 0.0, 1.972, 0.0, 0.0, -3.947, -2.987, 0.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            [-4.059, 0.0, 22.891, 5.133, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
             -7.497, -10.285, 0.0, 0.0, 0.0, 0.0],
            [-1.820, 0.0, 5.133, 4.604, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
             3.362, 0.0, 0.0, -1.774, 0.0, 0.0],
            [0.0, 1.972, 0.0, 0.0, 3.290, 2.386, 1.439, -3.292, -2.492, 0.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, 0.0, 2.386, 6.923, 2.088, 0.0, 0.0, -3.273,
             -4.663, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, 0.0, 1.439, 2.088, 2.519, 0.0, 0.0, 1.974, 0.0,
             0.0, 0.0, -2.213, 0.0, 0.0, 0.0],
            [0.0, -3.947, 0.0, 0.0, -3.292, 0.0, 0.0, 13.177, 4.986, 0.0, 0.0,
             0.0, 0.0, 0.0, 0.0, 4.596, -3.957],
            [0.0, -2.987, 0.0, 0.0, -2.492, 0.0, 0.0, 4.986, 7.548, 0.0, 0.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 2.995],
            [0.0, 0.0, 0.0, 0.0, 0.0, -3.273, 1.974, 0.0, 0.0, 6.190, 4.410,
             0.0, 0.0, -3.469, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, 0.0, 0.0, -4.663, 0.0, 0.0, 0.0, 4.410, 12.565,
             0.0, 0.0, 4.942, 0.0, 0.0, 0.0],
            [0.0, 0.0, -7.497, 3.362, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
             9.8221, 6.737, 0.0, -2.591, 0.0, 0.0],
            [0.0, 0.0, -10.285, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.737,
             18.484, 0.0, 3.554, -5.443, 0.0],
            [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -2.213, 0.0, 0.0, -3.469, 4.942,
             0.0, 0.0, 7.776, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, -1.774, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -2.591,
             3.554, 0.0, 2.734, -2.093, 0.0],
            [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.596, 0.0, 0.0, 0.0, 0.0,
             -5.443, 0.0, -2.093, 6.411, -2.760],
            [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.957, 2.995, 0.0, 0.0, 0.0,
             0.0, 0.0, 0.0, -2.760, 4.754]
        ])

        act = get_vcmt(self.ifgs, maxvar)
        assert_array_almost_equal(act, exp, decimal=3)
Exemple #8
0
 def setUpClass(cls):
     params = Configuration(TEST_CONF_ROIPAC).__dict__
     cls.temp_out_dir = tempfile.mkdtemp()
     sys.argv = ['prepifg.py', TEST_CONF_ROIPAC]
     params[cf.OUT_DIR] = cls.temp_out_dir
     params[cf.TMPDIR] = os.path.join(cls.temp_out_dir, cf.TMPDIR)
     shared.mkdir_p(params[cf.TMPDIR])
     params[cf.REF_EST_METHOD] = 2
     conv2tif.main(params)
     prepifg.main(params)
     cls.params = params
     base_ifg_paths = [
         c.unwrapped_path for c in params[cf.INTERFEROGRAM_FILES]
     ]
     dest_paths = [c.converted_path for c in params[cf.INTERFEROGRAM_FILES]]
     dest_paths = dest_paths[:-2]
     for i in dest_paths:
         Path(i).chmod(
             0o664
         )  # assign write permission as conv2tif output is readonly
     ifgs = common.pre_prepare_ifgs(dest_paths, params)
     refx, refy = process._ref_pixel_calc(dest_paths, params)
     headers = [roipac.roipac_header(i, cls.params) for i in base_ifg_paths]
     pyrate.core.orbital.remove_orbital_error(ifgs, params, headers)
     ifgs = prepare_ifgs_without_phase(dest_paths, params)
     for ifg in ifgs:
         ifg.close()
     _, cls.ifgs = process._ref_phase_estimation(dest_paths, params, refx,
                                                 refy)
     ifgs[0].open()
     r_dist = RDist(ifgs[0])()
     ifgs[0].close()
     # Calculate interferogram noise
     cls.maxvar = [
         cvd(i,
             params,
             r_dist,
             calc_alpha=True,
             save_acg=True,
             write_vals=True)[0] for i in dest_paths
     ]
     cls.vcmt = get_vcmt(ifgs, cls.maxvar)
     for ifg in ifgs:
         ifg.close()
Exemple #9
0
    def setUpClass(cls):
        params = Configuration(common.TEST_CONF_ROIPAC).__dict__
        cls.temp_out_dir = tempfile.mkdtemp()
        params[cf.OUT_DIR] = cls.temp_out_dir
        params[cf.PARALLEL] = 0
        conv2tif.main(params)
        prepifg.main(params)

        params[cf.REF_EST_METHOD] = 2

        base_ifg_paths = [
            c.unwrapped_path for c in params[cf.INTERFEROGRAM_FILES]
        ]
        headers = [roipac.roipac_header(i, params) for i in base_ifg_paths]
        dest_paths = [
            Path(cls.temp_out_dir).joinpath(Path(
                c.sampled_path).name).as_posix()
            for c in params[cf.INTERFEROGRAM_FILES][:-2]
        ]
        # start run_pyrate copy
        ifgs = common.pre_prepare_ifgs(dest_paths, params)
        mst_grid = common.mst_calculation(dest_paths, params)

        refx, refy = process._ref_pixel_calc(dest_paths, params)

        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params, headers)
        ifgs = common.prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        _, ifgs = process._ref_phase_estimation(dest_paths, params, refx, refy)
        ifgs[0].open()
        r_dist = covariance.RDist(ifgs[0])()
        ifgs[0].close()
        # Calculate interferogram noise
        maxvar = [covariance.cvd(i, params, r_dist)[0] for i in dest_paths]
        for ifg in ifgs:
            ifg.open()
        vcmt = covariance.get_vcmt(ifgs, maxvar)
        for ifg in ifgs:
            ifg.close()
            ifg.open()
            ifg.nodata_value = 0.0

        params[cf.TIME_SERIES_METHOD] = 2
        params[cf.PARALLEL] = 1
        # Calculate time series
        cls.tsincr, cls.tscum, _ = common.calculate_time_series(ifgs,
                                                                params,
                                                                vcmt,
                                                                mst=mst_grid)

        params[cf.PARALLEL] = 0
        # Calculate time series serailly by the pixel
        cls.tsincr_0, cls.tscum_0, _ = common.calculate_time_series(
            ifgs, params, vcmt, mst=mst_grid)

        # copy legacy data
        SML_TIME_SERIES_DIR = os.path.join(common.SML_TEST_DIR, 'time_series')
        tsincr_path = os.path.join(SML_TIME_SERIES_DIR,
                                   'ts_incr_interp0_method2.csv')
        ts_incr = np.genfromtxt(tsincr_path)

        tscum_path = os.path.join(SML_TIME_SERIES_DIR,
                                  'ts_cum_interp0_method2.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')
Exemple #10
0
    def setup_class(cls):
        params = Configuration(common.TEST_CONF_ROIPAC).__dict__
        params[cf.TEMP_MLOOKED_DIR] = os.path.join(params[cf.OUT_DIR],
                                                   cf.TEMP_MLOOKED_DIR)
        conv2tif.main(params)
        prepifg.main(params)

        params[cf.REF_EST_METHOD] = 2

        xlks, _, crop = cf.transform_params(params)

        dest_paths, headers = common.repair_params_for_correct_tests(
            params[cf.OUT_DIR], params)
        correct._copy_mlooked(params)
        copied_dest_paths = [
            os.path.join(params[cf.TEMP_MLOOKED_DIR], os.path.basename(d))
            for d in dest_paths
        ]
        del dest_paths
        # start run_pyrate copy
        ifgs = common.pre_prepare_ifgs(copied_dest_paths, params)
        mst_grid = common.mst_calculation(copied_dest_paths, params)
        refx, refy = pyrate.core.refpixel.ref_pixel_calc_wrapper(params)

        params[cf.REFX] = refx
        params[cf.REFY] = refy
        params[cf.ORBFIT_OFFSET] = True

        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = common.prepare_ifgs_without_phase(copied_dest_paths, params)
        for ifg in ifgs:
            ifg.close()

        correct._update_params_with_tiles(params)
        _, ifgs = pyrate.core.ref_phs_est.ref_phase_est_wrapper(params)
        ifgs[0].open()
        r_dist = covariance.RDist(ifgs[0])()
        ifgs[0].close()
        # Calculate interferogram noise
        maxvar = [
            covariance.cvd(i, params, r_dist)[0] for i in copied_dest_paths
        ]
        for ifg in ifgs:
            ifg.open()
        vcmt = covariance.get_vcmt(ifgs, maxvar)
        for ifg in ifgs:
            ifg.close()
            ifg.open()
            ifg.nodata_value = 0.0

        params[cf.TIME_SERIES_METHOD] = 2
        params[cf.PARALLEL] = 1
        # Calculate time series
        cls.tsincr, cls.tscum, _ = common.calculate_time_series(ifgs,
                                                                params,
                                                                vcmt,
                                                                mst=mst_grid)

        params[cf.PARALLEL] = 0
        # Calculate time series serailly by the pixel
        cls.tsincr_0, cls.tscum_0, _ = common.calculate_time_series(
            ifgs, params, vcmt, mst=mst_grid)

        # copy legacy data
        SML_TIME_SERIES_DIR = os.path.join(common.SML_TEST_DIR, 'time_series')
        tsincr_path = os.path.join(SML_TIME_SERIES_DIR,
                                   'ts_incr_interp0_method2.csv')
        ts_incr = np.genfromtxt(tsincr_path)

        tscum_path = os.path.join(SML_TIME_SERIES_DIR,
                                  'ts_cum_interp0_method2.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')
        cls.params = params
Exemple #11
0
    def setUpClass(cls):
        params = cf.get_config_params(TEST_CONF_ROIPAC)
        cls.temp_out_dir = tempfile.mkdtemp()

        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])
        conv2tif.main(params)
        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],
                                               params[cf.OBS_DIR])

        dest_paths = cf.get_dest_paths(base_ifg_paths, crop, params, xlks)
        print(f"base_ifg_paths={base_ifg_paths}")
        print(f"dest_paths={dest_paths}")
        # start run_pyrate copy
        ifgs = pre_prepare_ifgs(dest_paths, params)
        mst_grid = tests.common.mst_calculation(dest_paths, params)

        refx, refy = process._ref_pixel_calc(dest_paths, params)

        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params)
        ifgs = prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        _, ifgs = process._ref_phase_estimation(dest_paths, params, refx, refy)
        ifgs[0].open()
        r_dist = vcm_module.RDist(ifgs[0])()
        ifgs[0].close()
        maxvar = [vcm_module.cvd(i, params, r_dist)[0] for i in dest_paths]
        for ifg in ifgs:
            ifg.open()
        vcmt = vcm_module.get_vcmt(ifgs, maxvar)
        for ifg in ifgs:
            ifg.close()
            ifg.open()

        # 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)

        linrate_dir = os.path.join(SML_TEST_DIR, 'linrate')

        cls.rate_container = np.genfromtxt(os.path.join(
            linrate_dir, 'stackmap.csv'),
                                           delimiter=',')
        cls.error_container = np.genfromtxt(os.path.join(
            linrate_dir, 'errormap.csv'),
                                            delimiter=',')

        cls.samples_container = np.genfromtxt(os.path.join(
            linrate_dir, 'coh_sta.csv'),
                                              delimiter=',')

        for ifg in ifgs:
            ifg.close()
Exemple #12
0
    def setUpClass(cls):
        params = Configuration(TEST_CONF_ROIPAC).__dict__
        cls.temp_out_dir = tempfile.mkdtemp()

        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])
        conv2tif.main(params)
        prepifg.main(params)

        params[cf.REF_EST_METHOD] = 2

        xlks, _, crop = cf.transform_params(params)

        base_ifg_paths = [
            c.unwrapped_path for c in params[cf.INTERFEROGRAM_FILES]
        ]
        headers = [roipac.roipac_header(i, params) for i in base_ifg_paths]
        dest_paths = [
            Path(cls.temp_out_dir).joinpath(Path(
                c.sampled_path).name).as_posix()
            for c in params[cf.INTERFEROGRAM_FILES][:-2]
        ]
        # start run_pyrate copy
        ifgs = pre_prepare_ifgs(dest_paths, params)
        mst_grid = tests.common.mst_calculation(dest_paths, params)

        refx, refy = process._ref_pixel_calc(dest_paths, params)

        # Estimate and remove orbit errors
        pyrate.core.orbital.remove_orbital_error(ifgs, params, headers)
        ifgs = prepare_ifgs_without_phase(dest_paths, params)
        for ifg in ifgs:
            ifg.close()
        _, ifgs = process._ref_phase_estimation(dest_paths, params, refx, refy)
        ifgs[0].open()
        r_dist = vcm_module.RDist(ifgs[0])()
        ifgs[0].close()
        maxvar = [vcm_module.cvd(i, params, r_dist)[0] for i in dest_paths]
        for ifg in ifgs:
            ifg.open()
        vcmt = vcm_module.get_vcmt(ifgs, maxvar)
        for ifg in ifgs:
            ifg.close()
            ifg.open()

        # Calculate stacked rate map
        params[cf.PARALLEL] = 1
        cls.rate, cls.error, cls.samples = tests.common.calculate_stack_rate(
            ifgs, params, vcmt, mst_mat=mst_grid)

        # Calculate stacked rate map
        params[cf.PARALLEL] = 0
        cls.rate_s, cls.error_s, cls.samples_s = tests.common.calculate_stack_rate(
            ifgs, params, vcmt, mst_mat=mst_grid)

        stackrate_dir = os.path.join(SML_TEST_DIR, 'stackrate')

        cls.rate_container = np.genfromtxt(os.path.join(
            stackrate_dir, 'stackmap.csv'),
                                           delimiter=',')
        cls.error_container = np.genfromtxt(os.path.join(
            stackrate_dir, 'errormap.csv'),
                                            delimiter=',')
        cls.samples_container = np.genfromtxt(os.path.join(
            stackrate_dir, 'coh_sta.csv'),
                                              delimiter=',')

        for ifg in ifgs:
            ifg.close()