def _stacking_for_tile(tile, params): """ Wrapper for stacking calculation on a single tile """ preread_ifgs = params[C.PREREAD_IFGS] vcmt = params[C.VCMT] ifg_paths = [ ifg_path.tmp_sampled_path for ifg_path in params[C.INTERFEROGRAM_FILES] ] output_dir = params[C.TMPDIR] log.debug(f"Stacking of tile {tile.index}") ifg_parts = [ shared.IfgPart(p, tile, preread_ifgs, params) for p in ifg_paths ] mst_tile = np.load(Configuration.mst_path(params, tile.index)) rate, error, samples = stack_rate_array(ifg_parts, params, vcmt, mst_tile) np.save(file=os.path.join(output_dir, 'stack_rate_{}.npy'.format(tile.index)), arr=rate) np.save(file=os.path.join(output_dir, 'stack_error_{}.npy'.format(tile.index)), arr=error) np.save(file=os.path.join(output_dir, 'stack_samples_{}.npy'.format(tile.index)), arr=samples)
def _calc_svd_time_series(ifg_paths, params, preread_ifgs, tiles: List[shared.Tile]): """ Helper function to obtain time series for spatio-temporal filter using SVD method """ # Is there other existing functions that can perform this same job? log.info('Calculating time series via SVD method for ' 'APS correction') # copy params temporarily new_params = deepcopy(params) new_params[cf.TIME_SERIES_METHOD] = 2 # use SVD method process_tiles = mpiops.array_split(tiles) nvels = None for t in process_tiles: log.debug( 'Calculating time series for tile {} during APS correction'.format( t.index)) ifg_parts = [ shared.IfgPart(p, t, preread_ifgs, params) for p in ifg_paths ] mst_tile = np.load(Configuration.mst_path(params, t.index)) tsincr = time_series(ifg_parts, new_params, vcmt=None, mst=mst_tile)[0] np.save(file=os.path.join(params[cf.TMPDIR], 'tsincr_aps_{}.npy'.format(t.index)), arr=tsincr) nvels = tsincr.shape[2] nvels = mpiops.comm.bcast(nvels, root=0) mpiops.comm.barrier() # need to assemble tsincr from all processes tsincr_g = _assemble_tsincr(ifg_paths, params, preread_ifgs, tiles, nvels) log.debug('Finished calculating time series for spatio-temporal filter') return tsincr_g
def __run_once(self): tiles = self.params[cf.TILES] mst_files = [Configuration.mst_path(self.params, t.index) for t in tiles] correct._copy_mlooked(self.params) correct._create_ifg_dict(self.params) save_numpy_phase(self.ifg_paths, self.params) mst.mst_calc_wrapper(self.params) assert all(m.exists() for m in mst_files) return [os.stat(o).st_mtime for o in mst_files]
def _save_mst_tile(tile: Tile, params: dict) -> None: """ Convenient inner loop for mst tile saving """ preread_ifgs = params[cf.PREREAD_IFGS] dest_tifs = [ifg_path.tmp_sampled_path for ifg_path in params[cf.INTERFEROGRAM_FILES]] mst_file_process_n = Configuration.mst_path(params, index=tile.index) if mst_file_process_n.exists(): return mst_tile = mst_multiprocessing(tile, dest_tifs, preread_ifgs, params) # locally save the mst_mat np.save(file=mst_file_process_n, arr=mst_tile)
def __calc_time_series_for_tile(tile, params): """ Wrapper for time series calculation on a single tile """ preread_ifgs = params[cf.PREREAD_IFGS] vcmt = params[cf.VCMT] ifg_paths = [ ifg_path.tmp_sampled_path for ifg_path in params[cf.INTERFEROGRAM_FILES] ] output_dir = params[cf.TMPDIR] log.debug(f"Calculating time series for tile {tile.index}") ifg_parts = [ shared.IfgPart(p, tile, preread_ifgs, params) for p in ifg_paths ] mst_tile = np.load(Configuration.mst_path(params, tile.index)) tsincr, tscuml, _ = time_series(ifg_parts, params, vcmt, mst_tile) np.save(file=os.path.join(output_dir, 'tscuml_{}.npy'.format(tile.index)), arr=tscuml) # optional save of tsincr npy tiles if params["savetsincr"] == 1: np.save(file=os.path.join(output_dir, 'tsincr_{}.npy'.format(tile.index)), arr=tsincr) tscuml = np.insert(tscuml, 0, 0, axis=2) # add zero epoch to tscuml 3D array log.info('Calculating linear regression of cumulative time series') linrate, intercept, r_squared, std_err, samples = linear_rate_array( tscuml, ifg_parts, params) np.save(file=os.path.join(output_dir, 'linear_rate_{}.npy'.format(tile.index)), arr=linrate) np.save(file=os.path.join(output_dir, 'linear_intercept_{}.npy'.format(tile.index)), arr=intercept) np.save(file=os.path.join(output_dir, 'linear_rsquared_{}.npy'.format(tile.index)), arr=r_squared) np.save(file=os.path.join(output_dir, 'linear_error_{}.npy'.format(tile.index)), arr=std_err) np.save(file=os.path.join(output_dir, 'linear_samples_{}.npy'.format(tile.index)), arr=samples)