Example #1
0
    def test_mixed_metadata_raises(self):

        # change config to 5 ifgs
        self.params[cf.INTERFEROGRAM_FILES] = [
            MultiplePaths(p, self.params) for p in self.small_tifs[:5]
        ]
        for p in self.params[cf.INTERFEROGRAM_FILES]:
            p.sampled_path = p.converted_path
            p.tmp_sampled_path = p.sampled_path

        # correct reference phase for some of the ifgs
        ref_phase_est_wrapper(self.params)
        for ifg in self.ifgs:
            ifg.open()

        # change config to all ifgs
        self.params[cf.INTERFEROGRAM_FILES] = [
            MultiplePaths(p, self.params) for p in self.small_tifs
        ]
        for p in self.params[cf.INTERFEROGRAM_FILES]:
            p.sampled_path = p.converted_path
            p.tmp_sampled_path = p.sampled_path

        # now it should raise exception if we want to correct refernece phase again on all of them
        with pytest.raises(CorrectionStatusError):
            ref_phase_est_wrapper(self.params)
Example #2
0
    def test_need_at_least_two_ifgs(self):
        self.params[cf.INTERFEROGRAM_FILES] = [
            MultiplePaths(p, self.params) for p in self.small_tifs[:1]
        ]
        for p in self.params[cf.INTERFEROGRAM_FILES]:
            p.sampled_path = p.converted_path
            p.tmp_sampled_path = p.sampled_path

        with pytest.raises(ReferencePhaseError):
            ref_phase_est_wrapper(self.params)
Example #3
0
 def test_metadata(self):
     for ifg in self.ifgs:
         ifg.open()
         assert ifc.PYRATE_REF_PHASE not in ifg.dataset.GetMetadata()
         ifg.close()
     ref_phase_est_wrapper(self.params)
     for ifg in self.ifgs:
         ifg.open()
         assert ifg.dataset.GetMetadataItem(
             ifc.PYRATE_REF_PHASE) == ifc.REF_PHASE_REMOVED
         ifg.close()
Example #4
0
    def test_calc_dem_errors(self):
        # validate output of current version of the code with saved files from an independent test run
        # only the reference phase and dem_error are used in this test

        # saved dem_error.tif (expected)
        dem_error_tif_exp = join(dem_error_path, 'dem_error.tif')
        dem = DEM(dem_error_tif_exp)
        dem_error_exp = dem.data
        # run relevant parts of the 'correct' step
        correct._copy_mlooked(self.params)
        correct._update_params_with_tiles(self.params)
        correct._create_ifg_dict(self.params)
        save_numpy_phase(self.ifg_paths, self.params)
        # subtract the reference phase to enable comparison with a 'normal' pyrate run
        ref_phase_est_wrapper(self.params)
        dem_error_calc_wrapper(self.params)
        # dem_error.tif from this run (result)
        dem_error_tif_res = join(self.params[C.DEM_ERROR_DIR], 'dem_error.tif')
        dem = DEM(dem_error_tif_res)
        dem_error_res = dem.data
        # check equality
        np.testing.assert_allclose(dem_error_exp, dem_error_res)

        # ifg correction files in subdirectory out/dem_error/
        # three different ifgs:
        # ifg1 -> short_baseline_ifg: 20180106-20180319 (ca. 3 m)
        # ifg2 -> long_baseline_ifg: 20180130-20180412(ca. 108 m)
        # ifg3 -> medium_baseline_ifg: 20180412-20180518 (ca. 48 m)
        # load saved files
        dem_error_ifg1_path = join(dem_error_path,
                                   '20180106-20180319_ifg_20_dem_error.npy')
        dem_error_ifg1_exp = np.load(dem_error_ifg1_path)
        dem_error_ifg2_path = join(dem_error_path,
                                   '20180130-20180412_ifg_20_dem_error.npy')
        dem_error_ifg2_exp = np.load(dem_error_ifg2_path)
        dem_error_ifg3_path = join(dem_error_path,
                                   '20180412-20180518_ifg_20_dem_error.npy')
        dem_error_ifg3_exp = np.load(dem_error_ifg3_path)
        # load correction values saved from this run (result)
        dem_error_ifg1_path = Path(self.params[C.DEM_ERROR_DIR]).joinpath(
            '20180106-20180319_ifg_20_dem_error.npy')
        dem_error_ifg1_res = np.load(dem_error_ifg1_path)
        dem_error_ifg2_path = Path(self.params[C.DEM_ERROR_DIR]).joinpath(
            '20180130-20180412_ifg_20_dem_error.npy')
        dem_error_ifg2_res = np.load(dem_error_ifg2_path)
        dem_error_ifg3_path = Path(self.params[C.DEM_ERROR_DIR]).joinpath(
            '20180412-20180518_ifg_20_dem_error.npy')
        dem_error_ifg3_res = np.load(dem_error_ifg3_path)
        # check equality
        np.testing.assert_allclose(dem_error_ifg1_exp, dem_error_ifg1_res)
        np.testing.assert_allclose(dem_error_ifg2_exp, dem_error_ifg2_res)
        np.testing.assert_allclose(dem_error_ifg3_exp, dem_error_ifg3_res)
Example #5
0
 def __run_once(self):
     ref_phs_file = Configuration.ref_phs_file(self.params)
     correct._copy_mlooked(self.params)
     multi_paths = self.params[cf.INTERFEROGRAM_FILES]
     ifg_paths = [p.tmp_sampled_path for p in multi_paths]
     ifgs = [Ifg(i) for i in ifg_paths]
     self.params[cf.REFX_FOUND], self.params[
         cf.REFY_FOUND] = ref_pixel_calc_wrapper(self.params)
     correct._create_ifg_dict(self.params)
     ref_phase_est_wrapper(self.params)
     for i in ifgs:
         i.open()
     phase_prev = [i.phase_data for i in ifgs]
     # assert ref_ph_file present
     assert ref_phs_file.exists()
     time_written = os.stat(ref_phs_file).st_mtime
     for i in ifgs:
         i.close()
     return phase_prev, time_written
Example #6
0
    def setup_class(cls):
        params = Configuration(common.TEST_CONF_ROIPAC).__dict__
        conv2tif.main(params)
        prepifg.main(params)
        for p in params[cf.INTERFEROGRAM_FILES]:  # hack
            p.tmp_sampled_path = p.sampled_path
            Path(p.sampled_path).chmod(
                0o664
            )  # assign write permission as conv2tif output is readonly

        params[cf.REF_EST_METHOD] = 2
        params[cf.PARALLEL] = False
        params[cf.ORBFIT_OFFSET] = True

        dest_paths, headers = common.repair_params_for_correct_tests(
            params[cf.OUT_DIR], params)

        # start run_pyrate copy
        ifgs = common.pre_prepare_ifgs(dest_paths, params)
        mst_grid = common.mst_calculation(dest_paths, params)
        # Estimate reference pixel location
        refx, refy = ref_pixel_calc_wrapper(params)

        # Estimate and remove orbit errors
        remove_orbital_error(ifgs, params)

        for i in ifgs:
            i.close()

        ifgs = common.pre_prepare_ifgs(dest_paths, params)

        for i in ifgs:
            i.close()
        for p in params[cf.INTERFEROGRAM_FILES]:
            p.tmp_sampled_path = p.sampled_path
        params[cf.REFX], params[cf.REFY] = refx, refy
        params['rows'], params['cols'] = 3, 2
        correct._update_params_with_tiles(params)

        cls.ref_phs, cls.ifgs = ref_phase_est_wrapper(params)
        cls.params = params