def setUp(self): self.BASE_DIR = tempfile.mkdtemp() self.params = cf.get_config_params(TEST_CONF_ROIPAC) # change to orbital error correction method 2 self.params[cf.ORBITAL_FIT_METHOD] = NETWORK_METHOD self.params[cf.ORBITAL_FIT_LOOKS_X] = 1 self.params[cf.ORBITAL_FIT_LOOKS_Y] = 1 data_paths = [ os.path.join(SML_TEST_TIF, p) for p in small_ifg_file_list() ] self.new_data_paths = [ os.path.join(self.BASE_DIR, os.path.basename(d)) for d in data_paths ] for d in data_paths: d_copy = os.path.join(self.BASE_DIR, os.path.basename(d)) shutil.copy(d, d_copy) os.chmod(d_copy, 0o660) self.ifgs = small_data_setup(datafiles=self.new_data_paths) for i in self.ifgs: if not i.is_open: i.open() if not i.nan_converted: i.convert_to_nans() if not i.mm_converted: i.convert_to_mm() i.write_modified_phase()
def setUp(self): ifg_instance = IfgList(small_ifg_file_list()) self.ifg_list, _ = get_nml(ifg_instance, nodata_value=0) self.sorted_list = sort_list(self.ifg_list.id, self.ifg_list.master_num, self.ifg_list.slave_num, self.ifg_list.nan_frac) self.matlab_sorted_list_zero_nan_frac = [(1, 1, 3, 0.0), (2, 2, 5, 0.0), (3, 3, 7, 0.0), (4, 3, 9, 0.0), (5, 4, 5, 0.0), (6, 4, 6, 0.0), (7, 4, 8, 0.0), (8, 5, 11, 0.0), (9, 5, 12, 0.0), (10, 6, 8, 0.0), (11, 6, 13, 0.0), (12, 7, 9, 0.0), (13, 7, 10, 0.0), (14, 8, 13, 0.0), (15, 9, 10, 0.0), (16, 10, 11, 0.0), (17, 11, 12, 0.0)] self.ifg_list_mst_matlab = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 16]
def setUp(self): self.ifg_dir = tempfile.mkdtemp() small_files = small_ifg_file_list() for sf in small_files: dest = os.path.join(self.ifg_dir, os.path.basename(sf)) shutil.copy(sf, dest) os.chmod(dest, 0o660) self.small_files = glob.glob(os.path.join(self.ifg_dir, "*.tif")) self.small_ifgs = small_data_setup(self.small_files)
def test_cmd_ifg_no_roipac_files_created_roipac(self): self.dataPaths = common.small_data_roipac_unws() base_exp = common.small_ifg_file_list() self.expPaths = [os.path.join(self.roipac_base_dir, os.path.basename(i)) for i in base_exp] self.confFile = self.roipac_conffile self.ifgListFile = self.roipac_ifgListFile self.base_dir = self.roipac_base_dir self.check_roipac()
def test_calculate_connect_and_ntrees_small_data(self): ifg_instance = IfgList(small_ifg_file_list()) ifg_list, _ = get_nml(ifg_instance, nodata_value=0) edges = get_sub_structure(ifg_list, np.zeros(len(ifg_list.id), dtype=bool)) mst, connected, ntrees = matlab_mst_kruskal(edges, ntrees=True) self.assertTrue(connected[0].all()) self.assertEqual(ntrees, 1) self.assertEqual(len(connected[0]), len(mst) + 1)
def test_cmd_ifg_luigi_files_created(self): self.dataPaths = small_data_roipac_unws() base_exp = small_ifg_file_list() self.expPaths = [ join(self.luigi_base_dir, os.path.basename(i)) for i in base_exp ] self.luigi = '1' self.confFile = self.luigi_conf_file self.ifgListFile = self.luigi_ifgListFile self.base_dir = self.luigi_base_dir self.common_check()
def setUp(self): self.matlab_n = [1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 3, 5, 7, 9, 5, 6, 8, 11, 12, 8, 13, 9, 10, 13, 10, 11, 12] self.matlab_masnum = [1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11] self.matlab_slvnum = [3, 5, 7, 9, 5, 6, 8, 11, 12, 8, 13, 9, 10, 13, 10, 11, 12] ifg_instance = IfgList(small_ifg_file_list()) self.ifg_list, self.epoch_list = get_nml(ifg_instance, nodata_value=0)
def test_assert_is_not_tree(self): non_overlapping = [1, 2, 5, 6, 12, 13, 14, 15, 16, 17] small_files = small_ifg_file_list() datafiles = [f for i, f in enumerate(small_files) if i+1 in non_overlapping] non_overlapping_ifg_isntance = IfgList(datafiles) ifg_list, _ = get_nml(non_overlapping_ifg_isntance, nodata_value=0) edges = _get_sub_structure(ifg_list, np.zeros(len(ifg_list.id), dtype=bool)) mst, connected, ntrees = _matlab_mst_kruskal(edges, ntrees=True) self.assertEqual(connected.shape[0], 4) self.assertEqual(ntrees, 4)
def test_assert_two_trees_overlapping(self): overlapping = [3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17] small_files = small_ifg_file_list() datafiles = [f for i, f in enumerate(small_files) if i+1 in overlapping] overlapping_ifg_isntance = IfgList(datafiles) ifg_list, _ = get_nml(overlapping_ifg_isntance, nodata_value=0) edges = _get_sub_structure(ifg_list, np.zeros(len(ifg_list.id), dtype=bool)) mst, connected, ntrees = _matlab_mst_kruskal(edges, ntrees=True) self.assertEqual(connected.shape[0], 2) self.assertEqual(ntrees, 2)
def setUp(self): self.ifgs = small_data_setup() self.ifg_file_list = small_ifg_file_list() self.matlab_mst_list = [ 'geo_060619-061002_unw.tif', 'geo_060828-061211_unw.tif', 'geo_061002-070219_unw.tif', 'geo_061002-070430_unw.tif', 'geo_061106-061211_unw.tif', 'geo_061106-070115_unw.tif', 'geo_061106-070326_unw.tif', 'geo_061211-070709_unw.tif', 'geo_061211-070813_unw.tif', 'geo_070115-070917_unw.tif', 'geo_070219-070604_unw.tif', 'geo_070604-070709_unw.tif' ] # reorder ifgs as per the matlab list self.ifgs = small_data_setup()
def setUp(self): self.ifg_paths = small_ifg_file_list() self.params = cf.get_config_params(TEST_CONF_ROIPAC) self.params[cf.PARALLEL] = False self.params[cf.OUT_DIR] = tempfile.mkdtemp() self.params_alt_ref_frac = copy.copy(self.params) self.params_alt_ref_frac[cf.REF_MIN_FRAC] = 0.5 self.params_all_2s = copy.copy(self.params) self.params_all_2s[cf.REFNX] = 2 self.params_all_2s[cf.REFNY] = 2 self.params_chipsize_15 = copy.copy(self.params_all_2s) self.params_chipsize_15[cf.REF_CHIP_SIZE] = 15 self.params_all_1s = copy.copy(self.params) self.params_all_1s[cf.REFNX] = 1 self.params_all_1s[cf.REFNY] = 1 self.params_all_1s[cf.REF_MIN_FRAC] = 0.7
def setup_class(cls): # change to orbital error correction method 2 cls.params = Configuration(common.TEST_CONF_ROIPAC).__dict__ cls.BASE_DIR = cls.params[cf.OUT_DIR] cls.params[cf.ORBITAL_FIT_METHOD] = NETWORK_METHOD cls.params[cf.ORBITAL_FIT_LOOKS_X] = 1 cls.params[cf.ORBITAL_FIT_LOOKS_Y] = 1 cls.params[cf.ORBFIT_OFFSET] = True cls.params[cf.OUT_DIR] = cls.BASE_DIR data_paths = [os.path.join(SML_TEST_TIF, p) for p in small_ifg_file_list()] cls.new_data_paths = [os.path.join(cls.BASE_DIR, os.path.basename(d)) for d in data_paths] cls.params[cf.INTERFEROGRAM_FILES] = [MultiplePaths(file_name=d, params=cls.params) for d in data_paths] for p in cls.params[cf.INTERFEROGRAM_FILES]: p.sampled_path = p.converted_path # copy the files from the dir into temp dir for d in data_paths: d_copy = os.path.join(cls.BASE_DIR, os.path.basename(d)) shutil.copy(d, d_copy) os.chmod(d_copy, 0o660) cls.headers = [roipac.roipac_header(i, cls.params) for i in cls.new_data_paths] cls.orb_error_dir = Path(cls.params[cf.OUT_DIR]).joinpath(ORB_ERROR_DIR) cls.orb_error_dir.mkdir(parents=True, exist_ok=True)