コード例 #1
0
ファイル: test_gamma.py プロジェクト: wzmucas/PyRate
def series_ifgs(gamma_conf):

    print('======================setup series==========================')
    tdir = Path(tempfile.mkdtemp())

    params_s = manipulate_test_conf(gamma_conf, tdir)
    params_s[cf.PARALLEL] = 0

    output_conf_file = 'conf.conf'
    output_conf = tdir.joinpath(output_conf_file)
    cf.write_config_file(params=params_s, output_conf_file=output_conf)

    params_s = Configuration(output_conf).__dict__

    gtif_paths = conv2tif.main(params_s)
    prepifg.main(params_s)

    parallel_df = list(Path(tdir).joinpath('out').glob(glob_prefix))

    s_ifgs = small_data_setup(datafiles=parallel_df)

    yield s_ifgs

    print('======================teardown series==========================')

    shutil.rmtree(params_s[cf.OBS_DIR])
コード例 #2
0
ファイル: test_shared.py プロジェクト: woxin5295/PyRate
    def setup_class(cls, gamma_params):
        # change the required params
        shutil.rmtree(gamma_params[cf.OUT_DIR])  # start with a clean directory
        shared.mkdir_p(gamma_params[cf.OUT_DIR])
        cls.params = gamma_params
        cls.params[cf.OBS_DIR] = common.SML_TEST_GAMMA
        cls.params[cf.PROCESSOR] = 1  # gamma
        cls.params[cf.PARALLEL] = 0
        cls.params[cf.REF_EST_METHOD] = 1
        cls.params[cf.DEM_FILE] = common.SML_TEST_DEM_GAMMA
        # base_unw_paths need to be geotiffed and multilooked by run_prepifg
        cls.base_unw_paths = cf.original_ifg_paths(
            cls.params[cf.IFG_FILE_LIST], cls.params[cf.OBS_DIR])
        cls.base_unw_paths.append(common.SML_TEST_DEM_GAMMA)

        # dest_paths are tifs that have been geotif converted and multilooked
        conv2tif.main(cls.params)
        prepifg.main(cls.params)

        cls.dest_paths = [
            Path(cls.params[cf.OUT_DIR]).joinpath(Path(
                c.sampled_path).name).as_posix()
            for c in cls.params[cf.INTERFEROGRAM_FILES][:-2]
        ]
        cls.ifgs = [dem_or_ifg(i) for i in cls.dest_paths]
        for i in cls.ifgs:
            i.open()
            i.nodata_value = 0
コード例 #3
0
ファイル: test_prepifg.py プロジェクト: bopopescu/PyRate
    def common_check(self, ele, inc):
        import glob
        from pyrate.configuration import Configuration
        assert os.path.exists(self.conf_file)

        params = Configuration(self.conf_file).__dict__

        conv2tif.main(params)
        sys.argv = ['dummy', self.conf_file]
        prepifg.main(params)
        # test 17 geotiffs created
        geotifs = glob.glob(os.path.join(params[cf.OUT_DIR], '*_unw_ifg.tif'))
        self.assertEqual(17, len(geotifs))
        # test dem geotiff created
        demtif = glob.glob(os.path.join(params[cf.OUT_DIR], '*_dem.tif'))
        self.assertEqual(1, len(demtif))
        # elevation/incidence file
        # not computing anymore
        # ele = glob.glob(os.path.join(params[cf.OBS_DIR],
        #                              '*utm_{ele}.tif'.format(ele=ele)))[0]
        # self.assertTrue(os.path.exists(ele))
        # mlooked tifs
        mlooked_tifs = glob.glob(os.path.join(self.base_dir, '*_1cr.tif'))
        # 19 including 17 ifgs, 1 dem and one incidence
        self.assertEqual(18, len(mlooked_tifs))
        inc = glob.glob(
            os.path.join(self.base_dir, '*utm_{inc}.tif'.format(inc=inc)))
        self.assertEqual(0, len(inc))
