Esempio n. 1
0
    def setup_class(cls):

        # testing constants2
        cls.BASE_DIR = tempfile.mkdtemp()
        cls.BASE_OUT_DIR = join(cls.BASE_DIR, 'out')
        cls.BASE_DEM_DIR = join(cls.BASE_DIR, 'dem')
        cls.BASE_DEM_FILE = join(cls.BASE_DEM_DIR, 'roipac_test_trimmed.tif')

        try:
            # copy source data (treat as prepifg already run)
            os.makedirs(cls.BASE_OUT_DIR)
            for path in glob.glob(join(common.SML_TEST_TIF, '*')):
                dest = join(cls.BASE_OUT_DIR, os.path.basename(path))
                shutil.copy(path, dest)
                os.chmod(dest, 0o660)

            os.makedirs(cls.BASE_DEM_DIR)
            orig_dem = common.SML_TEST_DEM_TIF
            os.symlink(orig_dem, cls.BASE_DEM_FILE)
            os.chdir(cls.BASE_DIR)

            # Turn off validation because we're in a different working dir
            #  and relative paths in config won't be work.
            params = config.get_config_params(common.TEST_CONF_ROIPAC)
            params['correct'] = [
                'orbfit', 'refphase', 'mst', 'apscorrect', 'maxvar'
            ]
            params[cf.OUT_DIR] = cls.BASE_OUT_DIR
            params[cf.PROCESSOR] = 0  # roipac
            params[cf.APS_CORRECTION] = 0
            paths = glob.glob(join(cls.BASE_OUT_DIR, 'geo_*-*.tif'))
            paths = sorted(paths)
            params[cf.PARALLEL] = False
            params[cf.ORBFIT_OFFSET] = True
            params[cf.TEMP_MLOOKED_DIR] = cls.BASE_OUT_DIR.join(
                cf.TEMP_MLOOKED_DIR)
            params[cf.INTERFEROGRAM_FILES] = [
                MultiplePaths(p, params) for p in paths
            ]
            for p in params[cf.INTERFEROGRAM_FILES]:  # cheat
                p.sampled_path = p.converted_path
                p.tmp_sampled_path = p.converted_path
            params["rows"], params["cols"] = 2, 2
            params[cf.REF_PIXEL_FILE] = Configuration.ref_pixel_path(params)
            Path(params[cf.OUT_DIR]).joinpath(cf.APS_ERROR_DIR).mkdir(
                exist_ok=True, parents=True)
            Path(params[cf.OUT_DIR]).joinpath(cf.MST_DIR).mkdir(exist_ok=True,
                                                                parents=True)
            correct.correct_ifgs(params)

            if not hasattr(cls, 'ifgs'):
                cls.ifgs = get_ifgs(out_dir=cls.BASE_OUT_DIR)
        except:
            # revert working dir & avoid paths busting other tests
            os.chdir(CURRENT_DIR)
            raise
Esempio n. 2
0
def test_unsupported_process_steps_raises(gamma_conf):
    config = Configuration(gamma_conf)
    gamma_params = config.__dict__
    gamma_params['correct'] = ['orbfit2', 'something_other_step']
    with pytest.raises(ConfigException):
        correct.correct_ifgs(config)
Esempio n. 3
0
    def setup_class(cls):
        gamma_conf = common.TEST_CONF_GAMMA
        from tests.common import manipulate_test_conf
        rate_types = ['stack_rate', 'stack_error', 'stack_samples']
        cls.tif_dir = Path(tempfile.mkdtemp())
        params = manipulate_test_conf(gamma_conf, cls.tif_dir)

        from pyrate.configuration import Configuration
        # change the required params
        params[C.PROCESSES] = 4
        params[C.PROCESSOR] = 1  # gamma
        params[C.IFG_FILE_LIST] = os.path.join(common.GAMMA_SML_TEST_DIR,
                                               'ifms_17')
        params[C.PARALLEL] = 1
        params[C.APS_CORRECTION] = 0
        params[C.REFX], params[C.REFY] = -1, -1
        rows, cols = params["rows"], params["cols"]

        output_conf_file = 'gamma.conf'
        output_conf = cls.tif_dir.joinpath(output_conf_file).as_posix()
        pyrate.configuration.write_config_file(params=params,
                                               output_conf_file=output_conf)

        config = Configuration(output_conf)
        params = config.__dict__

        common.sub_process_run(f"pyrate conv2tif -f {output_conf}")
        common.sub_process_run(f"pyrate prepifg -f {output_conf}")

        cls.sampled_paths = [
            p.tmp_sampled_path for p in params[C.INTERFEROGRAM_FILES]
        ]

        ifgs = common.small_data_setup()
        correct._copy_mlooked(params)
        tiles = pyrate.core.shared.get_tiles(cls.sampled_paths[0], rows, cols)
        correct.correct_ifgs(config)
        pyrate.main.timeseries(config)
        pyrate.main.stack(config)
        cls.refpixel_p, cls.maxvar_p, cls.vcmt_p = \
            (params[C.REFX], params[C.REFY]), params[C.MAXVAR], params[
                C.VCMT]
        cls.mst_p = common.reconstruct_mst(ifgs[0].shape, tiles,
                                           params[C.OUT_DIR])
        cls.rate_p, cls.error_p, cls.samples_p = \
            [common.reconstruct_stack_rate(ifgs[0].shape, tiles, params[C.TMPDIR], t) for t in rate_types]

        common.remove_tifs(params[C.OUT_DIR])

        # now create the non parallel version
        cls.tif_dir_s = Path(tempfile.mkdtemp())
        params = manipulate_test_conf(gamma_conf, cls.tif_dir_s)
        params[C.PROCESSES] = 4
        params[C.PROCESSOR] = 1  # gamma
        params[C.IFG_FILE_LIST] = os.path.join(common.GAMMA_SML_TEST_DIR,
                                               'ifms_17')
        params[C.PARALLEL] = 0
        params[C.APS_CORRECTION] = 0
        params[C.REFX], params[C.REFY] = -1, -1
        output_conf_file = 'gamma.conf'
        output_conf = cls.tif_dir_s.joinpath(output_conf_file).as_posix()
        pyrate.configuration.write_config_file(params=params,
                                               output_conf_file=output_conf)
        config = Configuration(output_conf)
        params = config.__dict__

        common.sub_process_run(f"pyrate conv2tif -f {output_conf}")
        common.sub_process_run(f"pyrate prepifg -f {output_conf}")

        correct._copy_mlooked(params)
        correct.correct_ifgs(config)
        pyrate.main.timeseries(config)
        pyrate.main.stack(config)
        cls.refpixel, cls.maxvar, cls.vcmt = \
            (params[C.REFX], params[C.REFY]), params[C.MAXVAR], params[
                C.VCMT]
        cls.mst = common.reconstruct_mst(ifgs[0].shape, tiles,
                                         params[C.OUT_DIR])
        cls.rate, cls.error, cls.samples = \
            [common.reconstruct_stack_rate(ifgs[0].shape, tiles, params[C.TMPDIR], t) for t in rate_types]
        cls.params = params
Esempio n. 4
0
def test_unsupported_process_steps_raises(gamma_params):
    gamma_params['correct'] = ['orbfit2', 'something_other_step']
    with pytest.raises(ConfigException):
        correct.correct_ifgs(gamma_params)