Beispiel #1
0
def test_prepifg_mpi(mpisync, get_config, tempdir, roipac_or_gamma, get_lks,
                     get_crop):
    from tests.common import TEST_CONF_ROIPAC, TEST_CONF_GAMMA
    from os.path import join, basename
    if roipac_or_gamma == 1:
        params = get_config(TEST_CONF_GAMMA)
    else:
        params = get_config(TEST_CONF_ROIPAC)
    outdir = mpiops.run_once(tempdir)
    params[cf.OUT_DIR] = outdir
    params[cf.PARALLEL] = False
    params[cf.IFG_LKSX], params[cf.IFG_LKSY] = get_lks, get_lks
    params[cf.IFG_CROP_OPT] = get_crop
    if roipac_or_gamma == 1:
        params[cf.IFG_FILE_LIST] = join(common.SML_TEST_GAMMA, 'ifms_17')
        params[cf.OBS_DIR] = common.SML_TEST_GAMMA
        params[cf.DEM_FILE] = common.SML_TEST_DEM_GAMMA
        params[cf.DEM_HEADER_FILE] = common.SML_TEST_DEM_HDR_GAMMA
    run_prepifg.main(params)

    if mpiops.rank == 0:
        if roipac_or_gamma == 1:
            params_s = get_config(TEST_CONF_GAMMA)
        else:
            params_s = get_config(TEST_CONF_ROIPAC)
        params_s[cf.OUT_DIR] = tempdir()
        params_s[cf.PARALLEL] = True
        params_s[cf.IFG_LKSX], params_s[cf.IFG_LKSY] = get_lks, get_lks
        params_s[cf.IFG_CROP_OPT] = get_crop
        if roipac_or_gamma == 1:
            base_unw_paths = glob.glob(join(common.SML_TEST_GAMMA,
                                            "*_utm.unw"))
            run_prepifg.gamma_prepifg(base_unw_paths, params_s)
        else:
            base_unw_paths = glob.glob(join(common.SML_TEST_OBS, "*.unw"))
            run_prepifg.roipac_prepifg(base_unw_paths, params_s)

        mpi_tifs = glob.glob(join(outdir, "*.tif"))
        serial_tifs = glob.glob(join(params[cf.OUT_DIR], "*.tif"))
        mpi_tifs.sort()
        serial_tifs.sort()
        # 17 geotifs, and 17 mlooked tifs
        assert len(mpi_tifs) == len(serial_tifs)
        for m_f, s_f in zip(mpi_tifs, serial_tifs):
            assert basename(m_f) == basename(s_f)

        shutil.rmtree(outdir)
        shutil.rmtree(params_s[cf.OUT_DIR])
Beispiel #2
0
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)