コード例 #4
0
    def setUpClass(cls):
        # read in the params
        _, _, params = cf.get_ifg_paths(TEST_CONF_GAMMA)
        glob_prefix = "*utm_unw_1rlks_1cr.tif"

        # SERIAL
        cls.serial_dir = tempfile.mkdtemp()
        params[cf.OUT_DIR] = cls.serial_dir
        params[cf.PARALLEL] = False
        shared.mkdir_p(cls.serial_dir)

        gtif_paths = conv2tif.main(params)
        prepifg.main(params)

        serial_df = glob.glob(os.path.join(cls.serial_dir, glob_prefix))
        cls.serial_ifgs = small_data_setup(datafiles=serial_df)

        # Clean up serial converted tifs so we can test parallel conversion
        common.remove_tifs(SML_TEST_GAMMA)

        # PARALLEL
        cls.parallel_dir = tempfile.mkdtemp()
        params[cf.OUT_DIR] = cls.parallel_dir
        params[cf.PARALLEL] = True
        shared.mkdir_p(cls.parallel_dir)

        gtif_paths = conv2tif.main(params)
        prepifg.main(params)

        para_df = glob.glob(os.path.join(cls.parallel_dir, glob_prefix))
        cls.para_ifgs = small_data_setup(datafiles=para_df)
コード例 #5
0
def test_vcm_legacy_vs_mpi(mpisync, tempdir, roipac_or_gamma_conf):

    params = configuration.Configuration(roipac_or_gamma_conf).__dict__
    LEGACY_VCM_DIR = os.path.join(SML_TEST_DIR, 'vcm')
    legacy_vcm = np.genfromtxt(os.path.join(LEGACY_VCM_DIR, 'vcmt.csv'), delimiter=',')
    tmpdir = Path(mpiops.run_once(tempdir))
    mpiops.run_once(common.copytree, params[cf.OBS_DIR], tmpdir)
    params[cf.OUT_DIR] = tmpdir.joinpath('out')
    params[cf.PARALLEL] = 0
    output_conf = Path(tmpdir).joinpath('conf.cfg')
    cf.write_config_file(params=params, output_conf_file=output_conf)
    params = configuration.Configuration(output_conf).__dict__

    dest_paths = [p.sampled_path for p in params[cf.INTERFEROGRAM_FILES]]
    # run conv2tif and prepifg, create the dest_paths files
    conv2tif.main(params)
    params[cf.INTERFEROGRAM_FILES].pop()
    prepifg.main(params)
    params[cf.INTERFEROGRAM_FILES].pop()
    preread_ifgs = process._create_ifg_dict(dest_paths, params=params)
    refpx, refpy = process._ref_pixel_calc(dest_paths, params)
    process._orb_fit_calc(params[cf.INTERFEROGRAM_FILES], params)
    process._ref_phase_estimation(dest_paths, params, refpx, refpy)

    maxvar, vcmt = process._maxvar_vcm_calc(dest_paths, params, preread_ifgs)

    # phase data after ref pixel has changed due to commit bf2f7ebd
    # Legacy tests won't match anymore
    np.testing.assert_array_almost_equal(maxvar, legacy_maxvar, decimal=4)
    np.testing.assert_array_almost_equal(legacy_vcm, vcmt, decimal=3)
    mpiops.run_once(shutil.rmtree, tmpdir)
