def setup_method(self): self.params = Configuration(common.TEST_CONF_GAMMA).__dict__ self.tmp_dir = tempfile.mkdtemp() self.params[cf.OUT_DIR] = self.tmp_dir self.params[cf.REF_EST_METHOD] = 1 self.params[cf.PARALLEL] = False self.params[cf.TMPDIR] = self.tmp_dir common.copytree(common.SML_TEST_TIF, self.tmp_dir) self.small_tifs = glob.glob(os.path.join(self.tmp_dir, "*.tif")) for s in self.small_tifs: os.chmod(s, 0o644) self.ifgs = common.small_data_setup(self.tmp_dir, is_dir=True) 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 for ifg in self.ifgs: ifg.close() self.params[cf.REFX], self.params[cf.REFY] = -1, -1 self.params[cf.REFNX], self.params[cf.REFNY] = 10, 10 self.params[cf.REF_CHIP_SIZE], self.params[cf.REF_MIN_FRAC] = 21, 0.5 self.params['rows'], self.params['cols'] = 3, 2 self.params[cf.REF_PIXEL_FILE] = Configuration.ref_pixel_path( self.params) correct._update_params_with_tiles(self.params) correct.ref_pixel_calc_wrapper(self.params)
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
def setup_class(cls): params = Configuration(common.TEST_CONF_ROIPAC).__dict__ cls.tmp_dir = tempfile.mkdtemp() common.copytree(common.SML_TEST_TIF, cls.tmp_dir) tifs = glob.glob(os.path.join(cls.tmp_dir, "*.tif")) for t in tifs: os.chmod(t, 0o644) small_ifgs = common.small_data_setup(datafiles=tifs) ifg_paths = [i.data_path for i in small_ifgs] cls.ifg_ret = common.pre_prepare_ifgs(ifg_paths, params=params) for i in cls.ifg_ret: i.close() nan_conversion = params[C.NAN_CONVERSION] # prepare a second set cls.tmp_dir2 = tempfile.mkdtemp() common.copytree(common.SML_TEST_TIF, cls.tmp_dir2) tifs = glob.glob(os.path.join(cls.tmp_dir2, "*.tif")) for t in tifs: os.chmod(t, 0o644) small_ifgs = common.small_data_setup(datafiles=tifs) ifg_paths = [i.data_path for i in small_ifgs] cls.ifgs = [shared.Ifg(p) for p in ifg_paths] for i in cls.ifgs: i.open(readonly=False) if nan_conversion: # nan conversion happens here in networkx mst i.nodata_value = params[C.NO_DATA_VALUE] i.convert_to_nans() if not i.mm_converted: i.convert_to_mm() i.close()
def setUp(self): self.tmp_dir = tempfile.mkdtemp() self.params = dict() self.params[cf.REF_EST_METHOD] = 1 self.params[cf.PARALLEL] = False self.refpx, self.refpy = 38, 58 common.copytree(common.SML_TEST_TIF, self.tmp_dir) small_tifs = glob.glob(os.path.join(self.tmp_dir, "*.tif")) for s in small_tifs: os.chmod(s, 0o644) self.ifgs = common.small_data_setup(self.tmp_dir, is_dir=True)
def setUp(self): self.test_dir = tempfile.mktemp() common.copytree(common.SML_TEST_TIF, self.test_dir) self.ifgs = common.small_data_setup(datafiles=glob.glob(os.path.join(self.test_dir, "*.tif"))) self.ref_gtif = gdal.Open(self.ifgs[0].data_path, gdalconst.GA_ReadOnly) self.ref_proj = self.ref_gtif.GetProjection() self.ref_gt = self.ref_gtif.GetGeoTransform() self.data = self.ref_gtif.ReadAsArray() self.md = self.ref_gtif.GetMetadata() self.temp_tif = tempfile.mktemp(suffix='.tif') self.out_tif = tempfile.mktemp(suffix='.tif') del self.ref_gtif
def modify_config(request, tempdir, get_config): test_conf = common.TEST_CONF_ROIPAC params_dict = get_config(test_conf) params_dict[cf.IFG_LKSX] = request.param params_dict[cf.IFG_LKSY] = request.param params_dict[cf.OBS_DIR] = tempdir() common.copytree(common.SML_TEST_GAMMA, params_dict[cf.OBS_DIR]) params_dict[cf.IFG_FILE_LIST] = os.path.join(params_dict[cf.OBS_DIR], 'ifms_17') params_dict[cf.PARALLEL] = False params_dict[cf.APS_CORRECTION] = 0 yield params_dict # clean up shutil.rmtree(params_dict[cf.OBS_DIR])
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