From 98e910786192176c4e5673184df2e9976a841bb0 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 16 Dec 2024 14:42:03 -0900 Subject: [PATCH] update ruff config --- pyproject.toml | 27 +++++++++++++++++ ruff.toml | 6 ---- src/asf_tools/__init__.py | 1 + src/asf_tools/aws.py | 6 ++-- src/asf_tools/composite.py | 6 ++-- src/asf_tools/dem.py | 4 +-- src/asf_tools/hydrosar/__init__.py | 1 + src/asf_tools/hydrosar/flood_map.py | 29 ++++++++++--------- src/asf_tools/hydrosar/hand/__init__.py | 1 + src/asf_tools/hydrosar/hand/calculate.py | 16 +++++----- src/asf_tools/hydrosar/hand/prepare.py | 8 ++--- src/asf_tools/hydrosar/threshold.py | 1 - src/asf_tools/hydrosar/water_map.py | 23 +++++++-------- src/asf_tools/raster.py | 13 +++++---- src/asf_tools/tile.py | 12 ++++---- src/asf_tools/util.py | 10 +++---- src/asf_tools/vector.py | 7 +++-- .../watermasking/generate_osm_tiles.py | 3 -- .../watermasking/generate_worldcover_tiles.py | 3 +- tests/hydrosar/test_flood_map.py | 3 +- tests/hydrosar/test_hand.py | 3 +- tests/test_dem.py | 1 + tests/test_raster.py | 1 - 23 files changed, 101 insertions(+), 84 deletions(-) delete mode 100644 ruff.toml diff --git a/pyproject.toml b/pyproject.toml index 42a13fbf..45cc39d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,3 +76,30 @@ where = ["src"] markers = [ "integration: long-running integration tests", ] + +[tool.ruff] +line-length = 120 +src = ["src", "tests"] +exclude = ["prototype"] + +[tool.ruff.format] +indent-style = "space" +quote-style = "single" + +[tool.ruff.lint] +extend-select = [ + "I", # isort: https://docs.astral.sh/ruff/rules/#isort-i + "UP", # pyupgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up + + # TODO: uncomment the following extensions and address their warnings: + #"D", # pydocstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d + #"ANN", # annotations: https://docs.astral.sh/ruff/rules/#flake8-annotations-ann + #"PTH", # use-pathlib-pth: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.isort] +case-sensitive = true +lines-after-imports = 2 diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 2aed2d63..00000000 --- a/ruff.toml +++ /dev/null @@ -1,6 +0,0 @@ -exclude = ["prototype"] - -line-length = 120 - -[format] -quote-style = "single" diff --git a/src/asf_tools/__init__.py b/src/asf_tools/__init__.py index 23022be7..b78cb088 100644 --- a/src/asf_tools/__init__.py +++ b/src/asf_tools/__init__.py @@ -2,6 +2,7 @@ from importlib.metadata import version + __version__ = version(__name__) __all__ = [ diff --git a/src/asf_tools/aws.py b/src/asf_tools/aws.py index a72ab525..c7b6a956 100644 --- a/src/asf_tools/aws.py +++ b/src/asf_tools/aws.py @@ -1,10 +1,10 @@ import logging from mimetypes import guess_type from pathlib import Path -from typing import Union import boto3 + S3_CLIENT = boto3.client('s3') log = logging.getLogger(__name__) @@ -14,14 +14,14 @@ def get_tag_set() -> dict: return tag_set -def get_content_type(file_location: Union[Path, str]) -> str: +def get_content_type(file_location: Path | str) -> str: content_type = guess_type(file_location)[0] if not content_type: content_type = 'application/octet-stream' return content_type -def upload_file_to_s3(path_to_file: Union[str, Path], bucket: str, prefix: str = ''): +def upload_file_to_s3(path_to_file: str | Path, bucket: str, prefix: str = ''): path_to_file = Path(path_to_file) key = str(Path(prefix) / path_to_file.name) extra_args = {'ContentType': get_content_type(key)} diff --git a/src/asf_tools/composite.py b/src/asf_tools/composite.py index 682cf295..e8f9e17c 100755 --- a/src/asf_tools/composite.py +++ b/src/asf_tools/composite.py @@ -17,7 +17,6 @@ import sys from statistics import multimode from tempfile import TemporaryDirectory -from typing import List import numpy as np from osgeo import gdal @@ -25,11 +24,12 @@ from asf_tools.raster import read_as_array, write_cog from asf_tools.util import get_epsg_code + gdal.UseExceptions() log = logging.getLogger(__name__) -def get_target_epsg_code(codes: List[int]) -> int: +def get_target_epsg_code(codes: list[int]) -> int: """Determine the target UTM EPSG projection for the output composite Args: @@ -151,7 +151,7 @@ def reproject_to_target(raster_info: dict, target_epsg_code: int, target_resolut return target_raster_info -def make_composite(out_name: str, rasters: List[str], resolution: float = None): +def make_composite(out_name: str, rasters: list[str], resolution: float = None): """Creates a local-resolution-weighted composite from Sentinel-1 RTC products Args: diff --git a/src/asf_tools/dem.py b/src/asf_tools/dem.py index 4991fa98..d9e6abfc 100644 --- a/src/asf_tools/dem.py +++ b/src/asf_tools/dem.py @@ -1,7 +1,6 @@ """Prepare a Copernicus GLO-30 DEM virtual raster (VRT) covering a given geometry""" from pathlib import Path -from typing import Union from osgeo import gdal, ogr from shapely.geometry.base import BaseGeometry @@ -9,13 +8,14 @@ from asf_tools import vector from asf_tools.util import GDALConfigManager + DEM_GEOJSON = '/vsicurl/https://asf-dem-west.s3.amazonaws.com/v2/cop30-2021.geojson' gdal.UseExceptions() ogr.UseExceptions() -def prepare_dem_vrt(vrt: Union[str, Path], geometry: Union[ogr.Geometry, BaseGeometry]): +def prepare_dem_vrt(vrt: str | Path, geometry: ogr.Geometry | BaseGeometry): """Create a DEM mosaic VRT covering a given geometry The DEM mosaic is assembled from the Copernicus GLO-30 DEM tiles that intersect the geometry. diff --git a/src/asf_tools/hydrosar/__init__.py b/src/asf_tools/hydrosar/__init__.py index 3caaaa1d..5c5bc3d6 100644 --- a/src/asf_tools/hydrosar/__init__.py +++ b/src/asf_tools/hydrosar/__init__.py @@ -1,5 +1,6 @@ from warnings import warn + HYDROSAR_MOVE_WARNING = """ --------------------------------------------------------------------------- The HydroSAR codes (`flood_map`, `water_map` and `hand` modules) are being diff --git a/src/asf_tools/hydrosar/flood_map.py b/src/asf_tools/hydrosar/flood_map.py index c514ca60..3a29aa79 100644 --- a/src/asf_tools/hydrosar/flood_map.py +++ b/src/asf_tools/hydrosar/flood_map.py @@ -13,9 +13,10 @@ import sys import tempfile import warnings +from collections.abc import Callable from pathlib import Path from shutil import make_archive -from typing import Callable, Literal, Optional, Tuple, Union +from typing import Literal import numpy as np from osgeo import gdal @@ -26,6 +27,7 @@ from asf_tools.raster import read_as_masked_array, write_cog from asf_tools.util import get_coordinates, get_epsg_code + log = logging.getLogger(__name__) @@ -36,7 +38,7 @@ def get_pw_threshold(water_array: np.array) -> float: return round(ths_orig) + 1 -def get_waterbody(input_info: dict, threshold: Optional[float] = None) -> np.array: +def get_waterbody(input_info: dict, threshold: float | None = None) -> np.array: epsg = get_epsg_code(input_info) west, south, east, north = get_coordinates(input_info) @@ -86,7 +88,7 @@ def _goal_fmi(w): tp, _, fp, fn = get_confusion_matrix(w) return 1 - np.sqrt((tp / (tp + fp)) * (tp / (tp + fn))) - class MyBounds(object): + class MyBounds: def __init__(self, xmax=max(water_levels), xmin=min(water_levels)): self.xmax = np.array(xmax) self.xmin = np.array(xmin) @@ -119,7 +121,7 @@ def __call__(self, **kwargs): return np.inf # set as inf to mark unstable solution -def logstat(data: np.ndarray, func: Callable = np.nanstd) -> Union[np.ndarray, float]: +def logstat(data: np.ndarray, func: Callable = np.nanstd) -> np.ndarray | float: """Calculate a function in logarithmic scale and return in linear scale. INF values inside the data array are set to nan. @@ -141,7 +143,7 @@ def estimate_flood_depth( flood_labels: np.ndarray, estimator: str = 'iterative', water_level_sigma: float = 3.0, - iterative_bounds: Tuple[int, int] = (0, 15), + iterative_bounds: tuple[int, int] = (0, 15), iterative_min_size: int = 0, minimization_metric: str = 'ts', ) -> float: @@ -179,14 +181,14 @@ def estimate_flood_depth( def make_flood_map( - out_raster: Union[str, Path], - vv_raster: Union[str, Path], - water_raster: Union[str, Path], - hand_raster: Union[str, Path], + out_raster: str | Path, + vv_raster: str | Path, + water_raster: str | Path, + hand_raster: str | Path, estimator: str = 'iterative', water_level_sigma: float = 3.0, - known_water_threshold: Optional[float] = None, - iterative_bounds: Tuple[int, int] = (0, 15), + known_water_threshold: float | None = None, + iterative_bounds: tuple[int, int] = (0, 15), iterative_min_size: int = 0, minimization_metric: str = 'ts', ): @@ -233,7 +235,6 @@ def make_flood_map( References: Jean-Francios Pekel, Andrew Cottam, Noel Gorelik, Alan S. Belward. 2016. """ - info = gdal.Info(str(water_raster), format='json') epsg = get_epsg_code(info) geotransform = info['geoTransform'] @@ -328,13 +329,13 @@ def make_flood_map( ) -def optional_str(value: str) -> Optional[str]: +def optional_str(value: str) -> str | None: if value.lower() == 'none': return None return value -def optional_float(value: str) -> Optional[float]: +def optional_float(value: str) -> float | None: if value.lower() == 'none': return None return float(value) diff --git a/src/asf_tools/hydrosar/hand/__init__.py b/src/asf_tools/hydrosar/hand/__init__.py index 558982d2..7c23e808 100644 --- a/src/asf_tools/hydrosar/hand/__init__.py +++ b/src/asf_tools/hydrosar/hand/__init__.py @@ -4,6 +4,7 @@ ) from asf_tools.hydrosar.hand.prepare import prepare_hand_vrt + __all__ = [ 'calculate_hand_for_basins', 'make_copernicus_hand', diff --git a/src/asf_tools/hydrosar/hand/calculate.py b/src/asf_tools/hydrosar/hand/calculate.py index 015d95c0..f31dfeb4 100644 --- a/src/asf_tools/hydrosar/hand/calculate.py +++ b/src/asf_tools/hydrosar/hand/calculate.py @@ -6,7 +6,6 @@ import warnings from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Optional, Union import astropy.convolution import fiona @@ -19,6 +18,7 @@ from asf_tools.dem import prepare_dem_vrt from asf_tools.raster import write_cog + log = logging.getLogger(__name__) @@ -59,7 +59,7 @@ def calculate_hand( dem_affine: rasterio.Affine, dem_crs: rasterio.crs.CRS, basin_mask, - acc_thresh: Optional[int] = 100, + acc_thresh: int | None = 100, ): """Calculate the Height Above Nearest Drainage (HAND) @@ -143,10 +143,10 @@ def calculate_hand( def calculate_hand_for_basins( - out_raster: Union[str, Path], + out_raster: str | Path, geometries: GeometryCollection, - dem_file: Union[str, Path], - acc_thresh: Optional[int] = 100, + dem_file: str | Path, + acc_thresh: int | None = 100, ): """Calculate the Height Above Nearest Drainage (HAND) for watershed boundaries (hydrobasins). @@ -177,9 +177,9 @@ def calculate_hand_for_basins( def make_copernicus_hand( - out_raster: Union[str, Path], - vector_file: Union[str, Path], - acc_thresh: Optional[int] = 100, + out_raster: str | Path, + vector_file: str | Path, + acc_thresh: int | None = 100, ): """Copernicus GLO-30 Height Above Nearest Drainage (HAND) diff --git a/src/asf_tools/hydrosar/hand/prepare.py b/src/asf_tools/hydrosar/hand/prepare.py index 8b993598..5b23e762 100644 --- a/src/asf_tools/hydrosar/hand/prepare.py +++ b/src/asf_tools/hydrosar/hand/prepare.py @@ -2,7 +2,6 @@ from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Union from osgeo import gdal, ogr from rasterio.enums import Resampling @@ -12,13 +11,14 @@ from asf_tools import vector from asf_tools.util import GDALConfigManager, get_epsg_code + HAND_GEOJSON = '/vsicurl/https://glo-30-hand.s3.amazonaws.com/v1/2021/glo-30-hand.geojson' gdal.UseExceptions() ogr.UseExceptions() -def prepare_hand_vrt(vrt: Union[str, Path], geometry: Union[ogr.Geometry, BaseGeometry]): +def prepare_hand_vrt(vrt: str | Path, geometry: ogr.Geometry | BaseGeometry): """Prepare a HAND mosaic VRT covering a given geometry Prepare a Height Above Nearest Drainage (HAND) virtual raster (VRT) covering a given geometry. @@ -50,8 +50,8 @@ def prepare_hand_vrt(vrt: Union[str, Path], geometry: Union[ogr.Geometry, BaseGe def prepare_hand_for_raster( - hand_raster: Union[str, Path], - source_raster: Union[str, Path], + hand_raster: str | Path, + source_raster: str | Path, resampling_method: str = 'lanczos', ): """Create a HAND raster pixel-aligned to a source raster diff --git a/src/asf_tools/hydrosar/threshold.py b/src/asf_tools/hydrosar/threshold.py index 8e5767d4..3062db90 100644 --- a/src/asf_tools/hydrosar/threshold.py +++ b/src/asf_tools/hydrosar/threshold.py @@ -54,7 +54,6 @@ def expectation_maximization_threshold(tile: np.ndarray, number_of_classes: int Returns: threshold: threshold value that can be used to create a water extent map """ - image_copy = tile.copy() image_copy2 = np.ma.filled(tile.astype(float), np.nan) # needed for valid posterior_lookup keys image = tile.flatten() diff --git a/src/asf_tools/hydrosar/water_map.py b/src/asf_tools/hydrosar/water_map.py index ab464978..7421033e 100644 --- a/src/asf_tools/hydrosar/water_map.py +++ b/src/asf_tools/hydrosar/water_map.py @@ -11,7 +11,7 @@ import sys from pathlib import Path from shutil import make_archive -from typing import Literal, Optional, Tuple, Union +from typing import Literal import numpy as np import skfuzzy as fuzz @@ -27,6 +27,7 @@ from asf_tools.tile import tile_array, untile_array from asf_tools.util import get_epsg_code + log = logging.getLogger(__name__) @@ -40,7 +41,7 @@ def mean_of_subtiles(tiles: np.ndarray) -> np.ndarray: def select_hand_tiles( - tiles: Union[np.ndarray, np.ma.MaskedArray], + tiles: np.ndarray | np.ma.MaskedArray, hand_threshold: float, hand_fraction: float, ) -> np.ndarray: @@ -98,7 +99,7 @@ def calculate_slope_magnitude(array: np.ndarray, pixel_size) -> np.ndarray: def determine_membership_limits( array: np.ndarray, mask_percentile: float = 90.0, std_range: float = 3.0 -) -> Tuple[float, float]: +) -> tuple[float, float]: array = np.ma.masked_values(array, 0.0) array = np.ma.masked_greater(array, np.nanpercentile(array.filled(np.nan), mask_percentile)) lower_limit = np.ma.median(array) @@ -146,9 +147,7 @@ def remove_small_segments(segments: np.ndarray, min_area: int = 3) -> np.ndarray def format_raster_data(raster, padding_mask=None, nodata=np.iinfo(np.uint8).max): - """ - Ensure raster data is uint8 and set the area outside the valid data to nodata - """ + """Ensure raster data is uint8 and set the area outside the valid data to nodata""" if padding_mask is None: array = read_as_masked_array(raster) padding_mask = array.mask @@ -163,7 +162,7 @@ def fuzzy_refinement( gaussian_array: np.ndarray, hand_array: np.ndarray, pixel_size: float, - gaussian_thresholds: Tuple[float, float], + gaussian_thresholds: tuple[float, float], membership_threshold: float = 0.45, ) -> np.ndarray: water_map = np.ones_like(initial_map) @@ -190,11 +189,11 @@ def fuzzy_refinement( def make_water_map( - out_raster: Union[str, Path], - vv_raster: Union[str, Path], - vh_raster: Union[str, Path], - hand_raster: Optional[Union[str, Path]] = None, - tile_shape: Tuple[int, int] = (100, 100), + out_raster: str | Path, + vv_raster: str | Path, + vh_raster: str | Path, + hand_raster: str | Path | None = None, + tile_shape: tuple[int, int] = (100, 100), max_vv_threshold: float = -15.5, max_vh_threshold: float = -23.0, hand_threshold: float = 15.0, diff --git a/src/asf_tools/raster.py b/src/asf_tools/raster.py index f030857f..e1762db7 100644 --- a/src/asf_tools/raster.py +++ b/src/asf_tools/raster.py @@ -2,22 +2,23 @@ import warnings from pathlib import Path from tempfile import NamedTemporaryFile -from typing import List, Literal, Union +from typing import Literal import numpy as np from osgeo import gdal from asf_tools.util import epsg_to_wkt + gdal.UseExceptions() log = logging.getLogger(__name__) def convert_scale( - array: Union[np.ndarray, np.ma.MaskedArray], + array: np.ndarray | np.ma.MaskedArray, in_scale: Literal['db', 'amplitude', 'power'], out_scale: Literal['db', 'amplitude', 'power'], -) -> Union[np.ndarray, np.ma.MaskedArray]: +) -> np.ndarray | np.ma.MaskedArray: """Convert calibrated raster scale between db, amplitude and power""" if in_scale == out_scale: warnings.warn(f'Nothing to do! {in_scale} is same as {out_scale}.') @@ -46,7 +47,7 @@ def convert_scale( raise ValueError(f'Cannot convert raster of scale {in_scale} to {out_scale}') -def read_as_masked_array(raster: Union[str, Path], band: int = 1) -> np.ma.MaskedArray: +def read_as_masked_array(raster: str | Path, band: int = 1) -> np.ma.MaskedArray: """Reads data from a raster image into memory, masking invalid and NoData values Args: @@ -85,9 +86,9 @@ def read_as_array(raster: str, band: int = 1) -> np.array: def write_cog( - file_name: Union[str, Path], + file_name: str | Path, data: np.ndarray, - transform: List[float], + transform: list[float], epsg_code: int, dtype=gdal.GDT_Float32, nodata_value=None, diff --git a/src/asf_tools/tile.py b/src/asf_tools/tile.py index c3e12fba..d05a461c 100644 --- a/src/asf_tools/tile.py +++ b/src/asf_tools/tile.py @@ -1,13 +1,11 @@ -from typing import Tuple, Union - import numpy as np def tile_array( - array: Union[np.ndarray, np.ma.MaskedArray], - tile_shape: Tuple[int, int] = (200, 200), + array: np.ndarray | np.ma.MaskedArray, + tile_shape: tuple[int, int] = (200, 200), pad_value: float = None, -) -> Union[np.ndarray, np.ma.MaskedArray]: +) -> np.ndarray | np.ma.MaskedArray: """Tile a 2D numpy array Turn a 2D numpy array like: @@ -69,8 +67,8 @@ def tile_array( def untile_array( - tiled_array: Union[np.ndarray, np.ma.MaskedArray], array_shape: Tuple[int, int] -) -> Union[np.ndarray, np.ma.MaskedArray]: + tiled_array: np.ndarray | np.ma.MaskedArray, array_shape: tuple[int, int] +) -> np.ndarray | np.ma.MaskedArray: """Untile a tiled array into a 2D numpy array This is the reverse of `tile_array` and will turn a tiled array like: diff --git a/src/asf_tools/util.py b/src/asf_tools/util.py index 8af4f485..101525cc 100644 --- a/src/asf_tools/util.py +++ b/src/asf_tools/util.py @@ -1,7 +1,6 @@ -from typing import Tuple - from osgeo import gdal, osr + gdal.UseExceptions() @@ -9,9 +8,8 @@ class GDALConfigManager: """Context manager for setting GDAL config options temporarily""" def __init__(self, **options): - """ - Args: - **options: GDAL Config `option=value` keyword arguments. + """Args: + **options: GDAL Config `option=value` keyword arguments. """ self.options = options.copy() self._previous_options = {} @@ -42,7 +40,7 @@ def get_epsg_code(info: dict) -> int: return epsg_code -def get_coordinates(info: dict) -> Tuple[int, int, int, int]: +def get_coordinates(info: dict) -> tuple[int, int, int, int]: """Get the corner coordinates from a GDAL Info dictionary Args: diff --git a/src/asf_tools/vector.py b/src/asf_tools/vector.py index 3f278f94..d50586cf 100644 --- a/src/asf_tools/vector.py +++ b/src/asf_tools/vector.py @@ -1,12 +1,13 @@ +from collections.abc import Iterator from pathlib import Path -from typing import Iterator, List, Union from osgeo import ogr + ogr.UseExceptions() -def get_features(vector_path: Union[str, Path]) -> List[ogr.Feature]: +def get_features(vector_path: str | Path) -> list[ogr.Feature]: ds = ogr.Open(str(vector_path)) layer = ds.GetLayer() return [feature for feature in layer] @@ -18,7 +19,7 @@ def get_property_values_for_intersecting_features(geometry: ogr.Geometry, featur return True -def intersecting_feature_properties(geometry: ogr.Geometry, features: Iterator, feature_property: str) -> List[str]: +def intersecting_feature_properties(geometry: ogr.Geometry, features: Iterator, feature_property: str) -> list[str]: property_values = [] for feature in features: if feature.GetGeometryRef().Intersects(geometry): diff --git a/src/asf_tools/watermasking/generate_osm_tiles.py b/src/asf_tools/watermasking/generate_osm_tiles.py index d42b6816..3d425754 100644 --- a/src/asf_tools/watermasking/generate_osm_tiles.py +++ b/src/asf_tools/watermasking/generate_osm_tiles.py @@ -28,7 +28,6 @@ def process_pbf(planet_file: str, output_file: str): planet_file: The path to the OSM Planet PBF file. output_file: The desired path of the processed PBF file. """ - natural_file = 'planet_natural.pbf' waterways_file = 'planet_waterways.pbf' reservoirs_file = 'planet_reservoirs.pbf' @@ -54,7 +53,6 @@ def process_ocean_tiles(ocean_polygons_path, lat, lon, tile_width_deg, tile_heig tile_width_deg: The width of the tile in degrees. tile_height_deg: The height of the tile in degrees. """ - tile = lat_lon_to_tile_string(lat, lon, is_worldcover=False, postfix='') tile_tif = output_dir + tile + '.tif' @@ -97,7 +95,6 @@ def extract_water(water_file, lat, lon, tile_width_deg, tile_height_deg, interio tile_width_deg: The desired width of the tile in degrees. tile_height_deg: The desired height of the tile in degrees. """ - tile = lat_lon_to_tile_string(lat, lon, is_worldcover=False, postfix='') tile_pbf = tile + '.osm.pbf' tile_tif = interior_tile_dir + tile + '.tif' diff --git a/src/asf_tools/watermasking/generate_worldcover_tiles.py b/src/asf_tools/watermasking/generate_worldcover_tiles.py index 92fd90d5..20055321 100644 --- a/src/asf_tools/watermasking/generate_worldcover_tiles.py +++ b/src/asf_tools/watermasking/generate_worldcover_tiles.py @@ -31,7 +31,6 @@ def tile_preprocessing(tile_dir, min_lat, max_lat, min_lon, max_lon): Args: tile_dir: The directory containing all of the worldcover tiles. """ - filenames = [f for f in os.listdir(tile_dir) if f.endswith('.tif')] def filename_filter(filename): @@ -100,6 +99,7 @@ def create_missing_tiles(tile_dir, lat_range, lon_range): Args: lat_range: The range of latitudes to check. lon_range: The range of longitudes to check. + Returns: current_existing_tiles: The list of tiles that exist after the function has completed. """ @@ -151,7 +151,6 @@ def get_tiles(osm_tile_coord: tuple, wc_tile_width: int, tile_width: int): Returns: tiles: A list of the lower left corner coordinates of the Worldcover tiles that overlap the OSM tile. """ - osm_lat = osm_tile_coord[0] osm_lon = osm_tile_coord[1] diff --git a/tests/hydrosar/test_flood_map.py b/tests/hydrosar/test_flood_map.py index f92062e8..72b0198b 100644 --- a/tests/hydrosar/test_flood_map.py +++ b/tests/hydrosar/test_flood_map.py @@ -1,8 +1,7 @@ import numpy as np import pytest -from osgeo_utils.gdalcompare import find_diff - from osgeo import gdal +from osgeo_utils.gdalcompare import find_diff from asf_tools.hydrosar import flood_map diff --git a/tests/hydrosar/test_hand.py b/tests/hydrosar/test_hand.py index 59291268..c5b624cf 100644 --- a/tests/hydrosar/test_hand.py +++ b/tests/hydrosar/test_hand.py @@ -1,13 +1,14 @@ import json +import numpy as np import pytest from osgeo import gdal, ogr from osgeo_utils.gdalcompare import find_diff -import numpy as np from asf_tools import vector from asf_tools.hydrosar import hand + HAND_BASINS = ( '/vsicurl/https://hyp3-testing.s3-us-west-2.amazonaws.com/' 'asf-tools/S1A_IW_20230228T120437_DVR_RTC30/hand/hybas_af_lev12_v1c_firstpoly.geojson' diff --git a/tests/test_dem.py b/tests/test_dem.py index 8d1f0796..4b3481ae 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -5,6 +5,7 @@ from asf_tools import dem + gdal.UseExceptions() diff --git a/tests/test_raster.py b/tests/test_raster.py index 143bc123..87e7a7d7 100644 --- a/tests/test_raster.py +++ b/tests/test_raster.py @@ -1,6 +1,5 @@ import numpy as np import pytest - from osgeo import gdal from asf_tools import raster