コード例 #6
0
def __workflow(params, tdir):
    copytree(params[cf.OBS_DIR], tdir)
    # manipulate params
    params[cf.OBS_DIR] = tdir.as_posix()
    outdir = tdir.joinpath('out')
    outdir.mkdir(exist_ok=True)
    params[cf.OUT_DIR] = outdir.as_posix()

    params[cf.DEM_FILE] = tdir.joinpath(Path(
        params[cf.DEM_FILE]).name).as_posix()
    params[cf.DEM_HEADER_FILE] = tdir.joinpath(
        Path(params[cf.DEM_HEADER_FILE]).name).as_posix()
    params[cf.HDR_FILE_LIST] = tdir.joinpath(
        Path(params[cf.HDR_FILE_LIST]).name).as_posix()
    params[cf.SLC_DIR] = tdir.as_posix()
    params[cf.IFG_FILE_LIST] = tdir.joinpath(
        Path(params[cf.IFG_FILE_LIST]).name).as_posix()
    params[cf.COH_FILE_DIR] = tdir.as_posix()
    params[cf.APS_INCIDENCE_MAP] = tdir.joinpath(
        Path(params[cf.APS_INCIDENCE_MAP]).name).as_posix()
    params[cf.TMPDIR] = tdir.joinpath(Path(params[cf.TMPDIR]).name).as_posix()
    output_conf = tdir.joinpath('roipac_temp.conf')
    cf.write_config_file(params=params, output_conf_file=output_conf)
    params = configuration.Configuration(output_conf).__dict__
    conv2tif.main(params)
    prepifg.main(params)
    return params
コード例 #7
0
def test_prepifg_largetifs_vs_python(modified_config_largetifs, gamma_conf, create_mpi_files):

    print("\n\n")
    print("===x==="*10)
    if GITHUB_ACTIONS and np.random.randint(0, 1000) > 499:  # skip 50% of tests randomly
        pytest.skip("Randomly skipping as part of 50 percent")

    params = create_mpi_files(gamma_conf)
    sr_conf, params_p = modified_config_largetifs(gamma_conf, 1, 'parallel_conf.conf')
    params_p = Configuration(sr_conf).__dict__
    conv2tif.main(params_p)
    params_p = Configuration(sr_conf).__dict__
    prepifg.main(params_p)
    params_p = Configuration(sr_conf).__dict__
    # convert2tif tests, 17 interferograms
    assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "*_unw.tif", 17)

    # if coherence masking, compare coh files were converted
    if params[cf.COH_FILE_LIST] is not None:
        assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "*_cc.tif", 17)
        # 17 ifgs + 1 dem + 17 mlooked file
        assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "*_coh.tif", 17)

    assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "*_dem.tif", 1)
    # prepifg
    # 17 ifgs + 1 dem
    assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "*_ifg.tif", 17)
    assert_two_dirs_equal(params[cf.OUT_DIR], params_p[cf.OUT_DIR], "dem.tif", 1)


    print("==========================xxx===========================")

    shutil.rmtree(params[cf.OBS_DIR])
    shutil.rmtree(params_p[cf.OBS_DIR])
コード例 #8
0
 def setup_class(cls):
     cls.conf = TEST_CONF_GAMMA
     params = Configuration(cls.conf).__dict__
     conv2tif.main(params)
     params = Configuration(cls.conf).__dict__
     prepifg.main(params)
     cls.params = params
コード例 #9
0
def test_prepifg_treats_inputs_and_outputs_read_only(gamma_conf, tempdir,
                                                     coh_mask):
    tdir = Path(tempdir())
    params = common.manipulate_test_conf(gamma_conf, tdir)
    params[C.COH_MASK] = coh_mask
    output_conf = tdir.joinpath('conf.cfg')
    pyrate.configuration.write_config_file(params=params,
                                           output_conf_file=output_conf)

    params = Configuration(output_conf.as_posix()).__dict__
    conv2tif.main(params)

    tifs = list(Path(params[C.INTERFEROGRAM_DIR]).glob('*_unw.tif'))
    assert len(tifs) == 17

    params = Configuration(output_conf.as_posix()).__dict__
    prepifg.main(params)
    cropped_ifgs = list(Path(params[C.INTERFEROGRAM_DIR]).glob('*_ifg.tif'))
    cropped_cohs = list(Path(params[C.COHERENCE_DIR]).glob('*_coh.tif'))
    cropped_dem = list(Path(params[C.GEOMETRY_DIR]).glob('*_dem.tif'))

    if params[C.COH_FILE_LIST] is not None:  # 17 + 1 dem + 17 coh files
        assert len(cropped_ifgs) + len(cropped_cohs) + len(cropped_dem) == 35
    else:  # 17 + 1 dem
        assert len(cropped_ifgs) + len(cropped_cohs) + len(cropped_dem) == 18
    # check all tifs from conv2tif are still readonly
    for t in tifs:
        assert t.stat().st_mode == 33060

    # check all prepifg outputs are readonly
    for c in cropped_cohs + cropped_ifgs + cropped_dem:
        assert c.stat().st_mode == 33060
