Skip to content

Commit

Permalink
Merge pull request #68 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.9.2
  • Loading branch information
jtherrmann authored Jan 8, 2025
2 parents 20b4b55 + 19ae4e7 commit bd0830a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ jobs:
call-ruff-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]

call-mypy-workflow:
uses: ASFHyP3/actions/.github/workflows/[email protected]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.2]

### Added
* Added `mypy` to [`static-analysis`](.github/workflows/static-analysis.yml)

## [0.9.1]

### Changed
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- pip
# For packaging, and testing
- ruff
- mypy
- setuptools
- setuptools_scm
- wheel
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ convention = "google"
[tool.ruff.lint.isort]
case-sensitive = true
lines-after-imports = 2

[tool.mypy]
python_version = "3.10"
warn_redundant_casts = true
warn_unused_ignores = true
warn_unreachable = true
strict_equality = true
check_untyped_defs = true
12 changes: 7 additions & 5 deletions src/hyp3_srg/back_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def check_required_files(required_files: Iterable, work_dir: Path) -> None:
def clean_up_after_back_projection(work_dir: Path) -> None:
patterns = ['*hgt*', 'dem*', 'DEM*', 'q*', '*positionburst*']
for pattern in patterns:
[f.unlink() for f in work_dir.glob(pattern)]
for f in work_dir.glob(pattern):
f.unlink()


def back_project_granules(granule_orbit_pairs: Iterable, work_dir: Path, gpu: bool = False) -> None:
Expand Down Expand Up @@ -85,10 +86,10 @@ def create_product(work_dir) -> Path:

def back_project(
granules: Iterable[str],
bounds: list[float] = None,
earthdata_username: str = None,
earthdata_password: str = None,
bucket: str = None,
bounds: list[float] | None = None,
earthdata_username: str | None = None,
earthdata_password: str | None = None,
bucket: str | None = None,
bucket_prefix: str = '',
use_gslc_prefix: bool = False,
work_dir: Path | None = None,
Expand Down Expand Up @@ -127,6 +128,7 @@ def back_project(

if bounds is None or bounds == [0, 0, 0, 0]:
bounds = unary_union(bboxs).buffer(0.1).bounds
assert bounds is not None # Return type annotation for unary_union is incorrect
dem_path = dem.download_dem_for_srg(bounds, work_dir)
utils.create_param_file(dem_path, dem_path.with_suffix('.dem.rsc'), work_dir)

Expand Down
2 changes: 1 addition & 1 deletion src/hyp3_srg/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ensure_egm_model_available():
f.write(chunk)


def download_dem_for_srg(bounds: list[float], work_dir: Path | None):
def download_dem_for_srg(bounds: list[float], work_dir: Path):
"""Download the DEM for the given bounds - [min_lon, min_lat, max_lon, max_lat].
Args:
Expand Down
4 changes: 2 additions & 2 deletions src/hyp3_srg/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ def compute_sbas_velocity_solution(


def create_time_series(
work_dir: Path,
looks: tuple[int, int] = (10, 10),
baselines: tuple[int, int] = (90, 1000),
threshold: float = 0.5,
do_tropo_correction: bool = True,
work_dir: Path | None = None,
) -> None:
"""Creates a time series from a stack of GSLCs consisting of interferograms and a velocity solution
Expand Down Expand Up @@ -300,7 +300,7 @@ def time_series(
granules: Iterable[str],
bounds: list[float],
use_gslc_prefix: bool,
bucket: str = None,
bucket: str | None = None,
bucket_prefix: str = '',
work_dir: Path | None = None,
) -> None:
Expand Down
10 changes: 5 additions & 5 deletions src/hyp3_srg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_creds(service, username, password) -> None:
os.environ[f'{service.upper()}_PASSWORD'] = password


def find_creds_in_env(username_name, password_name) -> tuple[str, str]:
def find_creds_in_env(username_name, password_name) -> tuple[str | None, str | None]:
"""Find credentials for a service in the environment.
Args:
Expand All @@ -75,7 +75,7 @@ def find_creds_in_env(username_name, password_name) -> tuple[str, str]:
return None, None


def find_creds_in_netrc(service) -> tuple[str, str]:
def find_creds_in_netrc(service) -> tuple[str | None, str | None]:
"""Find credentials for a service in the netrc file.
Args:
Expand Down Expand Up @@ -186,7 +186,7 @@ def download_orbit(granule_name: str, output_dir: Path) -> Path:
Returns:
Path to the downloaded orbit file
"""
orbit_path = str(fetch_for_scene(granule_name, dir=output_dir))
orbit_path = fetch_for_scene(granule_name, dir=output_dir)
return orbit_path


Expand Down Expand Up @@ -230,7 +230,7 @@ def how_many_gpus():
return ngpus


def get_s3_args(uri: str, dest_dir: Path | None = None) -> None:
def get_s3_args(uri: str, dest_dir: Path | None = None) -> tuple[str, str, Path]:
"""Retrieve the arguments for downloading from an S3 bucket
Args:
Expand Down Expand Up @@ -267,7 +267,7 @@ def s3_list_objects(bucket: str, prefix: str = '') -> dict:
return res


def download_from_s3(uri: str, dest_dir: Path | None = None) -> None:
def download_from_s3(uri: str, dest_dir: Path | None = None) -> Path:
"""Download a file from an S3 bucket
Args:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_create_time_series_product_name():
'S1A_IW_RAW__0SDV_004_005_054882_06AF26_2CE5.zip',
'S1A_IW_RAW__0SDV_010_020_055057_06B527_1346.zip',
]
bounds = [-100, 45, -90, 50]
bounds = [-100.0, 45.0, -90.0, 50.0]
name = time_series.create_time_series_product_name(granule_names, bounds)
assert name.startswith('S1_SRG_SBAS_35_W100_0_N45_0_W090_0_N50_0_001_010')

Expand Down Expand Up @@ -38,4 +38,4 @@ def test_get_size_from_dem(tmp_path):
with open(rsc_path, 'w') as rsc_file:
rsc_file.write(rsc_content.strip())
dem_width, dem_height = time_series.get_size_from_dem(dem_path=rsc_path)
assert dem_width, dem_height == (1235, 873)
assert (dem_width, dem_height) == (1235, 873)

0 comments on commit bd0830a

Please sign in to comment.