Skip to content

Commit 15be4ed

Browse files
authored
Merge pull request #18 from RolnickLab/improve-docstrings
Remove duplicate docstring entries create by using pyment
2 parents a3e38a5 + 04e28ed commit 15be4ed

6 files changed

Lines changed: 68 additions & 198 deletions

File tree

geospatial_tools/download.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ def _download_from_link(
1414
"""
1515
1616
Args:
17-
target_download: str:
18-
output_name: str: (Default value = None)
19-
output_directory: str | Path: (Default value = DATA_DIR)
17+
target_download:
18+
output_name:
19+
output_directory:
2020
2121
Returns:
2222
23-
2423
"""
2524
file_configs = get_yaml_config("data_file_links")
2625
key = target_download
@@ -42,8 +41,6 @@ def download_usa_polygon(output_name: str = USA_POLYGON, output_directory: str |
4241
Args:
4342
output_name: What name to give to downloaded file
4443
output_directory: Where to save the downloaded file
45-
output_name: str: (Default value = USA_POLYGON)
46-
output_directory: str | Path: (Default value = DATA_DIR)
4744
4845
Returns:
4946
"""
@@ -62,8 +59,6 @@ def download_s2_tiling_grid(
6259
Args:
6360
output_name: What name to give to downloaded file
6461
output_directory: Where to save the downloaded file
65-
output_name: str: (Default value = SENTINEL_2_TILLING_GRID)
66-
output_directory: str | Path: (Default value = DATA_DIR)
6762
6863
Returns:
6964
"""

geospatial_tools/planetary_computer/sentinel_2.py

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def max_cloud_cover(self, max_cloud_cover: int):
8080
"""
8181
8282
Args:
83-
max_cloud_cover: int:
83+
max_cloud_cover: int: Max percentage of cloud cover used for Sentinel 2 product search
8484
8585
Returns:
8686
@@ -123,12 +123,9 @@ def create_date_ranges(self, start_year: int, end_year: int, start_month: int, e
123123
end_year: End year for ranges
124124
start_month: Starting month for each period
125125
end_month: End month for each period (inclusively)
126-
start_year: int:
127-
end_year: int:
128-
start_month: int:
129-
end_month: int:
130126
131127
Returns:
128+
List of date ranges
132129
"""
133130
self.date_ranges = create_date_range_for_specific_period(
134131
start_year=start_year, end_year=end_year, start_month_range=start_month, end_month_range=end_month
@@ -144,10 +141,11 @@ def find_best_complete_products(self, max_cloud_cover: int | None = None, max_no
144141
the search has found no results will be stored in `self.error_list`
145142
146143
Args:
147-
max_cloud_cover: int | None: (Default value = None)
148-
max_no_data_value: int: (Default value = 5)
144+
max_cloud_cover: Max percentage of cloud cover allowed used for the search (Default value = None)
145+
max_no_data_value: Max percentage of no-data coverage by individual Sentinel 2 product (Default value = 5)
149146
150147
Returns:
148+
Dictionary of product IDs and their corresponding Sentinel 2 tile names.
151149
"""
152150
cloud_cover = self.max_cloud_cover
153151
if max_cloud_cover:
@@ -201,11 +199,7 @@ def to_file(self, output_dir: str | pathlib.Path) -> None:
201199
"""
202200
203201
Args:
204-
output_dir: str | pathlib.Path:
205-
206-
Returns:
207-
208-
202+
output_dir: Output directory used to write to file
209203
"""
210204
write_results_to_file(
211205
cloud_cover=self.max_cloud_cover,
@@ -225,10 +219,10 @@ def sentinel_2_complete_tile_search(
225219
"""
226220
227221
Args:
228-
tile_id: int:
229-
date_ranges: list[str]:
230-
max_cloud_cover: int:
231-
max_no_data_value: int: (Default value = 5)
222+
tile_id:
223+
date_ranges:
224+
max_cloud_cover:
225+
max_no_data_value: (Default value = 5)
232226
233227
Returns:
234228
@@ -276,11 +270,11 @@ def find_best_product_per_s2_tile(
276270
"""
277271
278272
Args:
279-
date_ranges: list[str]:
280-
max_cloud_cover: int:
281-
s2_tile_grid_list: list:
282-
max_no_data_value: int: (Default value = 5)
283-
num_of_workers: int: (Default value = 4)
273+
date_ranges:
274+
max_cloud_cover:
275+
s2_tile_grid_list:
276+
max_no_data_value: (Default value = 5)
277+
num_of_workers: (Default value = 4)
284278
285279
Returns:
286280
@@ -322,13 +316,12 @@ def _get_best_product_id_for_each_grid_tile(
322316
"""
323317
324318
Args:
325-
s2_tile_search_results: dict:
326-
feature_s2_tiles: GeoDataFrame:
327-
logger: logging.Logger: (Default value = LOGGER)
319+
s2_tile_search_results:
320+
feature_s2_tiles:
321+
logger: (Default value = LOGGER)
328322
329323
Returns:
330-
331-
324+
String value of product id
332325
"""
333326
search_result_keys = s2_tile_search_results.keys()
334327
all_keys_present = all(item in search_result_keys for item in feature_s2_tiles)
@@ -364,11 +357,11 @@ def write_best_product_ids_to_dataframe(
364357
"""
365358
366359
Args:
367-
spatial_join_results: GeoDataFrame:
368-
tile_dictionary: dict:
369-
best_product_column: str: (Default value = "best_s2_product_id")
370-
s2_tiles_column: str: (Default value = "s2_tiles")
371-
logger: logging.Logger: (Default value = LOGGER)
360+
spatial_join_results:
361+
tile_dictionary:
362+
best_product_column:
363+
s2_tiles_column:
364+
logger:
372365
373366
Returns:
374367
@@ -391,12 +384,12 @@ def write_results_to_file(
391384
"""
392385
393386
Args:
394-
cloud_cover: int:
395-
successful_results: dict:
396-
incomplete_results: list | None: (Default value = None)
397-
error_results: list | None: (Default value = None)
398-
output_dir: str | pathlib.Path: (Default value = DATA_DIR)
399-
logger: logging.Logger: (Default value = LOGGER)
387+
cloud_cover:
388+
successful_results:
389+
incomplete_results:
390+
error_results:
391+
output_dir:
392+
logger:
400393
401394
Returns:
402395
@@ -455,15 +448,9 @@ def download_and_process_sentinel2_asset(
455448
base_directory: The base directory path where the downloaded files will be stored
456449
delete_intermediate_files: Flag to determine if intermediate files should be deleted. Defaults to False
457450
logger: Logger instance
458-
product_id: str:
459-
product_bands: list[str]:
460-
collections: str: (Default value = "sentinel-2-l2a")
461-
target_projection: int | str | None: (Default value = None)
462-
base_directory: str | pathlib.Path: (Default value = DATA_DIR)
463-
delete_intermediate_files: bool: (Default value = False)
464-
logger: logging.Logger: (Default value = LOGGER)
465451
466452
Returns:
453+
Asset instance
467454
"""
468455
base_file_name = f"{base_directory}/{product_id}"
469456
merged_file = f"{base_file_name}_merged.tif"

geospatial_tools/raster.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ def reproject_raster(
3131
dataset_path: Path to the dataset to be reprojected.
3232
target_crs: EPSG code in string or int format. Can be given in the following ways: 5070 | "5070" | "EPSG:5070"
3333
target_path: Path and filename for reprojected dataset.
34-
logger:
35-
dataset_path: str | pathlib.Path:
36-
target_crs: str | int:
37-
target_path: str | pathlib.Path:
38-
logger: logging.Logger: (Default value = LOGGER)
34+
logger: Logger instance
3935
4036
Returns:
4137
@@ -88,12 +84,7 @@ def _clip_process(
8884
id_polygon: Tuple containing an id number and a polygon (row from a Geodataframe).
8985
base_output_filename: Base filename for outputs. If `None`, will be taken from input polygon layer.
9086
output_dir: Directory path where output will be written.
91-
raster_image: pathlib.Path | str:
92-
id_polygon: tuple[int:
93-
GeoDataFrame]:
94-
base_output_filename: str | None:
95-
output_dir: pathlib.Path | str:
96-
logger: logging.Logger: (Default value = LOGGER)
87+
logger: Logger instance
9788
9889
Returns:
9990
@@ -152,12 +143,6 @@ def clip_raster_with_polygon(
152143
output_dir: Directory path where output will be written.
153144
num_of_workers: The number of processes to use for parallel execution. Defaults to `cpu_count()`.
154145
logger: Logger instance
155-
raster_image: pathlib.Path | str:
156-
polygon_layer: pathlib.Path | str | GeoDataFrame:
157-
base_output_filename: str | None: (Default value = None)
158-
output_dir: str | pathlib.Path: (Default value = DATA_DIR)
159-
num_of_workers: int | None: (Default value = None)
160-
logger: logging.Logger: (Default value = LOGGER)
161146
162147
Returns:
163148
@@ -220,8 +205,6 @@ def get_total_band_count(raster_file_list: list[pathlib.Path | str], logger: log
220205
Args:
221206
raster_file_list: List of raster files to be processed.
222207
logger: Logger instance
223-
raster_file_list: list[pathlib.Path | str]:
224-
logger: logging.Logger: (Default value = LOGGER)
225208
226209
Returns:
227210
@@ -243,8 +226,6 @@ def create_merged_raster_bands_metadata(
243226
Args:
244227
raster_file_list:
245228
logger:
246-
raster_file_list: list[pathlib.Path | str]:
247-
logger: logging.Logger: (Default value = LOGGER)
248229
249230
Returns:
250231
@@ -283,11 +264,6 @@ def merge_raster_bands(
283264
With, merged_band_names, individual band id can be assigned for the final output raster;
284265
["B0", "B1", "B2"].
285266
logger: Logger instance
286-
raster_file_list: list[pathlib.Path | str]:
287-
merged_filename: pathlib.Path | str:
288-
merged_band_names: list[str]: (Default value = None)
289-
merged_metadata: dict: (Default value = None)
290-
logger: logging.Logger: (Default value = LOGGER)
291267
292268
Returns:
293269
"""

0 commit comments

Comments
 (0)