コード例 #10
0
ファイル: test_mpi.py プロジェクト: wzmucas/PyRate
def test_vcm_legacy_vs_mpi(mpisync, tempdir, roipac_or_gamma_conf):
    params = configuration.Configuration(roipac_or_gamma_conf).__dict__
    LEGACY_VCM_DIR = os.path.join(SML_TEST_DIR, 'vcm')
    legacy_vcm = np.genfromtxt(os.path.join(LEGACY_VCM_DIR, 'vcmt.csv'),
                               delimiter=',')
    tmpdir = Path(mpiops.run_once(tempdir))
    mpiops.run_once(common.copytree, params[cf.OBS_DIR], tmpdir)
    params[cf.OUT_DIR] = tmpdir.joinpath('out')
    params[cf.PARALLEL] = False
    xlks, ylks, crop = cf.transform_params(params)
    base_unw_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST],
                                           params[cf.OBS_DIR])
    # dest_paths are tifs that have been geotif converted and multilooked
    dest_paths = cf.get_dest_paths(base_unw_paths, crop, params, xlks)

    # run conv2tif and prepifg, create the dest_paths files
    conv2tif.main(params)
    prepifg.main(params)

    tiles = pyrate.core.shared.get_tiles(dest_paths[0], rows=1, cols=1)
    preread_ifgs = process._create_ifg_dict(dest_paths,
                                            params=params,
                                            tiles=tiles)
    refpx, refpy = process._ref_pixel_calc(dest_paths, params)
    process._orb_fit_calc(dest_paths, params)
    process._ref_phase_estimation(dest_paths, params, refpx, refpy)

    maxvar, vcmt = process._maxvar_vcm_calc(dest_paths, params, preread_ifgs)
    np.testing.assert_array_almost_equal(maxvar, legacy_maxvar, decimal=4)
    np.testing.assert_array_almost_equal(legacy_vcm, vcmt, decimal=3)
    mpiops.run_once(shutil.rmtree, tmpdir)
コード例 #11
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()
コード例 #12
0
    def setup_class(cls, gamma_params):
        # change the required params
        shared.mkdir_p(gamma_params[C.OUT_DIR])
        from copy import deepcopy
        cls.params = deepcopy(gamma_params)
        cls.params[WORKING_DIR] = common.GAMMA_SML_TEST_DIR
        cls.params[C.PROCESSOR] = 1  # gamma
        cls.params[C.PARALLEL] = 0
        cls.params[C.REF_EST_METHOD] = 1
        cls.params[C.DEM_FILE] = common.SML_TEST_DEM_GAMMA
        cls.params[C.BASE_FILE_LIST] = common.GAMMA_SML_TEST_DIR
        # base_unw_paths need to be geotiffed and multilooked by run_prepifg
        cls.base_unw_paths = tests.common.original_ifg_paths(
            cls.params[C.IFG_FILE_LIST], cls.params[WORKING_DIR])
        cls.base_unw_paths.append(common.SML_TEST_DEM_GAMMA)

        # dest_paths are tifs that have been geotif converted and multilooked
        conv2tif.main(cls.params)
        prepifg.main(cls.params)

        cls.dest_paths = [
            Path(cls.params[C.INTERFEROGRAM_DIR]).joinpath(
                Path(c.sampled_path).name).as_posix()
            for c in gamma_params[C.INTERFEROGRAM_FILES]
        ]
        cls.dest_paths += [
            Path(cls.params[C.COHERENCE_DIR]).joinpath(
                Path(c.sampled_path).name).as_posix()
            for c in gamma_params[C.COHERENCE_FILE_PATHS]
        ]

        cls.ifgs = [dem_or_ifg(i) for i in cls.dest_paths]
        for i in cls.ifgs:
            i.open()
            i.nodata_value = 0
