From fee48f4368bc6e229492cb75b6f595a3480391e7 Mon Sep 17 00:00:00 2001 From: Seongsu Jeong Date: Wed, 17 Jul 2024 09:38:27 -0700 Subject: [PATCH] typo fix and linting --- .../defaults/algorithm_parameter_ni.yaml | 4 +-- .../defaults/algorithm_parameter_s1.yaml | 4 +-- src/dswx_sar/defaults/dswx_ni.yaml | 2 +- src/dswx_sar/dswx_comparison.py | 2 +- src/dswx_sar/dswx_geogrid.py | 1 - src/dswx_sar/dswx_ni_runconfig.py | 2 +- src/dswx_sar/dswx_runconfig.py | 8 ++--- src/dswx_sar/dswx_sar_util.py | 12 ++++---- src/dswx_sar/filter_SAR.py | 2 +- src/dswx_sar/fuzzy_value_computation.py | 6 ++-- src/dswx_sar/initial_threshold.py | 12 ++++---- src/dswx_sar/masking_with_ancillary.py | 26 ++++++++--------- src/dswx_sar/metadata.py | 2 +- src/dswx_sar/mosaic_gcov_frame.py | 24 +++++++-------- src/dswx_sar/mosaic_rtc_burst.py | 21 +++++++------- src/dswx_sar/pre_processing.py | 4 +-- src/dswx_sar/process_nisar_rtc.py | 10 +++---- src/dswx_sar/refine_with_bimodality.py | 29 ++++++++++--------- src/dswx_sar/region_growing.py | 6 ++-- src/dswx_sar/save_mgrs_tiles.py | 22 +++++++------- src/dswx_sar/save_mgrs_tiles_ni.py | 10 +++---- .../schemas/algorithm_parameter_ni.yaml | 2 +- .../schemas/algorithm_parameter_s1.yaml | 2 +- src/dswx_sar/schemas/dswx_ni.yaml | 2 +- 24 files changed, 108 insertions(+), 107 deletions(-) diff --git a/src/dswx_sar/defaults/algorithm_parameter_ni.yaml b/src/dswx_sar/defaults/algorithm_parameter_ni.yaml index d155328..9af54b8 100644 --- a/src/dswx_sar/defaults/algorithm_parameter_ni.yaml +++ b/src/dswx_sar/defaults/algorithm_parameter_ni.yaml @@ -76,7 +76,7 @@ runconfig: # using bimodality strategy. # One values are required for bimodality method tile_selection_bimodality: 0.7 - # Stratey to interpolate the tile-based thresholds. + # Strategy to interpolate the tile-based thresholds. # Currently, only 'smoothed' is available. extending_method: 'gdal_grid' # Thresholding algorithm for initial thresholds. @@ -161,7 +161,7 @@ runconfig: # The elements will be masked out during this step. land_cover_darkland_list: ['Bare sparse vegetation', 'Urban', 'Moss and lichen'] # The elements is considered as the dark land candidates - # where these elemtns are spatially connected to the dark land. + # where these elements are spatially connected to the dark land. land_cover_darkland_extension_list: ['Grassland', 'Shrubs'] land_cover_water_label: ['Permanent water bodies'] # VV and VH threshold values for dark land candidates diff --git a/src/dswx_sar/defaults/algorithm_parameter_s1.yaml b/src/dswx_sar/defaults/algorithm_parameter_s1.yaml index 64a834e..ac46128 100644 --- a/src/dswx_sar/defaults/algorithm_parameter_s1.yaml +++ b/src/dswx_sar/defaults/algorithm_parameter_s1.yaml @@ -93,7 +93,7 @@ runconfig: # using bimodality strategy. # One values are required for bimodality method tile_selection_bimodality: 0.7 - # Stratey to interpolate the tile-based thresholds. + # Strategy to interpolate the tile-based thresholds. # Currently, only 'smoothed' is available. extending_method: 'gdal_grid' # Thresholding algorithm for initial thresholds. @@ -178,7 +178,7 @@ runconfig: # The elements will be masked out during this step. land_cover_darkland_list: ['Bare sparse vegetation', 'Urban', 'Moss and lichen'] # The elements is considered as the dark land candidates - # where these elemtns are spatially connected to the dark land. + # where these elements are spatially connected to the dark land. land_cover_darkland_extension_list: ['Grassland', 'Shrubs'] land_cover_water_label: ['Permanent water bodies'] # VV and VH threshold values for dark land candidates diff --git a/src/dswx_sar/defaults/dswx_ni.yaml b/src/dswx_sar/defaults/dswx_ni.yaml index c63e591..9e2da8b 100644 --- a/src/dswx_sar/defaults/dswx_ni.yaml +++ b/src/dswx_sar/defaults/dswx_ni.yaml @@ -50,7 +50,7 @@ runconfig: # algorithm parameter algorithm_parameters: - # placeholder for inundated vegettion + # placeholder for inundated vegetation mean_backscattering: standard_deviation_backscattering: diff --git a/src/dswx_sar/dswx_comparison.py b/src/dswx_sar/dswx_comparison.py index 46ac3e2..cfe820d 100644 --- a/src/dswx_sar/dswx_comparison.py +++ b/src/dswx_sar/dswx_comparison.py @@ -82,7 +82,7 @@ def _compare_dswx_sar_metadata(metadata_1, metadata_2): metadata_error_message = ( f'* input 1 metadata has {len(metadata_1.keys())} entries' f' whereas input 2 metadata has {len(metadata_2.keys())} entries.') - + set_1_m_2 = set(metadata_1.keys()) - set(metadata_2.keys()) if len(set_1_m_2) > 0: metadata_error_message += (' Input 1 metadata has extra entries' diff --git a/src/dswx_sar/dswx_geogrid.py b/src/dswx_sar/dswx_geogrid.py index 3d60382..a2f92bd 100644 --- a/src/dswx_sar/dswx_geogrid.py +++ b/src/dswx_sar/dswx_geogrid.py @@ -144,4 +144,3 @@ def update_geogrid(self, geotiff_path): self.epsg = new_geogrid.epsg \ if not np.isnan(new_geogrid.epsg) else self.epsg - diff --git a/src/dswx_sar/dswx_ni_runconfig.py b/src/dswx_sar/dswx_ni_runconfig.py index 30dfcc4..23166b8 100644 --- a/src/dswx_sar/dswx_ni_runconfig.py +++ b/src/dswx_sar/dswx_ni_runconfig.py @@ -307,7 +307,7 @@ def custom_sort(pol): pol_mode = pol_mode_name if pol_mode is None: - err_msg = 'unable to identify polarzation mode.' + err_msg = 'unable to identify polarization mode.' logger.warning(err_msg) return co_pol_list, cross_pol_list, sorted_pol_list, pol_mode diff --git a/src/dswx_sar/dswx_runconfig.py b/src/dswx_sar/dswx_runconfig.py index 42f7707..35815f0 100644 --- a/src/dswx_sar/dswx_runconfig.py +++ b/src/dswx_sar/dswx_runconfig.py @@ -19,10 +19,10 @@ # Potential polarization scenarios for DSWx-S1 # NOTE: DO NOT CHANGE THE ORDER of the items in the dictionary below. -# There are more modes such as 'MIX_DUAL_V_SINGLE_V' and +# There are more modes such as 'MIX_DUAL_V_SINGLE_V' and # 'MIX_DUAL_H_SINGLE_H' describing the dual_polarization and -# single polarization with same polarization. This mode will be -# deteremine by counting the available bursts. +# single polarization with same polarization. This mode will be +# determined by counting the available bursts. DSWX_S1_POL_DICT = { 'CO_POL': ['HH', 'VV'], 'CROSS_POL': ['HV', 'VH'], @@ -305,7 +305,7 @@ def custom_sort(pol): pol_mode = pol_mode_name if pol_mode is None: - err_msg = 'unable to identify polarzation mode.' + err_msg = 'unable to identify polarization mode.' logger.warning(err_msg) return co_pol_list, cross_pol_list, sorted_pol_list, pol_mode diff --git a/src/dswx_sar/dswx_sar_util.py b/src/dswx_sar/dswx_sar_util.py index 7739162..dee19a9 100644 --- a/src/dswx_sar/dswx_sar_util.py +++ b/src/dswx_sar/dswx_sar_util.py @@ -51,7 +51,7 @@ Internally, DSWx-S1 has 2 water classes; 1. low-backscattering water 2. high-backscattering water -There classes are collapesed into water class when +There classes are collapsed into water class when WTR layers converts to BWTR. Low-backscattering land (dark land) is captured from @@ -477,7 +477,7 @@ def change_epsg_tif(input_tif, output_tif, epsg_output, # Get pixel dimensions pixel_x_spacing = metadata['geotransform'][1] - pixel_y_sapcing = metadata['geotransform'][5] + pixel_y_spacing = metadata['geotransform'][5] # Get the number of rows and columns cols = metadata['width'] @@ -485,7 +485,7 @@ def change_epsg_tif(input_tif, output_tif, epsg_output, # Calculate coordinates of the lower right corner x_max = x_min + (cols * pixel_x_spacing) - y_min = y_max + (rows * pixel_y_sapcing) + y_min = y_max + (rows * pixel_y_spacing) corners = [ (x_min, y_max), # Top-left @@ -499,7 +499,7 @@ def change_epsg_tif(input_tif, output_tif, epsg_output, metadata['epsg'], epsg_output, x_snap=pixel_x_spacing, - y_snap=pixel_y_sapcing) + y_snap=pixel_y_spacing) x_coords, y_coords = zip(*corner_output) x_min_output, x_max_output = min(x_coords), max(x_coords) @@ -1120,7 +1120,7 @@ def merge_binary_layers(layer_list, value_list, merged_layer_path, cog_flag : bool, optional Write to COG if True. Defaults to True. scratch_dir : str, optional - Path to scrath dir. Defaults to '.'. + Path to scratch dir. Defaults to '.'. Returns ------- @@ -1182,7 +1182,7 @@ def intensity_display(intensity, outputdir, pol, immin=-30, immax=0): pol: str specific polarization added to the file name immin: float - mininum dB value for displaying intensity + minimum dB value for displaying intensity immax: float maximum dB value for displaying intensity """ diff --git a/src/dswx_sar/filter_SAR.py b/src/dswx_sar/filter_SAR.py index 3483f1a..5c74147 100644 --- a/src/dswx_sar/filter_SAR.py +++ b/src/dswx_sar/filter_SAR.py @@ -57,7 +57,7 @@ def compute_window_mean_std(arr, winsize): mean = masked_convolve2d(arr_masked, window, mode='same') c2 = masked_convolve2d(arr_masked*arr_masked, window, mode='same') - var = (c2 - mean * mean) + var = c2 - mean * mean # The negative number in sqrt is replaced # with the negligibly small number to avoid numpy warning message. diff --git a/src/dswx_sar/fuzzy_value_computation.py b/src/dswx_sar/fuzzy_value_computation.py index bd477b2..5a52f72 100644 --- a/src/dswx_sar/fuzzy_value_computation.py +++ b/src/dswx_sar/fuzzy_value_computation.py @@ -252,7 +252,7 @@ def compute_fuzzy_value(intensity, workflows i.e.twele or opera_dswx_s1 fuzzy_option : dict fuzzy options to compute the fuzzy values containing - fllowing key:value parameters + following key:value parameters 'hand_threshold': HAND value to mask out 'slope_min': minimum value for z membership function for slope 'slope_max': maximum value for z membership function for slope @@ -291,7 +291,7 @@ def compute_fuzzy_value(intensity, s-membership for reference water copol_only : numpy.ndarray binary image showing the area where - ony co-polization is used. + ony co-polarization is used. ''' _, rows, cols = intensity.shape @@ -377,7 +377,7 @@ def compute_fuzzy_value(intensity, change_ind = co_pol_ind # Cross-polarization intensity is replaced with co- (or span-) pol - # where water varation is high and areas are dark/flat. + # where water variation is high and areas are dark/flat. intensity_z_set[cross_pol_ind][high_frequent_water] = \ intensity_z_set[change_ind][high_frequent_water] intensity_z_set[cross_pol_ind][landcover_flat_area] = \ diff --git a/src/dswx_sar/initial_threshold.py b/src/dswx_sar/initial_threshold.py index 310ed3e..b93d057 100644 --- a/src/dswx_sar/initial_threshold.py +++ b/src/dswx_sar/initial_threshold.py @@ -117,7 +117,7 @@ def select_tile_bimodality(self, numstep+1), density=True) - bincenter = ((intensity_bins[:-1] + intensity_bins[1:]) / 2) + bincenter = (intensity_bins[:-1] + intensity_bins[1:]) / 2 intensity_db_variance = np.nanstd(intensity_db)**2 intensity_bins_step = intensity_bins[2] - intensity_bins[1] @@ -268,7 +268,7 @@ def tile_selection_wbd(self, water_mask, win_size=200, selection_methods=['combined'], - mininum_tile=20, + minimum_tile=20, minimum_pixel_number=40): '''Select the tile candidates containing water and non-water from aid of water body layer based on the selection method @@ -369,7 +369,7 @@ def tile_selection_wbd(self, # both water bodies and lands from the reference water map. # if 0.0 < water_coverage < 1 and 0.0 < land_coverage < 1: if water_area_flag: - while (num_detected_box_sum <= mininum_tile) and \ + while (num_detected_box_sum <= minimum_tile) and \ (win_size >= minimum_pixel_number): subrun += 1 @@ -489,7 +489,7 @@ def tile_selection_wbd(self, selected_tile_chini.append(False) selected_tile_bimodality.append(False) - # keep coordiates for the searching window. + # keep coordinates for the searching window. coordinate.append( [ind_subtile, x_start, x_end, @@ -524,7 +524,7 @@ def tile_selection_wbd(self, selected_tile_bimodality) num_detected_box = np.sum(detected_box_array) - if num_detected_box_sum <= mininum_tile: + if num_detected_box_sum <= minimum_tile: # try tile-selection with smaller win size win_size = int(win_size * 0.5) num_pixel_max = win_size * win_size / 3 @@ -1581,7 +1581,7 @@ def fill_threshold_with_distance(threshold_array, for block in range(0, nblocks): row_start = block * lines_per_block - if (row_start + lines_per_block > rows): + if row_start + lines_per_block > rows: block_rows = rows - row_start else: block_rows = lines_per_block diff --git a/src/dswx_sar/masking_with_ancillary.py b/src/dswx_sar/masking_with_ancillary.py index db566d0..ce18769 100644 --- a/src/dswx_sar/masking_with_ancillary.py +++ b/src/dswx_sar/masking_with_ancillary.py @@ -131,7 +131,7 @@ def extract_bbox_with_buffer( sizes : np.ndarray Sizes of the connected components. label_image : np.ndarray - 2 dimensional lebel array for each binary object + 2 dimensional label array for each binary object """ rows, cols = binary.shape @@ -515,7 +515,7 @@ def split_extended_water_parallel( def compute_spatial_coverage_from_ancillary_parallel( - flase_water_binary_path: str, + false_water_binary_path: str, reference_water_path: str, mask_landcover_path: str, output_file_path: str, @@ -530,7 +530,7 @@ def compute_spatial_coverage_from_ancillary_parallel( Parameters ---------- - flase_water_binary_path : str + false_water_binary_path : str Path to the binary water mask GeoTIFF file. reference_water_path : str Path to the reference water GeoTIFF file. @@ -555,8 +555,8 @@ def compute_spatial_coverage_from_ancillary_parallel( Saves the computed water mask indicating water areas in the specified output file path. """ - water_mask = dswx_sar_util.read_geotiff(flase_water_binary_path) - meta_info = dswx_sar_util.get_meta_from_tif(flase_water_binary_path) + water_mask = dswx_sar_util.read_geotiff(false_water_binary_path) + meta_info = dswx_sar_util.get_meta_from_tif(false_water_binary_path) # Extract bounding boxes with buffer coord_list, sizes, label_image = extract_bbox_with_buffer( @@ -611,7 +611,7 @@ def compute_spatial_coverage_from_ancillary_parallel( water_label_str, ref_land_tif_str) for i in range(len(sizes))] - # Output consists of index and 2D image consisting of True/Flase. + # Output consists of index and 2D image consisting of True/False. # True represents the land and False represents not-land. results = Parallel(n_jobs=number_workers)( delayed(compute_spatial_coverage)(args) @@ -997,7 +997,7 @@ def hand_filter_along_boundary( scratch_dir=scratch_dir, datatype='float32') hand_binary_path = os.path.join( - scratch_dir, "landcover_hand_bindary.tif") + scratch_dir, "landcover_hand_binary.tif") dswx_sar_util.save_dswx_product( hand_filtered_binary, hand_binary_path, @@ -1164,7 +1164,7 @@ def run(cfg): # spatially connected with `mask_excluded_landcover` are added. if extended_landcover_flag: logger.info('Extending landcover enabled.') - rg_excluded_area = (interp_wbd > dry_water_area_threshold) + rg_excluded_area = interp_wbd > dry_water_area_threshold mask_excluded_landcover = extend_land_cover( landcover_path=landcover_path, @@ -1187,7 +1187,7 @@ def run(cfg): projection=water_meta['projection'], scratch_dir=outputdir) - # 2) Create intial mask binary + # 2) Create initial mask binary # mask_excluded indicates the areas satisfying all conditions which are # 1: `dry_water_area_threshold` of water occurrence over 37 year (Pekel) # 2: specified landcovers (bare ground, sparse vegetation, urban, moss...) @@ -1259,14 +1259,14 @@ def run(cfg): cog_flag=True, scratch_dir=outputdir) - adjacent_false_positive_bindary_path = \ + adjacent_false_positive_binary_path = \ os.path.join(outputdir, 'false_positive_connected_water.tif') compute_spatial_coverage_from_ancillary_parallel( - flase_water_binary_path=false_water_candidate_path, + false_water_binary_path=false_water_candidate_path, reference_water_path=interp_wbd_str, mask_landcover_path=mask_excluded_landcover_path, - output_file_path=adjacent_false_positive_bindary_path, + output_file_path=adjacent_false_positive_binary_path, outputdir=outputdir, water_max_value=ref_water_max, number_workers=number_workers, @@ -1282,7 +1282,7 @@ def run(cfg): os.path.join(outputdir, f"refine_landcover_binary_{pol_str}.tif") dswx_sar_util.merge_binary_layers( - layer_list=[adjacent_false_positive_bindary_path, + layer_list=[adjacent_false_positive_binary_path, darkland_cand_path, water_map_tif_str], value_list=[0, 0, 1], diff --git a/src/dswx_sar/metadata.py b/src/dswx_sar/metadata.py index 8894763..d3c02eb 100644 --- a/src/dswx_sar/metadata.py +++ b/src/dswx_sar/metadata.py @@ -554,4 +554,4 @@ def create_dswx_ni_metadata(cfg, # Merge extra_meta_data with dswx_metadata_dict if provided if extra_meta_data is not None: dswx_metadata_dict.update(extra_meta_data) - return dswx_metadata_dict \ No newline at end of file + return dswx_metadata_dict diff --git a/src/dswx_sar/mosaic_gcov_frame.py b/src/dswx_sar/mosaic_gcov_frame.py index c6f8707..94e3149 100644 --- a/src/dswx_sar/mosaic_gcov_frame.py +++ b/src/dswx_sar/mosaic_gcov_frame.py @@ -78,7 +78,7 @@ def process_rtc_hdf5( # To Do: Read and write to geotiff # 1. If EPSG are the same between inputs, then write it to output # mosaicked Geotiff directly from input HDF5 - # 2. Otherwise, write all to intermeidate Geotiff first and re-use + # 2. Otherwise, write all to intermediate Geotiff first and re-use # existing functions to reproject data and create mosaicked output # from intermediate Geotiffs @@ -136,7 +136,7 @@ def write_rtc_geotiff( Returns ------- layover_exist: bool - Boolean which indicates if a layoverShadowMask layer exisits + Boolean which indicates if a layoverShadowMask layer exists in input RTC geogrid_in: DSWXGeogrid object A dataclass object representing the geographical grid @@ -196,7 +196,7 @@ def write_rtc_geotiff( f'{scratch_dir}/{input_prefix}_{data_name}.tif' temp_gtiff = \ f'{scratch_dir}/{input_prefix}_temp_{data_name}.tif' - + # Change EPSG change_epsg_tif( input_tif=input_gtiff, @@ -312,7 +312,7 @@ def mosaic_rtc_geotiff( Mosaicked output file name prefix layover_exist: bool Boolean which indicates if a layoverShadowMask layer - exisits in input RTC + exists in input RTC """ for idx, dataset_path in enumerate(data_path): data_name = Path(dataset_path).name[:2] @@ -461,8 +461,8 @@ def generate_nisar_layover_name(self, layover_name: str): def get_nisar_epsg(self, input_list): """extract data from RTC Geo information and store it as a dictionary - paremeters: - ----------- + parameters + ---------- input_list: list The HDF5 file paths of input RTCs to be mosaicked. @@ -500,11 +500,11 @@ def read_write_rtc( geotransform: Affine, crs: str, dswx_metadata_dict: dict): - """Read an level-2 RTC prodcut in HDF5 format and writ it out in + """Read an level-2 RTC product in HDF5 format and writ it out in GeoTiff format in data blocks defined by row_blk_size and col_blk_size. Parameters - ------------ + ---------- h5_ds: GDAL Dataset GDAL dataset object to be processed output_gtiff: str @@ -521,7 +521,7 @@ def read_write_rtc( Identify Inf in the dataset and replace them with a designated value geotransform: Affine Transformation object - Transformation matrix which maps pixcel locations in (row, col) + Transformation matrix which maps pixel locations in (row, col) coordinates to (x, y) spatial positions. crs: str Coordinate Reference System object in EPSG representation @@ -578,15 +578,15 @@ def read_write_rtc( def read_geodata_hdf5(self, input_rtc): """extract data from RTC Geo information and store it as a dictionary - paremeters: - ----------- + parameters + ---------- input_rtc: str The HDF5 RTC input file path Returns ------- geotransform: Affine Transformation object - Transformation matrix which maps pixcel locations in (row, col) + Transformation matrix which maps pixel locations in (row, col) coordinates to (x, y) spatial positions. crs: str Coordinate Reference System object in EPSG representation diff --git a/src/dswx_sar/mosaic_rtc_burst.py b/src/dswx_sar/mosaic_rtc_burst.py index 03b3a56..3bf37f6 100644 --- a/src/dswx_sar/mosaic_rtc_burst.py +++ b/src/dswx_sar/mosaic_rtc_burst.py @@ -83,8 +83,8 @@ def save_h5_metadata_to_tif(h5_meta_path, epsg_output): ''' extract data from RTC metadata and store it as geotiff - paremeters: - ----------- + parameters + ---------- h5_meta_path: str the path to the rtc metadata data_path: str @@ -151,7 +151,7 @@ def requires_reprojection(geogrid_mosaic, Check if the reprojection is required to mosaic input raster Parameters - ----------- + ---------- geogrid_mosaic: isce3.product.GeoGridParameters Mosaic geogrid rtc_image: str @@ -673,8 +673,8 @@ def mosaic_multiple_output_files( ''' Mosaic RTC images saving each mosaicked band into a separate file - Paremeters: - ----------- + Parameters + ---------- list_rtc_images: list List of the path to the rtc geobursts list_nlooks: list @@ -695,7 +695,6 @@ def mosaic_multiple_output_files( appended to this list verbose : bool Flag to enable/disable the verbose mode - ''' mosaic_dict = compute_mosaic_array( list_rtc_images, list_nlooks, mosaic_mode, scratch_dir=scratch_dir, @@ -775,8 +774,8 @@ def run(cfg): logger.info('Mosaic is enabled for burst RTCs ') mosaic_flag = True else: - logger.info('Singple input directories is found.') - logger.info('Mosaic is diabled for single burst RTC ') + logger.info('Single input directory is found.') + logger.info('Mosaic is disabled for single burst RTC ') mosaic_flag = True else: if num_input_path == 1: @@ -820,7 +819,7 @@ def run(cfg): # find HDF5 metadata layover_path = glob.glob(f'{input_dir}/*mask.tif') temp_mask_path = f'{scratch_path}/layover_{ind}.tif' - # If both `*_mask.tif` and `*.h5` exists in RTC-S1 burst product + # If both `*_mask.tif` and `*.h5` exists in RTC-S1 burst product # directory: # The metadata in `*_mask.tif` has priority over HDF5 file. if len(layover_path) > 0: @@ -866,7 +865,7 @@ def run(cfg): logger.warning('mask layer is not found!') # Check if metadata have common values on - # poliarzation /track number/ direction fields + # polarization /track number/ direction fields output_dir_mosaic_raster = scratch_path # Mosaic sub-bursts imagery @@ -897,7 +896,7 @@ def run(cfg): rtc_burst_imagery_list.append(rtc_path_input) geogrid_in.update_geogrid(rtc_path_input) else: - print(f'polarzation {pol} is not found in {input_dir}') + print(f'polarization {pol} is not found in {input_dir}') nlooks_list = [] if len(rtc_burst_imagery_list) > 0: diff --git a/src/dswx_sar/pre_processing.py b/src/dswx_sar/pre_processing.py index 51a05f4..05540fa 100644 --- a/src/dswx_sar/pre_processing.py +++ b/src/dswx_sar/pre_processing.py @@ -49,7 +49,7 @@ def validate_gtiff(geotiff_path, value_list): it suggests that all pixels in the file might have the same value. Parameters - ----------- + ---------- geotiff_path : str The file path to the GeoTIFF file to be checked. value_list : List[float] @@ -126,7 +126,7 @@ def relocate(self, Parameters ---------- ancillary_file_name : str - file name of ancilary data + file name of ancillary data relocated_file_str : str file name of output method : str diff --git a/src/dswx_sar/process_nisar_rtc.py b/src/dswx_sar/process_nisar_rtc.py index 3813c57..cffe8f6 100644 --- a/src/dswx_sar/process_nisar_rtc.py +++ b/src/dswx_sar/process_nisar_rtc.py @@ -101,7 +101,7 @@ def read_write_gcov( geodata, dswx_metadata_dict, ): - """Read an level-2 RTC prodcut in HDF5 format and writ it out in + """Read an level-2 RTC product in HDF5 format and writ it out in GeoTiff format in data blocks defined by row_blk_size and col_blk_size. Parameters @@ -200,8 +200,8 @@ def read_rtc_geo( ): """extract data from RTC Geo information and store it as a dictionary - paremeters: - ----------- + Parameters + ---------- input_file: str input HDF5 file group: str @@ -250,8 +250,8 @@ def process_nisar_gcov( """This wrapper reads the input HDF5 RTC product and writes it out in Geotiff format. - paremeters: - ----------- + Parameters + ---------- input_file: str input HDF5 RTC product file output_gtiff: str diff --git a/src/dswx_sar/refine_with_bimodality.py b/src/dswx_sar/refine_with_bimodality.py index 91c9432..dff2c99 100644 --- a/src/dswx_sar/refine_with_bimodality.py +++ b/src/dswx_sar/refine_with_bimodality.py @@ -198,7 +198,7 @@ def bimodal(self, array, mu1, sigma1, amplitud1, Amplitude of the second Gaussian. Returns - ---------- + ------- float or array-like The value(s) of the Gaussian function at x. """ @@ -212,8 +212,8 @@ def compute_ashman(self): which is a measure of bimodality, based on the first and second distributions of the input histogram. - Returns: - ---------- + Returns + ------- float: The computed Ashman coefficient. """ @@ -252,7 +252,8 @@ def compute_surface_ratio(self): Returns: ---------- - float: The computed Surface Ratio coefficient. + surface_ratio_coeff: float + The computed Surface Ratio coefficient. """ area_first = np.sum(self.simul_first) area_second = np.sum(self.simul_second) @@ -267,9 +268,10 @@ def compute_bc_coefficient(self): which is a measure of bimodality, based on the skewness and kurtosis of the input data. - Returns: - ---------- - float: The computed BC coefficient. + Returns + ------- + bc_coeff: float + The computed BC coefficient. """ sample_size = len(self.int_db) skewness_sq = stats.skew(self.int_db, @@ -295,9 +297,10 @@ def compute_bimodality(self): coefficient based on the mean values and probabilities of the two modes. - Returns: - ---------- - float: The computed bimodality coefficient. + Returns + ------- + sigma_b: float + The computed bimodality coefficient. """ try: local_left_ind = np.argmax(self.simul_first) @@ -400,7 +403,7 @@ def compute_metric(self, bimodal_metrics = (int(ashman_bool) + int(bm_coeff_bool) + int(bc_coeff_bool)) - # If more than two metric satisficed are higher than threshold + # If more than two metric satisfied are higher than threshold # or ashman coefficient is higher than 3 # and surface ratio is higher than threshold bool_set = [(bimodal_metrics >= 2) or @@ -479,7 +482,7 @@ def estimate_bimodality(array, bincenter = (bins[:-1] + bins[1:]) / 2 - # smooth histogram by appling gaussian filter + # smooth histogram by applying gaussian filter counts_smooth = scipy.signal.convolve(counts, [0.2261, 0.5478, 0.2261], 'same') @@ -580,7 +583,7 @@ def process_dark_land_component(args): - water_label_block: np.ndarray numpy array of the labeled water elements raster dataset. - thresholds: list - List of the thresholds to determine bimiodality. + List of the thresholds to determine bimodality. - minimum_pixel (int): minimum number of pixels to accept as water bodies. - debug_mode: boolean diff --git a/src/dswx_sar/region_growing.py b/src/dswx_sar/region_growing.py index a1fb29d..a6daa7e 100644 --- a/src/dswx_sar/region_growing.py +++ b/src/dswx_sar/region_growing.py @@ -166,10 +166,10 @@ def process_region_growing_block(block_param, ---------- block_param: BlockParam Object specifying where and how much to read and write to out_raster - data_block: numpy.ndarraya + data_block: numpy.ndarray fuzzy values after region growing """ - # At first loop, read block from intial fuzzy value geotiff + # At first loop, read block from initial fuzzy value geotiff # Otherwise, read block from previous loop if loopind == 0: @@ -352,7 +352,7 @@ def run(cfg): outputdir, f'temp_region_growing_{pol_str}.tif') # First, run region-growing algorithm for blocks - # to avoid to repeatly run with large image. + # to avoid repeated run with large image. run_parallel_region_growing( fuzzy_tif_path, temp_rg_tif_path, diff --git a/src/dswx_sar/save_mgrs_tiles.py b/src/dswx_sar/save_mgrs_tiles.py index 19a077d..597078f 100644 --- a/src/dswx_sar/save_mgrs_tiles.py +++ b/src/dswx_sar/save_mgrs_tiles.py @@ -96,13 +96,13 @@ def get_bounding_box_from_mgrs_tile_db( Returns ------- minx: float - Minimum x cooridate (UTM) for the given MGRS tile + Minimum x coordinate (UTM) for the given MGRS tile maxx: float - Maximum x cooridate (UTM) for the given MGRS tile + Maximum x coordinate (UTM) for the given MGRS tile miny: float - Minimum y cooridate (UTM) for the given MGRS tile + Minimum y coordinate (UTM) for the given MGRS tile maxy: float - Maximum y cooridate (UTM) for the given MGRS tile + Maximum y coordinate (UTM) for the given MGRS tile epsg: int EPSG code """ @@ -135,13 +135,13 @@ def get_bounding_box_from_mgrs_tile(mgrs_tile_name): Returns ------- minx: float - Minimum x cooridate (UTM) for the given MGRS tile + Minimum x coordinate (UTM) for the given MGRS tile maxx: float - Maximum x cooridate (UTM) for the given MGRS tile + Maximum x coordinate (UTM) for the given MGRS tile miny: float - Minimum y cooridate (UTM) for the given MGRS tile + Minimum y coordinate (UTM) for the given MGRS tile maxy: float - Maximum y cooridate (UTM) for the given MGRS tile + Maximum y coordinate (UTM) for the given MGRS tile epsg: int EPSG code """ @@ -742,7 +742,7 @@ def run(cfg): **extra_args) # metadata for final product - # e.g. geotransform, projection, length, width, utmzon, epsg + # e.g. geotransform, projection, length, width, utmzone, epsg water_meta = dswx_sar_util.get_meta_from_tif(paths['final_water']) # repackage the water map @@ -791,7 +791,7 @@ def run(cfg): inundated_vegetation[inundated_vegetation_mask] = 1 logger.info('Inundated vegetation file was found.') iv_target_file_type = inundated_vege_cfg.target_area_file_type - if (iv_target_file_type == 'auto'): + if iv_target_file_type == 'auto': # if target_file_type is auto and GLAD is provided, # GLAD is the source of inundated vegetation mapping interp_glad_path_str = os.path.join( @@ -807,7 +807,7 @@ def run(cfg): if worldcover_valid > 0 and glad_valid > 0: inundated_vege_cfg.target_area_file_type = 'GLAD/WorldCover' # If the GLAD is provided but all pixels come from 'WorldCover' - # due to the no-data of GLAD, + # due to the no-data of GLAD, # IV source is WorldCover elif worldcover_valid > 0 and glad_valid == 0: inundated_vege_cfg.target_area_file_type = 'WorldCover' diff --git a/src/dswx_sar/save_mgrs_tiles_ni.py b/src/dswx_sar/save_mgrs_tiles_ni.py index 92b33ff..d1061e7 100644 --- a/src/dswx_sar/save_mgrs_tiles_ni.py +++ b/src/dswx_sar/save_mgrs_tiles_ni.py @@ -69,7 +69,7 @@ def crop_and_save_mgrs_tile_spacing( output_format : str Output file format (i.e., COG, GeoTIFF) metadata : dict - Dictionry for metadata + Dictionary for metadata cog_compression: str Compression method for COG cog_nbits: int @@ -354,13 +354,13 @@ def run(cfg): logger.info(f'Number of frames to process: {num_input_path}') date_str_list = [] - rtc_readar = mosaic_gcov_frame.RTCReader(row_blk_size=200, + rtc_reader = mosaic_gcov_frame.RTCReader(row_blk_size=200, col_blk_size=200) for input_h5 in input_list: # Find HDF5 metadata - rtc_metadata = rtc_readar.read_metadata_hdf5(input_h5) + rtc_metadata = rtc_reader.read_metadata_hdf5(input_h5) # tags = src.tags(0) # date_str = tags['ZERO_DOPPLER_START_TIME'] platform = 'LSAR' @@ -518,10 +518,10 @@ def run(cfg): inundated_vegetation_mask = (inundated_vegetation == 2) & \ (water_map == 1) inundated_vegetation[inundated_vegetation_mask] = 1 - logger.info('Inudated vegetation file was found.') + logger.info('Inundated vegetation file was found.') else: inundated_vegetation = None - logger.warning('Inudated vegetation file was disabled.') + logger.warning('Inundated vegetation file was disabled.') # 5) create ocean mask if ocean_mask_enabled: diff --git a/src/dswx_sar/schemas/algorithm_parameter_ni.yaml b/src/dswx_sar/schemas/algorithm_parameter_ni.yaml index 788063c..a9c7cb8 100644 --- a/src/dswx_sar/schemas/algorithm_parameter_ni.yaml +++ b/src/dswx_sar/schemas/algorithm_parameter_ni.yaml @@ -154,7 +154,7 @@ runconfig: # The elements will be masked out during this step. land_cover_darkland_list: list(required=False) # The elements is considered as the dark land candidates - # where these elemtns are spatially connected to the dark land. + # where these elements are spatially connected to the dark land. land_cover_darkland_extension_list: list(required=False) land_cover_water_label: list(required=False) # VV and VH threshold values for dark land candidates diff --git a/src/dswx_sar/schemas/algorithm_parameter_s1.yaml b/src/dswx_sar/schemas/algorithm_parameter_s1.yaml index 54b92c1..bc5daf7 100644 --- a/src/dswx_sar/schemas/algorithm_parameter_s1.yaml +++ b/src/dswx_sar/schemas/algorithm_parameter_s1.yaml @@ -172,7 +172,7 @@ runconfig: # The elements will be masked out during this step. land_cover_darkland_list: list(required=False) # The elements is considered as the dark land candidates - # where these elemtns are spatially connected to the dark land. + # where these elements are spatially connected to the dark land. land_cover_darkland_extension_list: list(required=False) land_cover_water_label: list(required=False) # VV and VH threshold values for dark land candidates diff --git a/src/dswx_sar/schemas/dswx_ni.yaml b/src/dswx_sar/schemas/dswx_ni.yaml index d9c8974..539ed3c 100644 --- a/src/dswx_sar/schemas/dswx_ni.yaml +++ b/src/dswx_sar/schemas/dswx_ni.yaml @@ -46,7 +46,7 @@ runconfig: # algorithm parameter algorithm_parameters: str(required=True) - # placeholder for inundated vegettion + # placeholder for inundated vegetation mean_backscattering: str(required=False) standard_deviation_backscattering: str(required=False)