diff --git a/pyrate/algorithm.py b/pyrate/algorithm.py old mode 100644 new mode 100755 index 2d72bb959..14be61e83 --- a/pyrate/algorithm.py +++ b/pyrate/algorithm.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -This Python module contains a collection of algorithms used in PyRate +This Python module contains a collection of algorithms used in PyRate. """ import logging from numpy import sin, cos, unique, histogram, diag, dot @@ -28,10 +28,11 @@ def is_square(arr): """ Determines whether a numpy array is square or not. + + :param ndarray arr: numpy array - :param arr: numpy array - - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ shape = arr.shape if len(shape) == 2 and (shape[0] == shape[1]): @@ -44,11 +45,12 @@ def least_squares_covariance(A, b, v): Least squares solution in the presence of known covariance. This function is known as lscov() in MATLAB. - :param A: Design matrix - :param b: Observations (vector of phase values) - :param v: Covariances (weights) in vector form + :param xxx(eg str, tuple, int, float ...) A: Design matrix + :param xxx b: Observations (vector of phase values) + :param xxx v: Covariances (weights) in vector form - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-locals # X = LSCOV(A,b,V) returns the vector X that minimizes @@ -94,10 +96,11 @@ def los_conversion(phase_data, unit_vec): """ Converts phase from line-of-sight (LOS) to horizontal/vertical components. - :param phase_data: Phase band data array (eg. ifg.phase_data) - :param unit_vec: 3 component sequence, eg. [EW, NS, vertical] + :param xxx(eg str, tuple, int, float ...) phase_data: Phase band data array (eg. ifg.phase_data) + :param xxx unit_vec: 3 component sequence, eg. [EW, NS, vertical] - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # NB: currently not tested as implementation is too simple @@ -106,12 +109,13 @@ def los_conversion(phase_data, unit_vec): def unit_vector(incidence, azimuth): """ - xxxxxxx. + xxxx - :param incidence: xxxx - :param azimuth: xxxx + :param xxx(eg str, tuple, int, float ...) incidence: xxxx + :param xxx azimuth: xxxx - :return Unit vector tuple (east_west, north_south, vertical). + :return: Unit vector tuple (east_west, north_south, vertical). + :rtype: tuple """ vertical = cos(incidence) @@ -124,10 +128,11 @@ def ifg_date_lookup(ifgs, date_pair): """ Interferogram which has a master/slave dates given in 'date_pair'. - :param ifgs: List of interferogram objects to search in - :param date_pair: A (datetime.date, datetime.date) tuple + :param xxx(eg str, tuple, int, float ...) ifgs: List of interferogram objects to search in + :param tuple date_pair: A (datetime.date, datetime.date) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if len(date_pair) != 2: msg = "Need (datetime.date, datetime.date) master/slave pair" @@ -156,10 +161,11 @@ def ifg_date_index_lookup(ifgs, date_pair): """ Interferogram index which has a master/slave dates given in 'date_pair'. - :param ifgs: List of interferogram objects to search in - :param date_pair: A (datetime.date, datetime.date) tuple + :param xxx(eg str, tuple, int, float ...) ifgs: List of interferogram objects + :param tuple date_pair: A (datetime.date, datetime.date) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if len(date_pair) != 2: @@ -185,9 +191,10 @@ def get_epochs(ifgs): """ EpochList derived from all given interferograms. - :param ifgs: List of interferogram objects + :param xxx(eg str, tuple, int, float ...) ifgs: List of interferogram objects - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Finding unique epochs in given interferogram network') if isinstance(ifgs, dict): @@ -206,9 +213,10 @@ def get_all_epochs(ifgs): """ Sequence of all master and slave dates in given interferograms. - :param ifgs: List of interferogram objects + :param xxx(eg str, tuple, int, float ...) ifgs: List of interferogram objects - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ return [ifg.master for ifg in ifgs] + [ifg.slave for ifg in ifgs] @@ -220,9 +228,10 @@ def master_slave_ids(dates): from oldest to newest, starting at 0. Replaces ifglist.mas|slvnum used in the Matlab Pirate package. - :param dates: List of dates + :param xxx(eg str, tuple, int, float ...) dates: List of dates - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ dset = sorted(set(dates)) diff --git a/pyrate/config.py b/pyrate/config.py old mode 100644 new mode 100755 index 502c9cb19..1a2784650 --- a/pyrate/config.py +++ b/pyrate/config.py @@ -17,7 +17,7 @@ This Python module contains utilities to parse PyRate configuration files. It also includes numerous general constants relating to options in configuration files. Examples of PyRate configuration files are -provided in the configs/ directory +provided in the configs/ directory. """ # coding: utf-8 # pylint: disable= invalid-name @@ -179,9 +179,10 @@ def degree_conv(deg): """ Convenience: convert numerical degree to human readable string. - :param deg: xxxx + :param xxx(eg str, tuple, int, float...) deg: xxxx - :return xxxx + :return: xxxx + :rtype: str """ degree = int(deg) @@ -198,9 +199,10 @@ def method_conv(meth): """ Convenience: convert numerical method to human readable string. - :param meth: xxxx + :param xxx(eg str, tuple, int, float...) meth: xxxx - :return xxxx + :return: xxxx + :rtype: str """ method = int(meth) @@ -273,11 +275,12 @@ def method_conv(meth): def get_config_params(path): """ - Dictionary for the key:value pairs from the .conf file. + Dictionary for the key:value pairs from the config file. - :param path: xxxx + :param xxx(eg str, tuple, int, float...) path: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ txt = '' with open(path, 'r') as inputFile: @@ -300,12 +303,12 @@ def get_config_params(path): def _parse_conf_file(content): """ - Parser for converting text content into a dict of parameters. + Parser for converting text content into a dictionary of parameters. """ def is_valid(line): """ - check if line is not empty or has % or #. + Check if line is not empty or has % or #. """ return line != "" and line[0] not in "%#" @@ -392,9 +395,10 @@ def parse_namelist(nml): """ Parses name list file into array of paths. - :param nml: xxxx + :param xxx(eg str, tuple, int, float...) nml: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ with open(nml) as f_in: lines = [line.rstrip() for line in f_in] @@ -412,10 +416,11 @@ def write_config_file(params, output_conf_file): """ Takes a param object and write the config file. Reverse of get_conf_params. - :param params: params dictionary - ;param output_conf_file: xxxx + :param dict params: params dictionary + :param xxx(eg str, tuple, int, float...) output_conf_file: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ with open(output_conf_file, 'w') as f: for k, v in params.items(): @@ -431,9 +436,10 @@ def reverse_degree_conv(v): """ Convenience: convert numerical degree to human readable string. - ;param v: xxxx + :param xxx(eg str, tuple, int, float...) v: xxxx - :return xxxx + :return: xxxx + :rtype: str """ if v == PLANAR: return 1 @@ -450,7 +456,7 @@ def transform_params(params): """ Subset of config parameters for cropping and multi-looking. - ;param params: xxxx + :param xxx(eg str, tuple, int, float...) params: xxxx :return xxxx """ @@ -464,9 +470,10 @@ def original_ifg_paths(ifglist_path): """ Sequence of paths to files in given ifglist file. - ;param ifglist_path: xxxx + :param xxx(eg str, tuple, int, float...) ifglist_path: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ basedir = os.path.dirname(ifglist_path) @@ -478,11 +485,12 @@ def mlooked_path(path, looks, crop_out): """ Adds suffix to path, for creating a new path for mlooked files. - ;param path: xxxx - :param looks: xxxx - :param crop_out: xxxx + :param xxx(eg str, tuple, int, float...) path: xxxx + :param xxx looks: xxxx + :param xxx crop_out: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ base, ext = splitext(path) return "{base}_{looks}rlks_{crop_out}cr{ext}".format( @@ -493,12 +501,13 @@ def get_dest_paths(base_paths, crop, params, looks): """ xxxx - :param base_paths: Unwrapped interferogram paths - :param crop: Crop method to use - :param params: Parameters dictionary corresponding to config file used - :param looks: multi-looking + :param list base_paths: Unwrapped interferogram paths + :param int crop: Crop method to use + :param dict params: Parameters dictionary corresponding to config file used + :param int looks: multi-looking - :return list of output geotifs. + :return: List of output geotifs. + :rtype: xxxx(eg float) """ dest_mlooked_ifgs = [mlooked_path(os.path.basename(q).split('.')[0] + '_' + os.path.basename(q).split('.')[1] + @@ -512,11 +521,12 @@ def get_ifg_paths(config_file): """ xxxx - :param config_file: Config file path + :param str config_file: Config file path - :return base_unw_paths: List of unwrapped inteferrograms - :return dest_paths: List of multi-looked and cropped geotifs - :return pars: Dictionary corresponding to the config file. + :return: base_unw_paths: List of unwrapped inteferograms + :return: dest_paths: List of multi-looked and cropped geotifs + :return: pars: Dictionary corresponding to the config file + :rtype: xxxx(eg float) """ pars = get_config_params(config_file) ifg_file_list = pars.get(IFG_FILE_LIST) diff --git a/pyrate/gamma.py b/pyrate/gamma.py old mode 100644 new mode 100755 index a90fc4606..3c3861de0 --- a/pyrate/gamma.py +++ b/pyrate/gamma.py @@ -42,11 +42,12 @@ def check_raw_data(data_path, ncols, nrows): """ xxxx - :param data_path: Path to file - :param ncols: Expected number of columns - :param nrows: Expected number of rows + :param str data_path: Path to file + :param int ncols: Expected number of columns + :param int nrows: Expected number of rows - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ size = ncols * nrows * 4 # DEM and Ifg data are 4 byte floats @@ -60,9 +61,10 @@ def check_step_mismatch(hdr): """ xxxx - :param hdr: Dictionary corresponding to header file + :param dict hdr: Dictionary corresponding to header file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable= invalid-name xs, ys = [abs(i) for i in [hdr[ifc.PYRATE_X_STEP], hdr[ifc.PYRATE_Y_STEP]]] @@ -76,9 +78,10 @@ def parse_header(path): """ Parses all GAMMA epoch/DEM header file fields into a dictionary. - :param path: xxxx + :param xxx(eg str, tuple, int, float...) path: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ with open(path) as f: text = f.read().splitlines() @@ -92,9 +95,10 @@ def parse_epoch_header(path): """ Returns dictionary of the minimum required epoch metadata needed for PyRate. - :param path: xxxx + :param xxx(eg str, tuple, int, float...) path: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ lookup = parse_header(path) subset = parse_date_time(lookup) @@ -119,9 +123,10 @@ def parse_date_time(lookup): """ Grab date and time information and convert to datetime objects. - :param lookup: xxxx + :param xxx(eg str, tuple, int, float...) lookup: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ subset = {} if len(lookup[GAMMA_DATE]) == 3: # pragma: no cover @@ -145,9 +150,10 @@ def parse_dem_header(path): """ Dictionary of metadata for converting GAMMA to custom PyRate GeoTIFF. - :param lookup: xxxx + :param xxx(eg str, tuple, int, float...) path: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ lookup = parse_header(path) @@ -175,9 +181,10 @@ def frequency_to_wavelength(freq): """ Convert radar frequency to wavelength. - :param freq: xxxx + :param xxx(eg str, tuple, int, float...) freq: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ return ifc.SPEED_OF_LIGHT_METRES_PER_SECOND / freq @@ -186,11 +193,12 @@ def combine_headers(hdr0, hdr1, dem_hdr): """ Combines both epoch header lookups into single interferogram header/dictionary. - :param hdr0: Header for the earliest/master interferogram - :param hdr1: Header for the latest/slave interferogram - :param dem_hdr: Dictionary of DEM header attributes + :param xxx(eg str, tuple, int, float...) hdr0: Header for the earliest/master interferogram + :param xxx hdr1: Header for the latest/slave interferogram + :param xxx dem_hdr: Dictionary of DEM header attributes - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if not all([isinstance(a, dict) for a in [hdr0, hdr1, dem_hdr]]): raise GammaException('Header args need to be dicts') @@ -237,10 +245,11 @@ def manage_headers(dem_header_file, header_paths): """ xxxx - :param dem_header_file: Dem header path - :param header_paths: Header paths corresponding to the master and slave dates + :param xxx(eg str, tuple, int, float...) dem_header_file: DEM header path + :param xxx header_paths: Header paths corresponding to the master and slave dates - :return combined_header: Combined dictionary with dem, header file 1 and 2 + :return: combined_header: Combined dictionary with DEM, header file 1 and 2 + :rtype: dict """ dem_header = parse_dem_header(dem_header_file) # find param files containing filename dates @@ -257,5 +266,5 @@ def manage_headers(dem_header_file, header_paths): class GammaException(Exception): """ - Gamma generic exception class. + GAMMA generic exception class. """ diff --git a/pyrate/gdal_python.py b/pyrate/gdal_python.py old mode 100644 new mode 100755 index ba61bea75..81c4d765c --- a/pyrate/gdal_python.py +++ b/pyrate/gdal_python.py @@ -33,11 +33,12 @@ def world_to_pixel(geo_transform, x, y): the pixel location of a geospatial coordinate; from: http://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html#clip-a-geotiff-with-shapefile - :param geo_transform: xxxx - :param x: xxxx - :param y:xxxx + :param xxx(eg str, tuple, int, float...) geo_transform: xxxx + :param xxx x: xxxx + :param xxx y:xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ul_x = geo_transform[0] ul_y = geo_transform[3] @@ -60,12 +61,13 @@ def crop(input_file, extents, geo_trans=None, nodata=np.nan): http://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html #clip-a-geotiff-with-shapefile - :param input_file: A gdal.Dataset or a NumPy array - :param extents: The path to the clipping features - :param geo_trans: An optional GDAL GeoTransform to use instead - :param nodata: The NoData value; defaults to -9999 + :param array input_file (a gdal.Dataset or a NumPy array) + :param xxx extents: The path to the clipping features + :param xxx geo_trans: An optional GDAL GeoTransform to use instead + :param int nodata: The NoData value; defaults to -9999 - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ def image_to_array(i): @@ -174,12 +176,13 @@ def resample_nearest_neighbour(input_tif, extents, new_res, output_file): """ Nearest neighbor resampling via GDAL. - :param input_tif: xxxx - :param extents: xxxx - :param new_res: xxxx - :param output_file: xxxx + :param xxx(eg str, tuple, int, float...) input_tif: xxxx + :param xxx extents: xxxx + :param xxx new_res: xxxx + :param xxx output_file: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ dst, resampled_proj, src, _ = crop_rasample_setup(extents, input_tif, @@ -196,14 +199,15 @@ def crop_rasample_setup(extents, input_tif, new_res, output_file, """ Convenience function for crop/resample setup. - :param extents: xxxx - :param input_tif: xxxx - :param new_res: xxxx - :param output_file: xxxx - :param dst_driver_type: xxxx - :param out_bands: xxxx + :param xxx(eg str, tuple, int, float...) extents: xxxx + :param xxx input_tif: xxxx + :param xxx new_res: xxxx + :param xxx output_file: xxxx + :param xxx dst_driver_type: xxxx + :param xxx out_bands: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # Source src_ds = gdal.Open(input_tif, gdalconst.GA_ReadOnly) @@ -246,13 +250,14 @@ def gdalwarp_width_and_height(max_x, max_y, min_x, min_y, geo_trans): """ Modify pixel height and width based on world_to_pixel. - :param max_x: xxxx - :param max_y: xxxx - :param min_x: xxxx - :param min_y: xxxx - :param geo_trans: xxxx + :param xxx(eg str, tuple, int, float...) max_x: xxxx + :param xxx max_y: xxxx + :param xxx min_x: xxxx + :param xxx min_y: xxxx + :param xxx geo_trans: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # modified image extents ul_x, ul_y = world_to_pixel(geo_trans, min_x, max_y) @@ -270,15 +275,16 @@ def crop_resample_average( """ Crop, resample, and average a geotif. - :param input_tif: Path to input geotif to resample/crop - :param extents: Georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) - :param output_file: Output resampled/cropped file name - :param new_res: [xres, yres] Sets resolution output interferogram metadata - :param thresh: NaN fraction threshold - :param out_driver_type: The output driver type. `MEM` or `GTiff` (optional) - :param match_pirate: Whether to match Matlab Pirate style resampled/cropped output (optional) + :param str input_tif: Path to input geotif to resample/crop + :param tuple extents: Georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) + :param str output_file: Output resampled/cropped file name + :param list new_res: [xres, yres] Sets resolution output interferogram metadata + :param float thresh: NaN fraction threshold + :param str out_driver_type: The output driver type. `MEM` or `GTiff` (optional) + :param bool match_pirate: Whether to match Matlab Pirate style resampled/cropped output (optional) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ dst_ds, _, _, _ = crop_rasample_setup( extents, input_tif, new_res, output_file, @@ -332,18 +338,19 @@ def crop_resample_average( def matlab_alignment(input_tif, new_res, resampled_average, src_ds_mem, src_gt, tmp_ds): """ - Correction step to match python multilook/crop ouput to match that of + Correction step to match python multi-look/crop output to match that of Matlab Pirate code. - :param input_tif: Path to input geotif to resample/crop - :param new_res: [xres, yres] Sets resolution output interferogram metadata - :param resampled_average: ndarray from previous step with average resampling + :param str input_tif: Path to input geotif to resample/crop + :param list new_res: [xres, yres] Sets resolution output interferogram metadata + :param ndarray resampled_average: ndarray from previous step with average resampling applied to phase data - :param src_ds_mem: gdal memory dataset object - :param src_gt: Geotransform tuple - :param tmp_ds: gdal memory dataset object + :param gdal.Dataset src_ds_mem: gdal memory dataset object + :param tuple src_gt: Geotransform tuple + :param gdal.Dataset tmp_ds: gdal memory dataset object :return Modifies the resampled_average array in place. + :rtype: xxxx(eg float) """ src_ds = gdal.Open(input_tif) data = src_ds.GetRasterBand(1).ReadAsArray() @@ -368,16 +375,16 @@ def gdal_average(dst_ds, input_tif, thresh): """ xxxx - :param dst_ds: Destination gdal dataset object - :param input_tif: Input geotif - :param thresh: NaN fraction threshold + :param gdal.Dataset dst_ds: Destination gdal dataset object + :param str input_tif: Input geotif + :param float thresh: NaN fraction threshold :return resampled_average: ndarray of of ifg phase data :return src_ds_mem: Modified in memory src_ds with nan_fraction in Band2. The nan_fraction is computed efficiently here in gdal in the same step as the that of the resampled average (band 1). This results is huge memory and computational efficiency - + :rtype: ndarray """ src_ds, src_ds_mem = _setup_source(input_tif) src_ds_mem.GetRasterBand(2).SetNoDataValue(-100000) diff --git a/pyrate/linrate.py b/pyrate/linrate.py old mode 100644 new mode 100755 index e0328f1ca..3c6cc1ffc --- a/pyrate/linrate.py +++ b/pyrate/linrate.py @@ -35,16 +35,17 @@ def linear_rate(ifgs, params, vcmt, mst=None): Pixel-by-pixel linear rate (velocity) estimation using iterative weighted least-squares method. - :param ifgs: Sequence of interferogram objects from which to extract observations - :param params: Configuration parameters - :param vcmt: Derived positive definite temporal variance covariance matrix - :param mst: Pixel-wise matrix describing the minimum spanning tree network - :param parallel: Use multiprocessing or not - :param processes: Number of parallel processes to use - - :return rate: Linear rate (velocity) map - :return error: Standard deviation of the rate map - :return samples: Statistics of coherent observations used in calculation + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects from which to extract observations + :param xxx params: Configuration parameters + :param xxx vcmt: Derived positive definite temporal variance covariance matrix + :param xxx mst: Pixel-wise matrix describing the minimum spanning tree network + :param xxx parallel: Use multiprocessing or not + :param xxx processes: Number of parallel processes to use + + :return: rate: Linear rate (velocity) map + :return: error: Standard deviation of the rate map + :return: samples: Statistics of coherent observations used in calculation + :rtype: xxxx(eg float) """ maxsig, nsig, pthresh, cols, error, mst, obs, parallel, _, \ rate, rows, samples, span = linrate_setup(ifgs, mst, params) @@ -94,11 +95,12 @@ def linrate_setup(ifgs, mst, params): """ Convenience function for linrate setup. - :param ifgs: xxxx - :param mst: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx mst: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # MULTIPROCESSING parameters parallel = params[cf.PARALLEL] @@ -132,16 +134,17 @@ def linear_rate_by_rows(row, cols, mst, NSIG, obs, PTHRESH, span, vcmt): """ Helper function for parallel 'row' runs. - :param row: xxxx - :param cols: xxxx - :param mst: xxxx - :param NSIG: xxxx - :param obs: xxxx - :param PTHRESH: xxxx - :param span: Span calculated in linarate function - :param vcmt: Temporal vcm matrix + :param xxx(eg str, tuple, int, float...) row: xxxx + :param xxx cols: xxxx + :param xxx mst: xxxx + :param xxx NSIG: xxxx + :param xxx obs: xxxx + :param xxx PTHRESH: xxxx + :param xxx span: Span calculated in linarate function + :param xxx vcmt: Temporal vcm matrix - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ res = np.empty(shape=(cols, 3), dtype=np.float32) for col in range(cols): @@ -155,16 +158,17 @@ def linear_rate_by_pixel(row, col, mst, nsig, obs, pthresh, span, vcmt): """ Compute linear rate for one pixel. - :param row: xxxx - :param col: xxxx - :param mst: xxxx - :param nsig: xxxx - :param obs: xxxx - :param pthresh: xxxx - :param span: xxxx - :param vcmt: xxxx + :param xxx row: xxxx + :param xxx col: xxxx + :param xxx mst: xxxx + :param xxx nsig: xxxx + :param xxx obs: xxxx + :param xxx pthresh: xxxx + :param xxx span: xxxx + :param xxx vcmt: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # find the indices of independent ifgs for given pixel from MST ind = np.nonzero(mst[:, row, col])[0] # only True's in mst are chosen diff --git a/pyrate/matlab_mst.py b/pyrate/matlab_mst.py old mode 100644 new mode 100755 index 53ac9949d..8d0854fe0 --- a/pyrate/matlab_mst.py +++ b/pyrate/matlab_mst.py @@ -94,7 +94,7 @@ def make_data_stack(self): class IfgListPyRate(IfGMeta): """ Copy of Matlab Pirate ifglist in getnml.m. - Please note that we don't need BaseT unless we are using variance in ifg + Please note that we don't need BaseT unless we are using variance in interferogram data as cost. """ # pylint: disable=too-many-instance-attributes @@ -126,13 +126,14 @@ def get_nml_list(self): def data_setup(datafiles): """ - Interferogram objects for the files in the small_test data dir + Interferogram objects for the files in the small_test data directory input phase data is in radians; - these ifgs are in radians - not converted to mm + these interferograms are in radians - not converted to mm - :param datafiles: xxxx + :param xxx(eg str, tuple, int, float...) datafiles: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ datafiles.sort() ifgs = [Ifg(i) for i in datafiles] @@ -149,11 +150,12 @@ def get_nml(ifg_list_instance, nodata_value, Note: the Matlab version tested does not have nan's. replaces the ifg_list_instance in place. - :param ifg_list_instance: xxxx - :param nodata_value: xxxx - :param nan_conversion: xxxx + :param xxx(eg str, tuple, int, float...) ifg_list_instance: xxxx + :param xxx nodata_value: xxxx + :param xxx nan_conversion: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ _epoch_list, n = get_epochs(ifg_list_instance.ifgs) ifg_list_instance.reshape_n(n) @@ -169,9 +171,10 @@ def matlab_mst_kruskal(edges, ntrees=False): """ This is an implementation of the Matlab Pirate mst_kruskal.m - :param edges: List of edges, list of tuples (id, master, slave, nan_frac) + :param xxx(eg str, tuple, int, float...) edges: List of edges, list of tuples (id, master, slave, nan_frac) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ num_ifgs = len(edges) master_l = [e[1] for e in edges] @@ -213,10 +216,11 @@ def calculate_connect_and_ntrees(connect, mst_list): """ Count isolated trees. - :param connect: xxxx - :param mst_list: xxxx + :param xxx(eg str, tuple, int, float...) connect: xxxx + :param xxx(eg str, tuple, int, float...) mst_list: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ zero_count = np.where(np.sum(connect, axis=1) == 0)[0] if zero_count.shape[0]: @@ -234,10 +238,11 @@ def matlab_mst(ifg_object, p_threshold=1): """ This is an implementation of the Matlab Pirate make_mstmat.m function. - :param ifg_object: xxxx - :param p_threshold: xxxx + :param xxx(eg str, tuple, int, float...) ifg_object: xxxx + :param xxx p_threshold: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ edges = get_sub_structure(ifg_object, np.zeros(len(ifg_object.id), dtype=bool)) @@ -279,10 +284,11 @@ def matlab_mst_gen(ifg_instance, p_threshold=1): If memory was not a concern we could have found the entire mst matrix in the 'matlab_mst' function and this would have been unnecessary. - :param ifg_instance: IfgListPyRate instance - :param p_threshold: Minimum number of non-nan values at any pixel for selection + :param xxx(eg str, tuple, int, float...) ifg_instance: IfgListPyRate instance + :param xxx p_threshold: Minimum number of non-nan values at any pixel for selection - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ edges = get_sub_structure(ifg_instance, np.zeros(len(ifg_instance.id), dtype=bool)) @@ -325,10 +331,11 @@ def matlab_mst_bool(ifg_list_instance, p_threshold=1): If memory was not a concern we could have found the entire mst matrix in the previous function and this would have been unnecessary. - :param ifg_list_instance: IfgListPyRate instance - :param p_threshold: Minimum number of non-nan values at any pixel for selection + :param xxx(eg str, tuple, int, float...) ifg_list_instance: IfgListPyRate instance + :param xxx p_threshold: Minimum number of non-nan values at any pixel for selection - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ num_ifgs = len(ifg_list_instance.ifgs) no_y, no_x = ifg_list_instance.ifgs[0].phase_data.shape @@ -344,10 +351,11 @@ def get_sub_structure(ifg_list, nan_v): """ This is an implementation of the getsubstruct.m function from Matlab Pirate. - :param ifg_list: Original ifg_list class instance - :param nan_v: All interferogram values at this location + :param xxx(eg str, tuple, int, float...) ifg_list: Original ifg_list class instance + :param xxx nan_v: All interferogram values at this location - :returns List of tuples (id, master, slave, nan_frac) corresponding to the chosen interferograms. + :return: List of tuples (id, master, slave, nan_frac) corresponding to the chosen interferograms. + :rtype: tuple """ indices_chosen = np.nonzero(~nan_v)[0] diff --git a/pyrate/mpiops.py b/pyrate/mpiops.py old mode 100644 new mode 100755 index 81d2134e1..6d1fad425 --- a/pyrate/mpiops.py +++ b/pyrate/mpiops.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -This Python module contains MPI convenience functions for PyRate +This Python module contains MPI convenience functions for PyRate. """ # pylint: disable=no-member # pylint: disable=invalid-name @@ -43,22 +43,18 @@ def run_once(f, *args, **kwargs): - """Run a function on one node, broadcast result to all + """ + Run a function on one node, broadcast result to all This function evaluates a function on a single node in the MPI world, then broadcasts the result of that function to every node in the world. - Parameters - ---------- - f : callable - The function to be evaluated. Can take arbitrary arguments and return + + :param xxx(eg str, tuple, int, float...) f: The function to be evaluated. Can take arbitrary arguments and return anything or nothing - args : optional - Other positional arguments to pass on to f - kwargs : optional - Other named arguments to pass on to f - Returns - ------- - result - The value returned by f + :param xxx args: Other positional arguments to pass on to f (optional) + :param xxx kwargs: Other named arguments to pass on to f (optional) + + :return: The value returned by f. + :rtype: xxxx(eg float) """ if rank == 0: f_result = f(*args, **kwargs) @@ -70,16 +66,14 @@ def run_once(f, *args, **kwargs): def array_split(arr, process=None): """ - Convenience function for splitting array elements across MPI processes - Parameters - ---------- - arr: ndarray - 1-D array - process: int, optional - process for which array members are required. - If None, MPI.comm.rank is used instead. + Convenience function for splitting array elements across MPI processes. + + :param array arr: 1-D array + :parm xxx process: Process for which array members are required. + If None, MPI.comm.rank is used instead. (optional) - Returns list corresponding to array members in a a process + :return List corresponding to array members in a process. + :rtype: xxxx(eg float) """ r = process if process else rank return np.array_split(arr, size)[r] diff --git a/pyrate/mst.py b/pyrate/mst.py old mode 100644 new mode 100755 index f76b7a662..2f7791caf --- a/pyrate/mst.py +++ b/pyrate/mst.py @@ -40,12 +40,13 @@ def mst_from_ifgs(ifgs): """ - Returns default MST dict for the given Ifgs. The MST is calculated using a + Returns default MST dict for the given interferograms. The MST is calculated using a weighting based on the number of incoherent cells in the phase band. - :param ifgs: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ edges_with_weights_for_networkx = [(i.master, i.slave, i.nan_fraction) @@ -62,12 +63,13 @@ def mst_from_ifgs(ifgs): def mst_parallel(ifgs, params): """ - Wrapper function for calculating ifgs in non MPI runs. + Wrapper function for calculating interferograms in non MPI runs. - :param ifgs: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ print('Calculating mst using tiles') ncpus = params[cf.PROCESSES] @@ -103,16 +105,17 @@ def mst_parallel(ifgs, params): def mst_multiprocessing(tile, ifgs_or_paths, preread_ifgs=None): """ - The memory requirement during mpi mst computation is determined by the + The memory requirement during MPI MST computation is determined by the number of interferograms times size of IfgPart. Note that we need all interferogram header information (like masters/slave dates) for MST computation. - To manage memory we need smaller tiles (IfgPart) as number of ifgs go up. + To manage memory we need smaller tiles (IfgPart) as number of interferograms go up. - :param tile: Tile class instance - :param ifgs_or_paths: All interferograms paths of the problem. List of strings - :param preread_ifgs: xxxx + :param xxx(eg str, tuple, int, float...) tile: Tile class instance + :param xxx ifgs_or_paths: All interferograms paths of the problem. List of strings + :param xxx preread_ifgs: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ifg_parts = [IfgPart(p, tile, preread_ifgs) for p in ifgs_or_paths] t_mst = mst_boolean_array(ifg_parts) @@ -121,7 +124,7 @@ def mst_multiprocessing(tile, ifgs_or_paths, preread_ifgs=None): def _build_graph_networkx(edges_with_weights): """ - Convenience graph builder function: returns a new graph obj. + Convenience graph builder function: returns a new graph object. """ g = nx.Graph() g.add_weighted_edges_from(edges_with_weights) @@ -132,10 +135,11 @@ def mst_boolean_array(ifgs): """ The MSTs are stripped of connecting edge info, leaving just the interferograms. - :param ifgs: Sequence of interferogram objects + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects - :return Filter: Array of independent interferograms from the pixel by pixel MST, - like that used by the Matlab Pirate package + :return: Filter: Array of independent interferograms from the pixel by pixel MST, + like that used by the Matlab Pirate package. + :rtype: array """ no_ifgs = len(ifgs) no_y, no_x = ifgs[0].phase_data.shape @@ -157,9 +161,10 @@ def mst_matrix_ifgs_only(ifgs): """ The MSTs are stripped of connecting edge info, leaving just the interferograms. - :param ifgs: Sequence of interferogram objects + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects :return Filter: Array of independent interferograms from the pixel by pixel MST + :rtype: array """ result = empty(shape=ifgs[0].phase_data.shape, dtype=object) @@ -176,9 +181,10 @@ def mst_matrix_as_array(ifgs): """ Each pixel contains an MST (with connecting edges etc). - :param ifgs: Sequence of interferogram objects + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects - :return Filter: Array of pixel by pixel MSTs + :return: Filter: Array of pixel by pixel MSTs + :rtype: array """ mst_result = empty(shape=ifgs[0].phase_data.shape, dtype=object) @@ -194,9 +200,10 @@ def mst_matrix_networkx(ifgs): """ Generates/emits MST trees on a pixel-by-pixel basis for the given interferograms. - :param ifgs: Sequence of interferogram objects + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # make default MST to optimise result when no Ifg cells in a stack are nans edges_with_weights = [(i.master, i.slave, i.nan_fraction) for i in ifgs] @@ -242,9 +249,10 @@ def minimum_spanning_edges_from_mst(edges): """ xxxx - :param edges: List of tuples (master, slave, nan_frac) corresponding to interferograms + :param list edges: List of tuples (master, slave, nan_frac) corresponding to interferograms - :return edges: List of MST edges (g_nx: nx.Graph() instance) + :return: edges: List of MST edges (g_nx: nx.Graph() instance) + :rtype: list """ g_nx = _build_graph_networkx(edges) T = minimum_spanning_tree(g_nx) # step ifglist_mst in make_mstmat.m @@ -264,10 +272,11 @@ def minimum_spanning_tree(G, weight='weight'): spanning forest is a union of the spanning trees for each connected component of the graph. - :param G: NetworkX Graph - :param weight: Edge data key to use for weight (default 'weight') + :param xxx(eg str, tuple, int, float...) G: NetworkX Graph + :param str weight: Edge data key to use for weight (default 'weight') - :return G: NetworkX Graph, a minimum spanning tree or forest + :return: G: NetworkX Graph, a minimum spanning tree or forest + :rtype: xxxx(eg float) Examples >>> G=nx.cycle_graph(4) @@ -302,12 +311,13 @@ def minimum_spanning_edges(G, weight='weight', data=True): with the minimum sum of edge weights. A spanning forest is a union of the spanning trees for each connected component of the graph. - :param G: NetworkX Graph - :param weight: Edge data key to use for weight (default 'weight') - :param data: If True yield the edge data along with the edge (optional) + :param xxx(eg str, tuple, int, float...) G: NetworkX Graph + :param str weight: Edge data key to use for weight (default 'weight') + :param bool data: If True yield the edge data along with the edge (optional) - :return edges: iterator. A generator that produces edges in the minimum spanning tree. + :return: edges: A generator that produces edges in the minimum spanning tree. The edges are three-tuples (u,v,w) where w is the weight + :rtype: iterator Examples >>> G=nx.cycle_graph(4) diff --git a/pyrate/orbital.py b/pyrate/orbital.py old mode 100644 new mode 100755 index cf2eea1c9..a38a7cde6 --- a/pyrate/orbital.py +++ b/pyrate/orbital.py @@ -76,17 +76,18 @@ def orbital_correction(ifgs_or_ifg_paths, params, mlooked=None, offset=True, """ Removes orbital error from given interferograms. - NB: the ifg data is modified in situ, rather than create intermediate files. + NB: the interferogram data is modified in situ, rather than create intermediate files. The network method assumes the given interferograms have already been reduced to a minimum set from an MST type operation. - :param ifgs: Sequence ofintererogram objects to correct - :param degree: PLANAR, QUADRATIC or PART_CUBIC - :param method: INDEPENDENT_METHOD or NETWORK_METHOD - :param mlooked: Sequence of multi-looked interferograms (must correspond to 'ifgs' arg) + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects to correct + :param str degree: PLANAR, QUADRATIC or PART_CUBIC + :param str method: INDEPENDENT_METHOD or NETWORK_METHOD + :param mlooked: Sequence of multi-looked interferograms (must correspond to 'ifgs' argument) :param bool offset: True/False to include the constant/offset component - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ degree = params[cf.ORBITAL_FIT_DEGREE] method = params[cf.ORBITAL_FIT_METHOD] @@ -123,9 +124,9 @@ def orbital_correction(ifgs_or_ifg_paths, params, mlooked=None, offset=True, def _validate_mlooked(mlooked, ifgs): - ''' + """ Basic sanity checking of the multi-looked interferograms. - ''' + """ if len(mlooked) != len(ifgs): msg = "Mismatching # ifgs and # multilooked ifgs" @@ -137,9 +138,9 @@ def _validate_mlooked(mlooked, ifgs): def _get_num_params(degree, offset=None): - ''' + """ Returns number of model parameters. - ''' + """ if degree == PLANAR: nparams = 2 @@ -160,14 +161,15 @@ def _get_num_params(degree, offset=None): def independent_correction(ifg, degree, offset, params): """ Calculates and removes orbital correction from an interferogram. - .. warn:: This will write orbital error corrected phase_data in the interferograms. + warn:: This will write orbital error corrected phase_data in the interferograms. - :param ifg: the interferogram to remove remove the orbital error from - :param degree: Type of model to use PLANAR, QUADRATIC etc - :param offset: Boolean - :param params: Parameter dictionary + :param xxx(eg str, tuple, int, float...) ifg: the interferogram to remove remove the orbital error from + :param str degree: Type of model to use PLANAR, QUADRATIC etc + :param bool offset: xxxx + :param dict params: Parameter dictionary - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ifg = shared.Ifg(ifg) if isinstance(ifg, str) else ifg if not ifg.is_open: @@ -200,18 +202,19 @@ def network_correction(ifgs, degree, offset, params, m_ifgs=None, preread_ifgs=None): """ Calculates orbital correction model, removing this from the interferograms. - .. warn:: This will write orbital error corrected phase_data in the interferograms. + warn:: This will write orbital error corrected phase_data in the interferograms. - :param ifgs: Interferograms reduced to a minimum tree from prior + :param xxx(eg str, tuple, int, float...) ifgs: Interferograms reduced to a minimum tree from prior MST calculations - :param degree: PLANAR, QUADRATIC or PART_CUBIC - :param offset: True to calculate the model using offsets - :param params: Parameter dictionary - :param m_ifgs: Multi-looked orbfit interferograms (sequence must be mlooked - versions of 'ifgs' arg) + :param xxx degree: PLANAR, QUADRATIC or PART_CUBIC + :param xxx offset: True to calculate the model using offsets + :param xxx params: Parameter dictionary + :param xxx m_ifgs: Multi-looked orbfit interferograms (sequence must be mlooked + versions of 'ifgs' argument) :param preread_ifgs: Parameters dictionary corresponding to config file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-locals, too-many-arguments src_ifgs = ifgs if m_ifgs is None else m_ifgs @@ -278,7 +281,7 @@ def _save_orbital_error_corrected_phase(ifg): Convenceince function to update metadata and save latest phase after orbital fit correction. - :param ifg: Interferogram class instance + :param xxx(eg str, tuple, int, float...) ifg: Interferogram class instance """ # set orbfit tags after orbital error correction ifg.dataset.SetMetadataItem(ifc.PYRATE_ORBITAL_ERROR, ifc.ORB_REMOVED) @@ -291,12 +294,13 @@ def get_design_matrix(ifg, degree, offset, scale=100.0): """ Simple design matrix with columns for model parameters. - :param ifg: interferogram to base the DM on - :param degree: PLANAR, QUADRATIC or PART_CUBIC - :param offset: True to include offset cols, otherwise False - :param scale: amount to divide cell size by for improving inversion robustness + :param xxx(eg str, tuple, int, float...) ifg: interferogram to base the design matrix (DM) on + :param xxx degree: PLANAR, QUADRATIC or PART_CUBIC + :param xxx offset: True to include offset cols, otherwise False + :param xxx scale: amount to divide cell size by for improving inversion robustness - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if degree not in [PLANAR, QUADRATIC, PART_CUBIC]: @@ -344,11 +348,12 @@ def get_network_design_matrix(ifgs, degree, offset): Larger format design matrix for networked error correction. The network design matrix includes rows which relate to those of NaN cells. - :param ifgs: sequence of interferograms - :param degree: PLANAR, QUADRATIC or PART_CUBIC - :param offset: True to include offset cols, otherwise False + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferograms + :param xxx degree: PLANAR, QUADRATIC or PART_CUBIC + :param xxx offset: True to include offset cols, otherwise False - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if degree not in [PLANAR, QUADRATIC, PART_CUBIC]: raise OrbitalError("Invalid degree argument") @@ -401,11 +406,12 @@ def remove_orbital_error(ifgs, params, preread_ifgs=None): """ Wrapper for orbital error removal functionality. - :param ifgs: List of interferograms or interferogram paths - :param params: Dict corresponding to config parameters - :param preread_ifgs: Dict containing information regarding MPI jobs (optional) + :param list ifgs: List of interferograms or interferogram paths + :param dict params: Dictionary corresponding to config parameters + :param dict preread_ifgs: Dictionary containing information regarding MPI jobs (optional) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if not params[cf.ORBITAL_FIT]: log.info('Orbital correction not required') diff --git a/pyrate/prepifg.py b/pyrate/prepifg.py old mode 100644 new mode 100755 index 124676631..206c8eb32 --- a/pyrate/prepifg.py +++ b/pyrate/prepifg.py @@ -16,7 +16,7 @@ """ This Python module converts interferogram input files to a common geotiff format with PyRate specific metadata headers. The module also implements -multilooking/downsampling and cropping operations to reduce the size of +multi-looking/downsampling and cropping operations to reduce the size of the computational problem. """ # pylint: disable=too-many-arguments,invalid-name @@ -54,9 +54,10 @@ def is_number(s): """ Check whether string can be converted to float. - :param: s: xxxxx + :param xxx(eg str, tuple, int, float...) s: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ try: float(s) @@ -76,13 +77,14 @@ def get_analysis_extent( """ Returns extents/bounding box args for gdalwarp as strings. - :param: crop_opt: xxxxx - :param: rasters: xxxxx - :param: xlooks: xxxxx - :param: ylooks: xxxxx - :param: user_exts: xxxxx + :param xxx(eg str, tuple, int, float...) crop_opt: xxxxx + :param xxx rasters: xxxxx + :param xxx xlooks: xxxxx + :param xxx ylooks: xxxxx + :param xxx user_exts: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if crop_opt not in CROP_OPTIONS: @@ -118,15 +120,16 @@ def prepare_ifg( """ Resample and crop interferograms/DEMs. - :param: raster_path: xxxxx - :param: xlooks: xxxxx - :param: ylooks: xxxxx - :param: exts: xxxxx - :param: thresh: xxxxx - :param: crop_out: xxxxx - :param: write_to_disc: xxxxx + :param xxx(eg str, tuple, int, float...) raster_path: xxxxx + :param xxx xlooks: xxxxx + :param xxx ylooks: xxxxx + :param xxx exts: xxxxx + :param xxx thresh: xxxxx + :param xxx crop_out: xxxxx + :param xxx write_to_disc: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ do_multilook = xlooks > 1 or ylooks > 1 @@ -154,9 +157,10 @@ def dummy_warp(renamed_path): """ Convenience dummy operation. - :param: renamed_path: xxxxx + :param xxx(eg str, tuple, int, float...) renamed_path: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ifg = dem_or_ifg(renamed_path) ifg.open() @@ -178,22 +182,23 @@ def prepare_ifgs( """ Produces multi-looked/resampled data files for PyRate analysis. - :param raster_data_paths: Sequence of interferogram data paths + :param xxx(eg str, tuple, int, float...) raster_data_paths: Sequence of interferogram data paths (Currently DEMs are not supported) - :param crop_opt: Integer cropping type option (see config) - :param xlooks: Multi-looking factor for the X axis - :param ylooks: Multi-looking factor for the Y axis - :param float thresh: (0.0, 1.0). Controls NaN handling when resampling to + :param xxx crop_opt: Integer cropping type option (see config) + :param xxx xlooks: Multi-looking factor for the X axis + :param xxx ylooks: Multi-looking factor for the Y axis + :param xxx float thresh: (0.0, 1.0). Controls NaN handling when resampling to coarser grids. Value is the proportion above which the number of NaNs in an area is considered invalid. thresh=0 resamples to NaN if 1 or more contributing cells are NaNs. At 0.25, it resamples to NaN if 1/4 or more contributing cells are NaNs. At 1.0, areas are resampled to NaN only if all contributing cells are NaNs. - :param user_exts: CustomExts tuple with user specified lat long corners - :param verbose: Controls level of gdalwarp output - :param write_to_disc: Wether to write to disc during warp + :param xxx user_exts: CustomExts tuple with user specified lat long corners + :param xxx verbose: Controls level of gdalwarp output + :param xxx write_to_disc: Whether to write to disc during warp - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # use metadata check to check whether it's a dem or ifg rasters = [dem_or_ifg(r) for r in raster_data_paths] @@ -206,11 +211,12 @@ def prepare_ifgs( def dem_or_ifg(data_path): """ - Whether tif is a DEM or interferogram + Whether tif is a DEM or interferogram. - :param: data_path: xxxxx + :param xxx(eg str, tuple, int, float...) data_path: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ds = gdal.Open(data_path) md = ds.GetMetadata() @@ -222,13 +228,14 @@ def dem_or_ifg(data_path): def get_extents(ifgs, crop_opt, user_exts=None): """ - Returns extents/bounding box args for gdalwarp as strings. + Returns extents/bounding box arguments for gdalwarp as strings. - :param: ifgs: xxxxx - :param: crop_opt: xxxxx - :param: user_exts: xxxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxxx + :param xxx crop_opt: xxxxx + :param xxx user_exts: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if crop_opt == MINIMUM_CROP: @@ -247,7 +254,7 @@ def get_extents(ifgs, crop_opt, user_exts=None): # TODO: push out to a shared module def _file_ext(raster): """ - Returns file ext string based on type of raster. + Returns file extension string based on type of raster. """ if isinstance(raster, Ifg): return "tif" @@ -300,18 +307,19 @@ def _resample_ifg(ifg, cmd, x_looks, y_looks, thresh, md=None): def warp(ifg, x_looks, y_looks, extents, resolution, thresh, crop_out, write_to_disc=True): """ - Resamples 'ifg' and returns a new interferogram object. + Resamples interferogram and returns a new interferogram object. - :param xlooks: Factor to scale X axis by, 5 is 5x smaller, 1 is no change - :param ylooks: Factor to scale Y axis by, 5 is 5x smaller, 1 is no change - :param extents: Georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) - :param resolution: [xres, yres] or None. Sets resolution output interferogram metadata. + :param xxx(eg str, tuple, int, float...) xlooks: Factor to scale X axis by, 5 is 5x smaller, 1 is no change + :param xxx ylooks: Factor to scale Y axis by, 5 is 5x smaller, 1 is no change + :param xxx extents: Georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) + :param xxx resolution: [xres, yres] or None. Sets resolution output interferogram metadata. Use *None* if raster size is not being changed - :param thresh: See thresh in prepare_ifgs() - :param verbose: True to print gdalwarp output to stdout - :param write_to_disc: Whether to write to disc during warp + :param xxx thresh: See thresh in prepare_ifgs() + :param xxx verbose: True to print gdalwarp output to stdout + :param xxx write_to_disc: Whether to write to disc during warp - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if x_looks != y_looks: raise ValueError('X and Y looks mismatch') @@ -348,13 +356,14 @@ def resample(data, xscale, yscale, thresh): Resamples/averages 'data' to return an array from the averaging of blocks of several tiles in 'data'. NB: Assumes incoherent cells are NaNs. - :param data: Source array to resample to different size - :param xscale: Number of cells to average along X axis - :param yscale: Number of Y axis cells to average - :param thresh: Minimum allowable proportion of NaN cells (range from 0.0-1.0), eg. 0.25 = 1/4 or + :param xxx data: Source array to resample to different size + :param xxx xscale: Number of cells to average along X axis + :param xxx yscale: Number of cells to average along Y axis + :param xxx thresh: Minimum allowable proportion of NaN cells (range from 0.0-1.0), eg. 0.25 = 1/4 or more as NaNs results in a NaN value for the output cell - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if thresh < 0 or thresh > 1: raise ValueError("threshold must be >= 0 and <= 1") @@ -379,11 +388,12 @@ def resample(data, xscale, yscale, thresh): def check_resolution(ifgs): """ - Verifies Ifg resolutions are equal for the given grids. + Verifies interferogram resolutions are equal for the given grids. - :param: ifgs: xxxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ for var in ['x_step', 'y_step']: @@ -397,10 +407,11 @@ def check_looks(xlooks, ylooks): """ Verifies looks parameters are valid. - :param: xlooks: xxxx - :param: ylooks: xxxx + :param xxx(eg str, tuple, int, float...) xlooks: xxxx + :param xxx ylooks: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if not (isinstance(xlooks, Number) and @@ -418,9 +429,10 @@ def min_bounds(ifgs): """ Returns bounds for overlapping area of the given interferograms. - :param: ifgs: xxxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ xmin = max([i.x_first for i in ifgs]) @@ -434,9 +446,10 @@ def max_bounds(ifgs): """ Returns bounds for the total area covered by the given interferograms. - :param: ifgs: xxxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ xmin = min([i.x_first for i in ifgs]) @@ -450,9 +463,10 @@ def get_same_bounds(ifgs): """ Check and return bounding box for ALREADY_SAME_SIZE option. - :param: ifgs: xxxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ tfs = [i.dataset.GetGeoTransform() for i in ifgs] @@ -475,13 +489,14 @@ def custom_bounds(ifgs, xw, ytop, xe, ybot): """ Check and modify input custom crop bounds to line up with grid interval. - :param: ifgs: xxxx - :param: xw: xxxx - :param: ytop: xxxx - :param: xe: xxxx - :param: ybot: xxxx + :paramv xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx xw: xxxx + :param xxx ytop: xxxx + :param xxx xe: xxxx + :param xxx ybot: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-locals # pylint: disable=too-many-branches @@ -540,15 +555,16 @@ def custom_bounds(ifgs, xw, ytop, xe, ybot): def check_crop_coords(ifgs, xmin, ymin, xmax, ymax): """ - Ensures cropping coords line up with grid system within tolerance. + Ensures cropping coordinates line up with grid system within tolerance. - :param: ifgs: xxxx - :param: xmin: xxxx - :param: ymin: xxxx - :param: xmax: xxxx - :param: ymax: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx xmin: xxxx + :param xxx ymin: xxxx + :param xxx xmax: xxxx + :param xxx ymax: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # NB: assumption is the first Ifg is correct, so only test against it @@ -580,9 +596,10 @@ def extents_from_params(params): """ Custom extents from supplied parameters. - :param: params: xxxxx + :param xxx(eg str, tuple, int, float...) params: xxxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ keys = (cf.IFG_XFIRST, cf.IFG_YFIRST, cf.IFG_XLAST, cf.IFG_YLAST) return CustomExts(*[params[k] for k in keys]) diff --git a/pyrate/pyratelog.py b/pyrate/pyratelog.py old mode 100644 new mode 100755 index 781abd405..7f9ae5bfe --- a/pyrate/pyratelog.py +++ b/pyrate/pyratelog.py @@ -28,9 +28,10 @@ def configure(verbosity): """ Function to configure logging properties. - :param verbosity: 'DEBUG', 'INFO', 'WARNING', or 'ERROR' + :param str verbosity: 'DEBUG', 'INFO', 'WARNING', or 'ERROR' - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log = logging.getLogger("") log.setLevel(verbosity) diff --git a/pyrate/ref_phs_est.py b/pyrate/ref_phs_est.py old mode 100644 new mode 100755 index ca043358c..be2809747 --- a/pyrate/ref_phs_est.py +++ b/pyrate/ref_phs_est.py @@ -32,13 +32,14 @@ def estimate_ref_phase(ifgs, params, refpx, refpy): """ xxxxx - :param ifgs: List of interferograms - :param params: Parameters of the simulation - :param refpx: Reference pixel X found by ref pixel method - :param refpy: Reference pixel Y found by ref pixel method + :param xxx(eg str, tuple, int, float...) ifgs: List of interferograms + :param xxx params: Parameters of the simulation + :param xxx refpx: Reference pixel X found by ref pixel method + :param xxx refpy: Reference pixel Y found by ref pixel method - :return ref_phs: Reference phase correction - :return ifgs: Reference phase data removed from list of interferograms + :return: ref_phs: Reference phase correction + :return: ifgs: Reference phase data removed from list of interferograms + :rtype: xxxx(eg float) """ check_ref_phs_ifgs(ifgs) @@ -61,13 +62,14 @@ def est_ref_phase_method2(ifgs, params, refpx, refpy): """ Reference phase estimate method 2. xxxx - :param ifgs: List of interferograms - :param params: Parameters of the simulation - :param refpx: Reference pixel X found by ref pixel method - :param refpy: Reference pixel Y found by ref pixel method + :param xxx(eg str, tuple, int, float...) ifgs: List of interferograms + :param xxx params: Parameters of the simulation + :param xxx refpx: Reference pixel X found by ref pixel method + :param xxx refpy: Reference pixel Y found by ref pixel method - :return ref_phs: Reference phase correction - :return ifgs: Reference phase data removed from list of interferograms + :return: ref_phs: Reference phase correction + :return: ifgs: Reference phase data removed from list of interferograms + :rtype: xxxx(eg float) """ half_chip_size = int(np.floor(params[cf.REF_CHIP_SIZE] / 2.0)) chipsize = 2 * half_chip_size + 1 @@ -94,15 +96,16 @@ def est_ref_phase_method2(ifgs, params, refpx, refpy): def est_ref_phs_method2(phase_data, half_chip_size, refpx, refpy, thresh): """ - Convenience function for ref phs estimate method 2 parallelisation. + Convenience function for reference phase estimate method 2 parallelisation. - :param phase_data: xxxx - :param half_chip_size: xxxx - :param refpx: xxxx - :param refpy: xxxx - :param thres: xxxx + :param xxx(eg str, tuple, int, float...) phase_data: xxxx + :param xxx half_chip_size: xxxx + :param xxx refpx: xxxx + :param xxx refpy: xxxx + :param xxx thres: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ patch = phase_data[refpy - half_chip_size: refpy + half_chip_size + 1, refpx - half_chip_size: refpx + half_chip_size + 1] @@ -118,10 +121,11 @@ def est_ref_phase_method1(ifgs, params): """ Reference phase estimate method 1 estimation. - :param ifgs: List of interferograms or shared.IfgPart class instances - :param params: Parameter dictionary corresponding to config file + :param list ifgs: List of interferograms or shared.IfgPart class instances + :param dict params: Parameter dictionary corresponding to config file - :return ref_phs: Numpy array of size (nifgs, 1) + :return: ref_phs: Numpy array of size (nifgs, 1) + :rtype: ndarray """ ifg_phase_data_sum = np.zeros(ifgs[0].shape, dtype=np.float64) phase_data = [i.phase_data for i in ifgs] @@ -150,10 +154,11 @@ def est_ref_phs_method1(phase_data, comp): """ Convenience function for reference phase estimate method 1 parallelisation. - :param phase_data: xxxx - :param comp: xxxx + :param xxx(eg str, tuple, int, float...) phase_data: xxxx + :param xxx comp: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ ifgv = np.ravel(phase_data, order='F') ifgv[comp == 1] = np.nan @@ -164,10 +169,11 @@ def check_ref_phs_ifgs(ifgs, preread_ifgs=None): """ Check that the reference phase status of all interferograms are the same. - :param ifgs: xxxx - :param flags: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx flags: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Checking status of reference phase estimation') if len(ifgs) < 2: diff --git a/pyrate/refpixel.py b/pyrate/refpixel.py old mode 100644 new mode 100755 index 92efcdc18..f87d14cf4 --- a/pyrate/refpixel.py +++ b/pyrate/refpixel.py @@ -15,7 +15,7 @@ # limitations under the License. """ This Python module implements an algorithm to search for the location -of the interferometric reference pixel +of the interferometric reference pixel. """ import os import logging @@ -33,17 +33,18 @@ # TODO: move error checking to config step (for fail fast) def ref_pixel(ifgs, params): """ - Returns (y,x) reference pixel coordinate from given ifgs. + Returns (y,x) reference pixel coordinate from given interferograms. If the config file REFX or REFY values are empty or subzero, the search for the reference pixel is performed. If the REFX|Y values are within the bounds of the raster, a search is not performed. REFX|Y values outside the upper bounds cause an exception. - :param ifgs: Sequence of interferograms - :param params: Parameters dictionary + :param list ifgs: Sequence of interferograms + :param dict params: Parameters dictionary - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ half_patch_size, thresh, grid = ref_pixel_setup(ifgs, params) parallel = params[cf.PARALLEL] @@ -69,13 +70,14 @@ def ref_pixel(ifgs, params): def filter_means(mean_sds, grid): """ - Filter the mean standard deviations from each ref pixel block + Filter the mean standard deviations from each reference pixel block Parameters. - :param mean_sds: List of mean standard deviations from each reference pixel grid - :param grid: List of grid tuples + :param list mean_sds: List of mean standard deviations from each reference pixel grid + :param list grid: List of grid tuples :return Tuple of (refy, refx) + :rtype: tuple """ log.info('Filtering means during reference pixel computation') refp_index = np.nanargmin(mean_sds) @@ -87,10 +89,11 @@ def ref_pixel_setup(ifgs_or_paths, params): Sets up the grid for reference pixel computation. Also saves numpy files for later use during reference pixel computation. - :param ifgs_or_paths: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) ifgs_or_paths: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Setting up ref pixel computation') refnx, refny, chipsize, min_frac = params[cf.REFNX], \ @@ -128,13 +131,14 @@ def ref_pixel_mpi(process_grid, half_patch_size, ifgs, thresh, params): """ Convenience function for reference pixel calculation for each process. - :param process_grid: xxxx - :param half_patch_size: xxxx - :param ifgs: xxxx - :param thresh: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) process_grid: xxxx + :param xxx half_patch_size: xxxx + :param xxx ifgs: xxxx + :param xxx thresh: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Ref pixel calculation started') mean_sds = [] @@ -149,13 +153,14 @@ def ref_pixel_multi(g, half_patch_size, phase_data_or_ifg_paths, """ Convenience function for for reference pixel optimisation. - :param g: xxxx - :param half_patch_size: xxxx - :param phase_data_or_ifg_paths: xxxx - :param thresh: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) g: xxxx + :param xxx half_patch_size: xxxx + :param xxx phase_data_or_ifg_paths: xxxx + :param xxx thresh: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=invalid-name # phase_data_or_ifg is list of ifgs @@ -185,14 +190,15 @@ def ref_pixel_multi(g, half_patch_size, phase_data_or_ifg_paths, def step(dim, ref, radius): """ - Helper: returns xrange obj of axis indicies for a search window. + Helper: returns xrange object of axis indicies for a search window. - :param dim: Total length of the grid dimension - :param ref: The desired number of steps - :param radius: The number of cells from the centre of the chip eg. + :param xxx(eg str, tuple, int, float...) dim: Total length of the grid dimension + :param xxx ref: The desired number of steps + :param xxx radius: The number of cells from the centre of the chip eg. (chipsize / 2) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # if ref == 1: @@ -253,6 +259,6 @@ def _validate_search_win(refnx, refny, chipsize, head): class RefPixelError(Exception): - ''' + """ Generic exception for reference pixel errors. - ''' + """ diff --git a/pyrate/roipac.py b/pyrate/roipac.py old mode 100644 new mode 100755 index 54e4ec7f5..cbc903702 --- a/pyrate/roipac.py +++ b/pyrate/roipac.py @@ -75,12 +75,13 @@ def check_raw_data(is_ifg, data_path, ncols, nrows): """ xxxx - :param is_ifg: Whether interferogram or DEM - :param data_path: Path to file - :param ncols: Number of columns in interferogram/DEM - :param nrows: Number of rows in interferogram/DEM + :param bool is_ifg: Whether interferogram or DEM + :param str data_path: Path to file + :param int ncols: Number of columns in interferogram/DEM + :param int nrows: Number of rows in interferogram/DEM - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ base_size = ncols * nrows if is_ifg: @@ -98,9 +99,10 @@ def check_step_mismatch(header): """ xxxx - :param header: Dictionary corresponding to header file + :param dict header: Dictionary corresponding to header file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=invalid-name xs, ys = [abs(i) for i in [header[ifc.PYRATE_X_STEP], @@ -115,9 +117,10 @@ def parse_date(dstr): """ Parses ROI_PAC 'yymmdd' or 'yymmdd-yymmdd' to date or date tuple. - :param dstr: xxxx + :param xxx(eg str, tuple, int, float...) dstr: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ def to_date(date_str): """convert to date""" @@ -135,9 +138,10 @@ def parse_header(hdr_file): """ Parses ROI_PAC header file to a dictionary. - :param hdr_file: xxxx + :param xxx(eg str, tuple, int, float...) hdr_file: xxxx - :return xxxx + :return: xxxx + :rtype: dict """ with open(hdr_file) as f: text = f.read() @@ -224,10 +228,11 @@ def manage_header(header_file, projection): """ xxxx - :param header_file: xxxx - :param projection: Projection from dem header. projection = roipac.parse_header(dem_file)[ifc.PYRATE_DATUM] + :param xxx(eg str, tuple, int, float...) header_file: xxxx + :param xxx projection: Projection from dem header. projection = roipac.parse_header(dem_file)[ifc.PYRATE_DATUM] :return: xxxx + :rtype: xxxx(eg float) """ header = parse_header(header_file) if ifc.PYRATE_DATUM not in header: # DEM already has DATUM @@ -238,5 +243,5 @@ def manage_header(header_file, projection): class RoipacException(Exception): """ - Convenience class for throwing exception + Convenience class for throwing exception. """ diff --git a/pyrate/scripts/main.py b/pyrate/scripts/main.py old mode 100644 new mode 100755 index 5eed84d65..394c443c6 --- a/pyrate/scripts/main.py +++ b/pyrate/scripts/main.py @@ -45,7 +45,9 @@ def version_msg(): type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'ERROR']), default='INFO', help='Level of logging') def cli(verbosity): - """Commandline options and logging setup""" + """ + Commandline options and logging setup. + """ pylog.configure(verbosity) diff --git a/pyrate/scripts/postprocessing.py b/pyrate/scripts/postprocessing.py old mode 100644 new mode 100755 index dc521b02b..f21f2860b --- a/pyrate/scripts/postprocessing.py +++ b/pyrate/scripts/postprocessing.py @@ -43,11 +43,12 @@ def main(config_file, rows, cols): """ Post-processing main function. - :param config_file: xxxx - :param rows: xxxx - :param cols: xxxx + :param xxx(eg str, tuple, int, float...) config_file: xxxx + :param xxx rows: xxxx + :param xxx cols: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # setup paths _, _, params = cf.get_ifg_paths(config_file) @@ -60,11 +61,12 @@ def postprocess_linrate(rows, cols, params): """ Postprocess linear rate. - :param rows: xxxx - :param cols: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) rows: xxxx + :param xxx cols: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=expression-not-assigned # setup paths @@ -92,12 +94,13 @@ def save_linrate(ifgs_dict, params, tiles, out_type): """ Save linear rate outputs. - :param ifgs_dict: xxxx - :param params: xxxx - :param tiles: xxxx - :param out_type: xxxx + :param dict ifgs_dict: xxxx + :param xxx(eg str, tuple, int, float...) params: xxxx + :param xxx tiles: xxxx + :param xxx out_type: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Starting PyRate postprocessing {}'.format(out_type)) gt, md, wkt = ifgs_dict['gt'], ifgs_dict['md'], ifgs_dict['wkt'] @@ -129,11 +132,12 @@ def postprocess_timeseries(rows, cols, params): """ Postprocess time series output. - :param rows: xxxx - :param cols: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) rows: xxxx + :param xxx cols: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-locals xlks, _, crop = cf.transform_params(params) diff --git a/pyrate/scripts/run_prepifg.py b/pyrate/scripts/run_prepifg.py old mode 100644 new mode 100755 index 7ce58c0ea..0fcfb730c --- a/pyrate/scripts/run_prepifg.py +++ b/pyrate/scripts/run_prepifg.py @@ -48,9 +48,10 @@ def main(params=None): """ xxxx - :param params: Parameters dictionary read in from the config file + :param dict params: Parameters dictionary read in from the config file - :return: + :return: xxxx + :rtype: xxxx(eg float) """ # TODO: looks like base_ifg_paths are ordered according to ifg list # This probably won't be a problem because input list won't be reordered @@ -107,10 +108,11 @@ def roipac_prepifg(base_ifg_paths, params): ROI_PAC prepifg which combines both conversion to geotiff and multi-looking and cropping. - :param base_ifg_paths: List of unwrapped interferograms - :param params: Parameters dictionary corresponding to config file + :param list base_ifg_paths: List of unwrapped interferograms + :param dict params: Parameters dictionary corresponding to config file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info("Preparing ROI_PAC format interferograms") parallel = params[cf.PARALLEL] @@ -144,10 +146,11 @@ def gamma_prepifg(base_unw_paths, params): GAMMA prepifg which combines both conversion to geotiff and multi-looking and cropping. - :param base_unw_paths: List of unwrapped interferograms - :param params: Parameters dictionary corresponding to config file + :param list base_unw_paths: List of unwrapped interferograms + :param dict params: Parameters dictionary corresponding to config file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=expression-not-assigned log.info("Preparing GAMMA format interferograms") @@ -183,12 +186,13 @@ def gamma_prepifg(base_unw_paths, params): def gamma_multiprocessing(unw_path, params): """ - Gamma multiprocessing wrapper for geotif conversion. + GAMMA multiprocessing wrapper for geotif conversion. - :param unw_path: Wnwrapped interferogram path - :param params: Parameters dictionary corresponding to config file + :param str unw_path: Wnwrapped interferogram path + :param dict params: Parameters dictionary corresponding to config file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ dem_hdr_path = params[cf.DEM_HEADER_FILE] slc_dir = params[cf.SLC_DIR] diff --git a/pyrate/scripts/run_pyrate.py b/pyrate/scripts/run_pyrate.py old mode 100644 new mode 100755 index 9909e254b..362ceca86 --- a/pyrate/scripts/run_pyrate.py +++ b/pyrate/scripts/run_pyrate.py @@ -53,11 +53,12 @@ def get_tiles(ifg_path, rows, cols): """ Break up the interferograms into tiles based on user supplied rows and columns. - :param ifg_path: List of destination tifs - :param rows: Number of rows to break each interferogram into - :param cols: Number of columns to break each interferogram into + :param list ifg_path: List of destination tifs + :param int rows: Number of rows to break each interferogram into + :param int cols: Number of columns to break each interferogram into - :return tiles: List of shared.Tile instances + :return: tiles: List of shared.Tile instances + :rtype: list """ ifg = Ifg(ifg_path) ifg.open(readonly=True) @@ -70,9 +71,10 @@ def _join_dicts(dicts): """ xxxx - :param dicts: List of dictionaries to join + :param dict dicts: List of dictionaries to join - :return assembled_dict: Dictionary after join + :return: assembled_dict: Dictionary after join + :rtype: dict """ if dicts is None: # pragma: no cover return @@ -86,11 +88,12 @@ def create_ifg_dict(dest_tifs, params, tiles): 2. Save the preread_ifgs dictionary with information about the interferograms that are later used for fast loading of Ifg files in IfgPart class. - :param dest_tifs: List of destination tifs - :param params: Config dictionary - :param tiles: List of all Tile instances + :param list dest_tifs: List of destination tifs + :param dict params: Config dictionary + :param list tiles: List of all Tile instances - :return preread_ifgs: Dictionary containing information regarding interferograms that are used downstream + :return: preread_ifgs: Dictionary containing information regarding interferograms that are used downstream + :rtype: dict """ ifgs_dict = {} process_tifs = mpiops.array_split(dest_tifs) @@ -133,12 +136,13 @@ def mst_calc(dest_tifs, params, tiles, preread_ifgs): MPI function that control each process during MPI run Reference phase computation using method 2. - :params dest_tifs: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param tiles: List of all tiles used during MPI processes - :param preread_ifgs: Dictionary containing interferogram characteristics for efficient computing + :params list dest_tifs: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param list tiles: List of all tiles used during MPI processes + :param dict preread_ifgs: Dictionary containing interferogram characteristics for efficient computing - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ process_tiles = mpiops.array_split(tiles) @@ -170,11 +174,12 @@ def ref_pixel_calc(ifg_paths, params): """ Reference pixel calculation setup. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file - :return refx: Reference pixel x-coordinate - :return refy: Reference pixel y-coordinate + :return: refx: Reference pixel x-coordinate + :return: refy: Reference pixel y-coordinate + :rtype: xxxx (eg float) """ # unlikely, but possible the refpixel can be (0,0) # check if there is a pre-specified reference pixel coord @@ -208,10 +213,11 @@ def find_ref_pixel(ifg_paths, params): """ Find reference pixel using MPI Parameters. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file :return Tuple of (refy, refx). + :rtype: tuple """ half_patch_size, thresh, grid = refpixel.ref_pixel_setup(ifg_paths, params) process_grid = mpiops.array_split(grid) @@ -228,12 +234,13 @@ def save_ref_pixel_blocks(grid, half_patch_size, ifg_paths, params): """ xxxx - :param grid: List of tuples (y, x) corresponding reference pixel grids - :param half_patch_size: Patch size in pixels corresponding to reference pixel grids - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file + :param list grid: List of tuples (y, x) corresponding reference pixel grids + :param xxx(eg str, tuple, int, float...) half_patch_size: Patch size in pixels corresponding to reference pixel grids + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ log.info('Saving ref pixel blocks') outdir = params[cf.TMPDIR] @@ -258,11 +265,12 @@ def orb_fit_calc(ifg_paths, params, preread_ifgs=None): """ Orbital fit correction. - :param ifg_paths: List of ifg paths - :param params: Parameters dictionary corresponding to config file - :param preread_ifgs: Dictionary containing information regarding interferograms + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param dict preread_ifgs: Dictionary containing information regarding interferograms - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ #log.info('Calculating orbfit correction') if params[cf.ORBITAL_FIT_METHOD] == 1: @@ -284,13 +292,14 @@ def ref_phase_estimation(ifg_paths, params, refpx, refpy, preread_ifgs=None): """ Reference phase estimation. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param refpx: Reference pixel x-coordinate - :param refpy: Reference pixel y-coordinate - :param preread_ifgs: Dictionary containing information regarding interferograms + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param xxx(eg str, tuple, int, float...) refpx: Reference pixel x-coordinate + :param xxx refpy: Reference pixel y-coordinate + :param dict preread_ifgs: Dictionary containing information regarding interferograms - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # perform some checks on existing ifgs if preread_ifgs and mpiops.rank == MASTER_PROCESS: @@ -333,12 +342,13 @@ def ref_phs_method2(ifg_paths, params, refpx, refpy): """ Reference phase computation using method 2. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param refpx: Reference pixel x-coordinate - :param refpy: Reference pixel y-coordinate + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param xxx(eg str, tuple, int, float...) refpx: Reference pixel x-coordinate + :param xxx refpy: Reference pixel y-coordinate - :return ref_phs: Array of reference phase of shape ifg.shape + :return: ref_phs: Array of reference phase of shape ifg.shape + :rtype: array """ half_chip_size = int(np.floor(params[cf.REF_CHIP_SIZE] / 2.0)) chipsize = 2 * half_chip_size + 1 @@ -368,10 +378,11 @@ def ref_phs_method1(ifg_paths, comp): """ Reference phase computation using method 1. - :param ifg_paths: List of interferogram paths - :param comp: Array of phase sum of all interferograms of shape ifg.shape + :param list ifg_paths: List of interferogram paths + :param array comp: Array of phase sum of all interferograms of shape ifg.shape - :return ref_phs: Array of reference phase of shape ifg.shape + :return: ref_phs: Array of reference phase of shape ifg.shape + :rtype: array """ def _inner(ifg_path): @@ -398,12 +409,13 @@ def process_ifgs(ifg_paths, params, rows, cols): """ Top level function to perform PyRate correction steps on given interferograms. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param rows: Number of rows to break each interferogram into - :param cols: Number of columns to break each interferogram into + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param int rows: Number of rows to break each interferogram into + :param int cols: Number of columns to break each interferogram into - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if mpiops.size > 1: params[cf.PARALLEL] = False @@ -456,13 +468,14 @@ def linrate_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): """ MPI capable linrate calculation. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param vcmt: vcmt array - :param tiles: List of all tiles used during MPI processes - :param preread_ifgs: Dictionary containing interferogram characteristics for efficient computing + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param array vcmt: vcmt array + :param list tiles: List of all tiles used during MPI processes + :param dict preread_ifgs: Dictionary containing interferogram characteristics for efficient computing - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ process_tiles = mpiops.array_split(tiles) @@ -492,12 +505,13 @@ def maxvar_alpha_calc(ifg_paths, params, preread_ifgs): """ MPI capable maxvar and vcmt computation. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param preread_ifgs: Dictionary containing interferogram characteristics for efficient computing + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param dict preread_ifgs: Dictionary containing interferogram characteristics for efficient computing - :return maxvar: Array of shape (nifgs, 1) - :return vcmt: Array of shape (nifgs, nifgs) + :return: maxvar: Array of shape (nifgs, 1) + :return: vcmt: Array of shape (nifgs, nifgs) + :rtype: xxxx (eg float) """ process_indices = mpiops.array_split(range(len(ifg_paths))) prcs_ifgs = mpiops.array_split(ifg_paths) @@ -529,10 +543,11 @@ def vcm_calc(preread_ifgs, maxvar): """ Temporal Variance-Covariance Matrix computation. - :param preread_ifgs: Dictionary containing interferograms characteristics for efficient computing - :param maxvar: Array of shape (nifgs, 1) + :param dict preread_ifgs: Dictionary containing interferograms characteristics for efficient computing + :param array maxvar: Array of shape (nifgs, 1) - :return vcmt: Array of shape (nifgs, nifgs) + :return: vcmt: Array of shape (nifgs, nifgs) + :rtype: array """ maxvar = mpiops.comm.bcast(maxvar, root=0) log.info('Assembling Temporal Variance-Covariance Matrix') @@ -544,10 +559,11 @@ def phase_sum(ifg_paths, params): """ Save phase data and phs_sum used in the reference phase estimation. - :param ifg_paths: List of paths to interferograms - :param params: Config dictionary + :param list ifg_paths: List of interferogram paths + :param dict params: Config dictionary - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ p_paths = mpiops.array_split(ifg_paths) ifg = Ifg(p_paths[0]) @@ -584,13 +600,14 @@ def timeseries_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): """ Time series calculation. - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary corresponding to config file - :param vcmt: vcmt array - :param tiles: List of all tiles used during MPI processes - :param preread_ifgs: Dictionary containing interferogram characteristics for efficient computing + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary corresponding to config file + :param array vcmt: vcmt array + :param list tiles: List of all tiles used during MPI processes + :param dict preread_ifgs: Dictionary containing interferogram characteristics for efficient computing - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ process_tiles = mpiops.array_split(tiles) log.info('Calculating time series') @@ -610,6 +627,8 @@ def timeseries_calc(ifg_paths, params, vcmt, tiles, preread_ifgs): def main(config_file, rows, cols): # pragma: no cover - """ linear rate and timeseries execution starts here """ + """ + Linear rate and timeseries execution starts here. + """ _, dest_paths, pars = cf.get_ifg_paths(config_file) process_ifgs(sorted(dest_paths), pars, rows, cols) diff --git a/pyrate/shared.py b/pyrate/shared.py old mode 100644 new mode 100755 index 6e331841b..4bea9cbe1 --- a/pyrate/shared.py +++ b/pyrate/shared.py @@ -15,7 +15,7 @@ # limitations under the License. """ This Python module contains utilities and classes shared by -all other PyRate modules +all other PyRate modules. """ # pylint: disable=too-many-lines from __future__ import print_function @@ -224,7 +224,7 @@ def is_open(self): def close(self): """ - Explicitly closes file opened by gdal.Open() + Explicitly closes file opened by gdal.Open(). This is required in windows, otherwise opened files can not be removed, because windows locks opened files. """ @@ -242,7 +242,7 @@ def _get_band(self, band): """ Wrapper (with error checking) for GDAL's Band.GetRasterBand() method. - :param band: number of band, starting at 1 + :param int band: number of band, starting at 1 """ if self.dataset is not None: @@ -255,16 +255,14 @@ def _get_band(self, band): class Ifg(RasterBase): """ Interferrogram class, represents the difference between two acquisitions. - Ifg objects double as a container for related data. + Interferogram objects double as a container for related data. """ # pylint: disable=too-many-instance-attributes def __init__(self, path): """ - Interferogram constructor, for 2 band ROIPAC Ifg raster datasets. - Parameters - ---------- - path: str - path to ifg + Interferogram constructor, for 2 band ROI_PAC Ifg raster datasets. + + :param xxx(eg str, tuple, int, float...) path: Path to interferogram """ RasterBase.__init__(self, path) @@ -290,7 +288,7 @@ def open(self, readonly=None): def initialize(self): """ - Basic interferogram properties read on opening intereferogram. + Basic interferogram properties read on opening interferogram. """ self._init_dates() md = self.dataset.GetMetadata() @@ -320,8 +318,6 @@ def _to_date(datestr): def convert_to_nans(self): """ Converts given values in phase data to NaNs. - - :param val: value to convert, default is 0 """ if (self._nodata_value is None) \ or (self.dataset is None): # pragma: no cover @@ -476,14 +472,14 @@ def save_numpy_phase(self, numpy_file): """ xxxx - :param numpy_file: File path where phase data is saved + :param str numpy_file: File path where phase data is saved """ np.save(file=numpy_file, arr=self.phase_data) class IfgPart(object): """ - slice of Ifg data object + Slice of interferogram data object """ # pylint: disable=missing-docstring # pylint: disable=too-many-instance-attributes @@ -608,7 +604,7 @@ def azimuth_data(self): class DEM(RasterBase): """ - Generic raster class for ROIPAC single band DEM files. + Generic raster class for ROI_PAC single band DEM files. """ def __init__(self, path): @@ -659,10 +655,11 @@ def convert_radians_to_mm(data, wavelength): """ Translates phase from radians to millimetres. - :param data: Interferogram phase data - :param wavelength: Radar wavelength; normally included with SAR instrument metadata + :param xxx(eg str, tuple, int, float...) data: Interferogram phase data + :param xxx wavelength: Radar wavelength; normally included with SAR instrument metadata - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ return data * ifc.MM_PER_METRE * (wavelength / (4 * math.pi)) @@ -671,9 +668,10 @@ def nanmedian(x): """ xxxx - :param x: xxxx + :param xxx(eg str, tuple, int, float...) x: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=no-member version = [int(i) for i in @@ -690,12 +688,13 @@ def write_geotiff(header, data_path, dest, nodata): Writes input image data (interferograms, DEM, incidence maps etc) to GeoTIFF format with PyRate metadata. - :param header: xxxx - :param data_path: xxxx - :param dest: xxxx - :param nodata: xxxx + :param xxx(eg str, tuple, int, float...) header: xxxx + :param xxx data_path: xxxx + :param xxx dest: xxxx + :param xxx nodata: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-branches # pylint: disable=too-many-locals @@ -786,11 +785,12 @@ def write_unw_from_data_or_geotiff(geotif_or_data, dest_unw, ifg_proc): """ xxxx - :param geotif_or_data: Data or geotiff to covert into unwrapped - :param dest_unw: Destination unwrapped file - :param ifg_proc: Processor type, GAMMA=1, ROIPAC=0 + :param xxx(eg str, tuple, int, float...) geotif_or_data: Data or geotiff to covert into unwrapped + :param xxx dest_unw: Destination unwrapped file + :param xxx ifg_proc: Processor type, GAMMA=1, ROIPAC=0 - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if ifg_proc != 1: raise NotImplementedError('only support gamma processor for now') @@ -816,12 +816,12 @@ def write_output_geotiff(md, gt, wkt, data, dest, nodata): """ Writes PyRate output data to a GeoTIFF file. - :param md: Dictionary containing PyRate metadata - :param gt: GDAL geotransform for the data - :param wkt: GDAL projection information for the data - :param data: xxxx - :param dest: xxxx - :param nodata: xxxx + :param dict md: Dictionary containing PyRate metadata + :param xxx(eg str, tuple, int, float...) gt: GDAL geotransform for the data + :param xxx wkt: GDAL projection information for the data + :param xxx data: xxxx + :param xxx dest: xxxx + :param xxx nodata: xxxx :return xxxx """ @@ -864,11 +864,12 @@ def create_tiles(shape, nrows=2, ncols=2): When the array shape (rows, columns) are not divisible by (nrows, ncols) then some of the array dimensions can change according to numpy.array_split. - :param shape: Shape tuple of interferogram - :param nrows: Number of rows of tiles - :param ncols: Number of columns of tiles + :param tuple shape: Shape tuple of interferogram + :param int nrows: Number of rows of tiles + :param int ncols: Number of columns of tiles - :return List of Tile class instances. + :return: List of Tile class instances. + :rtype: list """ if len(shape) != 2: @@ -890,14 +891,9 @@ class Tile: """ def __init__(self, index, top_left, bottom_right): """ - Parameters - ---------- - index: int - identifying index of a tile - top_left: tuple - ifg index of top left of tile - bottom_right: tuple - ifg index of bottom right of tile + :param xxx(eg str, tuple, int, float...) index: Identifying index of a tile + :param xxx top_left: interferogram index of top left of tile + :param xxx bottom_right: interferogram index of bottom right of tile """ self.index = index @@ -916,12 +912,13 @@ def copytree(src, dst, symlinks=False, ignore=None): Copy contents of src dir into dst dir copied from: http://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth?lq=1 - :param src: Source directory to copy from - :param dst: Destination directory to copy to, created if does not exist - :param symlinks: Whether to copy symlink or not - :param ignore: xxxx + :param str src: Source directory to copy from + :param str dst: Destination directory to copy to, created if does not exist + :param xxx(eg str, tuple, int, float...) symlinks: Whether to copy symlink or not + :param xxx ignore: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ # pylint: disable=invalid-name if not os.path.exists(dst): # pragma: no cover @@ -954,10 +951,11 @@ def pre_prepare_ifgs(ifg_paths, params): """ xxxx - :param ifg_paths: List of interferogram paths - :param params: Parameters dictionary + :param list ifg_paths: List of interferogram paths + :param dict params: Parameters dictionary - :return ifgs: List of interferogram instances + :return: ifgs: List of interferogram instances + :rtype: list """ ifgs = [Ifg(p) for p in ifg_paths] for i in ifgs: @@ -972,10 +970,11 @@ def nan_and_mm_convert(ifg, params): """ xxxx - :param ifg: Interferogram class instance - :param params: Parameters dictionary + :param xxx(eg str, tuple, int, float...) ifg: Interferogram class instance + :param dict params: Parameters dictionary - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ nan_conversion = params[cf.NAN_CONVERSION] if nan_conversion: # nan conversion happens here in networkx mst @@ -994,12 +993,13 @@ def cell_size(lat, lon, x_step, y_step): llh2local.m used in Matlab Pirate. Converts X|Y_STEP in degrees to X & Y cell length/width in metres. - :param lat: Latitude in degrees - :param lon: Longitude in degrees - :param x_step: Horizontal step size in degrees - :param y_step: Vertical step size in degrees + :param xxx(eg str, tuple, int, float...) lat: Latitude in degrees + :param xxx(eg str, tuple, int, float...) lon: Longitude in degrees + :param xxx(eg str, tuple, int, float...) x_step: Horizontal step size in degrees + :param xxx(eg str, tuple, int, float...) y_step: Vertical step size in degrees - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ if lat > 84.0 or lat < -80: msg = "No UTM zone for polar region: > 84 degrees N or < 80 degrees S" @@ -1054,11 +1054,12 @@ def prepare_ifg(ifg_path, params): """ xxxx - :param ifg_path: Interferogram path - :param tiles: List of Tile instances - :param params: Configuration dictionary + :param str ifg_path: Interferogram path + :param list tiles: List of Tile instances + :param dict params: Configuration dictionary - :return ifg: Inteferogram class instance + :return: ifg: Interferogram class instance + :rtype: xxxx (eg flaot) """ ifg = Ifg(ifg_path) ifg.open() @@ -1070,11 +1071,12 @@ def save_numpy_phase(ifg_paths, tiles, params): """ Save interferogram phase data as numpy array. - :param ifg_paths: List of strings corresponding to interferogram paths - :param tiles: List of Shared.Tile instances - :param params: Configuration dictionary + :param list ifg_paths: List of strings corresponding to interferogram paths + :param list tiles: List of Shared.Tile instances + :param dict params: Configuration dictionary - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ process_ifgs = mpiops.array_split(ifg_paths) outdir = params[cf.TMPDIR] @@ -1099,9 +1101,10 @@ def get_projection_info(ifg_path): """ Return projection information of interferogram. - :param ifg_path: Interferogram path + :param str ifg_path: Interferogram path - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ ds = gdal.Open(ifg_path) md = ds.GetMetadata() # get metadata for writing on output tifs @@ -1115,11 +1118,12 @@ def warp_required(xlooks, ylooks, crop): """ Returns True if params show rasters need to be cropped and/or resized. - :param xlooks: Resampling/multi-looking in x dir - :param ylooks: Resampling/multilooking in y dir - :param crop: Interferogram crop option + :param int xlooks: Resampling/multi-looking in x dir + :param int ylooks: Resampling/multilooking in y dir + :param int crop: Interferogram crop option - :return xxxx + :return: xxxx + :rtype: xxxx (eg float) """ if xlooks > 1 or ylooks > 1: @@ -1135,10 +1139,11 @@ def output_tiff_filename(inpath, outpath): """ Geotiff filename for a given input filename. - :param inpath: path of input file location - :param outpath: path of output file location + :param str inpath: path of input file location + :param str outpath: path of output file location :return: Geotiff filename for a given file. + :rtype: str """ fname, ext = os.path.basename(inpath).split('.') return os.path.join(outpath, fname + '_' + ext + '.tif') diff --git a/pyrate/tasks/converttogeotif.py b/pyrate/tasks/converttogeotif.py old mode 100644 new mode 100755 index 4cf3f302b..1176bcc43 --- a/pyrate/tasks/converttogeotif.py +++ b/pyrate/tasks/converttogeotif.py @@ -28,7 +28,7 @@ class ConvertToGeotiff(luigi.WrapperTask): """ - Luigi wrapper class for both roipac and gamma geotiff conversion + Luigi wrapper class for both ROI_PAC and GAMMA geotiff conversion. """ processor = luigi.IntParameter(config_path=InputParam(config.PROCESSOR)) diff --git a/pyrate/tasks/gamma.py b/pyrate/tasks/gamma.py old mode 100644 new mode 100755 index 2ed63e34c..6055b942c --- a/pyrate/tasks/gamma.py +++ b/pyrate/tasks/gamma.py @@ -50,10 +50,13 @@ def output(self): def get_header_paths(input_file, slc_dir=None): """ - function that matches input file names with header file names - :param input_file: input gamma .unw file - :return: corresponding header files that matches, or empty list if no match + Function that matches input file names with header file names. + + :param xxx(eg str, tuple, int, float...) input_file: Input gamma .unw file + + :return: Corresponding header files that matches, or empty list if no match found + :rtype: xxxx (eg float) """ if slc_dir: dir_name = slc_dir @@ -113,7 +116,9 @@ def run(self): class ConvertToGeotiff(IfgListMixin, luigi.WrapperTask): - """ Wrapper class for gamma convert to geotiff""" + """ + Wrapper class for GAMMA convert to geotiff. + """ def requires(self): return [ConvertFileToGeotiff(input_file=fn) for fn in self.ifg_list(tif=False)] diff --git a/pyrate/tasks/prepifg.py b/pyrate/tasks/prepifg.py old mode 100644 new mode 100755 index f1cfea825..aa2c5796b --- a/pyrate/tasks/prepifg.py +++ b/pyrate/tasks/prepifg.py @@ -36,7 +36,7 @@ class GetAnalysisExtents(IfgListMixin, luigi.Task): """ - Dummy analysis extents gather class used during luigi tasks + Dummy analysis extents gather class used during luigi tasks. """ crop_opt = luigi.IntParameter(config_path=InputParam(cf.IFG_CROP_OPT)) ifgx_first = luigi.FloatParameter(default=None, @@ -82,18 +82,21 @@ class PrepareInterferogram(IfgListMixin, luigi.WrapperTask): """ Produces multilooked/resampled data files for PyRate analysis. - :param ifgs: sequence of Ifg objs (DEM obj may be included for processing) - :param crop_opt: integer cropping type option (see config) - :param xlooks: multilooking factor for the X axis - :param ylooks: Y axis multilooking factor - :param float thresh: (0.0, 1.0). Controls NaN handling when resampling to + :param xxx(eg str, tuple, int, float...) ifgs: Sequence of interferogram objects (DEM object may be included for processing) + :param xxx crop_opt: Integer cropping type option (see config) + :param xxx xlooks: Multi-looking factor for the X axis + :param xxx ylooks: Multi-looking factor for the Y axis + :param xxx float thresh: (0.0, 1.0). Controls NaN handling when resampling to coarser grids. Value is the proportion above which the number of NaNs in an area is considered invalid. thresh=0 resamples to NaN if 1 or more contributing cells are NaNs. At 0.25, it resamples to NaN if 1/4 or more contributing cells are NaNs. At 1.0, areas are resampled to NaN only if all contributing cells are NaNs. - :param user_exts: CustomExts tuple with user sepcified lat long corners - :param verbose: Controls level of gdalwarp output + :param xxx user_exts: CustomExts tuple with user sepcified lat long corners + :param xxx verbose: Controls level of gdalwarp output + + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=bad-super-call, no-member @@ -143,7 +146,9 @@ def complete(self): class PrepareInterferograms(IfgListMixin, luigi.WrapperTask): - """ Luigi wrapper class """ + """ + Luigi wrapper class. + """ def __init__(self, *args, **kwargs): super(PrepareInterferograms, self).__init__(*args, **kwargs) @@ -172,5 +177,5 @@ def complete(self): class PrepifgException(Exception): """ - Prepifg exception class + Prepifg exception class. """ diff --git a/pyrate/tasks/roipac.py b/pyrate/tasks/roipac.py old mode 100644 new mode 100755 index 6ba816ab4..becffc70e --- a/pyrate/tasks/roipac.py +++ b/pyrate/tasks/roipac.py @@ -26,7 +26,7 @@ class RoipacHasRun(luigi.task.ExternalTask): """ - Phaux task used to ensure that the required outputs from ROIPAC exist. + Phaux task used to ensure that the required outputs from ROI_PAC exist. """ fileName = luigi.Parameter() @@ -100,7 +100,7 @@ class _DoConvertToGeotiffRoipac(IfgListMixin, luigi.WrapperTask): @property def priority(self): """ - The requires method of this Task *may* reqire the existence of a header + The requires method of this Task *may* require the existence of a header file... so that needs to be checked first. """ return ResourceHeaderExists.priority - 1 @@ -128,7 +128,7 @@ def requires(self): class ConvertToGeotiff(luigi.WrapperTask): """ - Convert ROIPAC files to geotifs. + Convert ROI_PAC files to geotifs. This delegates the actual conversions tasks which operate on individual files and is purely a convenience wrapper. diff --git a/pyrate/tasks/utils.py b/pyrate/tasks/utils.py old mode 100644 new mode 100755 index 9f0db53a2..1fc574eea --- a/pyrate/tasks/utils.py +++ b/pyrate/tasks/utils.py @@ -52,7 +52,7 @@ class IfgListMixin(object): Mixin to aid access to commonly used computed values from the PyRate config file. - .. todo:: This should perhaps be renamed to something like *ConfigMixin* + todo:: This should perhaps be renamed to something like *ConfigMixin* for clarity, as it is ued for accessing more than the list of interferograms. """ @@ -66,9 +66,9 @@ def ifg_list(self, tif=True): """ Get the list of interferograms to process. - :param tif: Should the tif files be returned (*True*) or the raw + :param xxx(eg str, tuple, int, float...) tif: Should the tif files be returned (*True*) or the raw interferograms (*False*). The latter will probably only be required - before conversion to geotif files occurs. + before conversion to geotif files occurs """ file_names = config.parse_namelist(self.ifg_list_file) @@ -88,9 +88,9 @@ def ifg_tiff_list(self, tif=True): """ Get the list of interferograms to process. - :param tif: Should the tif files be returned (*True*) or the raw + :param xxx(eg str, tuple, int, float...) tif: Should the tif files be returned (*True*) or the raw interferograms (*False*). The latter will probably only be required - before conversion to geotif files occurs. + before conversion to geotif files occurs """ file_names = config.parse_namelist(self.ifg_list_file) @@ -123,7 +123,7 @@ class DictParam(luigi.Parameter): def parse(self, string): """ - override of :py:meth:`luigi.Parameter.parse`. + Override of :py:meth:`luigi.Parameter.parse`. """ sio = StringIO(string) @@ -131,7 +131,7 @@ def parse(self, string): def serialize(self, dct): """ - override of :py:meth:`luigi.Parameter.serialize`. + Override of :py:meth:`luigi.Parameter.serialize`. """ sio = BytesIO() pickle.dump(dct, sio) @@ -145,7 +145,7 @@ class RasterParam(DictParam): # pragma: no cover def parse(self, string): """ - override of :py:meth:`DictParam.parse`. + Override of :py:meth:`DictParam.parse`. """ dct = super(RasterParam, self).parse(string) raster_type = dct['type'] @@ -164,7 +164,7 @@ def parse(self, string): def serialize(self, rasterBase): """ - override of :py:meth:`DictParam.serialize`. + Override of :py:meth:`DictParam.serialize`. """ path = rasterBase.data_path diff --git a/pyrate/timeseries.py b/pyrate/timeseries.py old mode 100644 new mode 100755 index 0e06f9080..fce86117b --- a/pyrate/timeseries.py +++ b/pyrate/timeseries.py @@ -39,11 +39,12 @@ def time_series_setup(ifgs, mst, params): """ Convenience function setting up time series computation parameters. - :param ifgs: xxxx - :param mst: xxxx - :param params: xxxx + :param xxx(eg str, tuple, int, float...) ifgs: xxxx + :param xxx mst: xxxx + :param xxx params: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ if len(ifgs) < 1: msg = 'Time series requires 2+ interferograms' @@ -112,11 +113,11 @@ def time_series(ifgs, params, vcmt, mst=None): """ Returns time series data from the given interferograms. - :param ifgs: Network of interferograms - :param params: Configuration parameters - :param vcmt: Derived positive definite temporal variance covariance matrix - :param mst: Array of interferogram indexes from the MST-matrix (optional) - :param parallel: Use parallel processing or not + :param xxx(eg str, tuple, int, float...) ifgs: Network of interferograms + :param xxx params: Configuration parameters + :param xxx vcmt: Derived positive definite temporal variance covariance matrix + :param array mst: Array of interferogram indexes from the MST-matrix (optional) + :param xxx parallel: Use parallel processing or not :return: Tuple with the elements: @@ -130,6 +131,7 @@ def time_series(ifgs, params, vcmt, mst=None): - *nrows* is the number of rows in the interferograms - *ncols* is the number of columns in the interferograms - *nepochs* is the number of unique epochs (dates) covered by the interferograms + :rtype: tuple """ b0_mat, interp, p_thresh, sm_factor, sm_order, ts_method, ifg_data, mst, \ @@ -175,20 +177,21 @@ def time_series_by_rows(row, b0_mat, sm_factor, sm_order, ifg_data, mst, ncols, """ Time series computation for each row of interferograms. - :param row: xxxx - :param b0_mat: xxxx - :param sm_factor: xxxx - :param sm_order: xxxx - :param ifg_data: xxxx - :param mst: xxxx - :param ncols: xxxx - :param nvelpar: xxxx - :param p_thresh: xxxx - :param vcmt: xxxx - :param ts_method: xxxx - :param interp: xxxx + :param xxx(eg str, tuple, int, float...) row: xxxx + :param xxx b0_mat: xxxx + :param xxx sm_factor: xxxx + :param xxx sm_order: xxxx + :param xxx ifg_data: xxxx + :param xxx mst: xxxx + :param xxx ncols: xxxx + :param xxx nvelpar: xxxx + :param xxx p_thresh: xxxx + :param xxx vcmt: xxxx + :param xxx ts_method: xxxx + :param xxx interp: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ tsvel = np.empty(shape=(ncols, nvelpar), dtype=float32) for col in range(ncols): @@ -203,12 +206,13 @@ def remove_rank_def_rows(b_mat, nvelpar, ifgv, sel): """ Remove rank deficient rows. - :param b_mat: xxxx - :param nvelpar: xxxx - :param ifgv: xxxx - :param sel: xxxx + :param xxx(eg str, tuple, int, float...) b_mat: xxxx + :param xxx nvelpar: xxxx + :param xxx ifgv: xxxx + :param xxx sel: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ _, _, e_var = qr(b_mat, mode='economic', pivoting=True) licols = e_var[matrix_rank(b_mat):nvelpar] @@ -224,20 +228,21 @@ def time_series_by_pixel(row, col, b0_mat, sm_factor, sm_order, ifg_data, mst, """ Time series computation for each pixel. - :param row: xxxx - :param col: xxxx - :param b0_mat: xxxx - :param sm_factor: xxxx - :param sm_order: xxxx - :param ifg_data: xxxx - :param mst: xxxx - :param nvelpar: xxxx - :param p_thresh: xxxx - :param vcmt: xxxx - :param method: xxxx - :param interp: xxxx + :param xxx(eg str, tuple, int, float...) row: xxxx + :param xxx col: xxxx + :param xxx b0_mat: xxxx + :param xxx sm_factor: xxxx + :param xxx sm_order: xxxx + :param xxx ifg_data: xxxx + :param xxx mst: xxxx + :param xxx nvelpar: xxxx + :param xxx p_thresh: xxxx + :param xxx vcmt: xxxx + :param xxx method: xxxx + :param xxx interp: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # check pixel for non-redundant ifgs sel = np.nonzero(mst[:, row, col])[0] # trues in mst are chosen @@ -282,12 +287,13 @@ def solve_ts_svd(nvelpar, velflag, ifgv, b_mat): Solve the linear least squares system using the SVD method. Similar to the SBAS method implemented by Berardino et al. 2002. - :param nvelpar: xxxx - :param velflag: xxxx - :param ifgv: xxxx - :param b_mat: xxxx + :param xxx(eg str, tuple, int, float...) nvelpar: xxxx + :param xxx velflag: xxxx + :param xxx ifgv: xxxx + :param xxx b_mat: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pre-allocate the velocity matrix tsvel = np.empty(nvelpar, dtype=float32) * np.nan @@ -370,14 +376,15 @@ def plot_timeseries(tsincr, tscum, tsvel, output_dir): # pragma: no cover A very basic plotting function used in code development - .. todo:: this should be moved and tidied up + todo:: this should be moved and tidied up - :param tsincr: xxxx - :param tscum: xxxx - :param tsvel: xxxx - :param output_dir: xxxx + :param xxx(eg str, tuple, int, float...) tsincr: xxxx + :param xxx tscum: xxxx + :param xxx tsvel: xxxx + :param xxx output_dir: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ nvelpar = len(tsincr[0, 0, :]) @@ -409,9 +416,10 @@ def missing_option_error(option): """ Internal convenience function for raising similar missing option errors. - :param option: xxxx + :param xxx(eg str, tuple, int, float...) option: xxxx - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ msg = "Missing '%s' option in config file" % option raise ConfigException(msg) diff --git a/pyrate/vcm.py b/pyrate/vcm.py old mode 100644 new mode 100755 index 79240a897..31f976815 --- a/pyrate/vcm.py +++ b/pyrate/vcm.py @@ -42,11 +42,12 @@ def pendiffexp(alphamod, cvdav): Exponential function for fitting the 1D covariance after Parsons et al., Geophys. J. Int., 2006. - :param float alphamod: Exponential decay exponent. - :param array cvdav: Function magnitude at 0 radius (2 col array of radius, + :param xxx(eg str, tuple, int, float...) alphamod: Exponential decay exponent + :param xxx cvdav: Function magnitude at 0 radius (2 col array of radius, variance) - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=invalid-name @@ -68,13 +69,14 @@ def cvd(ifg_path, params, calc_alpha=False, write_vals=False, save_acg=False): Calculate average covariance versus distance (autocorrelation) and its best fitting exponential function. - :param ifg_path: An interferogram. ifg: :py:class:`pyrate.shared.Ifg` - :param: params: Dictionary of configuration parameters - :param calc_alpha: Calculate alpha, the exponential length-scale of decay factor - :param write_vals: Write maxvar and alpha values to interferogram metadata - :param save_acg: Write acg and radial distance data to numpy array + :param xxx(eg str, tuple, int, float...) ifg_path: An interferogram. ifg: :py:class:`pyrate.shared.Ifg` + :param: dict params: Dictionary of configuration parameters + :param xxx calc_alpha: Calculate alpha, the exponential length-scale of decay factor + :param xxx write_vals: Write maxvar and alpha values to interferogram metadata + :param xxx save_acg: Write acg and radial distance data to numpy array - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=invalid-name # pylint: disable=too-many-locals @@ -223,10 +225,11 @@ def get_vcmt(ifgs, maxvar): C = -0.5 if the master of i or j equals the slave of the other C = 0 otherwise - :param ifgs: A stack of interferograms.:py:class:`pyrate.shared.Ifg` - :param maxvar: numpy array of maximum variance values for each interferogram + :param xxx(eg str, tuple, int, float...) ifgs: A stack of interferograms.:py:class:`pyrate.shared.Ifg` + :param xxx maxvar: numpy array of maximum variance values for each interferogram - :return xxxx + :return: xxxx + :rtype: xxxx(eg float) """ # pylint: disable=too-many-locals # c=0.5 for common master or slave; c=-0.5 if master diff --git a/tests/common.py b/tests/common.py old mode 100644 new mode 100755 index 64343486d..e44e02dd4 --- a/tests/common.py +++ b/tests/common.py @@ -100,8 +100,10 @@ def small_data_setup(datafiles=None, is_dir=False): - """Returns Ifg objs for the files in the small test dir - input phase data is in radians; these ifgs are in radians - not converted to mm""" + """ + Returns interferogram objects for the files in the small test dir + input phase data is in radians; these interferograms are in radians - not converted to mm. + """ if is_dir: datafiles = glob.glob(join(datafiles, "*.tif")) else: @@ -121,8 +123,10 @@ def small_data_setup(datafiles=None, is_dir=False): def small_ifg_file_list(datafiles=None): - """Returns the file list of all the .tif files after prepifg conversion - input phase data is in radians; these ifgs are in radians - not converted to mm""" + """ + Returns the file list of all the .tif files after prepifg conversion + input phase data is in radians; these interferograms are in radians - not converted to mm. + """ if datafiles: for i, d in enumerate(datafiles): datafiles[i] = os.path.join(SML_TEST_TIF, d) @@ -133,19 +137,25 @@ def small_ifg_file_list(datafiles=None): def small_data_roipac_unws(): - """Returns unw file list before prepifg operation - input phase data is in radians; these ifgs are in radians - not converted to mm""" + """ + Returns unwrapped file list before prepifg operation + input phase data is in radians; these ifgs are in radians - not converted to mm. + """ return glob.glob(join(SML_TEST_OBS, "*.unw")) def small_data_setup_gamma_unws(): - """Returns unw file list before prepifg operation - input phase data is in radians; these ifgs are in radians - not converted to mm""" + """ + Returns unwrapped file list before prepifg operation + input phase data is in radians; these interferograms are in radians - not converted to mm. + """ return glob.glob(join(SML_TEST_GAMMA, "*.unw")) def small5_ifgs(): - """Convenience func to return a subset of 5 linked Ifgs from the testdata""" + """ + Convenience function to return a subset of 5 linked interferograms from the test data. + """ BASE_DIR = tempfile.mkdtemp() data_paths = [os.path.join(SML_TEST_TIF, p) for p in IFMS5.split()] new_data_paths = [os.path.join(BASE_DIR, os.path.basename(d)) @@ -157,7 +167,9 @@ def small5_ifgs(): def small5_mock_ifgs(xs=3, ys=4): - '''Returns smaller mocked version of small Ifgs for testing''' + """ + Returns smaller mocked version of small interferograms for testing. + """ ifgs = small5_ifgs() for i in ifgs: i.open() @@ -167,12 +179,13 @@ def small5_mock_ifgs(xs=3, ys=4): class MockIfg(object): - """Mock Ifg for detailed testing""" + """ + Mock interferogram for detailed testing.""" def __init__(self, ifg, xsize=None, ysize=None): """ - Creates mock Ifg based on a given interferogram. Size args specify the - dimensions of the phase band (so the mock ifg can be resized differently + Creates mock interferogram based on a given interferogram. Size arguments specify the + dimensions of the phase band (so the mock interferogram can be resized differently to the source interferogram for smaller test datasets). """ self.dataset = ifg.dataset diff --git a/tests/test_algorithm.py b/tests/test_algorithm.py old mode 100644 new mode 100755 index a8357cd47..0783fb5c0 --- a/tests/test_algorithm.py +++ b/tests/test_algorithm.py @@ -72,7 +72,7 @@ def test_least_squares_covariance_overdetermined(self): class AlgorithmTests(TestCase): """ - Misc unittests for functions in the algorithm module. + Miscellaneous unit tests for functions in the algorithm module. """ def test_is_square(self): @@ -174,7 +174,7 @@ def test_date_lookup_bad_inputs(self): class EpochsTests(TestCase): """ - Unittests for the EpochList class. + Unit tests for the EpochList class. """ def test_get_epochs(self): diff --git a/tests/test_gamma.py b/tests/test_gamma.py old mode 100644 new mode 100755 index 16830df13..fea7c3003 --- a/tests/test_gamma.py +++ b/tests/test_gamma.py @@ -116,7 +116,9 @@ def common_check(self, data): class GammaToGeoTiffTests(unittest.TestCase): - """Tests conversion of GAMMA rasters to custom PyRate GeoTIFF""" + """ + Tests conversion of GAMMA rasters to custom PyRate GeoTIFF. + """ @classmethod def setUpClass(cls): @@ -221,7 +223,9 @@ def test_bad_projection(self): class GammaHeaderParsingTests(unittest.TestCase): - 'Tests conversion of GAMMA headers to Py dicts' + """ + Tests conversion of GAMMA headers to Python dictionaries. + """ def test_parse_gamma_epoch_header(self): # minimal required headers are: @@ -278,7 +282,9 @@ def test_parse_gamma_dem_header(self): class HeaderCombinationTests(unittest.TestCase): - 'Tests GAMMA epoch and DEM headers can be combined into a single Py dict' + """ + Tests GAMMA epoch and DEM headers can be combined into a single Python dictionary. + """ def setUp(self): self.err = gamma.GammaException diff --git a/tests/test_gdal_python.py b/tests/test_gdal_python.py old mode 100644 new mode 100755 index c218df918..b143a8d90 --- a/tests/test_gdal_python.py +++ b/tests/test_gdal_python.py @@ -619,16 +619,20 @@ def test_gtiff(self): def warp_old(ifg, x_looks, y_looks, extents, resolution, thresh, crop_out, verbose, ret_ifg=True): """ - Resamples 'ifg' and returns a new Ifg obj. - - :param xlooks: integer factor to scale X axis by, 5 is 5x smaller, - 1 is no change. - :param ylooks: as xlooks, but for Y axis - :param extents: georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) - :param resolution: [xres, yres] or None. Sets resolution output Ifg metadata. - Use *None* if raster size is not being changed. - :param thresh: see thresh in prepare_ifgs(). + Resamples interferogram and returns a new interferogram object. + + :param ifg: Input interferogram + :param x_looks: Integer factor to scale X axis by, 5 is 5x smaller, + 1 is no change + :param y_looks: Integer factor to scale Y axis by, 5 is 5x smaller, + 1 is no change + :param extents: Georeferenced extents for new file: (xfirst, yfirst, xlast, ylast) + :param resolution: [xres, yres] or None. Sets resolution output interferogram metadata + Use *None* if raster size is not being changed + :param thresh: See thresh in prepare_ifgs() + :param crop_out: xxxx :param verbose: True to print gdalwarp output to stdout + :param ret_ifg: xxxx """ # pylint: disable=too-many-locals if x_looks != y_looks: diff --git a/tests/test_linrate.py b/tests/test_linrate.py old mode 100644 new mode 100755 index 03eaf4337..2b5f9cf61 --- a/tests/test_linrate.py +++ b/tests/test_linrate.py @@ -52,8 +52,8 @@ def __init__(self, timespan, phase): class LinearRateTests(unittest.TestCase): """ - Tests the weighted least squares algorithm for determinining - the best fitting velocity + Tests the weighted least squares algorithm for determining + the best fitting velocity. """ def setUp(self): @@ -78,7 +78,7 @@ def test_linear_rate(self): class MatlabEqualityTest(unittest.TestCase): """ - Tests equality vs matlab + Tests equality vs Matlab. """ @classmethod @@ -148,63 +148,63 @@ def tearDownClass(cls): def test_linear_rate_full_parallel(self): """ - python multiprocessing by rows vs serial + Python multiprocessing by rows vs serial. """ np.testing.assert_array_almost_equal( self.rate, self.rate_s, decimal=3) def test_linrate_error_parallel(self): """ - python multiprocessing by rows vs serial + Python multiprocessing by rows vs serial. """ np.testing.assert_array_almost_equal( self.error, self.error_s, decimal=3) def test_linrate_samples_parallel(self): """ - python multiprocessing by rows vs serial + Python multiprocessing by rows vs serial. """ np.testing.assert_array_almost_equal( self.samples, self.samples_s, decimal=3) def test_linrate_full_parallel_pixel(self): """ - python multiprocessing by pixel vs serial + Python multiprocessing by pixel vs serial. """ np.testing.assert_array_almost_equal( self.rate_2, self.rate_s, decimal=3) def test_linrate_error_parallel_pixel(self): """ - python multiprocessing by pixel vs serial + Python multiprocessing by pixel vs serial. """ np.testing.assert_array_almost_equal( self.error_2, self.error_s, decimal=3) def test_linrate_samples_parallel_pixel(self): """ - python multiprocessing pixel level vs serial + Python multiprocessing pixel level vs serial. """ np.testing.assert_array_almost_equal( self.samples_2, self.samples_s, decimal=3) def test_linear_rate(self): """ - python vs matlab + Python vs Matlab. """ np.testing.assert_array_almost_equal( self.rate_s, self.rate_matlab, decimal=3) def test_linrate_error(self): """ - python vs matlab + Python vs Matlab. """ np.testing.assert_array_almost_equal( self.error_s, self.error_matlab, decimal=3) def test_linrate_samples(self): """ - python linrate samples vs matlab + Python linrate samples vs Matlab. """ np.testing.assert_array_almost_equal( self.samples_s, self.samples_matlab, decimal=3) diff --git a/tests/test_matlab_mst.py b/tests/test_matlab_mst.py old mode 100644 new mode 100755 index 7db08cc23..687df16ca --- a/tests/test_matlab_mst.py +++ b/tests/test_matlab_mst.py @@ -68,7 +68,7 @@ def test_matlab_slvnum(self): # SB: this is not used anywhere now def sort_list(id_l, master_l, slave_l, nan_frac_l): """ - sort list based on nan_frac + Sort list based on nan_frac. """ sorted_list = [(i, m, s, n) for i, m, s, n in zip(id_l, master_l, slave_l, nan_frac_l)] @@ -219,7 +219,7 @@ def test_assert_two_trees_non_overlapping(self): class MatlabMSTTests(unittest.TestCase): """ - Tests to ensure matlab and python mst outputs are the same. + Tests to ensure Matlab and Python MST outputs are the same. """ def setUp(self): self.ifgs = small_data_setup() @@ -243,7 +243,7 @@ def setUp(self): def test_matlab_mst_kruskal(self): """ - test that the matlab and python mst algos outputs are the same + Test that the Matlab and Python MST algorithms outputs are the same. """ ifg_instance = IfgList(datafiles=self.ifg_file_list) ifg_list, _ = get_nml(ifg_instance, nodata_value=0) @@ -260,7 +260,7 @@ def test_matlab_mst_kruskal(self): def test_matlab_make_mstmat(self): """ - tests equality of boolean mst arrays of both python and matlab. + Tests equality of boolean MST arrays of both Python and Matlab. """ ifg_instance = IfgList(datafiles=self.ifg_file_list) ifg_list, _ = get_nml(ifg_instance, nodata_value=0) @@ -282,7 +282,7 @@ def test_matlab_make_mstmat(self): def test_matlab_make_mstmat_boolean_array(self): """ - tests equality of boolean mst arrays of both python and matlab. + Tests equality of boolean MST arrays of both Python and Matlab. """ ifg_instance = IfgList(datafiles=self.ifg_file_list) ifg_list, _ = get_nml(ifg_instance, nodata_value=0) diff --git a/tests/test_mpi.py b/tests/test_mpi.py old mode 100644 new mode 100755 index 95363f13b..e6f3dea6c --- a/tests/test_mpi.py +++ b/tests/test_mpi.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -This Python module contains tests for mpi operations in PyRate. -Tun this module as 'mpirun -n 4 pytest tests/test_mpi.py' +This Python module contains tests for MPI operations in PyRate. +Run this module as 'mpirun -n 4 pytest tests/test_mpi.py'. """ from __future__ import print_function @@ -56,7 +56,7 @@ @pytest.fixture() def tempdir(): """ - tempdir for tests + Temporary directory for tests. """ def tmpdir(): return tempfile.mkdtemp() @@ -76,15 +76,9 @@ def make_random_filename(ext=''): @pytest.fixture() def get_config(): """ - Parameters - ---------- - conf_file: str - config file - - Returns - ------- - params: dict - dict of params + :param conf_file: Config file + + :return params: Dictionary of parameters """ def params(conf_file): return cf.get_config_params(conf_file) diff --git a/tests/test_mst.py b/tests/test_mst.py old mode 100644 new mode 100755 index 0ff72b6cf..27d8e6ef3 --- a/tests/test_mst.py +++ b/tests/test_mst.py @@ -38,7 +38,9 @@ class MSTTests(unittest.TestCase): - '''Basic verification of minimum spanning tree (MST) functionality.''' + """ + Basic verification of minimum spanning tree (MST) functionality. + """ def setUp(self): self.ifgs = small_data_setup() diff --git a/tests/test_orbital.py b/tests/test_orbital.py old mode 100644 new mode 100755 index 7f0aaeb2d..e6a9c6844 --- a/tests/test_orbital.py +++ b/tests/test_orbital.py @@ -60,9 +60,9 @@ class SingleDesignMatrixTests(unittest.TestCase): """ - Tests to verify correctness of basic planar & quadratic design matrices or - DMs. This class serves two purposes, ensuring the independent method DMs are - produced correctly. Secondly, these indivdual DMs are subsets of the larger + Tests to verify correctness of basic planar and quadratic design matrices or + design matrices (DM). This class serves two purposes, ensuring the independent method DMs are + produced correctly. Secondly, these individual DMs are subsets of the larger DM 'grid' required for the networked orbital correction method. """ @@ -160,7 +160,9 @@ def test_create_partcubic_dm_network(self): class IndependentCorrectionTests(unittest.TestCase): - """Test cases for the orbital correction component of PyRate.""" + """ + Test cases for the orbital correction component of PyRate. + """ def setUp(self): self.ifgs = small5_mock_ifgs() @@ -220,7 +222,9 @@ def check_correction(self, degree, method, offset, decimal=2): assert_array_almost_equal(e, a, decimal=decimal) def check_results(self, ifgs, corrections): - """Helper method for result verification""" + """ + Helper method for result verification. + """ for i, c in zip(ifgs, corrections): ys, xs = c.shape self.assertEqual(i.nrows, ys) @@ -251,7 +255,9 @@ def test_independent_correction_partcubic_offsets(self): class ErrorTests(unittest.TestCase): - """Tests for the networked correction method""" + """ + Tests for the networked correction method. + """ def test_invalid_ifgs_arg(self): # min requirement is 1 ifg, can still subtract one epoch from the other @@ -293,7 +299,9 @@ def test_multilooked_ifgs_arg(self): class NetworkDesignMatrixTests(unittest.TestCase): - """Contains tests verifying creation of sparse network design matrix.""" + """ + Contains tests verifying creation of sparse network design matrix. + """ def setUp(self): self.ifgs = small5_mock_ifgs() @@ -361,11 +369,12 @@ def test_partcubic_network_dm_offset(self): def check_equality(self, ncoef, dm, ifgs, offset): """ - Internal test function to check subsets against network design matrix - ncoef - base number of coefficients, without extra col for offsets - dm - network design matrix to check the results - ifgs - sequence of Ifg objs - offset - boolean to include extra parameters for model offsets + Internal test function to check subsets against network design matrix. + + :param ncoef: Base number of coefficients, without extra column for offsets + :param dm: Network design matrix to check the results + :param ifgs: Sequence of interferogram objects + :param offset: Boolean to include extra parameters for model offsets """ deg = DEG_LOOKUP[ncoef] np = ncoef * self.nepochs # index of 1st offset col @@ -398,8 +407,9 @@ def check_equality(self, ncoef, dm, ifgs, offset): def network_correction(ifgs, deg, off, ml_ifgs=None, tol=1e-6): """ Compares results of orbital_correction() to alternate implementation. - deg - PLANAR, QUADRATIC or PART_CUBIC - off - True/False to calculate correction with offsets + + :param deg: PLANAR, QUADRATIC or PART_CUBIC + :param off: True/False to calculate correction with offsets """ ncells = ifgs[0].num_cells @@ -428,11 +438,12 @@ def network_correction(ifgs, deg, off, ml_ifgs=None, tol=1e-6): def _expand_corrections(ifgs, dm, params, ncoef, offsets): """ - Convenience func returns model converted to data points. - dm: design matrix (do not filter/remove nan cells) - params: model parameters array from pinv() * dm - ncoef: number of model coefficients (2 planar, 5 quadratic) - offsets: True/False to calculate correction with offsets + Convenience function returns model converted to data points. + + :param dm: design matrix (do not filter/remove nan cells) + :param params: model parameters array from pinv() * dm + :param ncoef: number of model coefficients (2 planar, 5 quadratic) + :param offsets: True/False to calculate correction with offsets """ # NB: cannot work on singular ifgs due to date ID id/indexing requirement date_ids = get_date_ids(ifgs) @@ -457,7 +468,9 @@ def _expand_corrections(ifgs, dm, params, ncoef, offsets): class NetworkCorrectionTests(unittest.TestCase): - """Verifies orbital correction using network method and no multilooking""" + """ + Verifies orbital correction using network method and no multi-looking. + """ def setUp(self): # fake some real ifg data by adding nans @@ -473,10 +486,12 @@ def setUp(self): def test_offset_inversion(self): """ - Ensure pinv(DM)*obs gives equal results given constant change to fd + Ensure pinv(DM)*obs gives equal results given constant change to fd. """ def get_orbital_params(): - """Returns pseudo-inverse of the DM""" + """ + Returns pseudo-inverse of the design matrix. + """ ncells = self.ifgs[0].num_cells data = concatenate([i.phase_data.reshape(ncells) for i in self.ifgs]) dm = get_network_design_matrix(self.ifgs, PLANAR, True)[~isnan(data)] @@ -549,7 +564,9 @@ def verify_corrections(ifgs, exp, deg, offset): class NetworkCorrectionTestsMultilooking(unittest.TestCase): - 'Verifies orbital correction with multilooking and network method' + """ + Verifies orbital correction with multi-looking and network method. + """ def setUp(self): # fake some real ifg data by adding nans @@ -612,13 +629,14 @@ def verify_corrections(self, ifgs, exp, deg, offset): def unittest_dm(ifg, method, degree, offset=False, scale=100.0): - '''Helper/test func to create design matrix segments. Includes handling for + """Helper/test func to create design matrix segments. Includes handling for making quadratic DM segments for use in network method. - ifg - source interferogram to model design matrix on - method - INDEPENDENT_METHOD or NETWORK_METHOD - degree - PLANAR, QUADRATIC or PART_CUBIC - offset - True/False to include additional cols for offsets - ''' + + :param ifg: Source interferogram to model design matrix on + :param method: INDEPENDENT_METHOD or NETWORK_METHOD + :param degree: PLANAR, QUADRATIC or PART_CUBIC + :param offset: True/False to include additional cols for offsets + """ assert method in [INDEPENDENT_METHOD, NETWORK_METHOD] xlen = ncoef = NUM_COEF_LOOKUP[degree] @@ -659,9 +677,9 @@ def unittest_dm(ifg, method, degree, offset=False, scale=100.0): def get_date_ids(ifgs): - ''' - Returns unique master/slave date IDs from the given Ifgs. - ''' + """ + Returns unique master/slave date IDs from the given interferograms. + """ dates = [] for ifg in ifgs: @@ -670,7 +688,9 @@ def get_date_ids(ifgs): def _add_nodata(ifgs): - """Adds some NODATA/nan cells to the small mock ifgs""" + """ + Adds some NODATA/nan cells to the small mock interferograms. + """ ifgs[0].phase_data[0, :] = nan # 3 error cells ifgs[1].phase_data[2, 1:3] = nan # 2 error cells ifgs[2].phase_data[3, 2:3] = nan # 1 err @@ -680,14 +700,13 @@ def _add_nodata(ifgs): class MatlabComparisonTestsOrbfitMethod1(unittest.TestCase): """ - This is the matlab comparison test of orbital correction functionality. + This is the Matlab comparison test of orbital correction functionality. Tests use the following config orbfit: 1 orbfitmethod: 2 orbfitdegrees: 1 orbfitlksx: 2 orbfitlksy: 2 - """ def setUp(self): @@ -748,14 +767,13 @@ def test_orbital_correction_matlab_equality(self): class MatlabComparisonTestsOrbfitMethod2(unittest.TestCase): """ - This is the matlab comparison test of orbital correction functionality. + This is the Matlab comparison test of orbital correction functionality. Tests use the following config orbfit: 1 orbfitmethod: 2 orbfitdegrees: 1 orbfitlksx: 1 orbfitlksy: 1 - """ def setUp(self): self.BASE_DIR = tempfile.mkdtemp() @@ -820,7 +838,7 @@ def test_orbital_correction_matlab_equality_orbfit_method_2(self): def test_orbital_error_method2_dummy(self): """ - does not test anything except that the method is working + Does not test anything except that the method is working. """ # change to orbital error correction method 2 self.params[cf.ORBITAL_FIT_METHOD] = 2 diff --git a/tests/test_prepifg.py b/tests/test_prepifg.py old mode 100644 new mode 100755 index 6093ddfe7..8a2f01dda --- a/tests/test_prepifg.py +++ b/tests/test_prepifg.py @@ -77,7 +77,9 @@ # convenience ifg creation funcs def diff_exts_ifgs(): - """Returns pair of test Ifgs with different extents""" + """ + Returns pair of test interferograms with different extents. + """ bases = ['geo_060619-061002.tif', 'geo_070326-070917.tif'] random_dir = tempfile.mkdtemp() for p in bases: @@ -87,7 +89,9 @@ def diff_exts_ifgs(): def same_exts_ifgs(): - """Return pair of Ifgs with same extents""" + """ + Return pair of interferograms with same extents. + """ return [Ifg(join(PREP_TEST_TIF, f)) for f in ('0.tif', '1.tif')] @@ -101,7 +105,9 @@ def test_extents_from_params(): class PrepifgOutputTests(unittest.TestCase): - """Tests aspects of the prepifg.py script, such as resampling.""" + """ + Tests aspects of the prepifg.py script, such as resampling. + """ def __init__(self, *args, **kwargs): super(PrepifgOutputTests, self).__init__(*args, **kwargs) @@ -190,7 +196,9 @@ def test_multilooked_projection_same_as_geotiff(self): self.assert_projection_equal(self.ifg_paths + mlooked_paths) def test_default_max_extents(self): - """Test ifgcropopt=2 crops datasets to max bounding box extents.""" + """ + Test ifgcropopt=2 crops datasets to maximum bounding box extents. + """ xlooks = ylooks = 1 prepare_ifgs(self.ifg_paths, MAXIMUM_CROP, xlooks, ylooks) for f in [self.exp_files[1], self.exp_files[5]]: @@ -214,7 +222,9 @@ def test_default_max_extents(self): i.close() def test_min_extents(self): - """Test ifgcropopt=1 crops datasets to min extents.""" + """ + Test ifgcropopt=1 crops datasets to minimum extents. + """ xlooks = ylooks = 1 prepare_ifgs(self.ifg_paths, MINIMUM_CROP, xlooks, ylooks) ifg = Ifg(self.exp_files[0]) @@ -256,7 +266,9 @@ def test_custom_extents(self): i.close() def test_exception_without_all_4_crop_parameters(self): - """Test misaligned cropping extents raise errors.""" + """ + Test misaligned cropping extents raise errors. + """ xlooks = ylooks = 1 # empty string and none raises exceptio for i in [None, '']: @@ -272,7 +284,9 @@ def test_exception_without_all_4_crop_parameters(self): i.close() def test_custom_extents_misalignment(self): - """Test misaligned cropping extents raise errors.""" + """ + Test misaligned cropping extents raise errors. + """ xlooks = ylooks = 1 latlons = tuple(self._custom_ext_latlons()) for i, _ in enumerate(['xfirst', 'yfirst', 'xlast', 'ylast']): @@ -290,7 +304,9 @@ def test_custom_extents_misalignment(self): i.close() def test_nodata(self): - """Verify NODATA value copied correctly (amplitude band not copied)""" + """ + Verify NODATA value copied correctly (amplitude band not copied). + """ xlooks = ylooks = 1 prepare_ifgs(self.ifg_paths, MINIMUM_CROP, xlooks, ylooks) @@ -305,7 +321,9 @@ def test_nodata(self): i.close() def test_nans(self): - """Verify NaNs replace 0 in the multilooked phase band""" + """ + Verify NaNs replace 0 in the multi-looked phase band. + """ xlooks = ylooks = 1 prepare_ifgs(self.ifg_paths, MINIMUM_CROP, xlooks, ylooks) @@ -324,7 +342,9 @@ def test_nans(self): i.close() def test_multilook(self): - """Test resampling method using a scaling factor of 4""" + """ + Test resampling method using a scaling factor of 4. + """ scale = 4 # assumes square cells self.ifgs.append(DEM(SML_TEST_DEM_TIF)) self.ifg_paths = [i.data_path for i in self.ifgs] @@ -375,7 +395,9 @@ def test_multilook(self): os.remove(exp_dem_path) def test_output_datatype(self): - """Test resampling method using a scaling factor of 4""" + """ + Test resampling method using a scaling factor of 4. + """ scale = 4 # assumes square cells self.ifgs.append(DEM(SML_TEST_DEM_TIF)) self.ifg_paths = [i.data_path for i in self.ifgs] + [SML_TEST_DEM_TIF] @@ -395,7 +417,9 @@ def test_output_datatype(self): ds1 = ds2 = None def test_invalid_looks(self): - """Verify only numeric values can be given for multilooking""" + """ + Verify only numeric values can be given for multi-looking. + """ values = [0, -1, -10, -100000.6, ""] for v in values: self.assertRaises(PreprocessError, prepare_ifgs, self.ifg_paths, @@ -406,7 +430,9 @@ def test_invalid_looks(self): class ThresholdTests(unittest.TestCase): - """Tests for threshold of data -> NaN during resampling.""" + """ + Tests for threshold of data -> NaN during resampling. + """ def test_nan_threshold_inputs(self): data = ones((1, 1)) @@ -445,7 +471,9 @@ def test_nan_threshold_alt(): class SameSizeTests(unittest.TestCase): - """Tests aspects of the prepifg.py script, such as resampling.""" + """ + Tests aspects of the prepifg.py script, such as resampling. + """ def __init__(self, *args, **kwargs): super(SameSizeTests, self).__init__(*args, **kwargs) @@ -525,7 +553,9 @@ def test_mlooked_path(): class LocalMultilookTests(unittest.TestCase): - """Tests for local testing functions""" + """ + Tests for local testing functions. + """ @staticmethod def test_multilooking_thresh(): @@ -545,8 +575,8 @@ def multilooking(src, xscale, yscale, thresh=0): """ Implementation of Matlab Pirate looks.m function. - src: numpy array of phase data - thresh: min number of non-NaNs required for a valid tile resampling + :param src: numpy array of phase data + :param thresh: min number of non-NaNs required for a valid tile resampling """ thresh = int(thresh) num_cells = xscale * yscale @@ -580,7 +610,7 @@ def multilooking(src, xscale, yscale, thresh=0): class MatlabEqualityTestRoipacSmallTestData(unittest.TestCase): """ - Matlab to python roipac prepifg equality test for small test data + Matlab to Python ROI_PAC prepifg equality test for small test data. """ def setUp(self): @@ -602,7 +632,7 @@ def tearDown(self): def test_matlab_prepifg_equality_array(self): """ - Matlab to python prepifg equality test + Matlab to Python prepifg equality test. """ # path to csv folders from matlab output onlyfiles = [ @@ -624,7 +654,7 @@ def test_matlab_prepifg_equality_array(self): def test_matlab_prepifg_and_convert_phase(self): """ - Matlab to python prepifg equality test + Matlab to Python prepifg equality test. """ # path to csv folders from matlab output for i in self.ifgs_with_nan: diff --git a/tests/test_pyrate.py b/tests/test_pyrate.py old mode 100644 new mode 100755 index 83272e9ea..0680b9dac --- a/tests/test_pyrate.py +++ b/tests/test_pyrate.py @@ -76,7 +76,7 @@ def test_original_ifg_paths(): def dest_ifg_paths(ifg_paths, outdir): """ - Returns paths to out/dest ifgs. + Returns paths to out/destination interferograms. """ bases = [os.path.basename(p) for p in ifg_paths] @@ -150,7 +150,9 @@ def tearDownClass(cls): os.chdir(CURRENT_DIR) def key_check(self, ifg, key, value): - 'Helper to check for metadata flags' + """ + Helper to check for metadata flags. + """ md = ifg.dataset.GetMetadata() self.assertTrue(key in md, 'Missing %s in %s' % (key, ifg.data_path)) self.assertTrue(md[key], value) @@ -183,7 +185,7 @@ def test_orbital_correction(self): class ParallelPyRateTests(unittest.TestCase): """ - parallel vs serial pyrate tests verifying results from all steps equal + Parallel vs serial PyRate tests verifying results from all steps equal. """ @classmethod @@ -256,7 +258,9 @@ def test_orbital_correction(self): self.key_check(i, key, value) def key_check(self, ifg, key, value): - 'Helper to check for metadata flags' + """ + Helper to check for metadata flags. + """ md = ifg.dataset.GetMetadata() self.assertTrue(key in md, 'Missing %s in %s' % (key, ifg.data_path)) self.assertTrue(md[key], value) diff --git a/tests/test_ref_phs_est.py b/tests/test_ref_phs_est.py old mode 100644 new mode 100755 index bbec30488..8a379e263 --- a/tests/test_ref_phs_est.py +++ b/tests/test_ref_phs_est.py @@ -74,7 +74,9 @@ class RefPhsTests(unittest.TestCase): - """Basic reference phase estimation tests""" + """ + Basic reference phase estimation tests. + """ def setUp(self): self.tmp_dir = tempfile.mkdtemp() @@ -113,7 +115,7 @@ def test_mixed_metadata_raises(self): class RefPhsEstimationMatlabTestMethod1Serial(unittest.TestCase): """ - Reference phase estimation method 1 is tested vs matlab output + Reference phase estimation method 1 is tested vs Matlab output. """ @classmethod @@ -201,7 +203,7 @@ def test_ifgs_after_ref_phs_est(self): class RefPhsEstimationMatlabTestMethod1Parallel(unittest.TestCase): """ - Reference phase estimation method 1 is tested vs matlab output + Reference phase estimation method 1 is tested vs Matlab output. """ @classmethod def setUpClass(cls): @@ -290,7 +292,7 @@ def test_ifgs_after_ref_phs_est(self): class RefPhsEstimationMatlabTestMethod2Serial(unittest.TestCase): """ - Reference phase estimation method 2 is tested vs matlab output + Reference phase estimation method 2 is tested vs Matlab output. """ @classmethod @@ -379,7 +381,7 @@ def test_estimate_reference_phase_method2(self): class RefPhsEstimationMatlabTestMethod2Parallel(unittest.TestCase): """ - Reference phase estimation method 2 is tested vs matlab output + Reference phase estimation method 2 is tested vs Matlab output. """ # TODO: Improve the parallel tests to remove duplication from serial tests diff --git a/tests/test_refpixel.py b/tests/test_refpixel.py old mode 100644 new mode 100755 index d19fbeaf4..05a533eb6 --- a/tests/test_refpixel.py +++ b/tests/test_refpixel.py @@ -37,9 +37,9 @@ class ReferencePixelInputTests(unittest.TestCase): - ''' - Verifies error checking capabilities of the reference pixel function - ''' + """ + Verifies error checking capabilities of the reference pixel function. + """ def setUp(self): self.ifgs = small_data_setup() @@ -91,7 +91,7 @@ def test_missing_search_windows(self): class ReferencePixelTests(unittest.TestCase): """ - Tests reference pixel search + Tests reference pixel search. """ def setUp(self): @@ -196,7 +196,9 @@ def test_ref_pixel(self): def _expected_ref_pixel(ifgs, cs): - """Helper function for finding reference pixel when refnx/y=2""" + """ + Helper function for finding reference pixel when refnx/y=2. + """ # calculate expected data data = [i.phase_data for i in ifgs] # len 17 list of arrays diff --git a/tests/test_roipac.py b/tests/test_roipac.py old mode 100644 new mode 100755 index 455d13019..bf8e9b3c7 --- a/tests/test_roipac.py +++ b/tests/test_roipac.py @@ -129,7 +129,9 @@ def common_check(self): class RoipacToGeoTiffTests(unittest.TestCase): - """Tests conversion of GAMMA rasters to custom PyRate GeoTIFF""" + """ + Tests conversion of ROI_PAC rasters to custom PyRate GeoTIFF. + """ @classmethod def setUpClass(cls): @@ -250,7 +252,9 @@ def test_parse_date_range(self): class HeaderParsingTests(unittest.TestCase): - """Verifies ROIPAC headers are parsed correctly.""" + """ + Verifies ROI_PAC headers are parsed correctly. + """ # short format header tests def test_parse_short_roipac_header(self): diff --git a/tests/test_shared.py b/tests/test_shared.py old mode 100644 new mode 100755 index 980d8c2c3..0f1b9ecfc --- a/tests/test_shared.py +++ b/tests/test_shared.py @@ -51,7 +51,9 @@ class IfgTests(unittest.TestCase): - """Unit tests for the Ifg/interferogram class.""" + """ + Unit tests for the Ifg/interferogram class. + """ def setUp(self): self.ifg = Ifg(join(SML_TEST_TIF, 'geo_060619-061002_unw.tif')) @@ -165,8 +167,8 @@ def test_open(self): def test_open_ifg_from_dataset(self): """ - Test showing open() can not be used for Ifg created with - gdal.Dataset object as Dataset has already been read in + Test showing open() can not be used for inteferogram created with + gdal.Dataset object as Dataset has already been read in. """ paths = [self.ifg.data_path] mlooked_phase_data = prepifg.prepare_ifgs(paths, @@ -291,7 +293,9 @@ def test_phase_data_properties(self): class DEMTests(unittest.TestCase): - 'Unit tests to verify operations on GeoTIFF format DEMs' + """ + Unit tests to verify operations on GeoTIFF format DEMs. + """ def setUp(self): self.ras = DEM(SML_TEST_DEM_TIF) diff --git a/tests/test_timeseries.py b/tests/test_timeseries.py old mode 100644 new mode 100755 index ea8e9ce01..fc5183954 --- a/tests/test_timeseries.py +++ b/tests/test_timeseries.py @@ -51,7 +51,7 @@ def default_params(): class SinglePixelIfg(object): """ - A single pixel ifg (interferogram) solely for unit testing + A single pixel interferogram solely for unit testing. """ def __init__(self, master, slave, phase, nan_fraction): @@ -64,15 +64,18 @@ def __init__(self, master, slave, phase, nan_fraction): def convert_to_nans(self, val=0): """ - Converts given values in phase data to NaNs - val - value to convert, default is 0 + Converts given values in phase data to NaNs. + + :param: val: Value to convert, default is 0 """ self.phase_data = where(self.phase_data == val, nan, self.phase_data) self.nan_converted = True class TimeSeriesTests(unittest.TestCase): - """Verifies error checking capabilities of the time_series function""" + """ + Verifies error checking capabilities of the time_series function. + """ @classmethod def setUpClass(cls): @@ -102,7 +105,7 @@ def setUpClass(cls): def test_time_series_unit(self): """ - Checks that the code works the same as the calculated example + Checks that the code works the same as the calculated example. """ imaster = asarray([1, 1, 2, 2, 3, 3, 4, 5]) islave = asarray([2, 4, 3, 4, 5, 6, 6, 6]) @@ -128,7 +131,7 @@ def test_time_series_unit(self): class MatlabTimeSeriesEquality(unittest.TestCase): """ - Checks the python function to that of Matlab Pirate ts.m and tsinvlap.m + Checks the Python function to that of Matlab Pirate ts.m and tsinvlap.m functionality. """ @@ -197,7 +200,7 @@ def tearDownClass(cls): def test_time_series_equality_parallel_by_rows(self): """ - check time series parallel by rows jobs + Check time series parallel by rows jobs. """ self.assertEqual(self.tsincr_1.shape, self.tscum_1.shape) @@ -211,7 +214,7 @@ def test_time_series_equality_parallel_by_rows(self): def test_time_series_equality_parallel_by_the_pixel(self): """ - check time series parallel by pixel jobs + Check time series parallel by pixel jobs. """ self.assertEqual(self.tsincr_2.shape, self.tscum_2.shape) self.assertEqual(self.tsvel_2.shape, self.tsincr_2.shape) @@ -224,7 +227,7 @@ def test_time_series_equality_parallel_by_the_pixel(self): def test_time_series_equality_serial_by_the_pixel(self): """ - check time series + Check time series. """ self.assertEqual(self.tsincr_0.shape, self.tscum_0.shape) @@ -238,7 +241,7 @@ def test_time_series_equality_serial_by_the_pixel(self): class MatlabTimeSeriesEqualityMethod2Interp0(unittest.TestCase): """ - Checks the python function to that of Matlab Pirate ts.m and tsinvlap.m + Checks the Python function to that of Matlab Pirate ts.m and tsinvlap.m functionality. """ @classmethod diff --git a/utils/create_lv_theta.py b/utils/create_lv_theta.py old mode 100644 new mode 100755 index d53320b86..b94e33e74 --- a/utils/create_lv_theta.py +++ b/utils/create_lv_theta.py @@ -13,10 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -''' -This is used to create the dummy incidence map file .inc file -This is used to create the dummy elevation map file .lv_theta file -''' +""" +This is used to create the dummy incidence map file .inc file. +This is used to create the dummy elevation map file .lv_theta file. +""" import os diff --git a/utils/crop_ifgs.py b/utils/crop_ifgs.py old mode 100644 new mode 100755 index 03942c608..8597041f4 --- a/utils/crop_ifgs.py +++ b/utils/crop_ifgs.py @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -python utility to crop an interferogram +Python utility to crop an interferogram. example usage: + python pyrate/utils/crop_ifgs.py -i tests/test_data/small_test/tif/geo_060619-061002.tif -o out.tif -e '150.91 -34.229999976 150.949166651 -34.17' - """ from optparse import OptionParser import subprocess