コード例 #13
0
def test_vcm_legacy_vs_mpi(mpisync, tempdir, roipac_or_gamma_conf):

    params = configuration.Configuration(roipac_or_gamma_conf).__dict__
    LEGACY_VCM_DIR = os.path.join(SML_TEST_DIR, 'vcm')
    legacy_vcm = np.genfromtxt(os.path.join(LEGACY_VCM_DIR, 'vcmt.csv'),
                               delimiter=',')
    tmpdir = Path(mpiops.run_once(tempdir))
    params[C.OUT_DIR] = tmpdir.joinpath('out')
    params[C.PARALLEL] = 0
    output_conf = Path(tmpdir).joinpath('conf.cfg')
    pyrate.configuration.write_config_file(params=params,
                                           output_conf_file=output_conf)
    params = configuration.Configuration(output_conf).__dict__

    # dest_paths = [p.sampled_path for p in params[cf.INTERFEROGRAM_FILES]]
    # run conv2tif and prepifg, create the dest_paths files
    conv2tif.main(params)
    params = configuration.Configuration(output_conf).__dict__
    prepifg.main(params)
    params = configuration.Configuration(output_conf).__dict__
    params[C.ORBFIT_OFFSET] = True
    correct._copy_mlooked(params=params)
    correct._update_params_with_tiles(params)
    correct._create_ifg_dict(params=params)
    pyrate.core.refpixel.ref_pixel_calc_wrapper(params)
    pyrate.core.orbital.orb_fit_calc_wrapper(params)
    pyrate.core.ref_phs_est.ref_phase_est_wrapper(params)

    maxvar, vcmt = pyrate.core.covariance.maxvar_vcm_calc_wrapper(params)

    # phase data after ref pixel has changed due to commit bf2f7ebd
    # Legacy tests won't match anymore
    np.testing.assert_array_almost_equal(maxvar, legacy_maxvar, decimal=4)
    np.testing.assert_array_almost_equal(legacy_vcm, vcmt, decimal=3)
    mpiops.run_once(shutil.rmtree, tmpdir)
コード例 #14
0
ファイル: test_timeseries.py プロジェクト: wzmucas/PyRate
    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')
コード例 #15
0
ファイル: test_stackrate.py プロジェクト: woxin5295/PyRate
    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
コード例 #16
0
 def common_check(self, ele, inc):
     os.path.exists(self.conf_file)
     params = cf.get_config_params(self.conf_file)
     conv2tif.main(params)
     sys.argv = ['dummy', self.conf_file]
     prepifg.main(params)
     # test 17 geotiffs created
     geotifs = glob.glob(os.path.join(params[cf.OBS_DIR], '*_unw.tif'))
     self.assertEqual(17, len(geotifs))
     # test dem geotiff created
     demtif = glob.glob(os.path.join(params[cf.OBS_DIR], '*_dem.tif'))
     self.assertEqual(1, len(demtif))
     # elevation/incidence file
     ele = glob.glob(os.path.join(params[cf.OBS_DIR],
                                  '*utm_{ele}.tif'.format(ele=ele)))[0]
     self.assertTrue(os.path.exists(ele))
     # mlooked tifs
     mlooked_tifs = [f for f in
                     glob.glob(os.path.join(self.base_dir, '*.tif'))
                     if "cr" in f and "rlks" in f]
     # 19 including 17 ifgs, 1 dem and one incidence
     self.assertEqual(19, len(mlooked_tifs))
     inc = glob.glob(os.path.join(self.base_dir,
                                  '*utm_{inc}.tif'.format(inc=inc)))
     self.assertEqual(0, len(inc))
