コード例 #1
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)
コード例 #2
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)
コード例 #3
0
ファイル: test_conv2tif.py プロジェクト: bopopescu/PyRate
def test_conv2tif_file_types(tempdir, gamma_conf):
    tdir = Path(tempdir())
    params = manipulate_test_conf(gamma_conf, tdir)
    params[cf.COH_MASK] = 1
    output_conf_file = 'conf.conf'
    output_conf = tdir.joinpath(output_conf_file)
    cf.write_config_file(params=params, output_conf_file=output_conf)
    params_s = configuration.Configuration(output_conf).__dict__
    conv2tif.main(params_s)
    ifg_files = list(
        Path(tdir.joinpath(params_s[cf.OUT_DIR])).glob('*_ifg.tif'))
    coh_files = list(
        Path(tdir.joinpath(params_s[cf.OUT_DIR])).glob('*_coh.tif'))
    dem_file = list(
        Path(tdir.joinpath(params_s[cf.OUT_DIR])).glob('*_dem.tif'))[0]
    # assert coherence and ifgs have correct metadata
    for i in itertools.chain(*[ifg_files, coh_files]):
        ifg = Ifg(i)
        ifg.open()
        md = ifg.meta_data
        if i.name.endswith('_ifg.tif'):
            assert md[ifc.DATA_TYPE] == ifc.ORIG
            continue
        if i.name.endswith('_coh.tif'):
            assert md[ifc.DATA_TYPE] == ifc.COH
            continue

    # assert dem has correct metadata
    dem = DEM(dem_file.as_posix())
    dem.open()
    md = dem.dataset.GetMetadata()
    assert md[ifc.DATA_TYPE] == ifc.DEM
    shutil.rmtree(tdir)
コード例 #4
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)
コード例 #5
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
コード例 #6
0
ファイル: test_gamma_vs_roipac.py プロジェクト: sixy6e/PyRate
def __workflow(params, tdir):
    copytree(params[WORKING_DIR], tdir)
    # manipulate params
    outdir = tdir.joinpath('out')
    outdir.mkdir(exist_ok=True)
    params[C.OUT_DIR] = outdir.as_posix()

    params[C.DEM_FILE] = tdir.joinpath(Path(
        params[C.DEM_FILE]).name).as_posix()
    params[C.DEM_HEADER_FILE] = tdir.joinpath(
        Path(params[C.DEM_HEADER_FILE]).name).as_posix()
    params[C.HDR_FILE_LIST] = tdir.joinpath(
        Path(params[C.HDR_FILE_LIST]).name).as_posix()
    params[C.IFG_FILE_LIST] = tdir.joinpath(
        Path(params[C.IFG_FILE_LIST]).name).as_posix()
    params[C.TMPDIR] = tdir.joinpath(Path(params[C.TMPDIR]).name).as_posix()
    output_conf = tdir.joinpath('roipac_temp.conf')
    pyrate.configuration.write_config_file(params=params,
                                           output_conf_file=output_conf)
    params = configuration.Configuration(output_conf).__dict__
    conv2tif.main(params)
    prepifg.main(params)
    params[WORKING_DIR] = tdir.as_posix()
    return params