diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 8702d25b..ed228992 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -14,6 +14,6 @@ on: jobs: call-changelog-check-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.8.2 secrets: USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index f4c354cb..6258bcfc 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} diff --git a/.github/workflows/create-jira-issue.yml b/.github/workflows/create-jira-issue.yml index a2ee3bb1..3615af15 100644 --- a/.github/workflows/create-jira-issue.yml +++ b/.github/workflows/create-jira-issue.yml @@ -6,7 +6,7 @@ on: jobs: call-create-jira-issue-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.8.2 secrets: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} diff --git a/.github/workflows/labeled-pr.yml b/.github/workflows/labeled-pr.yml index 205ed76c..125c59c6 100644 --- a/.github/workflows/labeled-pr.yml +++ b/.github/workflows/labeled-pr.yml @@ -13,4 +13,4 @@ on: jobs: call-labeled-pr-check-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.8.2 diff --git a/.github/workflows/release-checklist-comment.yml b/.github/workflows/release-checklist-comment.yml index c5ff9af3..1f670fd7 100644 --- a/.github/workflows/release-checklist-comment.yml +++ b/.github/workflows/release-checklist-comment.yml @@ -10,7 +10,7 @@ on: jobs: call-release-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.8.2 permissions: pull-requests: write secrets: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee8e0814..5d114b52 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: jobs: call-release-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.8.2 with: release_prefix: HyP3 ISCE2 secrets: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f6197023..5585241e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -5,10 +5,10 @@ on: push jobs: call-secrets-analysis-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.8.2 call-flake8-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.8.2 with: local_package_names: hyp3_isce2 diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml index c8f3d71a..7208d0c3 100644 --- a/.github/workflows/tag-version.yml +++ b/.github/workflows/tag-version.yml @@ -8,7 +8,7 @@ on: jobs: call-bump-version-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.8.2 with: user: tools-bot email: UAF-asf-apd@alaska.edu diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 7d05cba4..cf1c5513 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -13,7 +13,7 @@ on: jobs: call-pytest-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.8.2 with: local_package_name: hyp3_isce2 python_versions: >- @@ -21,12 +21,12 @@ jobs: call-version-info-workflow: # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.8.2 call-docker-ghcr-workflow: needs: call-version-info-workflow # Docs: https://github.com/ASFHyP3/actions - uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.8.1 + uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.8.2 with: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} release_branch: main diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index ebaebccf..b2d6ec82 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -93,7 +93,7 @@ def wait_for_extractor(response: requests.Response, sleep_time: int = 15) -> boo True if the burst was successfully downloaded, False otherwise. """ if response.status_code == 202: - time.sleep(15) + time.sleep(sleep_time) return False response.raise_for_status() @@ -382,7 +382,7 @@ def get_burst_params(scene_name: str) -> BurstParams: ) -def validate_bursts(reference_name: str, secondary_name: str) -> None: +def validate_bursts(reference_scene: str, secondary_scene: str) -> None: """Check whether the reference and secondary bursts are valid. Args: @@ -392,8 +392,8 @@ def validate_bursts(reference_name: str, secondary_name: str) -> None: Returns: None """ - ref_split = reference_name.split('_') - sec_split = secondary_name.split('_') + ref_split = reference_scene.split('_') + sec_split = secondary_scene.split('_') ref_burst_id = ref_split[1] sec_burst_id = sec_split[1] diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index fa3f9116..adfaff06 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -72,7 +72,7 @@ def distance_meters_to_degrees(distance_meters, latitude): latitude_circumference = EARTHS_CIRCUMFERENCE * np.cos(np.radians(latitude)) distance_degrees_lon = distance_meters / latitude_circumference * 360 distance_degrees_lat = distance_meters / EARTHS_CIRCUMFERENCE * 360 - return (np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15)) + return np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15) def download_dem_for_isce2( diff --git a/src/hyp3_isce2/insar_tops_burst.py b/src/hyp3_isce2/insar_tops_burst.py index 95942301..ab87b901 100644 --- a/src/hyp3_isce2/insar_tops_burst.py +++ b/src/hyp3_isce2/insar_tops_burst.py @@ -49,12 +49,11 @@ def insar_tops_burst( - reference_scene: str, - secondary_scene: str, - swath_number: int, - azimuth_looks: int = 4, - range_looks: int = 20, -) -> Path: + reference_scene: str, + secondary_scene: str, + swath_number: int, + azimuth_looks: int = 4, + range_looks: int = 20) -> Path: """Create a burst interferogram Args: @@ -143,7 +142,7 @@ def make_readme( wrapped_phase_path = product_dir / f'{product_name}_wrapped_phase.tif' info = gdal.Info(str(wrapped_phase_path), format='json') - secondary_granule_datetime_str = secondary_scene.split("_")[3] + secondary_granule_datetime_str = secondary_scene.split('_')[3] payload = { 'processing_date': datetime.now(timezone.utc), @@ -171,15 +170,14 @@ def make_readme( def make_parameter_file( - out_path: Path, - reference_scene: str, - secondary_scene: str, - swath_number: int, - azimuth_looks: int, - range_looks: int, - dem_name: str = 'GLO_30', - dem_resolution: int = 30, -) -> None: + out_path: Path, + reference_scene: str, + secondary_scene: str, + swath_number: int, + azimuth_looks: int, + range_looks: int, + dem_name: str = 'GLO_30', + dem_resolution: int = 30) -> None: """Create a parameter file for the output product Args: @@ -195,7 +193,6 @@ def make_parameter_file( returns: None """ - SPEED_OF_LIGHT = 299792458.0 SPACECRAFT_HEIGHT = 693000.0 EARTH_RADIUS = 6337286.638938101 @@ -270,18 +267,19 @@ def make_parameter_file( 'Speckle filter: yes\n' ] - output_string = "".join(output_strings) + output_string = ''.join(output_strings) with open(out_path.__str__(), 'w') as outfile: outfile.write(output_string) -def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: float = 30.): +def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: float) -> None: """Translate ISCE outputs to a standard GTiff format with a UTM projection Args: isce_output_dir: Path to the ISCE output directory product_name: Name of the product + pixel_size: Pixel size """ src_ds = gdal.Open(str(isce_output_dir / 'filt_topophase.unw.geo')) @@ -377,9 +375,8 @@ def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: floa ) -def get_pixel_size(choice): - choices = {'20x4': 80.0, '10x2': 40.0, '5x1': 20.0} - return choices[choice] +def get_pixel_size(looks: str) -> float: + return {'20x4': 80.0, '10x2': 40.0, '5x1': 20.0}[looks] def main(): diff --git a/src/hyp3_isce2/topsapp.py b/src/hyp3_isce2/topsapp.py index 3906080a..d5b17407 100644 --- a/src/hyp3_isce2/topsapp.py +++ b/src/hyp3_isce2/topsapp.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Iterable, Union +from typing import Iterable, Sequence, Union from isce.applications.topsApp import TopsInSAR from jinja2 import Template @@ -52,8 +52,8 @@ def __init__( aux_cal_directory: str, dem_filename: str, geocode_dem_filename: str, - roi: Iterable[float], - swaths: int or Iterable[int] = [1, 2, 3], + roi: Sequence[float], + swaths: Union[int, Iterable[int]] = (1, 2, 3), azimuth_looks: int = 4, range_looks: int = 20, do_unwrap: bool = True, @@ -139,7 +139,7 @@ def run_topsapp_burst(dostep: str = '', start: str = '', end: str = '', config_x Args: dostep: The step to run start: The step to start at - stop: The step to stop at + end: The step to stop at config_xml: The config file to use Raises: diff --git a/tests/data/test_browse_image.png b/tests/data/test_browse_image.png new file mode 100644 index 00000000..6a5ed843 Binary files /dev/null and b/tests/data/test_browse_image.png differ diff --git a/tests/test_insar_tops_burst.py b/tests/test_insar_tops_burst.py new file mode 100644 index 00000000..28690f6a --- /dev/null +++ b/tests/test_insar_tops_burst.py @@ -0,0 +1,7 @@ +from hyp3_isce2 import insar_tops_burst + + +def test_get_pixel_size(): + assert insar_tops_burst.get_pixel_size('20x4') == 80.0 + assert insar_tops_burst.get_pixel_size('10x2') == 40.0 + assert insar_tops_burst.get_pixel_size('5x1') == 20.0 diff --git a/tests/test_utils.py b/tests/test_utils.py index e988cabd..c4dfdba5 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,14 @@ +import os + from osgeo import gdal -from hyp3_isce2.utils import GDALConfigManager, extent_from_geotransform, oldest_granule_first, utm_from_lon_lat +from hyp3_isce2.utils import ( + GDALConfigManager, + extent_from_geotransform, + make_browse_image, + oldest_granule_first, + utm_from_lon_lat +) gdal.UseExceptions() @@ -49,3 +57,11 @@ def test_oldest_granule_first(): latest = "S1_249434_IW1_20230523T170733_VV_8850-BURST" assert oldest_granule_first(oldest, latest) == (oldest, latest) assert oldest_granule_first(latest, oldest) == (oldest, latest) + + +def test_make_browse_image(): + input_tif = "tests/data/test_geotiff.tif" + output_png = "tests/data/test_browse_image2.png" + make_browse_image(input_tif, output_png) + assert open(output_png, "rb").read() == open("tests/data/test_browse_image.png", "rb").read() + os.remove(output_png)