コード例 #17
0
ファイル: test_gamma.py プロジェクト: sixy6e/PyRate
def series_ifgs(gamma_conf):

    print('======================setup series==========================')
    tdir = Path(tempfile.mkdtemp())

    params_s = manipulate_test_conf(gamma_conf, tdir)
    params_s[C.PARALLEL] = 0

    output_conf_file = 'conf.conf'
    output_conf = tdir.joinpath(output_conf_file)
    pyrate.configuration.write_config_file(params=params_s,
                                           output_conf_file=output_conf)

    params_s = Configuration(output_conf).__dict__

    conv2tif.main(params_s)

    prepifg.main(params_s)

    serial_ifgs = list(
        Path(params_s[C.INTERFEROGRAM_DIR]).glob(ifg_glob_suffix))
    coh_files = list(Path(params_s[C.COHERENCE_DIR]).glob(coh_glob_suffix))

    s_ifgs = small_data_setup(datafiles=serial_ifgs + coh_files)
    yield s_ifgs
コード例 #18
0
ファイル: __main__.py プロジェクト: truth-quark/PyRate
def prepifg_handler(config_file):
    """
    Perform multilooking and cropping on geotiffs.
    """
    config_file = os.path.abspath(config_file)
    params = cf.get_config_params(config_file, step=PREPIFG)
    prepifg.main(params)
コード例 #19
0
def series_ifgs(gamma_conf):

    print('======================setup series==========================')
    tdir = Path(tempfile.mkdtemp())

    params_s = manipulate_test_conf(gamma_conf, tdir)
    params_s[cf.PARALLEL] = 0

    output_conf_file = 'conf.conf'
    output_conf = tdir.joinpath(output_conf_file)
    pyrate.configuration.write_config_file(params=params_s,
                                           output_conf_file=output_conf)

    params_s = Configuration(output_conf).__dict__

    conv2tif.main(params_s)

    prepifg.main(params_s)

    serial_ifgs = list(Path(tdir).joinpath('out').glob(ifg_glob_suffix))
    coh_files = list(Path(tdir).joinpath('out').glob(coh_glob_suffix))

    s_ifgs = small_data_setup(datafiles=serial_ifgs + coh_files)
    yield s_ifgs
    print('======================teardown series==========================')

    shutil.rmtree(params_s[cf.OBS_DIR], ignore_errors=True)
コード例 #20
0
 def setup_class(cls):
     cls.conf = common.MEXICO_CROPA_CONF
     cls.params = Configuration(cls.conf).__dict__
     prepifg.main(cls.params)
     cls.params = Configuration(cls.conf).__dict__
     multi_paths = cls.params[C.INTERFEROGRAM_FILES]
     cls.ifg_paths = [p.tmp_sampled_path for p in multi_paths]
コード例 #21
0
 def setup_class(cls):
     cls.conf = TEST_CONF_GAMMA
     cls.params = Configuration(cls.conf).__dict__
     conv2tif.main(cls.params)
     cls.params = Configuration(cls.conf).__dict__
     prepifg.main(cls.params)
     cls.params = Configuration(cls.conf).__dict__
     multi_paths = cls.params[cf.INTERFEROGRAM_FILES]
     cls.ifg_paths = [p.tmp_sampled_path for p in multi_paths]
コード例 #22
0
    def _create(conf):

        mpi_conf, params = modified_config_short(conf, 0, 'mpi_conf.conf')
        params = Configuration(mpi_conf).__dict__
        conv2tif.main(params)
        params = Configuration(mpi_conf).__dict__
        prepifg.main(params)

        return params  # don't need the reamining params
コード例 #23
0
ファイル: test_orbital.py プロジェクト: woxin5295/PyRate
 def setup_class(cls):
     cls.conf = TEST_CONF_GAMMA
     params = Configuration(cls.conf).__dict__
     conv2tif.main(params)
     params = Configuration(cls.conf).__dict__
     prepifg.main(params)
     cls.params = Configuration(cls.conf).__dict__
     correct._copy_mlooked(cls.params)
     correct._create_ifg_dict(cls.params)
コード例 #24
0
 def check_roipac(self):
     self.make_roipac_input_files(self.dataPaths, 'WGS84')
     sys.argv = ['pyrate', 'conv2tif', self.confFile]
     conv2tif.main()
     sys.argv = ['pyrate', 'prepifg', self.confFile]
     prepifg.main()
     for path in self.expPaths:
         self.assertTrue(os.path.exists(path),
                         '{} does not exist'.format(path))
コード例 #25
0
 def setup_method(cls):
     cls.conf = TEST_CONF_GAMMA
     params = Configuration(cls.conf).__dict__
     conv2tif.main(params)
     params = Configuration(cls.conf).__dict__
     prepifg.main(params)
     params = Configuration(cls.conf).__dict__
     correct._copy_mlooked(params)
     cls.params = params
コード例 #26
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
コード例 #27
0
ファイル: test_orbital.py プロジェクト: woxin5295/PyRate
 def setup_method(cls):
     cls.conf = TEST_CONF_GAMMA
     params = Configuration(cls.conf).__dict__
     conv2tif.main(params)
     params = Configuration(cls.conf).__dict__
     prepifg.main(params)
     cls.params = Configuration(cls.conf).__dict__
     correct._copy_mlooked(cls.params)
     correct._create_ifg_dict(cls.params)
     multi_paths = cls.params[cf.INTERFEROGRAM_FILES]
     cls.ifg_paths = [p.tmp_sampled_path for p in multi_paths]
コード例 #28
0
 def setup_class(cls):
     cls.conf = common.MEXICO_CROPA_CONF
     cls.params = Configuration(cls.conf).__dict__
     prepifg.main(cls.params)
     cls.params = Configuration(cls.conf).__dict__
     multi_paths = cls.params[C.INTERFEROGRAM_FILES]
     cls.ifg_paths = [p.tmp_sampled_path for p in multi_paths]
     cls.params[
         C.
         REFX_FOUND] = 8  # this is the pixel of the location given in the pyrate_mexico_cropa.conf file
     cls.params[
         C.
         REFY_FOUND] = 33  # however, the median of the whole interferogram is used for this validation
コード例 #29
0
def _get_mlooked_files(gamma_conf, tdir, refx, refy):
    params = manipulate_test_conf(gamma_conf, tdir)
    params[C.REFX] = refx
    params[C.REFY] = refy
    output_conf_file = 'config.conf'
    output_conf = tdir.joinpath(output_conf_file)
    pyrate.configuration.write_config_file(params=params,
                                           output_conf_file=output_conf)
    params = Configuration(output_conf).__dict__
    conv2tif.main(params)
    params = Configuration(output_conf).__dict__
    prepifg.main(params)
    err = run(f"pyrate correct -f {output_conf}",
              shell=True,
              universal_newlines=True,
              stderr=PIPE).stderr
    return params, err
コード例 #30
0
ファイル: test_aps.py プロジェクト: woxin5295/PyRate
 def setup_method(cls):
     cls.conf = common.TEST_CONF_GAMMA
     params = Configuration(cls.conf).__dict__
     conv2tif.main(params)
     params = Configuration(cls.conf).__dict__
     prepifg.main(params)
     cls.params = Configuration(cls.conf).__dict__
     correct._copy_mlooked(cls.params)
     correct._update_params_with_tiles(cls.params)
     correct._create_ifg_dict(cls.params)
     multi_paths = cls.params[cf.INTERFEROGRAM_FILES]
     cls.ifg_paths = [p.tmp_sampled_path for p in multi_paths]
     cls.ifgs = [shared.Ifg(i) for i in cls.ifg_paths]
     for i in cls.ifgs:
         i.open()
     shared.save_numpy_phase(cls.ifg_paths, cls.params)
     correct.mst_calc_wrapper(cls.params)